diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6be544b1fd1..ba57163208e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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 () @@ -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 @@ -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 () @@ -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 () @@ -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 ()