aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/goacc/kernels-acc-loop-reduction.c
blob: b52f280c484d2afc71d30621eb63e784bfd79364 (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
/* { dg-additional-options "-O2" } */
/* { dg-additional-options "-fdump-tree-parloops1-all" } */
/* { dg-additional-options "-fdump-tree-optimized" } */

unsigned int
foo (int n, unsigned int *a)
{
  unsigned int sum = 0;

#pragma acc kernels loop gang reduction(+:sum)
  for (int i = 0; i < n; i++)
    sum += a[i];

  return sum;
}

/* Check that only one loop is analyzed, and that it can be parallelized.  */
/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
/* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */

/* Check that the loop has been split off into a function.  */
/* { dg-final { scan-tree-dump-times "(?n);; Function .*foo.*\\._omp_fn\\.0" 1 "optimized" } } */

/* { dg-final { scan-tree-dump-times "(?n)oacc function \\(0," 1 "parloops1" } } */