title: OpenMP time and clock() give two different results
body: <p>I have sequential code to parallelize via OpenMP. I have put in the corresponding pragmas and tested it. I measure the performance gain by checking the time spent in the main function.</p>
  
  <p>The weird thing is the elapsed time calculated via <code>cpu_time()</code> and <code>omp_get_wtime()</code> is different. Why?</p>
  
  <p>The elapsed time according to <code>cpu_time()</code> is similar to the sequential time.</p>
  
  <p>Before computation starts:</p>
  
  <pre><code>ctime1_ = cpu_time();
  #ifdef _OPENMP
  ctime1 = omp_get_wtime();
  #endif
  </code></pre>
  
  <p>After computation ends:</p>
  
  <pre><code>ctime2_ = cpu_time();
  #ifdef _OPENMP
  ctime2 = omp_get_wtime();
  #endif
  </code></pre>
  
  <p>cpu_time() function definition:</p>
  
  <pre><code>double cpu_time(void)
  {
    double value;
    value = (double) clock () / (double) CLOCKS_PER_SEC;
    return value;
  }
  </code></pre>
  
  <p>Printing result:</p>
  
  <pre><code>printf("%f - %f seconds.\n", ctime2 - ctime1, ctime2_ - ctime1_);
  </code></pre>
  
  <p>Sample result:</p>
  
  <pre><code>7.009537 - 11.575277 seconds.
  </code></pre>