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