-
Notifications
You must be signed in to change notification settings - Fork 15k
Open
Labels
Description
I am using the most recent flang version 22.0.0git ([email protected]:llvm/llvm-project.git 89f53af3fffed3e41167fbb7bc10d4885cd97c7f)
.
The snippet below shows that when omitting the optional mapper-identifier (custom
in this case), then real_arr
is not mapped properly from and/or to the device.
! flang -O2 -fopenmp -fopenmp-version=52 -fopenmp-targets=nvptx64-nvidia-cuda main.F90 -D_IDENTIFIER_
PROGRAM reproducer
IMPLICIT NONE
TYPE :: real_t
REAL, ALLOCATABLE :: real_arr(:)
END TYPE real_t
#ifdef _IDENTIFIER_
!$omp declare mapper(custom: real_t :: t) map(tofrom: t%real_arr)
#else
!$omp declare mapper(real_t :: t) map(tofrom: t%real_arr)
#endif
TYPE(real_t) :: r
ALLOCATE(r%real_arr(10), source=1.0)
PRINT*, "BEFORE TARGET REGION:"
PRINT*, "real_arr: ", r%real_arr
PRINT*, ""
!$omp target map(tofrom: r)
r%real_arr = 3.0
!$omp end target
PRINT*, "AFTER TARGET REGION:"
PRINT*, "real_arr: ", r%real_arr
DEALLOCATE(r%real_arr)
END PROGRAM reproducer
- Compiling the program with
-D_IDENTIFIER_
gives the expected result wherereal_arr
contains the values3.0
after the target region since it is being written to there and mapped back to the host - Compiling without the flag gives the bad behavior, where
real_arr
contains the values1.0
after the target region. Thus the data mapping is not performed properly