Hi! On Mon, 29 Aug 2016 15:46:47 +0800, Chung-Lin Tang <clt...@codesourcery.com> wrote: > this patch is a port of some changes from gomp-4_0-branch, > including adding additional map type handling in OpenACC enter/exit data > directives, and some pointer set handling changes. Updated > testsuite case are also included. > > Tested on trunk to ensure no regressions, is this okay for trunk?
> 2016-08-29 Cesar Philippidis <ce...@codesourcery.com> > Thomas Schwinge <tho...@codesourcery.com> > Chung-Lin Tang <clt...@codesourcery.com> Maybe I'm misremembering, but I can't remember having been involved in this. ;-) > libgomp/ > * oacc-parallel.c (find_pset): Adjust and rename from... > (find_pointer): ...this function. > (GOACC_enter_exit_data): Handle GOMP_MAP_TO and GOMP_MAP_ALLOC, > adjust find_pointer calls into find_pset, adjust pointer map handling, > add acc_is_present guards to calls to gomp_acc_insert_pointer and > gomp_acc_remove_pointer. > --- oacc-parallel.c (revision 239814) > +++ oacc-parallel.c (working copy) > @@ -38,15 +38,23 @@ > #include <stdarg.h> > #include <assert.h> > > +/* Returns the number of mappings associated with the pointer or pset. PSET > + have three mappings, whereas pointer have two. */ > + > static int > -find_pset (int pos, size_t mapnum, unsigned short *kinds) > +find_pointer (int pos, size_t mapnum, unsigned short *kinds) > { > if (pos + 1 >= mapnum) > return 0; > > unsigned char kind = kinds[pos+1] & 0xff; > > - return kind == GOMP_MAP_TO_PSET; > + if (kind == GOMP_MAP_TO_PSET) > + return 3; > + else if (kind == GOMP_MAP_POINTER) > + return 2; > + > + return 0; > } I'm still confused about that find_pset/find_pointer handling. Why is that required? Essentially, that means that GOACC_enter_exit_data is skipping over some mappings, right? If yes, why do the front ends (Fortran only?) then emit these mappings to begin with, if we're then ignoring them in the runtime? > @@ -298,7 +306,9 @@ GOACC_enter_exit_data (int device, size_t mapnum, > > if (kind == GOMP_MAP_FORCE_ALLOC > || kind == GOMP_MAP_FORCE_PRESENT > - || kind == GOMP_MAP_FORCE_TO) > + || kind == GOMP_MAP_FORCE_TO > + || kind == GOMP_MAP_TO > + || kind == GOMP_MAP_ALLOC) > { > data_enter = true; > break; > @@ -312,31 +322,39 @@ GOACC_enter_exit_data (int device, size_t mapnum, > kind); > } > > + /* In c, non-pointers and arrays are represented by a single data clause. > + Dynamically allocated arrays and subarrays are represented by a data > + clause followed by an internal GOMP_MAP_POINTER. > + > + In fortran, scalars and not allocated arrays are represented by a > + single data clause. Allocated arrays and subarrays have three mappings: > + 1) the original data clause, 2) a PSET 3) a pointer to the array data. > + */ > + > if (data_enter) > { > for (i = 0; i < mapnum; i++) > { > unsigned char kind = kinds[i] & 0xff; > > - /* Scan for PSETs. */ > - int psets = find_pset (i, mapnum, kinds); > + /* Scan for pointers and PSETs. */ > + int pointer = find_pointer (i, mapnum, kinds); > > - if (!psets) > + if (!pointer) > { > switch (kind) > { > - case GOMP_MAP_POINTER: > - gomp_acc_insert_pointer (1, &hostaddrs[i], &sizes[i], > - &kinds[i]); > + case GOMP_MAP_ALLOC: > + acc_present_or_create (hostaddrs[i], sizes[i]); > break; > case GOMP_MAP_FORCE_ALLOC: > acc_create (hostaddrs[i], sizes[i]); > break; > - case GOMP_MAP_FORCE_PRESENT: > + case GOMP_MAP_TO: > acc_present_or_copyin (hostaddrs[i], sizes[i]); > break; > case GOMP_MAP_FORCE_TO: > - acc_present_or_copyin (hostaddrs[i], sizes[i]); > + acc_copyin (hostaddrs[i], sizes[i]); > break; > default: > gomp_fatal (">>>> GOACC_enter_exit_data UNHANDLED kind > 0x%.2x", > @@ -346,12 +364,16 @@ GOACC_enter_exit_data (int device, size_t mapnum, > } > else > { > - gomp_acc_insert_pointer (3, &hostaddrs[i], &sizes[i], &kinds[i]); > + if (!acc_is_present (hostaddrs[i], sizes[i])) > + { > + gomp_acc_insert_pointer (pointer, &hostaddrs[i], > + &sizes[i], &kinds[i]); > + } > /* Increment 'i' by two because OpenACC requires fortran > arrays to be contiguous, so each PSET is associated with > one of MAP_FORCE_ALLOC/MAP_FORCE_PRESET/MAP_FORCE_TO, and > one MAP_POINTER. */ > - i += 2; > + i += pointer - 1; > } > } > } > @@ -360,19 +382,15 @@ GOACC_enter_exit_data (int device, size_t mapnum, > { > unsigned char kind = kinds[i] & 0xff; > > - int psets = find_pset (i, mapnum, kinds); > + int pointer = find_pointer (i, mapnum, kinds); > > - if (!psets) > + if (!pointer) > { > switch (kind) > { > - case GOMP_MAP_POINTER: > - gomp_acc_remove_pointer (hostaddrs[i], (kinds[i] & 0xff) > - == GOMP_MAP_FORCE_FROM, > - async, 1); > - break; > case GOMP_MAP_DELETE: > - acc_delete (hostaddrs[i], sizes[i]); > + if (acc_is_present (hostaddrs[i], sizes[i])) > + acc_delete (hostaddrs[i], sizes[i]); > break; > case GOMP_MAP_FORCE_FROM: > acc_copyout (hostaddrs[i], sizes[i]); > @@ -385,10 +403,14 @@ GOACC_enter_exit_data (int device, size_t mapnum, > } > else > { > - gomp_acc_remove_pointer (hostaddrs[i], (kinds[i] & 0xff) > - == GOMP_MAP_FORCE_FROM, async, 3); > - /* See the above comment. */ > - i += 2; > + if (acc_is_present (hostaddrs[i], sizes[i])) > + { > + gomp_acc_remove_pointer (hostaddrs[i], (kinds[i] & 0xff) > + == GOMP_MAP_FORCE_FROM, async, > + pointer); > + /* See the above comment. */ > + } > + i += pointer - 1; > } > } > Grüße Thomas