title: How to add two arrays using openMP?
body: <p>I am trying to parallelize this:  c[i]=a[i]+b[i] 
  By using C program I am getting:</p>
  
  <pre><code>Elapsed time = 1667417 nanoseconds
  </code></pre>
  
  <p>with OpenMP I get:</p>
  
  <pre><code>Elapsed time = 8673966 nanoseconds
  </code></pre>
  
  <p>I don't clearly understand why this is happening and what needs to be done to parallelize this code. I am assuming that it is very simple addition so probably parallelism is not getting exploited here but would like to know the correct reason and any other way by which I could effectively parallelize this addition. I also tried using dynamic, guided and various chunksizes but it gives more or less similar results.</p>
  
  <pre><code>#define N 100
      int main (int argc, char *argv[])
      {
          int i;
          float a[N], b[N], c[N];
          uint64_t diff; /* Elapsed time */
          struct timespec start, end;
  
      /* Some initializations */
          #pragma omp parallel for schedule(static,10) num_threads(4) 
          for (i=0; i &lt; N; i++){
              a[i] = b[i] = i * 1.0;
          }
          /*add two arrays*/
      clock_gettime(CLOCK_MONOTONIC, &amp;start); /* mark start time */
          #pragma omp parallel for schedule(static) num_threads(4) 
          for (i=0; i&lt;N; i++){
              c[i] = a[i] + b[i];
              printf("Thread number:%d,c[%d]= %f\n", omp_get_thread_num(),i,c[i]);
  
          }
  
      clock_gettime(CLOCK_MONOTONIC, &amp;end); /* mark the end time */
  
          diff = BILLION * (end.tv_sec - start.tv_sec) + end.tv_nsec - start.tv_nsec;
  
  
  printf("\nElapsed time = %llu nanoseconds\n", (long long unsigned int) diff);
      }
  </code></pre>