/* sum3.c compute sum = atan(1) + atan(2) + ... + atan(n) */ #include #include #include #include #define NUM_THREADS 4 int main(int argc, char** argv) { long n = 100000000; double totalsum; long i; double t1, t2; double sum[NUM_THREADS]; //one for each thread t1 = omp_get_wtime(); //initialize all sums to 0 for (i=0; i< NUM_THREADS; i++) sum[i] = 0; omp_set_num_threads(NUM_THREADS); #pragma omp parallel private (i) { int thread_id = omp_get_thread_num(); printf("Start(%d)\n", thread_id); for (i=thread_id; i