[Openmp-commits] [PATCH] D132885: [libomptarget] Deprecate old method for setting the tripcount

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Aug 29 16:04:32 PDT 2022


jhuber6 updated this revision to Diff 456486.
jhuber6 added a comment.

Adding deprecation warning


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132885/new/

https://reviews.llvm.org/D132885

Files:
  openmp/libomptarget/include/device.h
  openmp/libomptarget/src/LegacyAPI.cpp
  openmp/libomptarget/src/omptarget.cpp


Index: openmp/libomptarget/src/omptarget.cpp
===================================================================
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -1130,26 +1130,6 @@
   return nullptr;
 }
 
-/// Get loop trip count
-/// FIXME: This function will not work right if calling
-/// __kmpc_push_target_tripcount_mapper in one thread but doing offloading in
-/// another thread, which might occur when we call task yield.
-uint64_t getLoopTripCount(int64_t DeviceId) {
-  DeviceTy &Device = *PM->Devices[DeviceId];
-  uint64_t LoopTripCount = 0;
-
-  {
-    std::lock_guard<std::mutex> TblMapLock(PM->TblMapMtx);
-    auto I = Device.LoopTripCnt.find(__kmpc_global_thread_num(NULL));
-    if (I != Device.LoopTripCnt.end()) {
-      LoopTripCount = I->second;
-      Device.LoopTripCnt.erase(I);
-    }
-  }
-
-  return LoopTripCount;
-}
-
 /// A class manages private arguments in a target region.
 class PrivateArgumentManagerTy {
   /// A data structure for the information of first-private arguments. We can
@@ -1512,8 +1492,6 @@
   }
   assert(TargetTable && "Global data has not been mapped\n");
 
-  // FIXME: Use legacy tripcount method if it is '-1'.
-  Tripcount = Tripcount == -1UL ? getLoopTripCount(DeviceId) : Tripcount;
   DP("loop trip count is %" PRIu64 ".\n", Tripcount);
 
   // We need to keep bases and offsets separate. Sometimes (e.g. in OpenCL) we
Index: openmp/libomptarget/src/LegacyAPI.cpp
===================================================================
--- openmp/libomptarget/src/LegacyAPI.cpp
+++ openmp/libomptarget/src/LegacyAPI.cpp
@@ -77,7 +77,7 @@
                                map_var_info_t *ArgNames, void **ArgMappers) {
   TIMESCOPE_WITH_IDENT(Loc);
   __tgt_kernel_arguments KernelArgs{
-      1, ArgNum, ArgsBase, Args, ArgSizes, ArgTypes, ArgNames, ArgMappers, -1};
+      1, ArgNum, ArgsBase, Args, ArgSizes, ArgTypes, ArgNames, ArgMappers, 0};
   return __tgt_target_kernel(Loc, DeviceId, -1, -1, HostPtr, &KernelArgs);
 }
 
@@ -120,7 +120,7 @@
   TIMESCOPE_WITH_IDENT(Loc);
 
   __tgt_kernel_arguments KernelArgs{
-      1, ArgNum, ArgsBase, Args, ArgSizes, ArgTypes, ArgNames, ArgMappers, -1};
+      1, ArgNum, ArgsBase, Args, ArgSizes, ArgTypes, ArgNames, ArgMappers, 0};
   return __tgt_target_kernel(Loc, DeviceId, NumTeams, ThreadLimit, HostPtr,
                              &KernelArgs);
 }
@@ -165,17 +165,7 @@
 EXTERN void __kmpc_push_target_tripcount_mapper(ident_t *Loc, int64_t DeviceId,
                                                 uint64_t LoopTripcount) {
   TIMESCOPE_WITH_IDENT(Loc);
-  if (checkDeviceAndCtors(DeviceId, Loc)) {
-    DP("Not offloading to device %" PRId64 "\n", DeviceId);
-    return;
-  }
-
-  DP("__kmpc_push_target_tripcount(%" PRId64 ", %" PRIu64 ")\n", DeviceId,
-     LoopTripcount);
-  PM->TblMapMtx.lock();
-  PM->Devices[DeviceId]->LoopTripCnt[__kmpc_global_thread_num(NULL)] =
-      LoopTripcount;
-  PM->TblMapMtx.unlock();
+  DP("WARNING: __kmpc_push_target_tripcount has been deprecated and is a noop");
 }
 
 EXTERN void __kmpc_push_target_tripcount(int64_t DeviceId,
Index: openmp/libomptarget/include/device.h
===================================================================
--- openmp/libomptarget/include/device.h
+++ openmp/libomptarget/include/device.h
@@ -334,10 +334,6 @@
 
   std::mutex PendingGlobalsMtx, ShadowMtx;
 
-  // NOTE: Once libomp gains full target-task support, this state should be
-  // moved into the target task in libomp.
-  std::map<int32_t, uint64_t> LoopTripCnt;
-
   DeviceTy(RTLInfoTy *RTL);
   // DeviceTy is not copyable
   DeviceTy(const DeviceTy &D) = delete;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132885.456486.patch
Type: text/x-patch
Size: 3653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220829/021599b5/attachment.bin>


More information about the Openmp-commits mailing list