aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.oacc-fortran/par-reduction-2-1.f
blob: dcd6592868567dde603a73eb88aef45cd79dfeb8 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
!     Test of reduction on parallel directive (with async).
!     Variant of "../libgomp.oacc-c-c++-common/par-reduction-2.c".
!     Variant using "openacc_lib.h".

!     { dg-do run }

      PROGRAM MAIN
      IMPLICIT NONE
      INCLUDE "openacc_lib.h"

      INTEGER RES, RES1, RES2

      RES1 = 0
      RES2 = 0

!$ACC PARALLEL NUM_GANGS(256) NUM_WORKERS(32) VECTOR_LENGTH(32)
!$ACC& REDUCTION(+:RES1) COPY(RES1, RES2) ASYNC(1)
      res1 = res1 + 5

!$ACC ATOMIC
      res2 = res2 + 5
!$ACC END PARALLEL

      IF (ACC_GET_DEVICE_TYPE () .EQ. ACC_DEVICE_HOST) THEN
         RES = 1 * 5
      ELSE
         RES = 256 * 5
      END IF

      CALL ACC_ASYNC_WAIT (1)

      IF (RES .NE. RES1) CALL ABORT
      IF (RES .NE. RES2) CALL ABORT

      RES1 = 1
      RES2 = 1

!$ACC PARALLEL NUM_GANGS(8) NUM_WORKERS(32) VECTOR_LENGTH(32)
!$ACC& REDUCTION(*:RES1) COPY(RES1, RES2) ASYNC(1)
      res1 = res1 * 5

!$ACC ATOMIC
      res2 = res2 * 5
!$ACC END PARALLEL

      IF (ACC_GET_DEVICE_TYPE () .EQ. ACC_DEVICE_HOST) THEN
         RES = 5 ** 1
      ELSE
         RES = 5 ** 8
      END IF

      CALL ACC_ASYNC_WAIT_ALL

      IF (RES .NE. RES1) CALL ABORT
      IF (RES .NE. RES2) CALL ABORT

      END PROGRAM