/* #pragma omp parallel private(local_sum) { } In front of the loop (inside the parallel region) there is a 'work-sharing" for directive (Chandra et al., p.113) that cares about the splitting of the work. This unburdens the programer from setting the index range of the for-loop for each thread. I attach the code. */ #include #include #include #include #define N 100000 #define CT 100 int main() { int i, p, ict, ticks; struct tms t; clock_t elapsed_ticks; double elapsed_time; double local_sum, sum, x[N], y[N]; ticks = sysconf(CLK_TCK); #pragma omp parallel for for (i=0; i< N; i++){ x[i] = i; y[i] = 1.0; }; #pragma omp parallel { p = omp_get_num_threads(); } /* --------------- CASE 1 --------------- */ elapsed_ticks = times(&t); for (ict=0; ict