blob: 35cb904a540f142c1cfa08a110a67b597dcf8fa1 (
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
39
40
41
|
/* { dg-do run } */
/* { dg-options "-O3 -fcilkplus" } */
#define N 256
#if HAVE_IO
#include <stdio.h>
#endif
#include <stdlib.h>
int
reduction_simd (int *a)
{
int s = 0;
#pragma simd reduction (+:s)
for (int 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;
}
|