-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Closed
Copy link
Labels
Description
I am using the most recent flang version 22.0.0git (git@github.com:llvm/llvm-project.git 89f53af3fffed3e41167fbb7bc10d4885cd97c7f)
.
The reproducer below shows that when using a custom declare mapper
for real_t
, then even when we specify t%base_arr
within the mapper, the array is not mapped properly in a target region.
I am compiling this reproducer with flang -O2 -fopenmp -fopenmp-version=52 -fopenmp-targets=nvptx64-nvidia-cuda main.F90
and run it with OMP_TARGET_OFFLOAD=mandatory ./a.out
.
PROGRAM reproducer
IMPLICIT NONE
TYPE, ABSTRACT :: base_t
REAL, ALLOCATABLE :: base_arr(:)
END TYPE base_t
TYPE, EXTENDS(base_t) :: real_t
REAL, ALLOCATABLE :: real_arr(:)
END TYPE real_t
!$omp declare mapper(custommapper: real_t :: t) map(t%base_arr, t%real_arr)
TYPE(real_t) :: r
ALLOCATE(r%base_arr(10), source=1.0)
ALLOCATE(r%real_arr(10), source=1.0)
PRINT*, "BEFORE TARGET REGION:"
PRINT*, "base_arr: ", r%base_arr
PRINT*, "real_arr: ", r%real_arr
PRINT*, ""
!$omp target map(tofrom: r)
r%base_arr = 2.0 ! This write has no effect since base_arr is not mapped properly
r%real_arr = 3.0 ! This is fine
!r%real_arr = r%base_arr(1) ! UNCOMMENT THIS --> results in (core dumped) since we read from an unmapped base_arr
!$omp end target
PRINT*, "AFTER TARGET REGION:"
PRINT*, "base_arr: ", r%base_arr ! We would expect "2. ..." here
PRINT*, "real_arr: ", r%real_arr
DEALLOCATE(r%real_arr)
DEALLOCATE(r%base_arr)
END PROGRAM reproducer
The error message when reading from base_arr(1)
by uncommenting the third line in the target region is:
"PluginInterface" error: Failure to copy data from device to host. Pointers: host = 0x000064a6f0418ab0, device = 0x00007ac120a00200, size = 40: "unknown or internal error" error in cuMemcpyDtoHAsync: an illegal memory access was encountered
omptarget error: Copying data from device failed.
omptarget error: Call to targetDataEnd failed, abort target.
omptarget error: Failed to process data after launching the kernel.
omptarget error: Consult https://openmp.llvm.org/design/Runtimes.html for debugging options.
omptarget error: Source location information not present. Compile with -g or -gline-tables-only.
omptarget fatal error 1: failure of target construct while offloading is mandatory
Aborted (core dumped)