[Openmp-commits] [openmp] 0029059 - [NFC][OpenMP][Offloading] Unified the construction of mapping table entry

Shilei Tian via Openmp-commits openmp-commits at lists.llvm.org
Tue Jun 22 09:38:53 PDT 2021


Author: Shilei Tian
Date: 2021-06-22T12:38:47-04:00
New Revision: 002905907432b19c1ce303d2cd8e3896dd360683

URL: https://github.com/llvm/llvm-project/commit/002905907432b19c1ce303d2cd8e3896dd360683
DIFF: https://github.com/llvm/llvm-project/commit/002905907432b19c1ce303d2cd8e3896dd360683.diff

LOG: [NFC][OpenMP][Offloading] Unified the construction of mapping table entry

This patch unifies construction of mapping table entry to use `emplace`.

Reviewed By: grokos

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

Added: 
    

Modified: 
    openmp/libomptarget/src/device.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/src/device.cpp b/openmp/libomptarget/src/device.cpp
index 82692c05d700a..7950a07b7bc51 100644
--- a/openmp/libomptarget/src/device.cpp
+++ b/openmp/libomptarget/src/device.cpp
@@ -76,17 +76,16 @@ int DeviceTy::associatePtr(void *HstPtrBegin, void *TgtPtrBegin, int64_t Size) {
   }
 
   // Mapping does not exist, allocate it with refCount=INF
-  HostDataToTargetTy newEntry((uintptr_t)HstPtrBegin /*HstPtrBase*/,
-                              (uintptr_t)HstPtrBegin /*HstPtrBegin*/,
-                              (uintptr_t)HstPtrBegin + Size /*HstPtrEnd*/,
-                              (uintptr_t)TgtPtrBegin /*TgtPtrBegin*/, nullptr,
-                              true /*IsRefCountINF*/);
-
+  auto Res = HostDataToTargetMap.emplace(
+      (uintptr_t)HstPtrBegin /*HstPtrBase*/,
+      (uintptr_t)HstPtrBegin /*HstPtrBegin*/,
+      (uintptr_t)HstPtrBegin + Size /*HstPtrEnd*/,
+      (uintptr_t)TgtPtrBegin /*TgtPtrBegin*/, nullptr, true /*IsRefCountINF*/);
+  auto NewEntry = Res.first;
   DP("Creating new map entry: HstBase=" DPxMOD ", HstBegin=" DPxMOD
      ", HstEnd=" DPxMOD ", TgtBegin=" DPxMOD "\n",
-     DPxPTR(newEntry.HstPtrBase), DPxPTR(newEntry.HstPtrBegin),
-     DPxPTR(newEntry.HstPtrEnd), DPxPTR(newEntry.TgtPtrBegin));
-  HostDataToTargetMap.insert(newEntry);
+     DPxPTR(NewEntry->HstPtrBase), DPxPTR(NewEntry->HstPtrBegin),
+     DPxPTR(NewEntry->HstPtrEnd), DPxPTR(NewEntry->TgtPtrBegin));
 
   DataMapMtx.unlock();
 
@@ -269,9 +268,8 @@ void *DeviceTy::getOrAllocTgtPtr(void *HstPtrBegin, void *HstPtrBase,
          "HstPtrBegin=" DPxMOD ", TgtPtrBegin=" DPxMOD ", Size=%ld, Name=%s\n",
          DPxPTR(HstPtrBegin), DPxPTR(tp), Size,
          (HstPtrName) ? getNameFromMapping(HstPtrName).c_str() : "unknown");
-    HostDataToTargetMap.emplace(
-        HostDataToTargetTy((uintptr_t)HstPtrBase, (uintptr_t)HstPtrBegin,
-                           (uintptr_t)HstPtrBegin + Size, tp, HstPtrName));
+    HostDataToTargetMap.emplace((uintptr_t)HstPtrBase, (uintptr_t)HstPtrBegin,
+                                (uintptr_t)HstPtrBegin + Size, tp, HstPtrName);
     rc = (void *)tp;
   }
 


        


More information about the Openmp-commits mailing list