[flang-commits] [flang] [flang][OpenMP] Attach compiler-emitted mappers to arrays of records (PR #179892)
Kareem Ergawy via flang-commits
flang-commits at lists.llvm.org
Tue Feb 10 22:17:22 PST 2026
================
@@ -2784,7 +2784,8 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
if (!mapperIdName.empty()) {
bool allowImplicitMapper =
- semantics::IsAllocatableOrObjectPointer(&sym);
+ semantics::IsAllocatableOrObjectPointer(&sym) ||
+ requiresImplicitDefaultDeclareMapper(*typeSpec);
----------------
ergawy wrote:
Thanks for the suggestion Akash. But, unfortunately, that does not seem to solve the offload issue. With your suggestion, `explicit-and-implicit-record-field-mapping.f90` would still fail if the test is changed to use arrays of records:
```diff
@@ -25,52 +25,52 @@ program reproducer
use test
implicit none
integer :: i, j
- TYPE(chunk_type) :: chunk
+ TYPE(chunk_type) :: chunk(1)
- allocate(chunk%tiles(2))
+ allocate(chunk(1)%tiles(2))
do i = 1, 2
- allocate(chunk%tiles(i)%field%density0(2, 2))
- allocate(chunk%tiles(i)%field%density1(2, 2))
+ allocate(chunk(1)%tiles(i)%field%density0(2, 2))
+ allocate(chunk(1)%tiles(i)%field%density1(2, 2))
do j = 1, 4
- chunk%tiles(i)%tile_neighbours(j) = j * 10
+ chunk(1)%tiles(i)%tile_neighbours(j) = j * 10
end do
end do
!$omp target enter data map(alloc: &
- !$omp chunk%tiles(2)%field%density0)
+ !$omp chunk(1)%tiles(2)%field%density0)
!$omp target
- chunk%tiles(2)%field%density0(1,1) = 25
- chunk%tiles(2)%field%density0(1,2) = 50
- chunk%tiles(2)%field%density0(2,1) = 75
- chunk%tiles(2)%field%density0(2,2) = 100
+ chunk(1)%tiles(2)%field%density0(1,1) = 25
+ chunk(1)%tiles(2)%field%density0(1,2) = 50
+ chunk(1)%tiles(2)%field%density0(2,1) = 75
+ chunk(1)%tiles(2)%field%density0(2,2) = 100
!$omp end target
!$omp target exit data map(from: &
- !$omp chunk%tiles(2)%field%density0)
+ !$omp chunk(1)%tiles(2)%field%density0)
- if (chunk%tiles(2)%field%density0(1,1) /= 25) then
+ if (chunk(1)%tiles(2)%field%density0(1,1) /= 25) then
print*, "======= Test Failed! ======="
stop 1
end if
- if (chunk%tiles(2)%field%density0(1,2) /= 50) then
+ if (chunk(1)%tiles(2)%field%density0(1,2) /= 50) then
print*, "======= Test Failed! ======="
stop 1
end if
- if (chunk%tiles(2)%field%density0(2,1) /= 75) then
+ if (chunk(1)%tiles(2)%field%density0(2,1) /= 75) then
print*, "======= Test Failed! ======="
stop 1
end if
- if (chunk%tiles(2)%field%density0(2,2) /= 100) then
+ if (chunk(1)%tiles(2)%field%density0(2,2) /= 100) then
print*, "======= Test Failed! ======="
stop 1
end if
do j = 1, 4
- if (chunk%tiles(2)%tile_neighbours(j) /= j * 10) then
+ if (chunk(1)%tiles(2)%tile_neighbours(j) /= j * 10) then
print*, "======= Test Failed! ======="
stop 1
end if
```
We would still get the runtime crash:
```
explicit extension not allowed: host address specified is 0x00000000002dff90 (72 bytes), but device allocation maps to host at 0x00000000002dff98 (64 bytes)
```
I think the fact that the map is implicit is lost somewhere during MLIR to LLVM translation and this is where I think the fix should be.
https://github.com/llvm/llvm-project/pull/179892
More information about the flang-commits
mailing list