]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Set OMP_NUM_THREADS=2 in the test suite. 4501/head
authorDavid Wells <wellsd2@rpi.edu>
Thu, 8 Jun 2017 20:44:18 +0000 (16:44 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Thu, 8 Jun 2017 23:44:37 +0000 (19:44 -0400)
cmake/scripts/run_test.sh
tests/base/openmp_threads.cc [new file with mode: 0644]
tests/base/openmp_threads.output [new file with mode: 0644]

index 4365a5ab3370013593a137d61dafce3c4091cefa..d0b798e0b906eabba2f2f17e6cd1aea0238d7e68 100644 (file)
@@ -32,6 +32,8 @@ shift 2
 
 # Ensure uniform sorting for pathname expansion
 export LC_ALL=C
+# Prevent OpenMP from creating additional threads
+export OMP_NUM_THREADS=2
 
 case $STAGE in
   run)
diff --git a/tests/base/openmp_threads.cc b/tests/base/openmp_threads.cc
new file mode 100644 (file)
index 0000000..2ea9835
--- /dev/null
@@ -0,0 +1,42 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// Ensure that, when executing test suite programs, the environment variable
+// OMP_NUM_THREADS is set to 2.
+
+#include "../tests.h"
+
+#include <cstdlib>
+
+int main()
+{
+  initlog();
+
+  // This might not work on Windows; always pass if we don't have getenv
+  // available
+#ifdef _POSIX_C_SOURCE
+  const char *omp_env_variable = getenv("OMP_NUM_THREADS");
+  AssertThrow(omp_env_variable != nullptr,
+              ExcMessage("The environment variable OMP_NUM_THREADS should be "
+                         "defined when running the test suite."));
+  if (std::string(omp_env_variable) == "2")
+    {
+      deallog << "OK" << std::endl;
+    }
+#else
+  deallog << "OK" << std::endl;
+#endif
+}
diff --git a/tests/base/openmp_threads.output b/tests/base/openmp_threads.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK

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.