[clang-format][NFC] Add a TypeScript test case
[llvm-project.git] / flang / test / Semantics / OpenACC / acc-serial.f90
bloba23daecce8dd3508eeeecd82ef2e9eeb55759ca9
1 ! RUN: %python %S/../test_errors.py %s %flang -fopenacc -pedantic
3 ! Check OpenACC clause validity for the following construct and directive:
4 ! 2.5.2 Serial
6 program openacc_serial_validity
8 implicit none
10 type atype
11 real(8), dimension(10) :: arr
12 real(8) :: s
13 end type atype
15 integer :: i, j, b, gang_size, vector_size, worker_size
16 integer, parameter :: N = 256
17 integer, dimension(N) :: c
18 logical, dimension(N) :: d, e
19 integer :: async1
20 integer :: wait1, wait2
21 real :: reduction_r
22 logical :: reduction_l
23 real(8), dimension(N, N) :: aa, bb, cc
24 real(8), dimension(:), allocatable :: dd
25 real(8), pointer :: p
26 logical :: ifCondition = .TRUE.
27 type(atype) :: t
28 type(atype), dimension(10) :: ta
30 real(8), dimension(N) :: a, f, g, h
32 !$acc serial
33 !ERROR: Directive SET may not be called within a compute region
34 !$acc set default_async(i)
35 !$acc end serial
37 !$acc serial
38 !$acc loop
39 do i = 1, N
40 !ERROR: Directive SET may not be called within a compute region
41 !$acc set default_async(i)
42 a(i) = 3.14
43 end do
44 !$acc end serial
46 !$acc serial
47 !$acc end serial
49 !$acc serial async
50 !$acc end serial
52 !$acc serial async(1)
53 !$acc end serial
55 !ERROR: At most one ASYNC clause can appear on the SERIAL directive
56 !$acc serial async(1) async(2)
57 !$acc end serial
59 !$acc serial async(async1)
60 !$acc end serial
62 !$acc serial wait
63 !$acc end serial
65 !$acc serial wait(1)
66 !$acc end serial
68 !$acc serial wait(wait1)
69 !$acc end serial
71 !$acc serial wait(1,2)
72 !$acc end serial
74 !$acc serial wait(wait1, wait2)
75 !$acc end serial
77 !$acc serial wait(wait1) wait(wait2)
78 !$acc end serial
80 !PORTABILITY: NUM_GANGS clause is not allowed on the SERIAL directive and will be ignored
81 !$acc serial num_gangs(8)
82 !$acc end serial
84 !PORTABILITY: NUM_WORKERS clause is not allowed on the SERIAL directive and will be ignored
85 !$acc serial num_workers(8)
86 !$acc end serial
88 !PORTABILITY: VECTOR_LENGTH clause is not allowed on the SERIAL directive and will be ignored
89 !$acc serial vector_length(128)
90 !$acc end serial
92 !$acc serial if(.true.)
93 !$acc end serial
95 !ERROR: At most one IF clause can appear on the SERIAL directive
96 !$acc serial if(.true.) if(ifCondition)
97 !$acc end serial
99 !$acc serial if(ifCondition)
100 !$acc end serial
102 !$acc serial self
103 !$acc end serial
105 !$acc serial self(.true.)
106 !$acc end serial
108 !$acc serial self(ifCondition)
109 !$acc end serial
111 !$acc serial reduction(.neqv.: reduction_l)
112 !$acc loop reduction(.neqv.: reduction_l)
113 do i = 1, N
114 reduction_l = d(i) .neqv. e(i)
115 end do
116 !$acc end serial
118 !$acc serial copy(aa) copyin(bb) copyout(cc)
119 !$acc end serial
121 !$acc serial copy(aa, bb) copyout(zero: cc)
122 !$acc end serial
124 !$acc serial present(aa, bb) create(cc)
125 !$acc end serial
127 !$acc serial copyin(readonly: aa, bb) create(zero: cc)
128 !$acc end serial
130 !$acc serial deviceptr(aa, bb) no_create(cc)
131 !$acc end serial
133 !ERROR: Argument `aa` on the ATTACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute
134 !$acc serial attach(aa, dd, p)
135 !$acc end serial
137 !$acc serial firstprivate(bb, cc)
138 !$acc end serial
140 !$acc serial private(aa)
141 !$acc end serial
143 !$acc serial default(none)
144 !$acc end serial
146 !$acc serial default(present)
147 !$acc end serial
149 !ERROR: At most one DEFAULT clause can appear on the SERIAL directive
150 !$acc serial default(present) default(none)
151 !$acc end serial
153 !$acc serial device_type(*) async wait
154 !$acc end serial
156 !$acc serial device_type(*) async
157 do i = 1, N
158 a(i) = 3.14
159 end do
160 !$acc end serial
162 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the SERIAL directive
163 !$acc serial device_type(*) if(.TRUE.)
164 do i = 1, N
165 a(i) = 3.14
166 end do
167 !$acc end serial
169 do i = 1, 100
170 !$acc serial
171 !ERROR: CYCLE to construct outside of SERIAL construct is not allowed
172 if (i == 10) cycle
173 !$acc end serial
174 end do
176 !$acc serial
177 do i = 1, 100
178 if (i == 10) cycle
179 end do
180 !$acc end serial
182 end program openacc_serial_validity