title: openMP excessive synchronization
body: <p>I am trying to add an openMP parallelization into quite a big Project and I found out the openMP does too much synchronization <strong>outside</strong> the parallel blocks.</p>
  
  <p>This synchronization is done for all of the variables, even those not used in the parallel block and it is done continuously, not only before entering the block.</p>
  
  <p>I made an example proving this:</p>
  
  <pre><code>#include &lt;cmath&gt;
  
  int main()
  {
      double dummy1 = 1.234;
  
      int const size = 1000000;
      int const size1 = 2500;
      int const size2 = 500;
  
      for(unsigned int i=0; i&lt;size; ++i){
  
          //for (unsigned int j=0; j&lt;size1; j++){
          //  dummy1 = pow(dummy1/2 + 1, 1.5);
          //}
  
          #pragma omp parallel for
          for (unsigned int j=0; j&lt;size2; j++){
              double dummy2 = 2.345;
              dummy2 = pow(dummy2/2 + 1, 1.5);
          }
      }
  }
  </code></pre>
  
  <p>If I run this code (with the for cycle commented), the runtimes are 6.75s with parallelization and 30.6s without. Great.</p>
  
  <p>But if I uncomment the for cycle and run it again, the excessive synchronization kicks in and I get results 67.9s with parallelization and 73s without. If I increase size1 I even get slower results with parallelization than without it.</p>
  
  <p>Is there a way to disable this synchronization and force it only before the second for cycle? Or any other way how to improve the speed? </p>
  
  <p>Note that the outer neither the first for cycle are in the real example parallelizable. The outer one is in fact a ODE solver and the first inner one updating of loads of inner values.</p>
  
  <p>I am using gcc (SUSE Linux) 4.8.5</p>
  
  <p>Thanks for Your answers.</p>