From: Matthias Maier Date: Tue, 8 Feb 2022 23:47:14 +0000 (-0600) Subject: Testsuite: Allow to set deal.II thread pool via TEST_N_THREADS X-Git-Tag: v9.4.0-rc1~518^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41f7992346cd7c81deb156c0f6075c12b51e788c;p=dealii.git Testsuite: Allow to set deal.II thread pool via TEST_N_THREADS --- diff --git a/cmake/scripts/run_test.sh b/cmake/scripts/run_test.sh index 6643c31e4d..f941daa5fe 100644 --- a/cmake/scripts/run_test.sh +++ b/cmake/scripts/run_test.sh @@ -44,7 +44,7 @@ case $STAGE in ## # Limit the deal.II thread pool to TEST_THREAD_LIMIT threads. - export DEAL_II_NUM_THREADS="${TEST_THREAD_LIMIT}" + export TEST_N_THREADS="${TEST_THREAD_LIMIT}" # Limit the OpenMP pool to two threads. export OMP_NUM_THREADS="2" diff --git a/tests/tests.h b/tests/tests.h index 5e7a85d8cd..f12d9e1542 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -418,15 +418,26 @@ filter_out_small_numbers(const Number number, const double tolerance) /* - * If we run 64 tests at the same time on a 64-core system, and - * each of them runs 64 threads, then we get astronomical loads. - * Limit concurrency to a fixed (small) number of threads, independent - * of the core count. + * If we run 64 tests at the same time on a 64-core system, and each of + * them runs 64 threads, then we get astronomical loads. Limit concurrency + * to a fixed (small) number of threads, independent of the core count. The + * limit defaults to 3 and can be overriden by the environment variable + * TEST_N_THREADS. */ inline unsigned int testing_max_num_threads() { - return 3; + if (const char *penv = std::getenv("TEST_N_THREADS")) + try + { + return Utilities::string_to_int(std::string(penv)); + } + catch (...) + { + return 3; + } + else + return 3; } struct LimitConcurrency