title: No performance with pragma omp for
body: <p>I'm start learn the OpenMP, uses for parallel computing, and I test the following code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(int argc, char* argv[])
  {
      int i,j,k,a = -59, b = 19,N,R;      
      struct timeval T1, T2;
          long delta_ms;
  
          N = atoi(argv[1]);
      float m1[N][N], m2[N][N], m3[N][N];
  
      gettimeofday(&amp;T1, NULL); 
  
  
      #pragma omp parallel for default(none) private(R,i,j,k) shared(N,b,a,m1, m2, m3)
      for (R=0; R&lt;100; R++) 
          {
          srand(R);
  
          #pragma omp parallel for default(none) private(i,j) shared(N,b,a,m1)
          for (i = 0; i &lt; N; i++){
              for (j = 0; j &lt; N; j++){
                  m1[i][j] = (float) rand() / RAND_MAX * (b - a + 1) + a;
              }
          }
  
          #pragma omp parallel for default(none) private(i,j) shared(N,m1,m2)
          for (i = 0; i &lt; N; i++){
              for (j = 0; j &lt; N; j++){
                  m2[i][j] = m1[i][j] * 5;  
              }
          }
  
          #pragma omp parallel for default(none) private(i,j,k) shared(N,m1,m2,m3)
          for(i = 0; i &lt; N; i++){
              for(j = 0; j &lt; N; j++){
                  m3[i][j] = 0;
                  for(k = 0; k &lt; N; k++){
                      m3[i][j] = m3[i][j] + (m1[i][k] * m2[k][j]);
                  }
              }
          }
  
  
          }
      gettimeofday(&amp;T2, NULL);
      delta_ms = 1000*(T2.tv_sec - T1.tv_sec) + (T2.tv_usec - T1.tv_usec)/1000;
      printf("\nN=%d. Milliseconds passed: %ld\n", N, delta_ms);
      return 0;
  }
  </code></pre>
  
  <p>the characteristics of my computer:</p>
  
  <p>I use the virtual machine (Virtual Box). I installed the Ubuntu 14.04. My virtual machine uses the 3 CPU's and 1 Gb RAM. I use the gcc compiler, version 4.8</p>
  
  <p>Now I have the big interest by the following situation:</p>
  
  <ol>
  <li>I compile my code with no <code>-fopenmp</code> key: <code>gcc -o code1 code1.c</code>.</li>
  </ol>
  
  <p>When I run the code1 and I see:</p>
  
  <pre><code>N=300. Milliseconds passed: 13706
  </code></pre>
  
  <ol start="2">
  <li>I compile my code with key <code>-fopenmp</code>: <code>gcc -o code1 code1.c -fopenmp</code>.</li>
  </ol>
  
  <p>When I run the code1 and I see:</p>
  
  <pre><code>N=300. Milliseconds passed: 4898
  </code></pre>
  
  <ol start="3">
  <li>I compile my code with key <code>-fopenmp</code> and I use only one <code>#pragma omp for</code>:</li>
  </ol>
  
  <p><code>#pragma omp parallel for default(none) private(R,i,j,k) shared(N,b,a,m1, m2, m3) 
  for (R=0; R&lt;100; R++) 
  {...}</code></p>
  
  <p>When I run the code1 and I see:</p>
  
  <pre><code>N=300. Milliseconds passed: 4919
  </code></pre>
  
  <p>The results from steps 2 and 3 are equals.</p>
  
  <p>Can anybody explain to me why this is happening? </p>
  
  <p>I read documentation by OpenMP, but I doesn't find the answer.</p>