[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / OpenACC / acc-serial.f90
blob2f206f5cfa3424192df64b920ccf5f55da06c22a
1 ! RUN: %S/../test_errors.sh %s %t %flang -fopenacc
2 ! REQUIRES: shell
4 ! Check OpenACC clause validity for the following construct and directive:
5 ! 2.5.2 Serial
7 program openacc_serial_validity
9 implicit none
11 type atype
12 real(8), dimension(10) :: arr
13 real(8) :: s
14 end type atype
16 integer :: i, j, b, gang_size, vector_size, worker_size
17 integer, parameter :: N = 256
18 integer, dimension(N) :: c
19 logical, dimension(N) :: d, e
20 integer :: async1
21 integer :: wait1, wait2
22 real :: reduction_r
23 logical :: reduction_l
24 real(8), dimension(N, N) :: aa, bb, cc
25 real(8), dimension(:), allocatable :: dd
26 real(8), pointer :: p
27 logical :: ifCondition = .TRUE.
28 type(atype) :: t
29 type(atype), dimension(10) :: ta
31 real(8), dimension(N) :: a, f, g, h
33 !$acc serial
34 !ERROR: Directive SET may not be called within a compute region
35 !$acc set default_async(i)
36 !$acc end serial
38 !$acc serial
39 !$acc loop
40 do i = 1, N
41 !ERROR: Directive SET may not be called within a compute region
42 !$acc set default_async(i)
43 a(i) = 3.14
44 end do
45 !$acc end serial
47 !$acc serial
48 !$acc end serial
50 !$acc serial async
51 !$acc end serial
53 !$acc serial async(1)
54 !$acc end serial
56 !ERROR: At most one ASYNC clause can appear on the SERIAL directive
57 !$acc serial async(1) async(2)
58 !$acc end serial
60 !$acc serial async(async1)
61 !$acc end serial
63 !$acc serial wait
64 !$acc end serial
66 !$acc serial wait(1)
67 !$acc end serial
69 !$acc serial wait(wait1)
70 !$acc end serial
72 !$acc serial wait(1,2)
73 !$acc end serial
75 !$acc serial wait(wait1, wait2)
76 !$acc end serial
78 !$acc serial wait(wait1) wait(wait2)
79 !$acc end serial
81 !ERROR: NUM_GANGS clause is not allowed on the SERIAL directive
82 !$acc serial num_gangs(8)
83 !$acc end serial
85 !ERROR: NUM_WORKERS clause is not allowed on the SERIAL directive
86 !$acc serial num_workers(8)
87 !$acc end serial
89 !ERROR: VECTOR_LENGTH clause is not allowed on the SERIAL directive
90 !$acc serial vector_length(128)
91 !$acc end serial
93 !$acc serial if(.true.)
94 !$acc end serial
96 !ERROR: At most one IF clause can appear on the SERIAL directive
97 !$acc serial if(.true.) if(ifCondition)
98 !$acc end serial
100 !$acc serial if(ifCondition)
101 !$acc end serial
103 !$acc serial self
104 !$acc end serial
106 !$acc serial self(.true.)
107 !$acc end serial
109 !$acc serial self(ifCondition)
110 !$acc end serial
112 !$acc serial reduction(.neqv.: reduction_l)
113 !$acc loop reduction(.neqv.: reduction_l)
114 do i = 1, N
115 reduction_l = d(i) .neqv. e(i)
116 end do
117 !$acc end serial
119 !$acc serial copy(aa) copyin(bb) copyout(cc)
120 !$acc end serial
122 !$acc serial copy(aa, bb) copyout(zero: cc)
123 !$acc end serial
125 !$acc serial present(aa, bb) create(cc)
126 !$acc end serial
128 !$acc serial copyin(readonly: aa, bb) create(zero: cc)
129 !$acc end serial
131 !$acc serial deviceptr(aa, bb) no_create(cc)
132 !$acc end serial
134 !ERROR: Argument `aa` on the ATTACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute
135 !$acc serial attach(aa, dd, p)
136 !$acc end serial
138 !$acc serial firstprivate(bb, cc)
139 !$acc end serial
141 !$acc serial private(aa)
142 !$acc end serial
144 !$acc serial default(none)
145 !$acc end serial
147 !$acc serial default(present)
148 !$acc end serial
150 !ERROR: At most one DEFAULT clause can appear on the SERIAL directive
151 !$acc serial default(present) default(none)
152 !$acc end serial
154 !$acc serial device_type(*) async wait
155 !$acc end serial
157 !$acc serial device_type(*) async
158 do i = 1, N
159 a(i) = 3.14
160 end do
161 !$acc end serial
163 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the SERIAL directive
164 !$acc serial device_type(*) if(.TRUE.)
165 do i = 1, N
166 a(i) = 3.14
167 end do
168 !$acc end serial
170 end program openacc_serial_validity