Note that there are some explanatory texts on larger screens.

plurals
  1. POParallelize recursive function with OpenMP v.2.0
    primarykey
    data
    text
    <p>I'm trying to parallelize parts of a project that relies on a lot of recursive algorithms.</p> <p>Most of them are some form of binary tree creation or traversal and processing.</p> <p>I'm stuck using GCC v. 4.1.2 on RedHat and the VC++ compiler on Windows (both don't support OpenMP 3.0 with its convenient <code>task</code> construct). I found <a href="https://stackoverflow.com/questions/8023135/c-openmp-parallel-quicksort">this question</a> which seems to get the job done with nested parallel sections and some throttling to prevent an exorbitant number of threads.</p> <p>My question: any way to avoid this approach? Some of the functions are called at each timestep, the overhead of repeatedly creating and destroying a thread team is unacceptable.</p> <p>Here's the basic structure of a recursive function I've been using, in line with the linked question:</p> <pre class="lang-cpp prettyprint-override"><code>extern int threads; omp_set_nested(1); omp_set_num_threads(2); void cell::updateRecursive() { // do stuff for cell for this timestep #pragma omp flush(threads) if (threads&gt;=omp_get_num_procs()) { child0-&gt;updateRecursive(); child1-&gt;updateRecursive(); // no new threads } else { #pragma omp atomic threads++; #pragma omp flush(threads) #pragma omp parallel sections nowait { #pragma omp seciton child0-&gt;updateRecursive(); #pragma omp section child1-&gt;updateRecursive(); } #pragma omp atomic threads--; } } </code></pre> <p>This would be sufficient if this function weren't called so often. I'd like a way to recurse that can use an existing team of threads to perform work, rather than creating one while traversing the tree.</p> <p>Would this be possible at all without <code>task</code>? I've experimented with simply using <code>sections</code>, but apparently they can't be nested to use an existing team of threads.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload