From 4ff93383cdbf4c51146e0ffb624426502a2aeb95 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 29 Nov 2023 14:50:01 -0800 Subject: [PATCH] Fix: nosmt OMP Threads Default Fix that `OMP_NUM_THREADS` was ignored in non-verbose runs. --- Src/Base/AMReX_OpenMP.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Src/Base/AMReX_OpenMP.cpp b/Src/Base/AMReX_OpenMP.cpp index 5ddd9944411..c0c33ce962f 100644 --- a/Src/Base/AMReX_OpenMP.cpp +++ b/Src/Base/AMReX_OpenMP.cpp @@ -152,12 +152,13 @@ namespace amrex::OpenMP // default or OMP_NUM_THREADS environment variable } else if (omp_threads == "nosmt") { char const *env_omp_num_threads = std::getenv("OMP_NUM_THREADS"); - if (env_omp_num_threads != nullptr && amrex::system::verbose > 1) { + if (env_omp_num_threads == nullptr) { + omp_set_num_threads(numUniquePhysicalCores()); + } + else if (amrex::system::verbose > 1) { amrex::Print() << "amrex.omp_threads was set to nosmt," << "but OMP_NUM_THREADS was set. Will keep " << "OMP_NUM_THREADS=" << env_omp_num_threads << ".\n"; - } else { - omp_set_num_threads(numUniquePhysicalCores()); } } else { std::optional num_omp_threads = to_int(omp_threads);