// test2.c check openMP loops #include #include #include #include int main(int argc, char * argv[]) { int i, j, k, myid; int num_threads, num_proc; double ttime; num_proc = omp_get_num_procs(); printf("test2.c check loops, num_proc=%d \n", num_proc); fflush(stdout); ttime = omp_get_wtime(); #pragma omp parallel { #pragma omp master { num_threads = omp_get_num_threads(); // must be in parallel printf("num_threads =%d \n", num_threads); fflush(stdout); } #pragma omp barrier #pragma omp loop static { for(i=0; i<3; i++) { #pragma omp loop static { for(j=0; j<3; j++) { for(k=0; k<3; k++) { myid = omp_get_thread_num(); printf("i=%d, j=%d, k=%d, myid=%d \n", i, j, k, myid); fflush(stdout); } } } } } } printf("test2.c ends, %f seconds \n", omp_get_wtime()-ttime); fflush(stdout); return 0; } // end test2.c