Mercurial > hg > CbC > CbC_gcc
comparison libgomp/testsuite/libgomp.c/thread-limit-1.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* { dg-do run } */ | |
2 /* { dg-set-target-env-var OMP_THREAD_LIMIT "6" } */ | |
3 | |
4 #include <stdlib.h> | |
5 #include <unistd.h> | |
6 #include <omp.h> | |
7 | |
8 int | |
9 main () | |
10 { | |
11 if (omp_get_thread_limit () != 6) | |
12 return 0; | |
13 omp_set_dynamic (0); | |
14 omp_set_nested (1); | |
15 #pragma omp parallel num_threads (3) | |
16 if (omp_get_num_threads () != 3) | |
17 abort (); | |
18 #pragma omp parallel num_threads (3) | |
19 if (omp_get_num_threads () != 3) | |
20 abort (); | |
21 #pragma omp parallel num_threads (8) | |
22 if (omp_get_num_threads () > 6) | |
23 abort (); | |
24 #pragma omp parallel num_threads (6) | |
25 if (omp_get_num_threads () != 6) | |
26 abort (); | |
27 int cnt = 0; | |
28 #pragma omp parallel num_threads (5) | |
29 #pragma omp parallel num_threads (5) | |
30 #pragma omp parallel num_threads (2) | |
31 { | |
32 int v; | |
33 #pragma omp atomic capture | |
34 v = ++cnt; | |
35 if (v > 6) | |
36 abort (); | |
37 usleep (10000); | |
38 #pragma omp atomic | |
39 --cnt; | |
40 } | |
41 return 0; | |
42 } |