[Openmp-commits] [PATCH] D32033: Make test/parallel/omp_nested.c not use so many threads

Hal Finkel via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Apr 13 10:37:11 PDT 2017


hfinkel created this revision.
Herald added a subscriber: mcrosier.

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.


https://reviews.llvm.org/D32033

Files:
  runtime/test/parallel/omp_nested.c


Index: runtime/test/parallel/omp_nested.c
===================================================================
--- runtime/test/parallel/omp_nested.c
+++ runtime/test/parallel/omp_nested.c
@@ -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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32033.95162.patch
Type: text/x-patch
Size: 383 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20170413/5c625001/attachment.bin>


More information about the Openmp-commits mailing list