This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][libstdc++-v3 parallel mode]

This patch improves handling the number of threads in parallel quicksort. Before, needless threads were created. This is a relict from switching to a more OpenMP compliant behavior.

Tested x86_64-unknown-linux-gnu: No regressions

Please approve for mainline and gcc-4_3-branch.

2008-05-06 Johannes Singler <>

       * include/parallel/quicksort.h:
       (parallel_sort_qs_conquer) Explicitly request number of threads
       in the parallel clause.
       (parallel_sort_qs) Remove setting the number of threads globally.

Index: include/parallel/quicksort.h
--- include/parallel/quicksort.h	(revision 134945)
+++ include/parallel/quicksort.h	(working copy)
@@ -138,7 +138,7 @@
-#pragma omp parallel sections
+#pragma omp parallel sections num_threads(2)
 #pragma omp section
 	parallel_sort_qs_conquer(begin, begin + split,
@@ -177,9 +177,6 @@
       if (num_threads > n)
         num_threads = static_cast<thread_index_t>(n);
-      // Hard to avoid.
-      omp_set_num_threads(num_threads);
       parallel_sort_qs_conquer(begin, begin + n, comp, num_threads);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]