Skip gnat.dg/prot7.adb on hppa.
[official-gcc.git] / libgomp / testsuite / libgomp.c / scan-1.c
blobdd34f33a694f435ef3e9a872653b351e0fc555c9
1 /* { dg-require-effective-target size32plus } */
3 extern void abort (void);
4 int r, a[1024], b[1024];
6 __attribute__((noipa)) void
7 foo (int *a, int *b)
9 #pragma omp for reduction (inscan, +:r)
10 for (int i = 0; i < 1024; i++)
12 r += a[i];
13 #pragma omp scan inclusive(r)
14 b[i] = r;
18 __attribute__((noipa)) int
19 bar (void)
21 int s = 0;
22 #pragma omp parallel
23 #pragma omp for reduction (inscan, +:s)
24 for (int i = 0; i < 1024; i++)
26 s += 2 * a[i];
27 #pragma omp scan inclusive(s)
28 b[i] = s;
30 return s;
33 __attribute__((noipa)) void
34 baz (int *a, int *b)
36 #pragma omp parallel for reduction (inscan, +:r)
37 for (int i = 0; i < 1024; i++)
39 r += a[i];
40 #pragma omp scan inclusive(r)
41 b[i] = r;
45 __attribute__((noipa)) int
46 qux (void)
48 int s = 0;
49 #pragma omp parallel for reduction (inscan, +:s)
50 for (int i = 0; i < 1024; i++)
52 s += 2 * a[i];
53 #pragma omp scan inclusive(s)
54 b[i] = s;
56 return s;
59 int
60 main ()
62 int s = 0;
63 for (int i = 0; i < 1024; ++i)
65 a[i] = i;
66 b[i] = -1;
67 asm ("" : "+g" (i));
69 #pragma omp parallel
70 foo (a, b);
71 if (r != 1024 * 1023 / 2)
72 abort ();
73 for (int i = 0; i < 1024; ++i)
75 s += i;
76 if (b[i] != s)
77 abort ();
78 else
79 b[i] = 25;
81 if (bar () != 1024 * 1023)
82 abort ();
83 s = 0;
84 for (int i = 0; i < 1024; ++i)
86 s += 2 * i;
87 if (b[i] != s)
88 abort ();
89 else
90 b[i] = -1;
92 r = 0;
93 baz (a, b);
94 if (r != 1024 * 1023 / 2)
95 abort ();
96 s = 0;
97 for (int i = 0; i < 1024; ++i)
99 s += i;
100 if (b[i] != s)
101 abort ();
102 else
103 b[i] = -25;
105 if (qux () != 1024 * 1023)
106 abort ();
107 s = 0;
108 for (int i = 0; i < 1024; ++i)
110 s += 2 * i;
111 if (b[i] != s)
112 abort ();
114 return 0;