Issue 156466
Summary [flang][OpenMP] Omitting optional mapper-identifier in declare mapper breaks data mapping
Labels
Assignees
Reporter jfuchs-kmt
    I am using the most recent `flang version 22.0.0git (g...@github.com: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.

```fortran
! 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
```

1. Compiling the program with `-D_IDENTIFIER_` gives the expected result where `real_arr` contains the values `3.0` after the target region since it is being written to there and mapped back to the host
2. Compiling without the flag gives the bad behavior, where `real_arr` contains the values `1.0` after the target region. Thus the data mapping is not performed properly
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to