[Openmp-commits] [openmp] 1d04563 - [OpenMP] Avoid checking parent reference count in targetDataEnd

Joel E. Denny via Openmp-commits openmp-commits at lists.llvm.org
Sat Jul 10 09:27:38 PDT 2021


Author: Joel E. Denny
Date: 2021-07-10T12:15:04-04:00
New Revision: 1d0456361a4216855e8e7646dc28a372aff07efb

URL: https://github.com/llvm/llvm-project/commit/1d0456361a4216855e8e7646dc28a372aff07efb
DIFF: https://github.com/llvm/llvm-project/commit/1d0456361a4216855e8e7646dc28a372aff07efb.diff

LOG: [OpenMP] Avoid checking parent reference count in targetDataEnd

The patch has the following benefits:

* Eliminates a lock/unlock of the data mapping table.
* Clarifies the logic that determines whether a struct member's
  device-to-host transfer occurs.  The old logic, which checks the
  parent struct's reference count, is a leftover from back when we had
  a different map interface (as pointed out at
  <https://reviews.llvm.org/D104924#2846972>).

Reviewed By: grokos

Differential Revision: https://reviews.llvm.org/D104924

Added: 
    

Modified: 
    openmp/libomptarget/src/omptarget.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp
index e187e3d650d60..19a3c4ddad698 100644
--- a/openmp/libomptarget/src/omptarget.cpp
+++ b/openmp/libomptarget/src/omptarget.cpp
@@ -731,14 +731,8 @@ int targetDataEnd(ident_t *loc, DeviceTy &Device, int32_t ArgNum,
         if (!(PM->RTLs.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY) ||
             HasCloseModifier) {
           if ((ArgTypes[I] & OMP_TGT_MAPTYPE_MEMBER_OF) &&
-              !(ArgTypes[I] & OMP_TGT_MAPTYPE_PTR_AND_OBJ)) {
-            // Copy data only if the "parent" struct has RefCount==1.
-            int32_t ParentIdx = getParentIndex(ArgTypes[I]);
-            uint64_t ParentRC = Device.getMapEntryRefCnt(Args[ParentIdx]);
-            assert(ParentRC > 0 && "parent struct not found");
-            if (ParentRC == 1)
-              CopyMember = true;
-          }
+              !(ArgTypes[I] & OMP_TGT_MAPTYPE_PTR_AND_OBJ))
+            CopyMember = IsLast;
         }
 
         if ((DelEntry || Always || CopyMember) &&


        


More information about the Openmp-commits mailing list