title: OpenMP drastically slows down for loop
body: <p>I am attempting to speed up this for loop with OpenMP parallelization.  I was under the impression that this should split up the work across a number of threads.  However, perhaps the overhead is too large for this to give me any speedup.  </p>
  
  <p>I should mention that this loop occurs many many many times, and each instance of the loop should be parallelized.  The number of loop iterations, newNx, can be as small as 3 or as large as 256.  However, if I conditionally have it parallelized only for newNx > 100 (only the largest loops), it still slows down significantly.  </p>
  
  <p>Is there anything in here which would cause this to be slower than anticipated?  I should also mention that the vectors A,v,b are VERY large, but access is O(1) I believe.</p>
  
  <pre><code>    #pragma omp parallel for private(j,k),shared(A,v,b)
      for(i=1;i&lt;=newNx;i+=2) {
        for(j=1;j&lt;=newNy;j++) { 
          for(k=1;k&lt;=newNz;k+=1) {
  
            nynz=newNy*newNz; 
  
            v[(i-1)*nynz+(j-1)*newNz+k] = 
            -(v[(i-1)*nynz+(j-1)*newNz+k+1 - 2*(k/newNz)]*A[((i-1)*nynz + (j-1)*newNz + (k-1))*spN + kup+offA] + 
            v[(i-1)*nynz+(j-1)*newNz+ k-1+2*(1/k)]*A[((i-1)*nynz + (j-1)*newNz + (k-1))*spN + kdo+offA] + 
            v[(i-1)*nynz+(j - 2*(j/newNy))*newNz+k]*A[((i-1)*nynz + (j-1)*newNz + (k-1))*spN + jup+offA] + 
            v[(i-1)*nynz+(j-2 + 2*(1/j))*newNz+k]*A[((i-1)*nynz + (j-1)*newNz + (k-1))*spN + jdo+offA] + 
            v[(i - 2*(i/newNx))*nynz+(j-1)*newNz+k]*A[((i-1)*nynz + (j-1)*newNz + (k-1))*spN + iup+offA] + 
            v[(i-2 + 2*(1/i))*nynz+(j-1)*newNz+k]*A[((i-1)*nynz + (j-1)*newNz + (k-1))*spN + ido+offA] - 
            b[(i-1)*nynz + (j-1)*newNz + k])
            /A[((i-1)*nynz + (j-1)*newNz + (k-1))*spN + ifi+offA];}}}
  </code></pre>