]> gcc.gnu.org Git - gcc.git/blob - libgomp/testsuite/libgomp.c-c++-common/scope-2.c
openmp: Add support for firstprivate and allocate clauses on scope construct
[gcc.git] / libgomp / testsuite / libgomp.c-c++-common / scope-2.c
1 #ifdef __cplusplus
2 extern "C"
3 #endif
4 void abort ();
5
6 int
7 main ()
8 {
9 int a[64] = {};
10 int r = 0, r2 = 0, i, n = 64;
11 #pragma omp parallel
12 {
13 #pragma omp scope nowait
14 #pragma omp scope nowait firstprivate (n)
15 #pragma omp for
16 for (i = 0; i < 64; i++)
17 a[i] += 1;
18 #pragma omp scope reduction(+: r) nowait firstprivate (n)
19 {
20 #pragma omp for nowait
21 for (i = 0; i < 64; i++)
22 {
23 r += i;
24 if (a[i] != 1)
25 abort ();
26 }
27 #pragma omp barrier
28 if (n != 64)
29 abort ();
30 else
31 n = 128;
32 }
33 #pragma omp barrier
34 if (r != 64 * 63 / 2)
35 abort ();
36 #pragma omp scope nowait private (i)
37 #pragma omp scope reduction(+: r2)
38 {
39 #pragma omp for nowait
40 for (i = 0; i < 64; i++)
41 {
42 r2 += 2 * i;
43 a[i] += i;
44 }
45 }
46 if (r2 != 64 * 63)
47 abort ();
48 #pragma omp for nowait
49 for (i = 0; i < 64; i++)
50 if (a[i] != i + 1)
51 abort ();
52 }
53 return 0;
54 }
This page took 0.038842 seconds and 5 git commands to generate.