[Openmp-commits] [PATCH] D123891: [libomptarget] Make omp_target_is_present checks storage instead of zero length array.
Ye Luo via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Fri Apr 22 15:37:43 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8a880db51929: [libomptarget] Make omp_target_is_present checks storage instead of zero length… (authored by ye-luo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123891/new/
https://reviews.llvm.org/D123891
Files:
openmp/libomptarget/src/api.cpp
openmp/libomptarget/test/mapping/target_implicit_partial_map.c
Index: openmp/libomptarget/test/mapping/target_implicit_partial_map.c
===================================================================
--- openmp/libomptarget/test/mapping/target_implicit_partial_map.c
+++ openmp/libomptarget/test/mapping/target_implicit_partial_map.c
@@ -13,6 +13,18 @@
#pragma omp target data map(alloc: arr[50:2]) // partially mapped
{
+ // CHECK: arr[50] must present: 1
+ fprintf(stderr, "arr[50] must present: %d\n",
+ omp_target_is_present(&arr[50], omp_get_default_device()));
+
+ // CHECK: arr[0] should not present: 0
+ fprintf(stderr, "arr[0] should not present: %d\n",
+ omp_target_is_present(&arr[0], omp_get_default_device()));
+
+ // CHECK: arr[49] should not present: 0
+ fprintf(stderr, "arr[49] should not present: %d\n",
+ omp_target_is_present(&arr[49], omp_get_default_device()));
+
#pragma omp target // would implicitly map with full size but already present
{
arr[50] = 5;
@@ -20,8 +32,8 @@
} // must treat as present (dec ref count) even though full size not present
} // wouldn't delete if previous ref count dec didn't happen
- // CHECK: still present: 0
- fprintf(stderr, "still present: %d\n",
+ // CHECK: arr[50] still present: 0
+ fprintf(stderr, "arr[50] still present: %d\n",
omp_target_is_present(&arr[50], omp_get_default_device()));
return 0;
Index: openmp/libomptarget/src/api.cpp
===================================================================
--- openmp/libomptarget/src/api.cpp
+++ openmp/libomptarget/src/api.cpp
@@ -108,8 +108,12 @@
DeviceTy &Device = *PM->Devices[device_num];
bool IsLast; // not used
bool IsHostPtr;
+ // omp_target_is_present tests whether a host pointer refers to storage that
+ // is mapped to a given device. However, due to the lack of the storage size,
+ // only check 1 byte. Cannot set size 0 which checks whether the pointer (zero
+ // lengh array) is mapped instead of the referred storage.
TargetPointerResultTy TPR =
- Device.getTgtPtrBegin(const_cast<void *>(ptr), 0, IsLast,
+ Device.getTgtPtrBegin(const_cast<void *>(ptr), 1, IsLast,
/*UpdateRefCount=*/false,
/*UseHoldRefCount=*/false, IsHostPtr);
int rc = (TPR.TargetPointer != NULL);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123891.424638.patch
Type: text/x-patch
Size: 2324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220422/dcf7b74f/attachment-0001.bin>
More information about the Openmp-commits
mailing list