Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Don't nest it too deep. Usually, it would be enough to identify a good point for parallelization and get away with just one directive.</p> <p>Some comments and probably the root of your problem:</p> <pre><code> #pragma omp parallel default(shared) // Here you open several threads ... { #pragma omp for for (int nY = nYTop; nY &lt;= nYBottom; nY++) { #pragma omp parallel shared(nY, nYBottom) // Same here ... { #pragma omp for for (int nX = nXLeft; nX &lt;= nXRight; nX++) { </code></pre> <p>(Conceptually) you are opening many threads, in each of them you open many threads again in the for loop. For each thread in the for loop, you open many threads again, and for each of those, you open again many in another for loop.</p> <p>That's <code>(thread (thread)*)+</code> in pattern matching words; there should just be <code>thread+</code></p> <p>Just do a single parallel for. Don't be to fine-grained, parallelize on the outer loop, each thread should run as long as possible:</p> <pre><code>#pragma omp parallel for for (int nY = nYTop; nY &lt;= nYBottom; nY++) { for (int nX = nXLeft; nX &lt;= nXRight; nX++) { } } </code></pre> <p>Avoid data and cache sharing between the threads (another reason why the threads shouldn't be too fine grained on your data).</p> <p>If that's running stable and shows good speed up, you can fine tune it with different scheduling algorithms as per your OpenMP reference card.</p> <p>And put your variable declarations to where you really need them. Do not overwrite what is read by sibling threads.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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