Need to map the base pointer for all directives, not only target
data-based ones.
The base pointer is mapped for array sections, array subscript, array
shaping and other array-like constructs with the base pointer. Also,
codegen for use_device_ptr clause was modified to correctly handle
mapping combination of array like constructs + use_device_ptr clause.
The data for use_device_ptr clause is emitted as the last records in the
data mapping array.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Please check the reproducer in https://bugs.llvm.org/show_bug.cgi?id=46868 with LIBOMPTARGET_DEBUG=1.
The reference counting on the base pointer variable has side effects. It was not cleaned up when these variables leave its scope.
This patch
GPU activities: 96.99% 350.05ms 10 35.005ms 1.5680us 350.00ms [CUDA memcpy HtoD]
before the July21 change
GPU activities: 95.33% 20.317ms 4 5.0793ms 1.6000us 20.305ms [CUDA memcpy HtoD]
Still more transfer than it should.
@ABataev could you have a look? My July 21 compiler was built before "[OPENMP]Fix PR46012: declare target pointer cannot be accessed in target region." gets in.
Are you talking about the number of calls value? The total number of calls will increase after the patch anyway, PTR_AND_OBJ adds 1 extra mem transfer for transferring translated pointer address.
clang/test/OpenMP/target_data_codegen.cpp | ||
---|---|---|
659–661 | MEMBER_OF_7=0x9000000000000 --> MEMBER_OF_7=0x7000000000000 |
MEMBER_OF_7=0x9000000000000 --> MEMBER_OF_7=0x7000000000000