2018-03-25 Thomas Koenig <tkoenig@gcc.gnu.org>
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-fortran / lib-32-1.f
blob99e8f3577641fde46e1aca03090b596157099fbc
1 ! ACC_PRESENT_OR_CREATE, ACC_PRESENT_OR_COPYIN, etc.
2 ! Variant of "../libgomp.oacc-c-c++-common/lib-32.c".
3 ! Variant using "openacc_lib.h".
5 ! { dg-do run }
7 PROGRAM MAIN
8 IMPLICIT NONE
9 INCLUDE "openacc_lib.h"
11 INTEGER, PARAMETER :: N = 10000
12 INTEGER, ALLOCATABLE :: H(:)
13 INTEGER :: I
14 LOGICAL :: SHARED_MEM
16 ALLOCATE (H(N))
17 DO I = 1, N
18 H(I) = I + 0
19 END DO
21 SHARED_MEM = ACC_IS_PRESENT (H)
23 CALL ACC_PRESENT_OR_CREATE (H, INT (SIZEOF (H), 4))
24 IF (.NOT. ACC_IS_PRESENT (H, INT (SIZEOF (H), 8))) STOP 1
26 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
27 DO I = 1, N
28 H(I) = I + 1
29 END DO
30 !$ACC END PARALLEL LOOP
32 DO I = 1, N
33 IF (H(I) .NE. I + MERGE (1, 0, SHARED_MEM)) STOP 2
34 H(I) = I + 2
35 END DO
37 CALL ACC_PRESENT_OR_CREATE (H)
39 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
40 DO I = 1, N
41 IF (H(I) .NE. I + MERGE (2, 1, SHARED_MEM)) STOP 3
42 H(I) = I + 3
43 END DO
44 !$ACC END PARALLEL LOOP
46 DO I = 1, N
47 IF (H(I) .NE. I + MERGE (3, 2, SHARED_MEM)) STOP 4
48 H(I) = I + 4
49 END DO
51 CALL ACC_PCREATE (H, INT (SIZEOF (H), 4))
53 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
54 DO I = 1, N
55 IF (H(I) .NE. I + MERGE (4, 3, SHARED_MEM)) STOP 5
56 H(I) = I + 5
57 END DO
58 !$ACC END PARALLEL LOOP
60 DO I = 1, N
61 IF (H(I) .NE. I + MERGE (5, 4, SHARED_MEM)) STOP 6
62 H(I) = I + 6
63 END DO
65 CALL ACC_PRESENT_OR_COPYIN (H, INT (SIZEOF (H), 8))
67 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
68 DO I = 1, N
69 IF (H(I) .NE. I + MERGE (6, 5, SHARED_MEM)) STOP 7
70 H(I) = I + 7
71 END DO
72 !$ACC END PARALLEL LOOP
74 DO I = 1, N
75 IF (H(I) .NE. I + MERGE (7, 6, SHARED_MEM)) STOP 8
76 H(I) = I + 8
77 END DO
79 CALL ACC_PCOPYIN (H, INT (SIZEOF (H), 4))
81 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
82 DO I = 1, N
83 IF (H(I) .NE. I + MERGE (8, 7, SHARED_MEM)) STOP 9
84 H(I) = I + 9
85 END DO
86 !$ACC END PARALLEL LOOP
88 DO I = 1, N
89 IF (H(I) .NE. I + MERGE (9, 8, SHARED_MEM)) STOP 10
90 H(I) = I + 10
91 END DO
93 CALL ACC_COPYOUT (H, INT (SIZEOF (H), 4))
94 IF (.NOT. SHARED_MEM) THEN
95 IF (ACC_IS_PRESENT (H, INT (SIZEOF (H), 8))) STOP 11
96 ENDIF
98 DO I = 1, N
99 IF (H(I) .NE. I + MERGE (10, 9, SHARED_MEM)) STOP 12
100 END DO
102 CALL ACC_PCOPYIN (H)
103 IF (.NOT. ACC_IS_PRESENT (H, INT (SIZEOF (H), 4))) STOP 13
105 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
106 DO I = 1, N
107 IF (H(I) .NE. I + MERGE (10, 9, SHARED_MEM)) STOP 14
108 H(I) = I + 11
109 END DO
110 !$ACC END PARALLEL LOOP
112 DO I = 1, N
113 IF (H(I) .NE. I + MERGE (11, 9, SHARED_MEM)) STOP 15
114 H(I) = I + 12
115 END DO
117 CALL ACC_PCOPYIN (H, INT (SIZEOF (H), 8))
119 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
120 DO I = 1, N
121 IF (H(I) .NE. I + MERGE (12, 11, SHARED_MEM)) STOP 16
122 H(I) = I + 13
123 END DO
124 !$ACC END PARALLEL LOOP
126 DO I = 1, N
127 IF (H(I) .NE. I + MERGE (13, 12, SHARED_MEM)) STOP 17
128 H(I) = I + 14
129 END DO
131 CALL ACC_PCREATE (H)
133 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
134 DO I = 1, N
135 IF (H(I) .NE. I + MERGE (14, 13, SHARED_MEM)) STOP 18
136 H(I) = I + 15
137 END DO
138 !$ACC END PARALLEL LOOP
140 DO I = 1, N
141 IF (H(I) .NE. I + MERGE (15, 14, SHARED_MEM)) STOP 19
142 H(I) = I + 16
143 END DO
145 CALL ACC_PCREATE (H, INT (SIZEOF (H), 8))
147 !$ACC PARALLEL LOOP DEFAULT (PRESENT)
148 DO I = 1, N
149 IF (H(I) .NE. I + MERGE (16, 15, SHARED_MEM)) STOP 20
150 H(I) = I + 17
151 END DO
152 !$ACC END PARALLEL LOOP
154 DO I = 1, N
155 IF (H(I) .NE. I + MERGE (17, 16, SHARED_MEM)) STOP 21
156 H(I) = I + 18
157 END DO
159 CALL ACC_UPDATE_SELF (H, INT (SIZEOF (H), 4))
160 IF (.NOT. ACC_IS_PRESENT (H, INT (SIZEOF (H), 8))) STOP 22
162 DO I = 1, N
163 IF (H(I) .NE. I + MERGE (18, 17, SHARED_MEM)) STOP 23
164 END DO
166 CALL ACC_DELETE (H)
167 IF (.NOT. SHARED_MEM) THEN
168 IF (ACC_IS_PRESENT (H, INT (SIZEOF (H), 4))) STOP 24
169 ENDIF
171 DEALLOCATE (H)
173 END PROGRAM MAIN