title: OpenMP parallelize for construct performance
body: <p>First method (parallelize inner loop):</p>
  
  <pre><code>for(j=0; j&lt;LATTICE_VW; ++j) {
      x = j*DX + LATTICE_W;
      #pragma omp parallel for ordered private(y, prob)
          for(i=0; i&lt;LATTICE_VH; ++i) {
              y = i*DY + LATTICE_S;
              prob = psi[i][j].norm();
  
              #pragma omp ordered
                  out &lt;&lt; x &lt;&lt; " " &lt;&lt; y &lt;&lt; " " &lt;&lt; prob &lt;&lt; endl;
          }
  }
  </code></pre>
  
  <p>Second method (parallelize outer loop):</p>
  
  <pre><code>#pragma omp parallel for ordered private(x, y, prob)
      for(j=0; j&lt;LATTICE_VW; ++j) {
          x = j*DX + LATTICE_W;
          for(i=0; i&lt;LATTICE_VH; ++i) {
              y = i*DY + LATTICE_S;
              prob = psi[i][j].norm();
  
              #pragma omp ordered
                  out &lt;&lt; x &lt;&lt; " " &lt;&lt; y &lt;&lt; " " &lt;&lt; prob &lt;&lt; endl;
          }
      }
  </code></pre>
  
  <p>Third method (parallelize collapsed loops)</p>
  
  <pre><code>#pragma omp parallel for collapse(2) ordered private(x, y, prob)
      for(j=0; j&lt;LATTICE_VW; ++j) {
          for(i=0; i&lt;LATTICE_VH; ++i) {
              x = j*DX + LATTICE_W;
              y = i*DY + LATTICE_S;
              prob = psi[i][j].norm();
  
              #pragma omp ordered
                  out &lt;&lt; x &lt;&lt; " " &lt;&lt; y &lt;&lt; " " &lt;&lt; prob &lt;&lt; endl;
          }
      }
  </code></pre>
  
  <p>If I was going to guess I would say that method 3 should be the fastest.</p>
  
  <p>However method 1 is the fastest, while both the second and third take about the same ammount of time as if there was no parallelization. Why does this happens?</p>