blob: a3c54364062e10ebe345a7a7220a3bbc7aee1ce0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#define N 256
#if HAVE_IO
#include <stdio.h>
#endif
#include <malloc.h>
int
reduction_simd (int *a)
{
int i, s = 0;
#pragma simd reduction (+:s) private(i)
for (i = 0; i < N; i++)
{
s += a[i];
}
return s;
}
int
main ()
{
int *a = (int *) malloc (N * sizeof (int));
int i, s = (N - 1) * N / 2;
for (i = 0; i < N; i++)
{
a[i] = i;
}
#if HAVE_IO
printf ("%d, %d\n", s, reduction_simd (a));
#endif
if (s == reduction_simd (a))
return 0;
else
return 1;
}
|