[Openmp-commits] [PATCH] D147511: [OpenMP] Fix nextgen plugin thread_limit clause bug on generic kernels.

Michael Halkenhäuser via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Apr 4 02:14:51 PDT 2023


mhalk created this revision.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a project: All.
mhalk requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, jplehr, sstefan1.
Herald added a project: OpenMP.

ThreadLimitClause is declared as uint, but could be set to '-1'. That case was causing problems and is handled in this patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147511

Files:
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp


Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
===================================================================
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -279,8 +279,13 @@
                                         uint32_t ThreadLimitClause[3]) const {
   assert(ThreadLimitClause[1] == 0 && ThreadLimitClause[2] == 0 &&
          "Multi dimensional launch not supported yet.");
-  if (ThreadLimitClause[0] > 0 && isGenericMode())
-    ThreadLimitClause[0] += GenericDevice.getWarpSize();
+
+  if (ThreadLimitClause[0] > 0 && isGenericMode()) {
+    if (ThreadLimitClause[0] == (uint32_t)-1)
+      ThreadLimitClause[0] = PreferredNumThreads;
+    else
+      ThreadLimitClause[0] += GenericDevice.getWarpSize();
+  }
 
   return std::min(MaxNumThreads, (ThreadLimitClause[0] > 0)
                                      ? ThreadLimitClause[0]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147511.510723.patch
Type: text/x-patch
Size: 1010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230404/15f0ed7f/attachment.bin>


More information about the Openmp-commits mailing list