Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/c-c++-common/cilk-plus/PS/reduction-3.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
line wrap: on
line source
/* { 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; }