| Issue |
176956
|
| Summary |
[flang][OpenMP] Standard Conformity of Pointer Deep Copies with Predefined Default Mapper
|
| Labels |
flang
|
| Assignees |
|
| Reporter |
jfuchs-kmt
|
When mapping a derived type containing POINTER members with the predefined default mapper, the pointers are currently deep copied. This contradicts the OpenMP Standard Version 5.2, Section 5.8.3 on page 151 at lines 29-33:
> If a component of a derived type list item is a map clause list item that results from the predefined default mapper for that derived type, and if the derived type component is not an explicit list item or the base _expression_ of an explicit list item in a map clause on the construct, then:
> - If it has the POINTER attribute, the map clause treats its association status as if it is undefined
Another resource I found was this OpenMP monthly telecon where it is also claimed that pointer members should not be deep copy with the predefined default mapper (page 15): https://www.openmp.org/wp-content/uploads/OMP-Users-Monthly-Telecon-20211210.pdf
In the code snippet below, it is shown that the pointer is actually deep copied. We fulfill the following:
- predefined mapper for `dt` is used
- pointer component for `obj%p` is not explicitly in the map clause
As such, querying `ASSOCIATED(obj%p)` should return `F` since it should be treated as undefined.
But in the current flang implementation the pointer is associated. This has the effect that its underlying data is copied with a predefined mapper which is against the standard. Additionally, the values inside `p` are transferred as shown with `ptr_content`. The expected behavior is undefined association and inaccessible data.
```fortran
PROGRAM main
IMPLICIT NONE
TYPE :: dt
REAL, POINTER :: p(:)
END TYPE dt
INTEGER, PARAMETER :: n = 5
REAL :: ptr_content(n)
LOGICAL :: assoc_result
INTEGER :: i
TYPE(dt) :: obj
ALLOCATE(obj%p(n))
obj%p = 42.0
ptr_content = -1.0
assoc_result = .FALSE.
!$omp target map(to: obj) map(from: assoc_result)
assoc_result = ASSOCIATED(obj%p)
!$omp end target
!$omp target teams loop map(to: obj) map(from: ptr_content)
DO i = 1, n
ptr_content(i) = obj%p(i)
END DO
!$omp end target teams loop
PRINT*, "associated(obj%p) on device:", assoc_result
PRINT*, "obj%p on device:", ptr_content
END PROGRAM main
```
I am compiling with `flang -fopenmp -fopenmp-targets=nvptx64 -fopenmp-version=52 main.F90` and run with `OMPTARGET_OFFLOAD=mandatory ./a.out`.
I am using a RTX 5070 Ti which should not have some unified memory interference in this test.
My flang version is very recent: `flang version 23.0.0git ([email protected]:llvm/llvm-project.git dd83ead9a51ff39fbde7e12fbf70a49a8353dbd2)`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs