1! { dg-do run }
2
3! { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
4! aspects of that functionality.
5
6program reduction
7  implicit none
8  integer, parameter :: n = 10
9  integer s1, s2
10  include "openacc_lib.h"
11
12  s1 = 0
13  s2 = 0
14
15  !$acc parallel reduction(+:s1,s2) num_gangs (n) copy(s1)
16  ! { dg-bogus "\[Ww\]arning: region is gang partitioned but does not contain gang partitioned code" "TODO 'reduction'" { xfail *-*-* } .-1 }
17  s1 = s1 + 1
18  s2 = s2 + 1
19  !$acc end parallel
20
21  if (acc_get_device_type () .ne. acc_device_host) then
22     if (s1 .ne. n) STOP 1
23     if (s2 .ne. n) STOP 2
24  else
25     if (s1 .ne. 1) STOP 3
26     if (s2 .ne. 1) STOP 4
27  end if
28
29  ! Test reductions inside subroutines
30
31  s1 = 0
32  s2 = 0
33  call redsub (s1, s2, n)
34
35  if (acc_get_device_type () .ne. acc_device_host) then
36     if (s1 .ne. n) STOP 5
37  else
38     if (s2 .ne. 1) STOP 6
39  end if
40end program reduction
41
42subroutine redsub(s1, s2, n)
43  implicit none
44  integer :: s1, s2, n
45
46  !$acc parallel reduction(+:s1,s2) num_gangs (10)  copy(s1)
47  ! { dg-bogus "\[Ww\]arning: region is gang partitioned but does not contain gang partitioned code" "TODO 'reduction'" { xfail *-*-* } .-1 }
48  s1 = s1 + 1
49  s2 = s2 + 1
50  !$acc end parallel
51end subroutine redsub
52