Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing openmp better
    primarykey
    data
    text
    <p>I am trying to implement openMP, but like so many other posters before me, the result has simply been to slow the code down. Inspired by previous answers, I went from using <code>#pragma omp parallel for</code> to <code>#pragma omp task</code>, in the hope that I could avoid some overhead. Unfortunately, the parallelized code is still twice as slow as the serial. From other answers, it seems that the proper procedure depends on the specific demands of the code, which is why I thought I would have to ask a question myself.</p> <p>First the pseudo-code:</p> <pre><code>#pragma omp parallel { #pragma omp master while (will be run some hundreds of millions of times) { for (between 5 and 20 iterations) { #pragma omp task (something) } #pragma omp taskwait &lt;- it is important that all the above tasks are completed before going on (something) if (something) { (something) for (between 50 and 200 iterations) { #pragma omp task (something) } #pragma omp taskwait (something) } } } </code></pre> <p>Only the two for-loops can be parallelized, the rest must be done in the right order. I came up with putting the parallel and master directives outside the while-loop in an attempt at reducing the overhead of creating the team. </p> <p>I am also a bit curious whether I am using taskwait properly - the specification states that the "parent task" is put on hold until all child tasks have been executed, but it is not quite clear whether that terminology also applies here, where the task regions are not nested.</p> <p>Can anyone come up with a better way of using openMP, such that I may actually get a speed-up?</p> <p>EDIT: each step in the while-loop depends on all previous steps, and thus they have to be done serially, with an update at the end. It is an implementation of an "event-driven-algorithm" for simulating neural networks, if anyone was wondering.</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.
 

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