title: Parallel tasks get better performances with boost::thread than with ppl or OpenMP
body: <p>I have a C++ program which could be parallelized. I'm using Visual Studio 2010, 32bit compilation.</p>
  
  <p>In short the structure of the program is the following</p>
  
  <pre><code>#define num_iterations 64 //some number
  
  struct result
  { 
      //some stuff
  }
  
  result best_result=initial_bad_result;
  
  for(i=0; i&lt;many_times; i++)
  { 
      result *results[num_iterations];
  
  
      for(j=0; j&lt;num_iterations; j++)
      {
          some_computations(results+j);
      }
  
      // update best_result; 
  }
  </code></pre>
  
  <p>Since each <code>some_computations()</code> is independent(some global variables read, but no global variables modified) I parallelized the inner <code>for</code>-loop.</p>
  
  <p>My first attempt was with <strong>boost::thread</strong>, </p>
  
  <pre><code> thread_group group;
   for(j=0; j&lt;num_iterations; j++)
   {
       group.create_thread(boost::bind(&amp;some_computation, this, result+j));
   } 
   group.join_all();
  </code></pre>
  
  <p>The results were good, but I decided to try more.</p>
  
  <p>I tried the <strong>OpenMP</strong> library</p>
  
  <pre><code> #pragma omp parallel for
   for(j=0; j&lt;num_iterations; j++)
   {
       some_computations(results+j);
   } 
  </code></pre>
  
  <p>The results were worse than the <code>boost::thread</code>'s ones.</p>
  
  <p>Then I tried the <strong>ppl</strong> library and used <code>parallel_for()</code>:</p>
  
  <pre><code> Concurrency::parallel_for(0,num_iterations, [=](int j) { 
       some_computations(results+j);
   })
  </code></pre>
  
  <p>The results were the worst.</p>
  
  <p>I found this behaviour quite surprising. Since OpenMP and ppl are designed for the parallelization, I would have expected better results, than <code>boost::thread</code>. Am I wrong?</p>
  
  <p>Why is <code>boost::thread</code> giving me better results? </p>