[Openmp-commits] [PATCH] D158802: [OpenMP] Honor `thread_limit` value when choosing grid size

Johannes Doerfert via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Aug 24 19:07:47 PDT 2023


jdoerfert added inline comments.


================
Comment at: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp:332
+      getNumBlocks(GenericDevice, KernelArgs.NumTeams, KernelArgs.Tripcount,
+                   NumThreads, NumThreads == KernelArgs.ThreadLimit[0]);
 
----------------
Just check if the user set anything (ThreadLimit[0] > 0), we might still reduce it before but we should not reduce it further here.


================
Comment at: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp:401
       [[maybe_unused]] auto OldNumThreads = NumThreads;
       if (LoopTripCount >= DefaultNumBlocks * NumThreads) {
         // Enough parallelism for teams and threads.
----------------
You don't need the changes above if you add `|| IsNumThreadsFromUser` above. That makes it clear we keep the value and just compute num teams based on it. Rather than having all these intermediate computations we do not use.


================
Comment at: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp:424
       } else {
-        // Not enough parallelism for teams and threads, limit both.
-        NumThreads = std::min(NumThreads, MinThreads);
+        // Not enough parallelism for teams and threads, limit both NumThreads
+        // value is not from user.
----------------



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158802/new/

https://reviews.llvm.org/D158802



More information about the Openmp-commits mailing list