[Openmp-commits] [PATCH] D107928: [OpenMP] Use IsHostPtr where needed in rest of omptarget.cpp

Joel E. Denny via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Aug 11 13:07:02 PDT 2021


jdenny created this revision.
jdenny added reviewers: grokos, tianshilei1992, RaviNarayanaswamy, jdoerfert.
jdenny added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
jdenny requested review of this revision.
Herald added a subscriber: sstefan1.

As started in D107925 <https://reviews.llvm.org/D107925>, this patch replaces the remaining occurrences of
`UNIFIED_SHARED_MEMORY && TgtPtrBegin == HstPtrBegin` in
`omptarget.cpp` with `IsHostPtr`.  The former condition is broken in
the rare case that the device and host happen to use the same address
for their mapped allocations.  I don't know how to write a test that's
likely to reveal this case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107928

Files:
  openmp/libomptarget/src/omptarget.cpp


Index: openmp/libomptarget/src/omptarget.cpp
===================================================================
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -825,8 +825,7 @@
     return OFFLOAD_SUCCESS;
   }
 
-  if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY &&
-      TgtPtrBegin == HstPtrBegin) {
+  if (IsHostPtr) {
     DP("hst data:" DPxMOD " unified and shared, becomes a noop\n",
        DPxPTR(HstPtrBegin));
     return OFFLOAD_SUCCESS;
@@ -1265,7 +1264,7 @@
         void *HstPtrVal = Args[I];
         void *HstPtrBegin = ArgBases[I];
         void *HstPtrBase = Args[Idx];
-        bool IsLast, IsHostPtr; // unused.
+        bool IsLast, IsHostPtr; // IsLast is unused.
         void *TgtPtrBase =
             (void *)((intptr_t)TgtArgs[TgtIdx] + TgtOffsets[TgtIdx]);
         DP("Parent lambda base " DPxMOD "\n", DPxPTR(TgtPtrBase));
@@ -1279,8 +1278,7 @@
              DPxPTR(HstPtrVal));
           continue;
         }
-        if (PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY &&
-            TgtPtrBegin == HstPtrBegin) {
+        if (IsHostPtr) {
           DP("Unified memory is active, no need to map lambda captured"
              "variable (" DPxMOD ")\n",
              DPxPTR(HstPtrVal));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107928.365831.patch
Type: text/x-patch
Size: 1282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210811/fb7fc0c6/attachment.bin>


More information about the Openmp-commits mailing list