Skip to content

Commit

Permalink
Use 1 thread when USE_OPENMP=0
Browse files Browse the repository at this point in the history
  • Loading branch information
alazzaro committed Dec 11, 2023
1 parent 6d3dfe0 commit d9de8d9
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
# =================================== OpenMP
if (USE_OPENMP)
set (NUM_THREADS ${TEST_OMP_THREADS})
else ()
set (NUM_THREADS 1)
endif ()

# =================================== MPI
if (USE_MPI)
if (TEST_MPI_RANKS STREQUAL "auto")
include(ProcessorCount)
ProcessorCount(nproc)
math(EXPR num_ranks "(${nproc}+${TEST_OMP_THREADS}-1)/${TEST_OMP_THREADS}"
)# get 1/$TEST_OMP_THREADS the number of procs (rounded up)
math(EXPR num_ranks "(${nproc}+${NUM_THREADS}-1)/${NUM_THREADS}"
)# get 1/$NUM_THREADS the number of procs (rounded up)
else ()
set(num_ranks ${TEST_MPI_RANKS})
endif ()
message(
"Tests will run with ${num_ranks} MPI ranks and ${TEST_OMP_THREADS} OpenMP threads each"
"Tests will run with ${num_ranks} MPI ranks and ${NUM_THREADS} OpenMP threads each"
)
endif ()

Expand Down Expand Up @@ -47,7 +54,7 @@ foreach (dbcsr_perf_test ${DBCSR_PERF_TESTS})
endif ()
set_tests_properties(
dbcsr_perf:${dbcsr_perf_test}
PROPERTIES ENVIRONMENT OMP_NUM_THREADS=${TEST_OMP_THREADS})
PROPERTIES ENVIRONMENT OMP_NUM_THREADS=${NUM_THREADS})
endforeach ()

# =================================== DBCSR CORRECTNESS TESTS Define all the
Expand Down Expand Up @@ -126,7 +133,7 @@ foreach (dbcsr_test ${DBCSR_TESTS_FTN})
if (OpenMP_FOUND)
target_link_libraries(${dbcsr_test} OpenMP::OpenMP_Fortran)
set_tests_properties(
${dbcsr_test} PROPERTIES ENVIRONMENT OMP_NUM_THREADS=${TEST_OMP_THREADS})
${dbcsr_test} PROPERTIES ENVIRONMENT OMP_NUM_THREADS=${NUM_THREADS})
endif ()
endforeach ()

Expand Down Expand Up @@ -158,7 +165,7 @@ if (WITH_C_API)
if (OpenMP_FOUND)
set_tests_properties(
${dbcsr_test_cpp_name} PROPERTIES ENVIRONMENT
OMP_NUM_THREADS=${TEST_OMP_THREADS})
OMP_NUM_THREADS=${NUM_THREADS})
endif ()
endforeach ()
endif ()
Expand All @@ -175,7 +182,7 @@ if (NOT USE_MPI)
if (OpenMP_FOUND)
set_tests_properties(
${dbcsr_test_backend} PROPERTIES ENVIRONMENT
OMP_NUM_THREADS=${TEST_OMP_THREADS})
OMP_NUM_THREADS=${NUM_THREADS})
endif ()
endforeach ()
endif ()
Expand Down

0 comments on commit d9de8d9

Please sign in to comment.