In OpenMP 5.2, §5.8.6, page 160 line 32-33, when a device pointer
allocated by omp_target_alloc has implicitly been included on a target
construct as a zero-length array, the pointer initialisation should not
find a matching mapped list item, and so should retain its value as a
firstprivate variable. Previously, we would return a null pointer if the
list item was not found. This patch updates the map handling to the
OpenMP 5.2 semantics.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
openmp/libomptarget/include/device.h | ||
---|---|---|
285 | IsPresent is not orthogonal to IsHostPointer. This unamed struct design is flawed. Also directly access TargetPointerResultTy member is also bad. There is lack of read only protection. accessing members should via a function. something like. std::unique_ptr<EntryFlags> flags# null is the entry doesn't exist. inline bool isPresent() const { return bool(flags); } } | |
openmp/libomptarget/test/mapping/implicit_device_ptr.c | ||
13 | Doesn't compile. Need (int *) omp_target_alloc |
openmp/libomptarget/include/device.h | ||
---|---|---|
285 |
Could you elaborate on this? They should mean different things, with the current semantics we pass the pointer first-private, but do not assume it is a valid host pointer. That's why we use both IsPresent and IsHostPointer. For USM we will have IsPresent be false and IsHostPointer be true, for this implicit mapping IsHostPointer will be false.
Sure, I'll add it. I'm not exactly sure what the utility of this struct is anyway, considering that these are just bools. | |
openmp/libomptarget/test/mapping/implicit_device_ptr.c | ||
13 | This is C code, the cast shouldn't be necessary. |
openmp/libomptarget/include/device.h | ||
---|---|---|
285 |
|
openmp/libomptarget/include/device.h | ||
---|---|---|
285 | OK. I was thinking of IsHostPointer for zero-length array. Actually your are right they are for USM. There is still some interaction between isNew and isPresent. I think isNew only make sense when isPresent is true. Maybe std::unque_ptr is not a good option because it involves memory alloc/dealloc, std::optional is better but it requires c++17. Probably still need to stay in C++14 now. So the current way is acceptable. | |
openmp/libomptarget/src/device.cpp | ||
433 | I'm wondering if the USM case and this case should be fused in a more compact way. Even the logic of USM is fishy https://github.com/llvm/llvm-project/blob/178554f3c8f983bd192818b6d46e4d95560c4964/openmp/libomptarget/src/api.cpp#L133 | |
openmp/libomptarget/test/mapping/implicit_device_ptr.c | ||
13 | You are right, I was compiling as C++. |
openmp/libomptarget/src/api.cpp | ||
---|---|---|
134 | 129-134 seems to be useless with this patch. |
IsPresent is not orthogonal to IsHostPointer. This unamed struct design is flawed.
Also directly access TargetPointerResultTy member is also bad. There is lack of read only protection. accessing members should via a function.
something like.
struct TargetPointerResultTy {
}