aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/execute/p_simd_test1.c
blob: 4a250cb3f3dbaa64972656c1243fd513868c57cb (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
/* { dg-do run } */
/* { dg-options "-O3 -ftree-vectorize -fcilkplus -w" } */

#define ARRAY_SIZE  (256)
#if HAVE_IO
#include <stdio.h>
#endif
int a[ARRAY_SIZE];

int main () {
  int i, s = 0, r = 0;
#if 1
  for (i = 0; i < ARRAY_SIZE; i++)
    {
      a[i] = i;
    }
#endif
#pragma simd reduction (+:s) private (i) 
  for (i = 0; i < ARRAY_SIZE; i++)
    {
#if HAVE_IO
      printf("i = %d\n", i); 
#endif
      s += a[i];
    }

  for (i = 0; i < ARRAY_SIZE; i++) 
    r += i;

  if (s == r)
    return 0;
  else
    {
#if HAVE_IO 
      printf("s = %5d\t (expected value = %5d)\n", s, r);
#endif 
      return 1;
    }
}