[Openmp-commits] [openmp] r306357 - Make test/parallel/omp_nested.c not use so many threads

Hal Finkel via Openmp-commits openmp-commits at lists.llvm.org
Mon Jun 26 20:04:25 PDT 2017


Author: hfinkel
Date: Mon Jun 26 20:04:25 2017
New Revision: 306357

URL: http://llvm.org/viewvc/llvm-project?rev=306357&view=rev
Log:
Make test/parallel/omp_nested.c not use so many threads

I've found it very difficult to get test/parallel/omp_nested.c to pass
consistently across my build environments. The problem is that it creates N^2
threads (it is testing nested parallel regions), and that often exceeds the
thread limits on systems with many cores. We do raise the process limits in
lit, and that often helps, but if running lit with a smaller number of threads
or on a system where we're otherwise resource constrained, this particular test
tends to fail (because the runtime cannot create a sufficient number of
threads).

This seems to work: if the maximum number of threads is more than some small
number, then cap the number of threads used for the parallel region. The choice
of 4 here is somewhat arbitrary.

Differential Revision: https://reviews.llvm.org/D32033

Modified:
    openmp/trunk/runtime/test/parallel/omp_nested.c

Modified: openmp/trunk/runtime/test/parallel/omp_nested.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/parallel/omp_nested.c?rev=306357&r1=306356&r2=306357&view=diff
==============================================================================
--- openmp/trunk/runtime/test/parallel/omp_nested.c (original)
+++ openmp/trunk/runtime/test/parallel/omp_nested.c Mon Jun 26 20:04:25 2017
@@ -9,6 +9,11 @@
  */
 int test_omp_nested()
 {
+#ifdef _OPENMP
+  if (omp_get_max_threads() > 4)
+    omp_set_num_threads(4);
+#endif
+
   int counter = 0;
 #ifdef _OPENMP
   omp_set_nested(1);




More information about the Openmp-commits mailing list