Mercurial > hg > CbC > CbC_gcc
comparison libgomp/testsuite/libgomp.c/critical-2.c @ 0:a06113de4d67
first commit
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Jul 2009 14:47:48 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a06113de4d67 |
---|---|
1 // { dg-do run } | |
2 // Test several constructs within a parallel. At one point in development, | |
3 // the critical directive clobbered the shared clause of the parallel. | |
4 | |
5 #include <omp.h> | |
6 #include <stdlib.h> | |
7 | |
8 #define N 2000 | |
9 | |
10 int main() | |
11 { | |
12 int A[N]; | |
13 int nthreads; | |
14 int i; | |
15 | |
16 #pragma omp parallel shared (A, nthreads) | |
17 { | |
18 #pragma omp master | |
19 nthreads = omp_get_num_threads (); | |
20 | |
21 #pragma omp for | |
22 for (i = 0; i < N; i++) | |
23 A[i] = 0; | |
24 | |
25 #pragma omp critical | |
26 for (i = 0; i < N; i++) | |
27 A[i] += 1; | |
28 } | |
29 | |
30 for (i = 0; i < N; i++) | |
31 if (A[i] != nthreads) | |
32 abort (); | |
33 | |
34 return 0; | |
35 } |