//compute the sum of two arrays in parallel
#include <stdio.h>
#include <omp.h>
#define N 1000000
#define CHUNKSIZE 10000
int main(void) {
double a[N], b[N], c[N];
long i, chunk;
/* Initialize arrays a and b */
for (i = 0; i < N; i++) {
a[i] = i * 2.0;
b[i] = i * 3.0;
}
chunk = CHUNKSIZE;
#pragma omp parallel shared(a, b, c, chunk) private(i)
{
#pragma omp for schedule (dynamic, chunk)
for (i = 0; i < N; i++) {
c[i] = a[i] + b[i];
printf ("%lf\n", c[10]);
}
}
}