[Openmp-commits] [PATCH] D145105: [Libomptarget] Fix block and thread limit environment variables not being respected
Joseph Huber via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Mar 1 12:12:54 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG656378085e7f: [Libomptarget] Fix block and thread limit environment variables not being… (authored by jhuber6).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145105/new/
https://reviews.llvm.org/D145105
Files:
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
openmp/libomptarget/test/api/omp_env_vars.c
Index: openmp/libomptarget/test/api/omp_env_vars.c
===================================================================
--- /dev/null
+++ openmp/libomptarget/test/api/omp_env_vars.c
@@ -0,0 +1,12 @@
+// RUN: %libomptarget-compile-generic
+// RUN: env OMP_NUM_TEAMS=1 OMP_TEAMS_THREAD_LIMIT=1 LIBOMPTARGET_INFO=16 \
+// RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic
+
+#define N 256
+
+int main() {
+ // CHECK: Launching kernel [[KERNEL:.+_main_.+]] with 1 blocks and 1 threads
+#pragma omp target teams
+#pragma omp parallel
+ {}
+}
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
@@ -352,15 +352,7 @@
OMPX_InitialNumEvents("LIBOMPTARGET_NUM_INITIAL_EVENTS", 32),
DeviceId(DeviceId), GridValues(OMPGridValues),
PeerAccesses(NumDevices, PeerAccessState::PENDING), PeerAccessesLock(),
- PinnedAllocs(*this) {
- if (OMP_NumTeams > 0)
- GridValues.GV_Max_Teams =
- std::min(GridValues.GV_Max_Teams, uint32_t(OMP_NumTeams));
-
- if (OMP_TeamsThreadLimit > 0)
- GridValues.GV_Max_WG_Size =
- std::min(GridValues.GV_Max_WG_Size, uint32_t(OMP_TeamsThreadLimit));
-}
+ PinnedAllocs(*this) {}
Error GenericDeviceTy::init(GenericPluginTy &Plugin) {
if (auto Err = initImpl(Plugin))
@@ -385,6 +377,16 @@
return HeapSizeEnvarOrErr.takeError();
OMPX_TargetHeapSize = std::move(*HeapSizeEnvarOrErr);
+ // Update the maximum number of teams and threads after the device
+ // initialization sets the corresponding hardware limit.
+ if (OMP_NumTeams > 0)
+ GridValues.GV_Max_Teams =
+ std::min(GridValues.GV_Max_Teams, uint32_t(OMP_NumTeams));
+
+ if (OMP_TeamsThreadLimit > 0)
+ GridValues.GV_Max_WG_Size =
+ std::min(GridValues.GV_Max_WG_Size, uint32_t(OMP_TeamsThreadLimit));
+
// Enable the memory manager if required.
auto [ThresholdMM, EnableMM] = MemoryManagerTy::getSizeThresholdFromEnv();
if (EnableMM)
@@ -1191,7 +1193,6 @@
GenericPluginTy &Plugin = Plugin::get();
GenericDeviceTy &Device = Plugin.getDevice(DeviceId);
-
auto TableOrErr = Device.loadBinary(Plugin, TgtImage);
if (!TableOrErr) {
auto Err = TableOrErr.takeError();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145105.501625.patch
Type: text/x-patch
Size: 2426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230301/9b90cdda/attachment-0001.bin>
More information about the Openmp-commits
mailing list