]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Testsuite: Allow to set deal.II thread pool via TEST_N_THREADS
authorMatthias Maier <tamiko@43-1.org>
Tue, 8 Feb 2022 23:47:14 +0000 (17:47 -0600)
committerMatthias Maier <tamiko@43-1.org>
Wed, 9 Feb 2022 09:42:45 +0000 (03:42 -0600)
cmake/scripts/run_test.sh
tests/tests.h

index 6643c31e4d5bb1e69226d7c4a8701639bce7c68a..f941daa5fe7674b2f878f7eb1dfcfd277f674bd2 100644 (file)
@@ -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"
index 5e7a85d8cd09daf6409b327602810408aaca3185..f12d9e15428a0e0ca97c818936d6a3e578c04e97 100644 (file)
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.