111
|
1 /* { dg-do run { target *-*-linux* *-*-gnu* *-*-freebsd* } } */
|
0
|
2
|
|
3 #ifndef _GNU_SOURCE
|
|
4 #define _GNU_SOURCE 1
|
|
5 #endif
|
|
6 #include <pthread.h>
|
|
7 #include <omp.h>
|
|
8 #include <stdio.h>
|
|
9 #include <stdlib.h>
|
|
10
|
|
11 pthread_barrier_t bar;
|
|
12
|
|
13 void *tf (void *p)
|
|
14 {
|
|
15 int l;
|
|
16 if (p)
|
|
17 omp_set_num_threads (3);
|
|
18 pthread_barrier_wait (&bar);
|
|
19 if (!p)
|
|
20 omp_set_num_threads (6);
|
|
21 pthread_barrier_wait (&bar);
|
|
22 omp_set_dynamic (0);
|
|
23 if (omp_get_max_threads () != (p ? 3 : 6))
|
|
24 abort ();
|
|
25 l = 0;
|
|
26 #pragma omp parallel num_threads (6) reduction (|:l)
|
|
27 {
|
|
28 l |= omp_get_max_threads () != (p ? 3 : 6);
|
|
29 omp_set_num_threads ((p ? 3 : 6) + omp_get_thread_num ());
|
|
30 l |= omp_get_max_threads () != ((p ? 3 : 6) + omp_get_thread_num ());
|
|
31 }
|
|
32 if (l)
|
|
33 abort ();
|
|
34 return NULL;
|
|
35 }
|
|
36
|
|
37 int
|
|
38 main (void)
|
|
39 {
|
|
40 pthread_t th;
|
|
41 pthread_barrier_init (&bar, NULL, 2);
|
|
42 pthread_create (&th, NULL, tf, NULL);
|
|
43 tf ("");
|
|
44 pthread_join (th, NULL);
|
|
45 return 0;
|
|
46 }
|