1 /* { dg-do run } */ 2 /* { dg-set-target-env-var OMP_THREAD_LIMIT "6" } */ 3 /* { dg-additional-options "-Wno-deprecated-declarations" } */ 4 5 #include <stdlib.h> 6 #include <unistd.h> 7 #include <omp.h> 8 9 int main()10main () 11 { 12 if (omp_get_thread_limit () != 6) 13 return 0; 14 omp_set_dynamic (0); 15 omp_set_nested (1); 16 #pragma omp parallel num_threads (3) 17 if (omp_get_num_threads () != 3) 18 abort (); 19 #pragma omp parallel num_threads (3) 20 if (omp_get_num_threads () != 3) 21 abort (); 22 #pragma omp parallel num_threads (8) 23 if (omp_get_num_threads () > 6) 24 abort (); 25 #pragma omp parallel num_threads (6) 26 if (omp_get_num_threads () != 6) 27 abort (); 28 int cnt = 0; 29 #pragma omp parallel num_threads (5) 30 #pragma omp parallel num_threads (5) 31 #pragma omp parallel num_threads (2) 32 { 33 int v; 34 #pragma omp atomic capture 35 v = ++cnt; 36 if (v > 6) 37 abort (); 38 usleep (10000); 39 #pragma omp atomic 40 --cnt; 41 } 42 return 0; 43 } 44