[Openmp-commits] [PATCH] D111950: [OpenMP][FIX] Query proper thread ID information to support nesting

Johannes Doerfert via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sat Oct 16 12:42:26 PDT 2021

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

The OpenMP thread ID is not the hardware thread ID if we have nesting.
We need to ask the runtime properly to ensure correct results.

Note that the loop interface is going to change soon so we do not adjust
it now but simply ignore the extra argument.

  rG LLVM Github Monorepo



Index: openmp/libomptarget/DeviceRTL/src/Workshare.cpp
--- openmp/libomptarget/DeviceRTL/src/Workshare.cpp
+++ openmp/libomptarget/DeviceRTL/src/Workshare.cpp
@@ -114,14 +114,10 @@
   // Support for Static Init
-  static void for_static_init(int32_t gtid, int32_t schedtype,
+  static void for_static_init(int32_t, int32_t schedtype,
                               int32_t *plastiter, T *plower, T *pupper,
                               ST *pstride, ST chunk, bool IsSPMDExecutionMode) {
-    // When IsRuntimeUninitialized is true, we assume that the caller is
-    // in an L0 parallel region and that all worker threads participate.
-    // Assume we are in teams region or that we use a single block
-    // per target region
+    int32_t gtid = omp_get_thread_num();
     int numberOfActiveOMPThreads = omp_get_num_threads();
     // All warps that are in excess of the maximum requested, do

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111950.380209.patch
Type: text/x-patch
Size: 1056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20211016/1a29dcc7/attachment.bin>

More information about the Openmp-commits mailing list