From: Matthias Maier Date: Tue, 8 Feb 2022 23:20:10 +0000 (-0600) Subject: CMake: add a TEST_THREAD_LIMIT variable to enforce thread limits X-Git-Tag: v9.4.0-rc1~518^2~6 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffe23ecfe60788351376f51609dff6258a2b8447;p=dealii.git CMake: add a TEST_THREAD_LIMIT variable to enforce thread limits --- diff --git a/cmake/macros/macro_deal_ii_add_test.cmake b/cmake/macros/macro_deal_ii_add_test.cmake index 3c460fba5c..97d5a77b2f 100644 --- a/cmake/macros/macro_deal_ii_add_test.cmake +++ b/cmake/macros/macro_deal_ii_add_test.cmake @@ -73,10 +73,13 @@ # to run # # TEST_MPI_RANK_LIMIT -# - specifying the maximal number of MPI ranks that can be used. If a +# - Specifies the maximal number of MPI ranks that can be used. If a # test variant configures a larger number of MPI ranks (via # .mpirun=N. in the output file) than this limit the test will be -# dropped. The special value "0" enforces no limit. +# dropped. The special value 0 enforces no limit. Defaults to 0. +# TEST_THREAD_LIMIT +# - Specifies the maximal number of worker threads that can be used by +# the threading backend. Defaults to 3. # # Usage: # DEAL_II_ADD_TEST(category test_name comparison_file) @@ -323,7 +326,8 @@ FUNCTION(DEAL_II_ADD_TEST _category _test_name _comparison_file) # ADD_CUSTOM_COMMAND(OUTPUT ${_test_directory}/output - COMMAND sh ${DEAL_II_PATH}/${DEAL_II_SHARE_RELDIR}/scripts/run_test.sh + COMMAND TEST_THREAD_LIMIT=${TEST_THREAD_LIMIT} + sh ${DEAL_II_PATH}/${DEAL_II_SHARE_RELDIR}/scripts/run_test.sh run "${_test_full}" ${_run_args} COMMAND ${PERL_EXECUTABLE} -pi ${DEAL_II_PATH}/${DEAL_II_SHARE_RELDIR}/scripts/normalize.pl diff --git a/cmake/macros/macro_deal_ii_pickup_tests.cmake b/cmake/macros/macro_deal_ii_pickup_tests.cmake index 2722cb2a59..3655ca1bc6 100644 --- a/cmake/macros/macro_deal_ii_pickup_tests.cmake +++ b/cmake/macros/macro_deal_ii_pickup_tests.cmake @@ -27,20 +27,23 @@ # TEST_LIBRARIES # TEST_LIBRARIES_DEBUG # TEST_LIBRARIES_RELEASE -# - specifying additional libraries (and targets) to link against. +# - Specify additional libraries (and targets) to link against. # # TEST_TARGET or # TEST_TARGET_DEBUG and TEST_TARGET_RELEASE -# - specifying a test target to be executed for a parameter run. +# - Specifies a test target to be executed for a parameter run. # # TEST_TIME_LIMIT # - Specifies the maximal wall clock time in seconds a test is # allowed to run. Defaults to 600. # TEST_MPI_RANK_LIMIT -# - specifying the maximal number of MPI ranks that can be used. If a +# - Specifies the maximal number of MPI ranks that can be used. If a # test variant configures a larger number of MPI ranks (via # .mpirun=N. in the output file) than this limit the test will be -# dropped. The special value "0" enforces no limit. +# dropped. The special value 0 enforces no limit. Defaults to 0. +# TEST_THREAD_LIMIT +# - Specifies the maximal number of worker threads that can be used +# by the threading backend. Defaults to 3. # # TEST_PICKUP_REGEX # - A regular expression to select only a subset of tests during setup. @@ -184,6 +187,9 @@ MACRO(DEAL_II_PICKUP_TESTS) SET_IF_EMPTY(TEST_MPI_RANK_LIMIT "$ENV{TEST_MPI_RANK_LIMIT}") SET_IF_EMPTY(TEST_MPI_RANK_LIMIT 0) + SET_IF_EMPTY(TEST_THREAD_LIMIT "$ENV{TEST_THREAD_LIMIT}") + SET_IF_EMPTY(TEST_THREAD_LIMIT 3) + # # ... and finally pick up tests: # diff --git a/cmake/scripts/run_test.sh b/cmake/scripts/run_test.sh index f5f3162686..6643c31e4d 100644 --- a/cmake/scripts/run_test.sh +++ b/cmake/scripts/run_test.sh @@ -31,10 +31,6 @@ shift 2 # Ensure uniform sorting for pathname expansion export LC_ALL=C -# Prevent OpenMP from creating additional threads -export OMP_NUM_THREADS=2 -# Allow oversubscription for MPI (needed for Openmpi@3.0) -export OMPI_MCA_rmaps_base_oversubscribe=1 case $STAGE in run) @@ -47,6 +43,15 @@ case $STAGE in # failing_output ## + # Limit the deal.II thread pool to TEST_THREAD_LIMIT threads. + export DEAL_II_NUM_THREADS="${TEST_THREAD_LIMIT}" + + # Limit the OpenMP pool to two threads. + export OMP_NUM_THREADS="2" + + # Allow oversubscription for MPI (needed for Openmpi@3.0) + export OMPI_MCA_rmaps_base_oversubscribe=1 + rm -f failing_output rm -f output rm -f stdout