Skip to content

Commit b1ed109

Browse files
committed
fix: use map(attach:/detach:) in OMP_ENTER/EXIT_DATA for correct Fortran pointer attachment
map(always,to/from:) for pointer components copies the host descriptor (with host addresses) to device, leaving device struct pointers invalid. OpenMP 5.1 map(attach:) correctly looks up the device address of the pointee and updates the device struct pointer to reference device memory. map(detach:) is the symmetric reverse. This fixes CUDA_ERROR_ILLEGAL_ADDRESS (Phoenix gpu-omp) and HSA_STATUS_ERROR_MEMORY_APERTURE_VIOLATION (Frontier AMD gpu-omp) caused by x%cc/x%spacing etc. being dereferenced as host addresses inside GPU kernels.
1 parent 28906e6 commit b1ed109

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/common/include/omp_macros.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
#:def OMP_ENTER_DATA(copyin=None, copyinReadOnly=None, create=None, attach=None, extraOmpArgs=None)
294294
#:set copyin_val = OMP_COPYIN_STR(copyin).strip('\n') + OMP_COPYIN_STR(copyinReadOnly).strip('\n')
295295
#:set create_val = OMP_CREATE_STR(create)
296-
#:set attach_val = OMP_MAP_STR('always,to', attach)
296+
#:set attach_val = OMP_MAP_STR('attach', attach)
297297
#:set extraOmpArgs_val = GEN_EXTRA_ARGS_STR(extraOmpArgs)
298298
#:set omp_clause_val = copyin_val.strip('\n') + create_val.strip('\n') + attach_val.strip('\n')
299299
#:set omp_directive = '!$omp target enter data ' + omp_clause_val + extraOmpArgs_val.strip('\n')
@@ -303,7 +303,7 @@
303303
#:def OMP_EXIT_DATA(copyout=None, delete=None, detach=None, extraOmpArgs=None)
304304
#:set copyout_val = OMP_COPYOUT_STR(copyout)
305305
#:set delete_val = OMP_DELETE_STR(delete)
306-
#:set detach_val = OMP_MAP_STR('always,from', detach)
306+
#:set detach_val = OMP_MAP_STR('detach', detach)
307307
#:set extraOmpArgs_val = GEN_EXTRA_ARGS_STR(extraOmpArgs)
308308
#:set clause_val = copyout_val.strip('\n') + delete_val.strip('\n') + detach_val.strip('\n')
309309
#:set omp_directive = '!$omp target exit data ' + clause_val + extraOmpArgs_val.strip('\n')

0 commit comments

Comments
 (0)