/* computearay.c compute a[i] = myfun(i); */ #include #include #include #include #include #define NUM_THREADS 4 int myfun(int i) { //or something else return i; } int main(int argc, char** argv) { if (argc < 3) { printf("usage: %s n nthreads\n", argv[0]); exit(1); } long n = atol(argv[1]); int nthreads = atol(argv[2]); int* a = malloc(n *sizeof(int)); assert(a); long i; double t1, t2; t1 = omp_get_wtime(); omp_set_num_threads(nthreads); #pragma omp parallel private (i) { #pragma omp for schedule(static,128*1024) for (i=0; i