[Openmp-commits] [PATCH] D104924: [OpenMP] Avoid checking parent reference count in targetDataEnd

Joel E. Denny via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Jun 25 08:36:14 PDT 2021


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

The patch is intended to have the following benefits:

- Eliminates a lock/unlock of the data mapping table.
- Avoids maintaining two different implementations of the `IsLast` logic in two different places: one based on the element's reference count, and one based on its parent's reference count.
- Shortens the code.

This patch does not cause any additional `openmp` tests to fail.
However, I don't know why the implementation was originally coded to
check the parent instead of the element's reference count.  If this
patch breaks a use case, can someone explain so we can extend the test
suite?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104924

Files:
  openmp/libomptarget/src/omptarget.cpp


Index: openmp/libomptarget/src/omptarget.cpp
===================================================================
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -728,14 +728,8 @@
         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) &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104924.354516.patch
Type: text/x-patch
Size: 959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210625/d5102734/attachment-0001.bin>


More information about the Openmp-commits mailing list