title: Performance OpenMP collapse vs no collapse for large nested loops
body: <p>I was wondering if anyone knows a bid more about the perfomance of the collapse cause for large nested loops?
  Meaning I would like to compare the pragmas</p>
  
  <p><code>omp parallel for private(i,j,k) collapse(3) schedule(static)</code></p>
  
  <p>and</p>
  
  <p><code>omp parallel for private(i,j,k) schedule(static)</code></p>
  
  <p>for a nested loop construct like</p>
  
  <pre><code>for(int i=0; i&lt;i_max; i++){
    for(int j=0; j&lt;j_max; j++){
     for(int k=0; k&lt;k_max; k++){
       A[i][j][k]=B[i][j][k]+C[i][j][k];
                                }
                               }
                              }
  </code></pre>
  
  <p>where i_max, j_max and k_max are all something like 5 - 10 times larger than the number of threads available.</p>
  
  <p>If I understood the collapse cause correctly openmp would just collapse the 3 loops into one having the size <code>i_max*j_max*k_max</code>and I would assume best perfomance if <code>(i_max*j_max*k_max) mod #threads = 0</code>.</p>
  
  <p>Is it right that without the collapse cause openmp would only take the i loop parallel? If so my next assumption would be to get the best perfomance for <code>i_max mod #threads = 0</code> and I would expect comparable performances for both pragmas.</p>
  
  <p>As you can see I am pretty much guessing here. Did anyone actually test the performance of both pragmas for cases such as this?</p>