Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/c-c++-common/goacc/reduction-2.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/c-c++-common/goacc/reduction-2.c Fri Oct 27 22:46:09 2017 +0900 @@ -0,0 +1,54 @@ +/* { dg-additional-options "-fdump-tree-gimple" } */ +/* float reductions. */ + +#define n 1000 + +int +main(void) +{ + int i; + float result, array[n]; + int lresult; + + /* '+' reductions. */ +#pragma acc parallel +#pragma acc loop gang worker vector reduction (+:result) + for (i = 0; i < n; i++) + result += array[i]; + + /* '*' reductions. */ +#pragma acc parallel +#pragma acc loop gang worker vector reduction (*:result) + for (i = 0; i < n; i++) + result *= array[i]; + + /* 'max' reductions. */ +#pragma acc parallel +#pragma acc loop gang worker vector reduction (max:result) + for (i = 0; i < n; i++) + result = result > array[i] ? result : array[i]; + + /* 'min' reductions. */ +#pragma acc parallel +#pragma acc loop gang worker vector reduction (min:result) + for (i = 0; i < n; i++) + result = result < array[i] ? result : array[i]; + + /* '&&' reductions. */ +#pragma acc parallel +#pragma acc loop gang worker vector reduction (&&:lresult) + for (i = 0; i < n; i++) + lresult = lresult && (result > array[i]); + + /* '||' reductions. */ +#pragma acc parallel +#pragma acc loop gang worker vector reduction (||:lresult) + for (i = 0; i < n; i++) + lresult = lresult || (result > array[i]); + + return 0; +} + +/* Check that default copy maps are generated for loop reductions. */ +/* { dg-final { scan-tree-dump-times "map\\(tofrom:result \\\[len: \[0-9\]+\\\]\\)" 4 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "map\\(tofrom:lresult \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */