[Openmp-commits] [llvm] [openmp] [OpenMP] Fix target data region codegen being omitted for device pass (PR #85218)

Akash Banerjee via Openmp-commits openmp-commits at lists.llvm.org
Tue Mar 19 10:59:52 PDT 2024


TIFitis wrote:

> Could you elaborate on this? What code associated with the target data is required on the device? That doesn't connect in my mind and I'm worried this hides a different problem. The test doesn't help me understand what happened before either.

Take the following test:
```
!$omp target data map(to: A, B) map(alloc: C)
!$omp target
  do I = 1, 10
     C(I) = A(I) + B(I) ! assigns 3, A:1 + B:2
  end do
!$omp end target
!$omp end target data
```

We don't need to emit any code for target data on the device pass, but the target directive nested inside it needs device pass codegen. By not having the BodyGenCB callback, we were omitting this codegen which this patch brings back.

Note that both Clang and Flang don't actually emit any code for the target data region unless it is target code.

The following example still doesn't produce any code for the device pass related to target data or it's nested region.
```
!$omp target data map(to: A, B) map(alloc: C)
  do I = 1, 10
     C(I) = A(I) + B(I) ! assigns 3, A:1 + B:2
  end do
!$omp end target data
```


https://github.com/llvm/llvm-project/pull/85218


More information about the Openmp-commits mailing list