This patch add codegen support for the has_device_addr clause. It use the same logic of is_device_ptr. But passing &var instead pointer to var to kernal.
This is follow up of revert of https://reviews.llvm.org/D134186
Paths
| Differential D134268
[Clang][OpenMP] Codegen generation for has_device_addr claues. ClosedPublic Authored by jyu2 on Sep 20 2022, 2:04 AM.
Details Summary This patch add codegen support for the has_device_addr clause. It use the same logic of is_device_ptr. But passing &var instead pointer to var to kernal. This is follow up of revert of https://reviews.llvm.org/D134186
Diff Detail
Event Timeline
Comment Actions Address @abhinavgaba's comment by setting capture by reference instead by copy.
This revision is now accepted and ready to land.Sep 20 2022, 1:13 PM Closed by commit rG48ffd40ba295: [Clang][OpenMP] Codegen generation for has_device_addr claues. (authored by jyu2). · Explain WhySep 20 2022, 9:32 PM This revision was automatically updated to reflect the committed changes. Comment Actions Hi there, I'm trying to fix https://github.com/llvm/llvm-project/issues/59160. The faulty case is basically like the following: void xoo() { short a[10], b[10]; a[1] = 111; b[1] = 111; #pragma omp target data map(to : a[0 : 2], b[0 : 2]) use_device_addr(a, b) #pragma omp target has_device_addr(a) has_device_addr(b[0]) { a[1] = 222; b[1] = 222; // CHECK: 222 222 printf("%hd %hd %p %p %p\n", a[1], b[1], &a, b, &b); } // CHECK:111 printf("%hd %hd %p %p %p\n", a[1], b[1], &a, b, &b); // 111 111 p1d p2d p3d } It looks like at runtime, we are trying to copy a (device) pointer to a device pointer by using host to device data transfer. I noticed that's because we have TO flag marked for the argument. However, since a and b are in has_device_addr, we are not supposed to map the two variables right?
Revision Contents
Diff 461789 clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/target_has_device_addr_codegen.cpp
clang/test/OpenMP/target_has_device_addr_codegen_01.cpp
openmp/libomptarget/test/mapping/has_device_addr.cpp
openmp/libomptarget/test/mapping/target_has_device_addr.c
|
The variable used in has_device_addr indicates it already has device address and can be accessed directly. Why do we need OMP_MAP_TO here? OMP_MAP_TO indicates we are gonna transfer data to the device right?