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