[llvm] [OpenMP][libomptarget] Add map checks when running under unified shared memory (PR #69005)

Gheorghe-Teodor Bercea via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 16 08:25:20 PDT 2023


================
@@ -444,6 +486,29 @@ DeviceTy::getTgtPtrBegin(void *HstPtrBegin, int64_t Size, bool UpdateRefCount,
          LR.TPR.getEntry()->dynRefCountToStr().c_str(), DynRefCountAction,
          LR.TPR.getEntry()->holdRefCountToStr().c_str(), HoldRefCountAction);
     LR.TPR.TargetPointer = (void *)TP;
+
+    // If this entry is not marked as being host pointer (the way the
+    // implementation works today this is never true, mistake?) then we
+    // have to check if this is a host pointer or not. This is a host pointer
+    // if the host address matches the target address.
+    if ((PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY) &&
+        !LR.TPR.Flags.IsHostPointer) {
+      // If addresses match it means that we are dealing with a host pointer
+      // which has to be marked as one and present flag reset:
+      if (LR.TPR.getEntry()->TgtPtrBegin == LR.TPR.getEntry()->HstPtrBegin) {
+        LR.TPR.Flags.IsPresent = false;
----------------
doru1004 wrote:

The idea is that in certain cases like implicit mapping this function will be called several times. The IsHostPointer and IsPresent flags need to be correctly set every time. This code ensure that.

https://github.com/llvm/llvm-project/pull/69005


More information about the llvm-commits mailing list