title: OpenMP parallelizing matrix multiplication by a triple for loop (performance issue)
body: <p>I'm writing a program for matrix multiplication with OpenMP, that, for cache convenience, implements the multiplication A x B(transpose) rows X rows instead of the classic A x B rows x columns, for better cache efficiency. Doing this I faced an interesting fact that for me is illogic: if in this code i parallelize the extern loop the program is slower than if I put the OpenMP directives in the most inner loop, in my computer the times are 10.9 vs 8.1 seconds.</p>
  
  <pre class="lang-c prettyprint-override"><code>//A and B are double* allocated with malloc, Nu is the lenght of the matrixes 
  //which are square
  
  //#pragma omp parallel for
  for (i=0; i&lt;Nu; i++){
    for (j=0; j&lt;Nu; j++){
      *(C+(i*Nu+j)) = 0.;
  #pragma omp parallel for
      for(k=0;k&lt;Nu ;k++){
        *(C+(i*Nu+j))+=*(A+(i*Nu+k)) * *(B+(j*Nu+k));//C(i,j)=sum(over k) A(i,k)*B(k,j)
      }
    }
  }
  </code></pre>