[Openmp-commits] [PATCH] D69485: [nfc][libomptarget] Move smid() into target_impl

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sun Oct 27 12:49:08 PDT 2019


JonChesterfield created this revision.
JonChesterfield added reviewers: ABataev, jdoerfert, grokos.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.

[nfc][libomptarget] Move smid() into target_impl


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69485

Files:
  openmp/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h


Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
@@ -91,6 +91,12 @@
   return res;
 }
 
+INLINE uint32_t __kmpc_impl_smid() {
+  uint32_t id;
+  asm("mov.u32 %0, %%smid;" : "=r"(id));
+  return id;
+}
+
 INLINE uint32_t __kmpc_impl_ffs(uint32_t x) { return __ffs(x); }
 
 INLINE uint32_t __kmpc_impl_popc(uint32_t x) { return __popc(x); }
Index: openmp/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu
+++ openmp/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu
@@ -25,12 +25,6 @@
 // init entry points
 ////////////////////////////////////////////////////////////////////////////////
 
-INLINE static unsigned smid() {
-  unsigned id;
-  asm("mov.u32 %0, %%smid;" : "=r"(id));
-  return id;
-}
-
 EXTERN void __kmpc_kernel_init_params(void *Ptr) {
   PRINT(LD_IO, "call to __kmpc_kernel_init_params with version %f\n",
         OMPTARGET_NVPTX_VERSION);
@@ -53,7 +47,7 @@
   PRINT0(LD_IO, "call to __kmpc_kernel_init for master\n");
 
   // Get a state object from the queue.
-  int slot = smid() % MAX_SM;
+  int slot = __kmpc_impl_smid() % MAX_SM;
   usedSlotIdx = slot;
   omptarget_nvptx_threadPrivateContext =
       omptarget_nvptx_device_State[slot].Dequeue();
@@ -98,7 +92,7 @@
                                                   : RuntimeUninitialized);
   int threadId = GetThreadIdInBlock();
   if (threadId == 0) {
-    usedSlotIdx = smid() % MAX_SM;
+    usedSlotIdx = __kmpc_impl_smid() % MAX_SM;
     parallelLevel[0] =
         1 + (GetNumberOfThreadsInBlock() > 1 ? OMP_ACTIVE_PARALLEL_LEVEL : 0);
   } else if (GetLaneId() == 0) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69485.226587.patch
Type: text/x-patch
Size: 1888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20191027/957036b1/attachment.bin>


More information about the Openmp-commits mailing list