aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-8.c
blob: d25060572b56bf159c50477bba8793e7e50380f7 (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
const int n = 100;
    
// Check async over parallel construct with reduction
    
int
async_sum (int c)
{
  int s = 0;
    
#pragma acc parallel loop num_gangs (10) gang reduction (+:s) async
  for (int i = 0; i < n; i++)
    s += i+c;
    
#pragma acc wait
  return s;
}
    
int
main()
{
  int result = 0;
    
  for (int i = 0; i < n; i++)
    result += i+1;
    
  if (async_sum (1) != result)
    __builtin_abort ();
    
  return 0;
}