Skip to content

Commit 0cd1385

Browse files
authored
Fix: nosmt OMP Threads Default (#3647)
## Summary Fix that `OMP_NUM_THREADS` was ignored in non-verbose runs. ## Additional background Follow-up to #3607 ## Checklist The proposed changes: - [x] fix a bug or incorrect behavior in AMReX - [ ] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate
1 parent 44c5c7a commit 0cd1385

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Src/Base/AMReX_OpenMP.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,13 @@ namespace amrex::OpenMP
152152
// default or OMP_NUM_THREADS environment variable
153153
} else if (omp_threads == "nosmt") {
154154
char const *env_omp_num_threads = std::getenv("OMP_NUM_THREADS");
155-
if (env_omp_num_threads != nullptr && amrex::system::verbose > 1) {
155+
if (env_omp_num_threads == nullptr) {
156+
omp_set_num_threads(numUniquePhysicalCores());
157+
}
158+
else if (amrex::system::verbose > 1) {
156159
amrex::Print() << "amrex.omp_threads was set to nosmt,"
157160
<< "but OMP_NUM_THREADS was set. Will keep "
158161
<< "OMP_NUM_THREADS=" << env_omp_num_threads << ".\n";
159-
} else {
160-
omp_set_num_threads(numUniquePhysicalCores());
161162
}
162163
} else {
163164
std::optional<int> num_omp_threads = to_int(omp_threads);

0 commit comments

Comments
 (0)