#include #include #include #include #include #define SIZE 100000000 void print_duration(struct timespec *b, struct timespec *c) { long long r = c->tv_nsec - b->tv_nsec; r += ((long long)(c->tv_sec - b->tv_sec) ) * 1000000000; printf("duration = %lld nanoseconds\n", r); } int main(int argc, char * argv[]) { int N; int i, j, k; struct timespec bb, ee; double *a, *b, *c; if (argc > 1) N = atoi(argv[1]); else N = 100; a = (double *)malloc(sizeof(double)*N); b = (double *)malloc(sizeof(double)*N); c = (double *)malloc(sizeof(double)*N); #pragma omp parallel { #pragma omp single { printf("%d threads.\n", omp_get_num_threads()); } } //#pragma omp parallel for private(i) shared(a, b, c, N) for (i=0 ;i