On Wed, Mar 09, 2022 at 10:43:56PM +0800, Chung-Lin Tang wrote: > when troubleshooting building/running SPEC HPC 2021 with GCC with OpenMP > offloading, > specifically 534.hpgmgfv_t, an issue encountered in the benchmark was: > when the benchmark was initializing and creating its data environment on the > GPU, > it was trying to map array sections where the base-pointer is actually NULL: > ... > for (block=0;block<3;++block) { > #pragma omp target enter data > map(to:level->restriction[shape].blocks[block][:length]) > // level->restriction[shape].blocks[block] == NULL for some values of index > 'block' > ... > > The benchmark appears to be assuming that such NULL base-pointers would > simply be > silently ignored, and the program would just keep running.
I'd say that looks like a clear SPEC HPC 2021 bug, array sections are similar to array elements and using even &ptr[0] or &ptr[10] when ptr is NULL is UB in C/C++. Perhaps it doesn't hurt to discuss it on omp-lang, but I wouldn't change anything on the compiler side until those discussions. > 2022-03-09 Chung-Lin Tang <clt...@codesourcery.com> > > libgomp/ChangeLog: > > * target.c (gomp_attach_pointer): When pointer is NULL, > return instead of calling gomp_fatal. > diff --git a/libgomp/target.c b/libgomp/target.c > index 9017458885e..0e8bbd83c20 100644 > --- a/libgomp/target.c > +++ b/libgomp/target.c > @@ -796,8 +796,8 @@ gomp_attach_pointer (struct gomp_device_descr *devicep, > > if ((void *) target == NULL) > { > - gomp_mutex_unlock (&devicep->lock); > - gomp_fatal ("attempt to attach null pointer"); > + n->aux->attach_count[idx] = 0; > + return; > } > > s.host_start = target + bias; Jakub