[Openmp-commits] [openmp] e95731c - [OpenMP] Add thread ID function into new RTL

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Tue Sep 21 14:44:06 PDT 2021


Author: Joseph Huber
Date: 2021-09-21T17:43:50-04:00
New Revision: e95731cca7ecf5be22ea67a273cb19ba2c14d54c

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

LOG: [OpenMP] Add thread ID function into new RTL

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.

Reviewed By: tianshilei1992

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/include/Interface.h b/openmp/libomptarget/DeviceRTL/include/Interface.h
index 1a8471a2352f3..027d2c9e13645 100644
--- a/openmp/libomptarget/DeviceRTL/include/Interface.h
+++ b/openmp/libomptarget/DeviceRTL/include/Interface.h
@@ -198,6 +198,9 @@ void __kmpc_end_sharing_variables();
 /// 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
 ///
 ///{

diff  --git a/openmp/libomptarget/DeviceRTL/src/Mapping.cpp b/openmp/libomptarget/DeviceRTL/src/Mapping.cpp
index 3bd055322cfbc..ee2aeeea47002 100644
--- a/openmp/libomptarget/DeviceRTL/src/Mapping.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Mapping.cpp
@@ -226,4 +226,9 @@ bool mapping::isSPMDMode() { return IsSPMDMode; }
 bool mapping::isGenericMode() { return !isSPMDMode(); }
 ///}
 
+extern "C" {
+uint32_t __kmpc_get_hardware_thread_id_in_block() {
+  return mapping::getThreadIdInBlock();
+}
+}
 #pragma omp end declare target


        


More information about the Openmp-commits mailing list