Skip to content

[flang][OpenMP] Custom mapper not found and crashing compilation when used in different module than which it was defined in #163385

@jfuchs-kmt

Description

@jfuchs-kmt

When using a custom mapper outside of the module it was defined, it is not found and crashes the compilation. Below is a short reproducer for the issue:

MODULE field_mod IMPLICIT NONE TYPE :: field_t REAL, ALLOCATABLE :: buf(:) END TYPE field_t !$omp declare mapper(custom: field_t :: t) map(t%buf) END MODULE field_mod PROGRAM reproducer USE field_mod IMPLICIT NONE REAL :: validation(5) TYPE(field_t) :: f_t ALLOCATE(f_t%buf(5)) f_t%buf = 42.0 !$omp target map(mapper(custom), tofrom: f_t) map(from: validation) validation(:) = f_t%buf(:) !$omp end target PRINT*, "Expected: 42. 42. 42. 42. 42." PRINT*, "Actual:", validation DEALLOCATE(f_t%buf) END PROGRAM reproducer

Compiling this code (with cuda in my case) crashes...

flang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-version=52 main.F90 -O3 

...with the error message:

error: loc("f_t"("/home/jfuchs/reproducer/main.F90":18:22)): invalid mapper id error: verification of lowering to FIR failed 

We can cross check the correct behavior by moving the !$omp declare mapper... line below into the PROGRAM directly. Then compilation succeeds and the values are as expected after the target region.

I am using flang version 22.0.0git (git@github.com:llvm/llvm-project.git a8057ff12956b7dd6dec44f9610c446c828c4af8).

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions