Daily bump.
[official-gcc.git] / libgomp / testsuite / libgomp.c / icv-2.c
blobda005ea1c311e2352a49cf8a38a001bd82a02f3a
1 /* { dg-do run { target *-*-linux* *-*-gnu* *-*-freebsd* } } */
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>
11 pthread_barrier_t bar;
13 void *tf (void *p)
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)
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 ());
32 if (l)
33 abort ();
34 return NULL;
37 int
38 main (void)
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;