[PATCH, v2, OpenMP 5.0] Implement relaxation of implicit map vs. existing device mappings (for mainline trunk)
Jakub Jelinek
jakub@redhat.com
Tue Nov 9 15:18:17 GMT 2021
On Sat, Nov 06, 2021 at 12:51:59AM +0800, Chung-Lin Tang wrote:
> static int
> get_kind (bool short_mapkind, void *kinds, int idx)
> {
> - return short_mapkind ? ((unsigned short *) kinds)[idx]
> - : ((unsigned char *) kinds)[idx];
> + int val = (short_mapkind
> + ? ((unsigned short *) kinds)[idx]
> + : ((unsigned char *) kinds)[idx]);
> +
> + if (short_mapkind && GOMP_MAP_IMPLICIT_P (val))
> + val &= ~GOMP_MAP_IMPLICIT;
> + return val;
> +}
It doesn't make sense to test it twice. I'd do:
if (!short_mapkind)
return ((unsigned char *) kinds)[idx];
int val = ((unsigned short *) kinds)[idx];
if (GOMP_MAP_IMPLICIT_P (val))
val &= ~GOMP_MAP_IMPLICIT;
return val;
> +
> +
> +static bool
> +get_implicit (bool short_mapkind, void *kinds, int idx)
> +{
> + int val = (short_mapkind
> + ? ((unsigned short *) kinds)[idx]
> + : ((unsigned char *) kinds)[idx]);
> +
> + return short_mapkind && GOMP_MAP_IMPLICIT_P (val);
> }
and here even simpler, no need to read kinds at all:
if (!short_mapkind)
return false;
int val = ((unsigned short *) kinds)[idx];
return GOMP_MAP_IMPLICIT_P (val);
?
Otherwise LGTM.
Jakub
More information about the Gcc-patches
mailing list