[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / OpenACC / acc-kernels.f90
blobccb128a0c9107e9e53484cb103e612da107610b3
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.3 Kernels
7 program openacc_kernels_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
30 real(8), dimension(N) :: a, f, g, h
32 !$acc kernels async
33 !$acc end kernels
35 !$acc kernels async(1)
36 !$acc end kernels
38 !$acc kernels async(async1)
39 !$acc end kernels
41 !$acc kernels wait(wait1)
42 !$acc end kernels
44 !$acc kernels wait(wait1, wait2)
45 !$acc end kernels
47 !$acc kernels wait(1, 2) async(3)
48 !$acc end kernels
50 !$acc kernels wait(queues: 1, 2) async(3)
51 !$acc end kernels
53 !$acc kernels wait(1) wait(2) async(3)
54 !$acc end kernels
56 !$acc kernels wait(devnum: 1: 1, 2) async(3)
57 !$acc end kernels
59 !$acc kernels wait(devnum: 1: queues: 1, 2) async(3)
60 !$acc end kernels
62 !$acc kernels num_gangs(8)
63 !$acc end kernels
65 !$acc kernels num_workers(8)
66 !$acc end kernels
68 !$acc kernels vector_length(128)
69 !$acc end kernels
71 !$acc kernels if(.true.)
72 !$acc end kernels
74 !$acc kernels if(ifCondition)
75 !$acc end kernels
77 !ERROR: At most one IF clause can appear on the KERNELS directive
78 !$acc kernels if(.true.) if(ifCondition)
79 !$acc end kernels
81 !$acc kernels self
82 !$acc end kernels
84 !$acc kernels self(.true.)
85 !$acc end kernels
87 !$acc kernels self(ifCondition)
88 !$acc end kernels
90 !$acc kernels copy(aa) copyin(bb) copyout(cc)
91 !$acc end kernels
93 !$acc kernels copy(aa, bb) copyout(zero: cc)
94 !$acc end kernels
96 !$acc kernels present(aa, bb) create(cc)
97 !$acc end kernels
99 !$acc kernels copyin(readonly: aa, bb) create(zero: cc)
100 !$acc end kernels
102 !$acc kernels deviceptr(aa, bb) no_create(cc)
103 !$acc end kernels
105 !ERROR: Argument `aa` on the ATTACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute
106 !$acc kernels attach(dd, p, aa)
107 !$acc end kernels
109 !ERROR: PRIVATE clause is not allowed on the KERNELS directive
110 !$acc kernels private(aa, bb, cc)
111 !$acc end kernels
113 !$acc kernels default(none)
114 !$acc end kernels
116 !$acc kernels default(present)
117 !$acc end kernels
119 !ERROR: At most one DEFAULT clause can appear on the KERNELS directive
120 !$acc kernels default(none) default(present)
121 !$acc end kernels
123 !$acc kernels device_type(*)
124 !$acc end kernels
126 !$acc kernels device_type(1)
127 !$acc end kernels
129 !$acc kernels device_type(1, 3)
130 !$acc end kernels
132 !$acc kernels device_type(*) async wait num_gangs(8) num_workers(8) vector_length(128)
133 !$acc end kernels
135 !$acc kernels device_type(*) async
136 do i = 1, N
137 a(i) = 3.14
138 end do
139 !$acc end kernels
141 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the KERNELS directive
142 !$acc kernels device_type(*) if(.TRUE.)
143 do i = 1, N
144 a(i) = 3.14
145 end do
146 !$acc end kernels
148 end program openacc_kernels_validity