1 /* PR libgomp/61200 */ 2 /* { dg-do run } */ 3 /* { dg-additional-options "-Wno-deprecated-declarations" } */ 4 5 #include <omp.h> 6 #include <stdlib.h> 7 #include <unistd.h> 8 9 volatile int x; 10 11 void foo()12foo () 13 { 14 int var = 1; 15 int i; 16 17 for (i = 0; i < 2; i++) 18 { 19 if (i == 1) 20 { 21 #pragma omp parallel num_threads(2) 22 if (x) 23 var++; 24 else 25 { 26 #pragma omp single 27 sleep (2); 28 } 29 } 30 else 31 { 32 #pragma omp task shared(var) 33 { 34 sleep (1); 35 var = 2; 36 } 37 } 38 } 39 #pragma omp taskwait 40 if (var != 2) 41 abort (); 42 } 43 44 void bar()45bar () 46 { 47 int var = 1; 48 int i; 49 50 for (i = 0; i < 2; i++) 51 { 52 if (i == 0) 53 { 54 #pragma omp task shared(var) 55 { 56 sleep (1); 57 var = 2; 58 } 59 } 60 else 61 { 62 #pragma omp parallel num_threads(2) 63 if (x) 64 var++; 65 else 66 { 67 #pragma omp single 68 sleep (2); 69 } 70 } 71 } 72 #pragma omp taskwait 73 if (var != 2) 74 abort (); 75 } 76 77 int main()78main () 79 { 80 omp_set_nested (1); 81 #pragma omp parallel num_threads(2) 82 #pragma omp single 83 foo (); 84 #pragma omp parallel num_threads(2) 85 #pragma omp single 86 bar (); 87 return 0; 88 } 89