aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/goacc/combined-reduction.c
blob: 0a541402d9d4383400a3bd2fd3f273f5108642de (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 compile } */
/* { dg-options "-fopenacc -fdump-tree-gimple" } */

/* See also '../../gfortran.dg/goacc/reduction-2.f95'.  */

#include <assert.h>

int
main ()
{
  int i, v1 = 0, n = 100;

#pragma acc parallel loop reduction(+:v1)
  for (i = 0; i < n; i++)
    v1++;

  assert (v1 == n);

#pragma acc kernels loop reduction(+:v1)
  for (i = 0; i < n; i++)
    v1++;

  assert (v1 == n);

#pragma acc serial loop reduction(+:v1)
  for (i = 0; i < n; i++)
    v1++;

  assert (v1 == n);

  return 0;
}

/* { dg-final { scan-tree-dump-times "omp target oacc_parallel reduction.+:v1. map.tofrom:v1" 1 "gimple" } } */
/* { dg-final { scan-tree-dump-times "acc loop reduction.+:v1. private.i." 1 "gimple" } } */
/* { dg-final { scan-tree-dump-times "omp target oacc_kernels map.force_tofrom:n .len: 4.. map.force_tofrom:v1 .len: 4.." 1 "gimple" } } */
/* { dg-final { scan-tree-dump-times "acc loop reduction.+:v1. private.i." 1 "gimple" } } */
/* { dg-final { scan-tree-dump-times "omp target oacc_serial reduction.+:v1. map.tofrom:v1" 1 "gimple" } } */
/* { dg-final { scan-tree-dump-times "acc loop reduction.+:v1. private.i." 1 "gimple" } } */