RISC-V: testsuite: fix old-style function definition error [NFC]
[official-gcc.git] / libgomp / testsuite / libgomp.c / simd-7.c
blob8239af950e847a46d090e82eafddc7c13313199e
1 /* { dg-do run } */
2 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
3 /* { dg-additional-options "-mavx" { target avx_runtime } } */
5 extern void abort ();
6 int a[1024] __attribute__((aligned (32))) = { 1 };
7 int b[1024] __attribute__((aligned (32))) = { 1 };
8 int k, m;
9 struct U { int u; };
10 struct V { int v; };
12 __attribute__((noinline, noclone)) int
13 foo (int *p)
15 int i, s = 0;
16 struct U u;
17 struct V v;
18 #pragma omp simd aligned(a, p : 32) linear(k: m + 1) \
19 linear(i) reduction(+:s) lastprivate(u, v)
20 for (i = 0; i < 1024; i++)
22 int *q = &i;
23 a[i] *= p[i];
24 u.u = p[i] + k;
25 k += m + 1;
26 v.v = p[i] + k;
27 s += p[i] + k;
29 if (u.u != 36 + 4 + 3 * 1023 || v.v != 36 + 4 + 3 * 1024 || i != 1024)
30 abort ();
31 return s;
34 __attribute__((noinline, noclone)) int
35 bar (int *p)
37 int i, s = 0;
38 struct U u;
39 struct V v;
40 #pragma omp simd aligned(a, p : 32) linear(k: m + 1) \
41 reduction(+:s) lastprivate(u, v)
42 for (i = 0; i < 1024; i++)
44 int *q = &i;
45 a[i] *= p[i];
46 u.u = p[i] + k;
47 k += m + 1;
48 v.v = p[i] + k;
49 s += p[i] + k;
51 if (u.u != 36 + 4 + 3 * 1023 || v.v != 36 + 4 + 3 * 1024 || i != 1024)
52 abort ();
53 return s;
56 int
57 main ()
59 #if __SIZEOF_INT__ >= 4
60 int i;
61 k = 4;
62 m = 2;
63 for (i = 0; i < 1024; i++)
65 a[i] = i - 512;
66 b[i] = (i - 51) % 39;
68 int s = foo (b);
69 for (i = 0; i < 1024; i++)
71 if (b[i] != (i - 51) % 39
72 || a[i] != (i - 512) * b[i])
73 abort ();
75 if (k != 4 + 3 * 1024 || s != 1596127)
76 abort ();
77 k = 4;
78 m = 2;
79 for (i = 0; i < 1024; i++)
81 a[i] = i - 512;
82 b[i] = (i - 51) % 39;
84 s = bar (b);
85 for (i = 0; i < 1024; i++)
87 if (b[i] != (i - 51) % 39
88 || a[i] != (i - 512) * b[i])
89 abort ();
91 if (k != 4 + 3 * 1024 || s != 1596127)
92 abort ();
93 #endif
94 return 0;