[Openmp-commits] [PATCH] D110195: [OpenMP] Add thread ID function into new RTL

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Sep 21 12:34:22 PDT 2021


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

The new device runtime library currently lacks the
`kmpc_get_hardware_thread_id_in_block` function which is currently used
when doing the SPMDzation optimization. This call would be introduced
through the optimization and then cause a linking error because it was
not present. This patch adds support for this runtime call.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110195

Files:
  openmp/libomptarget/DeviceRTL/include/Interface.h
  openmp/libomptarget/DeviceRTL/src/Mapping.cpp


Index: openmp/libomptarget/DeviceRTL/src/Mapping.cpp
===================================================================
--- openmp/libomptarget/DeviceRTL/src/Mapping.cpp
+++ openmp/libomptarget/DeviceRTL/src/Mapping.cpp
@@ -226,4 +226,9 @@
 bool mapping::isGenericMode() { return !isSPMDMode(); }
 ///}
 
+extern "C" {
+uint32_t __kmpc_get_hardware_thread_id_in_block() {
+  return mapping::getThreadIdInBlock();
+}
+}
 #pragma omp end declare target
Index: openmp/libomptarget/DeviceRTL/include/Interface.h
===================================================================
--- openmp/libomptarget/DeviceRTL/include/Interface.h
+++ openmp/libomptarget/DeviceRTL/include/Interface.h
@@ -198,6 +198,9 @@
 /// Called by the worker threads in the parallel region (function).
 void __kmpc_get_shared_variables(void ***GlobalArgs);
 
+/// External interface to get the thread ID.
+uint32_t __kmpc_get_hardware_thread_id_in_block();
+
 /// Kernel
 ///
 ///{


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110195.374011.patch
Type: text/x-patch
Size: 954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210921/aeaa460e/attachment.bin>


More information about the Openmp-commits mailing list