1 #include <stdlib.h> 2 3 int cnt; 4 5 void check(int x)6check (int x) 7 { 8 if (cnt++ != x) 9 abort (); 10 } 11 12 int main(void)13main (void) 14 { 15 int j; 16 17 cnt = 0; 18 #pragma omp parallel for ordered schedule (static, 1) num_threads (4) if (0) 19 for (j = 0; j < 1000; j++) 20 { 21 #pragma omp ordered 22 check (j); 23 } 24 25 cnt = 0; 26 #pragma omp parallel for ordered schedule (static, 1) num_threads (4) if (1) 27 for (j = 0; j < 1000; j++) 28 { 29 #pragma omp ordered 30 check (j); 31 } 32 33 cnt = 0; 34 #pragma omp parallel for ordered schedule (runtime) num_threads (4) if (0) 35 for (j = 0; j < 1000; j++) 36 { 37 #pragma omp ordered 38 check (j); 39 } 40 41 cnt = 0; 42 #pragma omp parallel for ordered schedule (runtime) num_threads (4) if (1) 43 for (j = 0; j < 1000; j++) 44 { 45 #pragma omp ordered 46 check (j); 47 } 48 49 cnt = 0; 50 #pragma omp parallel for ordered schedule (dynamic) num_threads (4) if (0) 51 for (j = 0; j < 1000; j++) 52 { 53 #pragma omp ordered 54 check (j); 55 } 56 57 cnt = 0; 58 #pragma omp parallel for ordered schedule (dynamic) num_threads (4) if (1) 59 for (j = 0; j < 1000; j++) 60 { 61 #pragma omp ordered 62 check (j); 63 } 64 65 cnt = 0; 66 #pragma omp parallel for ordered schedule (guided) num_threads (4) if (0) 67 for (j = 0; j < 1000; j++) 68 { 69 #pragma omp ordered 70 check (j); 71 } 72 73 cnt = 0; 74 #pragma omp parallel for ordered schedule (guided) num_threads (4) if (1) 75 for (j = 0; j < 1000; j++) 76 { 77 #pragma omp ordered 78 check (j); 79 } 80 81 return 0; 82 } 83