[AArch64] Fix brackets warning in assert. NFC
[llvm-project.git] / flang / test / Semantics / OpenACC / acc-kernels.f90
blob8a209040a7793614c47f29e3b8d1a8f98157a0ce
1 ! RUN: %python %S/../test_errors.py %s %flang -fopenacc
3 ! Check OpenACC clause validity for the following construct and directive:
4 ! 2.5.3 Kernels
6 program openacc_kernels_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
29 real(8), dimension(N) :: a, f, g, h
31 !$acc kernels async
32 !$acc end kernels
34 !$acc kernels async(1)
35 !$acc end kernels
37 !$acc kernels async(async1)
38 !$acc end kernels
40 !$acc kernels wait(wait1)
41 !$acc end kernels
43 !$acc kernels wait(wait1, wait2)
44 !$acc end kernels
46 !$acc kernels wait(1, 2) async(3)
47 !$acc end kernels
49 !$acc kernels wait(queues: 1, 2) async(3)
50 !$acc end kernels
52 !$acc kernels wait(1) wait(2) async(3)
53 !$acc end kernels
55 !$acc kernels wait(devnum: 1: 1, 2) async(3)
56 !$acc end kernels
58 !$acc kernels wait(devnum: 1: queues: 1, 2) async(3)
59 !$acc end kernels
61 !$acc kernels num_gangs(8)
62 !$acc end kernels
64 !$acc kernels num_workers(8)
65 !$acc end kernels
67 !$acc kernels vector_length(128)
68 !$acc end kernels
70 !$acc kernels if(.true.)
71 !$acc end kernels
73 !$acc kernels if(ifCondition)
74 !$acc end kernels
76 !ERROR: At most one IF clause can appear on the KERNELS directive
77 !$acc kernels if(.true.) if(ifCondition)
78 !$acc end kernels
80 !$acc kernels self
81 !$acc end kernels
83 !$acc kernels self(.true.)
84 !$acc end kernels
86 !$acc kernels self(ifCondition)
87 !$acc end kernels
89 !$acc kernels copy(aa) copyin(bb) copyout(cc)
90 !$acc end kernels
92 !$acc kernels copy(aa, bb) copyout(zero: cc)
93 !$acc end kernels
95 !$acc kernels present(aa, bb) create(cc)
96 !$acc end kernels
98 !$acc kernels copyin(readonly: aa, bb) create(zero: cc)
99 !$acc end kernels
101 !$acc kernels deviceptr(aa, bb) no_create(cc)
102 !$acc end kernels
104 !ERROR: Argument `aa` on the ATTACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute
105 !$acc kernels attach(dd, p, aa)
106 !$acc end kernels
108 !ERROR: PRIVATE clause is not allowed on the KERNELS directive
109 !$acc kernels private(aa, bb, cc)
110 !$acc end kernels
112 !$acc kernels default(none)
113 !$acc end kernels
115 !$acc kernels default(present)
116 !$acc end kernels
118 !ERROR: At most one DEFAULT clause can appear on the KERNELS directive
119 !$acc kernels default(none) default(present)
120 !$acc end kernels
122 !$acc kernels device_type(*)
123 !$acc end kernels
125 !$acc kernels device_type(default)
126 !$acc end kernels
128 !$acc kernels device_type(default, host)
129 !$acc end kernels
131 !$acc kernels device_type(*) async wait num_gangs(8) num_workers(8) vector_length(128)
132 !$acc end kernels
134 !$acc kernels device_type(*) async
135 do i = 1, N
136 a(i) = 3.14
137 end do
138 !$acc end kernels
140 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the KERNELS directive
141 !$acc kernels device_type(*) if(.TRUE.)
142 do i = 1, N
143 a(i) = 3.14
144 end do
145 !$acc end kernels
147 do i = 1, 100
148 !$acc kernels
149 !ERROR: CYCLE to construct outside of KERNELS construct is not allowed
150 if (i == 10) cycle
151 !$acc end kernels
152 end do
154 !$acc kernels
155 do i = 1, 100
156 if (i == 10) cycle
157 end do
158 !$acc end kernels
160 end program openacc_kernels_validity