1 /* { dg-do run } */ 2 3 #include <omp.h> 4 5 extern void abort (void); 6 7 int main(void)8main (void) 9 { 10 int i = 5, l = 0; 11 int foo (void) { return i == 6; } 12 int bar (void) { return i - 3; } 13 14 omp_set_dynamic (0); 15 16 #pragma omp parallel if (foo ()) num_threads (bar ()) reduction (|:l) 17 if (omp_get_num_threads () != 1) 18 l = 1; 19 20 i++; 21 22 #pragma omp parallel if (foo ()) num_threads (bar ()) reduction (|:l) 23 if (omp_get_num_threads () != 3) 24 l = 1; 25 26 i++; 27 28 #pragma omp master 29 if (bar () != 4) 30 abort (); 31 32 #pragma omp single 33 { 34 if (foo ()) 35 abort (); 36 i--; 37 if (! foo ()) 38 abort (); 39 } 40 41 if (l) 42 abort (); 43 44 i = 8; 45 #pragma omp atomic 46 l += bar (); 47 48 if (l != 5) 49 abort (); 50 51 return 0; 52 } 53