-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathserial_loop_reduction_max_general.F90
64 lines (56 loc) · 1.35 KB
/
serial_loop_reduction_max_general.F90
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
58
59
60
61
62
63
64
#ifndef T1
!T1:serial,reduction,combined-constructs,loop,V:2.6-2.7
LOGICAL FUNCTION test1()
IMPLICIT NONE
INCLUDE "acc_testsuite.Fh"
REAL(8),DIMENSION(LOOPCOUNT):: a, b
REAL(8):: maxval, host_max
INTEGER:: errors, x
SEEDDIM(1) = 1
#ifdef SEED
SEEDDIM(1) = SEED
#endif
CALL RANDOM_SEED(PUT=SEEDDIM)
CALL RANDOM_NUMBER(a)
CALL RANDOM_NUMBER(b)
errors = 0
DO x = 1, LOOPCOUNT
host_max = max(host_max, a(x) * b(x))
END DO
!$acc data copyin(a(1:LOOPCOUNT), b(1:LOOPCOUNT))
!$acc serial loop reduction(max:maxval)
DO x = 1, LOOPCOUNT
maxval = max(maxval, a(x) * b(x))
END DO
!$acc end data
IF (abs(host_max - maxval) .gt. PRECISION) THEN
errors = errors + 1
END IF
IF (errors .eq. 0) THEN
test1 = .FALSE.
ELSE
test1 = .TRUE.
END IF
END
#endif
PROGRAM serial_loop_reduction_max_general
IMPLICIT NONE
INTEGER :: failcode, testrun
LOGICAL :: failed
INCLUDE "acc_testsuite.Fh"
#ifndef T1
LOGICAL :: test1
#endif
failed = .FALSE.
failcode = 0
#ifndef T1
DO testrun = 1, NUM_TEST_CALLS
failed = failed .or. test1()
END DO
IF (failed) THEN
failcode = failcode + 2 ** 0
failed = .FALSE.
END IF
#endif
CALL EXIT (failcode)
END PROGRAM