blob: c8d7a8711291763fbb9278fc231cdff79beb3a2d [file] [log] [blame]
Valentin Clementdd4fb7c2020-09-30 16:23:061// RUN: mlir-opt -split-input-file -verify-diagnostics %s
Valentin Clement01f5fcd2020-09-15 15:41:502
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:293%1 = arith.constant 1 : i32
4%2 = arith.constant 10 : i32
Valentin Clement01f5fcd2020-09-15 15:41:505// expected-error@+1 {{gang, worker or vector cannot appear with the seq attr}}
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:366acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {
Valentin Clementdd4fb7c2020-09-30 16:23:067 "test.openacc_dummy_op"() : () -> ()
Valentin Clement01f5fcd2020-09-15 15:41:508 acc.yield
Valentin Clement (バレンタイン クレメン)e4566892024-01-05 00:33:339} attributes {seq = [#acc.device_type<none>], gang = [#acc.device_type<none>]}
Valentin Clement01f5fcd2020-09-15 15:41:5010
11// -----
12
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:2913%1 = arith.constant 1 : i32
14%2 = arith.constant 10 : i32
Valentin Clement01f5fcd2020-09-15 15:41:5015// expected-error@+1 {{gang, worker or vector cannot appear with the seq attr}}
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:3616acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {
Valentin Clementdd4fb7c2020-09-30 16:23:0617 "test.openacc_dummy_op"() : () -> ()
Valentin Clement01f5fcd2020-09-15 15:41:5018 acc.yield
Valentin Clement (バレンタイン クレメン)e4566892024-01-05 00:33:3319} attributes {seq = [#acc.device_type<none>], worker = [#acc.device_type<none>]}
Valentin Clement01f5fcd2020-09-15 15:41:5020
21// -----
22
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:2923%1 = arith.constant 1 : i32
24%2 = arith.constant 10 : i32
Valentin Clement01f5fcd2020-09-15 15:41:5025// expected-error@+1 {{gang, worker or vector cannot appear with the seq attr}}
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:3626acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {
Valentin Clementdd4fb7c2020-09-30 16:23:0627 "test.openacc_dummy_op"() : () -> ()
Valentin Clement01f5fcd2020-09-15 15:41:5028 acc.yield
Valentin Clement (バレンタイン クレメン)e4566892024-01-05 00:33:3329} attributes {seq = [#acc.device_type<none>], vector = [#acc.device_type<none>]}
Valentin Clement01f5fcd2020-09-15 15:41:5030
31// -----
32
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:2933%1 = arith.constant 1 : i32
34%2 = arith.constant 10 : i32
Valentin Clement01f5fcd2020-09-15 15:41:5035// expected-error@+1 {{gang, worker or vector cannot appear with the seq attr}}
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:3636acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {
Valentin Clementdd4fb7c2020-09-30 16:23:0637 "test.openacc_dummy_op"() : () -> ()
Valentin Clement01f5fcd2020-09-15 15:41:5038 acc.yield
Valentin Clement (バレンタイン クレメン)e4566892024-01-05 00:33:3339} attributes {seq = [#acc.device_type<none>], worker = [#acc.device_type<none>], gang = [#acc.device_type<none>]}
Valentin Clement01f5fcd2020-09-15 15:41:5040
41// -----
42
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:2943%1 = arith.constant 1 : i32
44%2 = arith.constant 10 : i32
Valentin Clement01f5fcd2020-09-15 15:41:5045// expected-error@+1 {{gang, worker or vector cannot appear with the seq attr}}
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:3646acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {
Valentin Clementdd4fb7c2020-09-30 16:23:0647 "test.openacc_dummy_op"() : () -> ()
Valentin Clement01f5fcd2020-09-15 15:41:5048 acc.yield
Valentin Clement (バレンタイン クレメン)e4566892024-01-05 00:33:3349} attributes {seq = [#acc.device_type<none>], vector = [#acc.device_type<none>], gang = [#acc.device_type<none>]}
Valentin Clement01f5fcd2020-09-15 15:41:5050
51// -----
52
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:2953%1 = arith.constant 1 : i32
54%2 = arith.constant 10 : i32
Valentin Clement01f5fcd2020-09-15 15:41:5055// expected-error@+1 {{gang, worker or vector cannot appear with the seq attr}}
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:3656acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {
Valentin Clementdd4fb7c2020-09-30 16:23:0657 "test.openacc_dummy_op"() : () -> ()
Valentin Clement01f5fcd2020-09-15 15:41:5058 acc.yield
Valentin Clement (バレンタイン クレメン)e4566892024-01-05 00:33:3359} attributes {seq = [#acc.device_type<none>], vector = [#acc.device_type<none>], worker = [#acc.device_type<none>]}
Valentin Clement01f5fcd2020-09-15 15:41:5060
61// -----
62
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:2963%1 = arith.constant 1 : i32
64%2 = arith.constant 10 : i32
Valentin Clement01f5fcd2020-09-15 15:41:5065// expected-error@+1 {{gang, worker or vector cannot appear with the seq attr}}
Valentin Clement (バレンタイン クレメン)e4566892024-01-05 00:33:3366acc.loop {
Valentin Clementdd4fb7c2020-09-30 16:23:0667 "test.openacc_dummy_op"() : () -> ()
Valentin Clement01f5fcd2020-09-15 15:41:5068 acc.yield
Valentin Clement (バレンタイン クレメン)e4566892024-01-05 00:33:3369} attributes {seq = [#acc.device_type<none>], vector = [#acc.device_type<none>], worker = [#acc.device_type<none>], gang = [#acc.device_type<none>]}
Valentin Clement01f5fcd2020-09-15 15:41:5070
71// -----
72
73// expected-error@+1 {{expected non-empty body.}}
74acc.loop {
75}
76
77// -----
78
Valentin Clement (バレンタイン クレメン)e4566892024-01-05 00:33:3379// expected-error@+1 {{'acc.loop' op duplicate device_type found in gang attribute}}
80acc.loop {
81 acc.yield
82} attributes {gang = [#acc.device_type<none>, #acc.device_type<none>]}
83
84// -----
85
86// expected-error@+1 {{'acc.loop' op duplicate device_type found in worker attribute}}
87acc.loop {
88 acc.yield
89} attributes {worker = [#acc.device_type<none>, #acc.device_type<none>]}
90
91// -----
92
93// expected-error@+1 {{'acc.loop' op duplicate device_type found in vector attribute}}
94acc.loop {
95 acc.yield
96} attributes {vector = [#acc.device_type<none>, #acc.device_type<none>]}
97
98// -----
99
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:29100%1 = arith.constant 1 : i32
101%2 = arith.constant 10 : i32
Valentin Clementb6c19302023-04-17 19:44:36102// expected-error@+1 {{only one of "auto", "independent", "seq" can be present at the same time}}
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:36103acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {
Valentin Clement01f5fcd2020-09-15 15:41:50104 acc.yield
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:29105} attributes {auto_ = [#acc.device_type<none>], seq = [#acc.device_type<none>], inclusiveUpperbound = array<i1: true>}
Valentin Clement01f5fcd2020-09-15 15:41:50106
107// -----
Valentin Clementbbb5dc42020-09-29 01:22:07108
109// expected-error@+1 {{at least one operand or the default attribute must appear on the data operation}}
110acc.data {
111 acc.yield
112}
113
114// -----
Valentin Clementcc3b8e72020-09-29 14:39:13115
Valentin Clementa7b50ef2023-05-08 16:26:34116%value = memref.alloc() : memref<10xf32>
117// expected-error@+1 {{expect data entry/exit operation or acc.getdeviceptr as defining op}}
118acc.data dataOperands(%value : memref<10xf32>) {
119 acc.yield
120}
121
122// -----
123
Valentin Clement689afa82023-05-08 17:03:04124// expected-error@+1 {{at least one value must be present in dataOperands}}
Valentin Clementecc997802020-09-29 13:56:54125acc.update
126
127// -----
128
Mogballa54f4ea2021-10-12 23:14:57129%cst = arith.constant 1 : index
Valentin Clement689afa82023-05-08 17:03:04130%value = memref.alloc() : memref<f32>
131%0 = acc.update_device varPtr(%value : memref<f32>) -> memref<f32>
River Riddleef72cf442022-02-02 18:22:57132// expected-error@+1 {{async attribute cannot appear with asyncOperand}}
Valentin Clement (バレンタイン クレメン)78ef0322024-01-25 21:58:58133acc.update async(%cst: index) dataOperands(%0 : memref<f32>) attributes {async = [#acc.device_type<none>]}
Valentin Clementecc997802020-09-29 13:56:54134
135// -----
136
Mogballa54f4ea2021-10-12 23:14:57137%cst = arith.constant 1 : index
Valentin Clement689afa82023-05-08 17:03:04138%value = memref.alloc() : memref<f32>
139%0 = acc.update_device varPtr(%value : memref<f32>) -> memref<f32>
Valentin Clementecc997802020-09-29 13:56:54140// expected-error@+1 {{wait attribute cannot appear with waitOperands}}
Valentin Clement (バレンタイン クレメン)c09dc2d2024-01-29 05:17:36141acc.update wait({%cst: index}) dataOperands(%0: memref<f32>) attributes {waitOnly = [#acc.device_type<none>]}
Valentin Clementcc3b8e72020-09-29 14:39:13142
143// -----
144
Mogballa54f4ea2021-10-12 23:14:57145%cst = arith.constant 1 : index
Valentin Clementcc3b8e72020-09-29 14:39:13146// expected-error@+1 {{wait_devnum cannot appear without waitOperands}}
147acc.wait wait_devnum(%cst: index)
148
149// -----
150
Mogballa54f4ea2021-10-12 23:14:57151%cst = arith.constant 1 : index
Valentin Clementcc3b8e72020-09-29 14:39:13152// expected-error@+1 {{async attribute cannot appear with asyncOperand}}
153acc.wait async(%cst: index) attributes {async}
Valentin Clement51323fe2020-09-29 14:58:46154
155// -----
156
157acc.parallel {
158// expected-error@+1 {{'acc.init' op cannot be nested in a compute operation}}
159 acc.init
160 acc.yield
161}
162
163// -----
164
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:29165%1 = arith.constant 1 : i32
166%2 = arith.constant 10 : i32
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:36167acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32){
Valentin Clement51323fe2020-09-29 14:58:46168// expected-error@+1 {{'acc.init' op cannot be nested in a compute operation}}
169 acc.init
170 acc.yield
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:29171} attributes {inclusiveUpperbound = array<i1: true>}
Valentin Clement9c773502020-09-29 17:12:54172
173// -----
174
175acc.parallel {
176// expected-error@+1 {{'acc.shutdown' op cannot be nested in a compute operation}}
177 acc.shutdown
178 acc.yield
179}
180
181// -----
182
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:29183%1 = arith.constant 1 : i32
184%2 = arith.constant 10 : i32
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:36185acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {
Valentin Clement9c773502020-09-29 17:12:54186// expected-error@+1 {{'acc.shutdown' op cannot be nested in a compute operation}}
187 acc.shutdown
188 acc.yield
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:29189} attributes {inclusiveUpperbound = array<i1: true>}
Valentin Clement9c773502020-09-29 17:12:54190
191// -----
192
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:29193%1 = arith.constant 1 : i32
194%2 = arith.constant 10 : i32
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:36195acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {
Valentin Clementdd4fb7c2020-09-30 16:23:06196 "test.openacc_dummy_op"() ({
Valentin Clement9c773502020-09-29 17:12:54197 // expected-error@+1 {{'acc.shutdown' op cannot be nested in a compute operation}}
198 acc.shutdown
199 }) : () -> ()
200 acc.yield
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:29201} attributes {inclusiveUpperbound = array<i1: true>}
Valentin Clement6260cb12020-10-10 01:02:29202
203// -----
204
Valentin Clement15a480c2023-05-09 18:36:28205// expected-error@+1 {{at least one operand must be present in dataOperands on the exit data operation}}
Valentin Clement6260cb12020-10-10 01:02:29206acc.exit_data attributes {async}
207
208// -----
209
Mogballa54f4ea2021-10-12 23:14:57210%cst = arith.constant 1 : index
Valentin Clement15a480c2023-05-09 18:36:28211%value = memref.alloc() : memref<f32>
212%0 = acc.getdeviceptr varPtr(%value : memref<f32>) -> memref<f32>
Valentin Clement6260cb12020-10-10 01:02:29213// expected-error@+1 {{async attribute cannot appear with asyncOperand}}
Valentin Clement15a480c2023-05-09 18:36:28214acc.exit_data async(%cst: index) dataOperands(%0 : memref<f32>) attributes {async}
215acc.delete accPtr(%0 : memref<f32>)
Valentin Clement6260cb12020-10-10 01:02:29216
217// -----
218
Mogballa54f4ea2021-10-12 23:14:57219%cst = arith.constant 1 : index
Valentin Clement15a480c2023-05-09 18:36:28220%value = memref.alloc() : memref<f32>
221%0 = acc.getdeviceptr varPtr(%value : memref<f32>) -> memref<f32>
Valentin Clement4b011902020-10-12 01:26:54222// expected-error@+1 {{wait_devnum cannot appear without waitOperands}}
Valentin Clement15a480c2023-05-09 18:36:28223acc.exit_data wait_devnum(%cst: index) dataOperands(%0 : memref<f32>)
224acc.delete accPtr(%0 : memref<f32>)
Valentin Clement4b011902020-10-12 01:26:54225
226// -----
227
Valentin Clement9dec07f2023-05-09 16:00:36228// expected-error@+1 {{at least one operand must be present in dataOperands on the enter data operation}}
Valentin Clement4b011902020-10-12 01:26:54229acc.enter_data attributes {async}
230
231// -----
232
Mogballa54f4ea2021-10-12 23:14:57233%cst = arith.constant 1 : index
Valentin Clement9dec07f2023-05-09 16:00:36234%value = memref.alloc() : memref<f32>
235%0 = acc.create varPtr(%value : memref<f32>) -> memref<f32>
Valentin Clement4b011902020-10-12 01:26:54236// expected-error@+1 {{async attribute cannot appear with asyncOperand}}
Valentin Clement9dec07f2023-05-09 16:00:36237acc.enter_data async(%cst: index) dataOperands(%0 : memref<f32>) attributes {async}
Valentin Clement4b011902020-10-12 01:26:54238
239// -----
240
Mogballa54f4ea2021-10-12 23:14:57241%cst = arith.constant 1 : index
Valentin Clement9dec07f2023-05-09 16:00:36242%value = memref.alloc() : memref<f32>
243%0 = acc.create varPtr(%value : memref<f32>) -> memref<f32>
Valentin Clement6260cb12020-10-10 01:02:29244// expected-error@+1 {{wait attribute cannot appear with waitOperands}}
Valentin Clement9dec07f2023-05-09 16:00:36245acc.enter_data wait(%cst: index) dataOperands(%0 : memref<f32>) attributes {wait}
Valentin Clement6260cb12020-10-10 01:02:29246
247// -----
248
Mogballa54f4ea2021-10-12 23:14:57249%cst = arith.constant 1 : index
Valentin Clement9dec07f2023-05-09 16:00:36250%value = memref.alloc() : memref<f32>
251%0 = acc.create varPtr(%value : memref<f32>) -> memref<f32>
Valentin Clement6260cb12020-10-10 01:02:29252// expected-error@+1 {{wait_devnum cannot appear without waitOperands}}
Valentin Clement9dec07f2023-05-09 16:00:36253acc.enter_data wait_devnum(%cst: index) dataOperands(%0 : memref<f32>)
Valentin Clemented35b582023-04-20 21:42:56254
255// -----
256
Valentin Clement7cb96292023-05-08 16:28:13257%value = memref.alloc() : memref<10xf32>
258// expected-error@+1 {{expect data entry operation as defining op}}
259acc.enter_data dataOperands(%value : memref<10xf32>)
260
261// -----
262
Valentin Clemented35b582023-04-20 21:42:56263%0 = arith.constant 1.0 : f32
264// expected-error@+1 {{operand #0 must be integer or index, but got 'f32'}}
265%1 = acc.bounds lowerbound(%0 : f32)
266
Valentin Clement78a09cb2023-05-08 16:29:08267// -----
268
269%value = memref.alloc() : memref<10xf32>
270// expected-error@+1 {{expect data entry/exit operation or acc.getdeviceptr as defining op}}
271acc.update dataOperands(%value : memref<10xf32>)
Valentin Clementaad53e32023-05-08 16:30:01272
273// -----
274
275%value = memref.alloc() : memref<10xf32>
276// expected-error@+1 {{expect data entry/exit operation or acc.getdeviceptr as defining op}}
277acc.parallel dataOperands(%value : memref<10xf32>) {
278 acc.yield
279}
280
281// -----
282
283%value = memref.alloc() : memref<10xf32>
284// expected-error@+1 {{expect data entry/exit operation or acc.getdeviceptr as defining op}}
285acc.serial dataOperands(%value : memref<10xf32>) {
286 acc.yield
287}
288
289// -----
290
291%value = memref.alloc() : memref<10xf32>
292// expected-error@+1 {{expect data entry/exit operation or acc.getdeviceptr as defining op}}
293acc.kernels dataOperands(%value : memref<10xf32>) {
294 acc.yield
295}
Valentin Clement9c3299b2023-05-17 18:06:07296
297// -----
298
299// expected-error@+1 {{expects non-empty init region}}
Christian Ulmann7ed96b12023-11-04 13:13:31300acc.private.recipe @privatization_i32 : !llvm.ptr init {
Valentin Clement9c3299b2023-05-17 18:06:07301}
302
303// -----
304
Valentin Clement1d498342023-07-19 17:30:42305// expected-error@+1 {{expects init region first argument of the privatization type}}
Christian Ulmann7ed96b12023-11-04 13:13:31306acc.private.recipe @privatization_i32 : !llvm.ptr init {
307^bb0(%arg0 : i32):
Valentin Clement9c3299b2023-05-17 18:06:07308 %c1 = arith.constant 1 : i32
Christian Ulmann7ed96b12023-11-04 13:13:31309 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr
310 acc.yield %0 : !llvm.ptr
Valentin Clement9c3299b2023-05-17 18:06:07311}
312
313// -----
314
Valentin Clement1d498342023-07-19 17:30:42315// expected-error@+1 {{expects destroy region first argument of the privatization type}}
Christian Ulmann7ed96b12023-11-04 13:13:31316acc.private.recipe @privatization_i32 : !llvm.ptr init {
317^bb0(%arg0 : !llvm.ptr):
Valentin Clement9c3299b2023-05-17 18:06:07318 %c1 = arith.constant 1 : i32
319 %c0 = arith.constant 0 : i32
Christian Ulmann7ed96b12023-11-04 13:13:31320 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr
321 llvm.store %c0, %0 : i32, !llvm.ptr
322 acc.yield %0 : !llvm.ptr
Valentin Clement9c3299b2023-05-17 18:06:07323} destroy {
324^bb0(%arg0 : f32):
325 "test.openacc_dummy_op"(%arg0) : (f32) -> ()
326}
Valentin Clement8497dfd2023-05-17 18:11:42327
328// -----
329
330// expected-error@+1 {{expects non-empty init region}}
Christian Ulmann7ed96b12023-11-04 13:13:31331acc.firstprivate.recipe @privatization_i32 : !llvm.ptr init {
Valentin Clement8497dfd2023-05-17 18:11:42332} copy {}
333
334// -----
335
Valentin Clement1d498342023-07-19 17:30:42336// expected-error@+1 {{expects init region first argument of the privatization type}}
Christian Ulmann7ed96b12023-11-04 13:13:31337acc.firstprivate.recipe @privatization_i32 : !llvm.ptr init {
338^bb0(%arg0 : i32):
Valentin Clement8497dfd2023-05-17 18:11:42339 %c1 = arith.constant 1 : i32
Christian Ulmann7ed96b12023-11-04 13:13:31340 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr
341 acc.yield %0 : !llvm.ptr
Valentin Clement8497dfd2023-05-17 18:11:42342} copy {}
343
344// -----
345
Valentin Clement8497dfd2023-05-17 18:11:42346// expected-error@+1 {{expects non-empty copy region}}
Christian Ulmann7ed96b12023-11-04 13:13:31347acc.firstprivate.recipe @privatization_i32 : !llvm.ptr init {
348^bb0(%arg0 : !llvm.ptr):
Valentin Clement8497dfd2023-05-17 18:11:42349 %c1 = arith.constant 1 : i32
350 %c0 = arith.constant 0 : i32
Christian Ulmann7ed96b12023-11-04 13:13:31351 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr
352 llvm.store %c0, %0 : i32, !llvm.ptr
353 acc.yield %0 : !llvm.ptr
Valentin Clement8497dfd2023-05-17 18:11:42354} copy {
355}
356
357// -----
358
359// expected-error@+1 {{expects copy region with two arguments of the privatization type}}
Christian Ulmann7ed96b12023-11-04 13:13:31360acc.firstprivate.recipe @privatization_i32 : !llvm.ptr init {
361^bb0(%arg0 : !llvm.ptr):
Valentin Clement8497dfd2023-05-17 18:11:42362 %c1 = arith.constant 1 : i32
363 %c0 = arith.constant 0 : i32
Christian Ulmann7ed96b12023-11-04 13:13:31364 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr
365 llvm.store %c0, %0 : i32, !llvm.ptr
366 acc.yield %0 : !llvm.ptr
Valentin Clement8497dfd2023-05-17 18:11:42367} copy {
368^bb0(%arg0 : f32):
369 "test.openacc_dummy_op"(%arg0) : (f32) -> ()
370}
371
372// -----
373
374// expected-error@+1 {{expects copy region with two arguments of the privatization type}}
Christian Ulmann7ed96b12023-11-04 13:13:31375acc.firstprivate.recipe @privatization_i32 : !llvm.ptr init {
376^bb0(%arg0 : !llvm.ptr):
Valentin Clement8497dfd2023-05-17 18:11:42377 %c1 = arith.constant 1 : i32
378 %c0 = arith.constant 0 : i32
Christian Ulmann7ed96b12023-11-04 13:13:31379 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr
380 llvm.store %c0, %0 : i32, !llvm.ptr
381 acc.yield %0 : !llvm.ptr
Valentin Clement8497dfd2023-05-17 18:11:42382} copy {
383^bb0(%arg0 : f32, %arg1 : i32):
384 "test.openacc_dummy_op"(%arg0) : (f32) -> ()
385}
386
387// -----
388
Valentin Clement1d498342023-07-19 17:30:42389// expected-error@+1 {{expects destroy region first argument of the privatization type}}
Valentin Clement8497dfd2023-05-17 18:11:42390acc.firstprivate.recipe @privatization_i32 : i32 init {
391^bb0(%arg0 : i32):
392 %0 = arith.constant 1 : i32
393 acc.yield %0 : i32
394} copy {
Christian Ulmann7ed96b12023-11-04 13:13:31395^bb0(%arg0 : i32, %arg1 : !llvm.ptr):
396 llvm.store %arg0, %arg1 : i32, !llvm.ptr
Valentin Clement8497dfd2023-05-17 18:11:42397 acc.yield
398} destroy {
399^bb0(%arg0 : f32):
400 acc.yield
401}
402
Valentin Clement12f3ae62023-05-18 23:20:57403// -----
Valentin Clement8497dfd2023-05-17 18:11:42404
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:29405%1 = arith.constant 1 : i32
406%2 = arith.constant 10 : i32
Valentin Clement2e699442023-06-13 18:16:31407// expected-error@+1 {{expected ')'}}
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:36408acc.loop gang({static=%i64Value: i64, num=%i64Value: i64} control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {
Valentin Clement2e699442023-06-13 18:16:31409 "test.openacc_dummy_op"() : () -> ()
410 acc.yield
411}
412
413// -----
414
Valentin Clement12f3ae62023-05-18 23:20:57415// expected-error@+1 {{expects non-empty init region}}
416acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
417} combiner {}
418
419// -----
420
Valentin Clement1d498342023-07-19 17:30:42421// expected-error@+1 {{expects init region first argument of the reduction type}}
Valentin Clement12f3ae62023-05-18 23:20:57422acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
423^bb0(%0: i32):
424 %1 = arith.constant 0 : i64
425 acc.yield %1 : i64
426} combiner {}
427
428// -----
429
Valentin Clement12f3ae62023-05-18 23:20:57430// expected-error@+1 {{expects non-empty combiner region}}
431acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
432^bb0(%0: i64):
433 %1 = arith.constant 0 : i64
434 acc.yield %1 : i64
435} combiner {}
436
437// -----
438
Valentin Clement1d498342023-07-19 17:30:42439// expected-error@+1 {{expects combiner region with the first two arguments of the reduction type}}
Valentin Clement12f3ae62023-05-18 23:20:57440acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
441^bb0(%0: i64):
442 %1 = arith.constant 0 : i64
443 acc.yield %1 : i64
444} combiner {
445^bb0(%0: i32):
446 acc.yield %0 : i32
447}
448
449// -----
450
Valentin Clement1d498342023-07-19 17:30:42451// expected-error@+1 {{expects combiner region with the first two arguments of the reduction type}}
Valentin Clement12f3ae62023-05-18 23:20:57452acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
453^bb0(%0: i64):
454 %1 = arith.constant 0 : i64
455 acc.yield %1 : i64
456} combiner {
457^bb0(%0: i64):
458 acc.yield %0 : i64
459}
460
461// -----
462
463// expected-error@+1 {{expects combiner region to yield a value of the reduction type}}
464acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {
465^bb0(%0: i64):
466 %1 = arith.constant 0 : i64
467 acc.yield %1 : i64
468} combiner {
469^bb0(%0: i64, %1: i64):
470 %2 = arith.constant 0 : i32
471 acc.yield %2 : i32
472}
Valentin Clementeaf29b32023-05-24 17:39:00473
474// -----
475
Valentin Clement (バレンタイン クレメン)3eb41782024-01-22 18:31:29476%1 = arith.constant 1 : i32
477%2 = arith.constant 10 : i32
Valentin Clement2e699442023-06-13 18:16:31478// expected-error@+1 {{new value expected after comma}}
Valentin Clement (バレンタイン クレメン)6b426252024-02-05 22:22:36479acc.loop gang({static=%i64Value: i64, ) control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {
Valentin Clement2e699442023-06-13 18:16:31480 "test.openacc_dummy_op"() : () -> ()
481 acc.yield
482}
483
484// -----
485
Christian Ulmann7ed96b12023-11-04 13:13:31486func.func @fct1(%0 : !llvm.ptr) -> () {
Valentin Clementeaf29b32023-05-24 17:39:00487 // expected-error@+1 {{expected symbol reference @privatization_i32 to point to a private declaration}}
Christian Ulmann7ed96b12023-11-04 13:13:31488 acc.serial private(@privatization_i32 -> %0 : !llvm.ptr) {
Valentin Clementeaf29b32023-05-24 17:39:00489 }
490 return
491}
Valentin Clement2e699442023-06-13 18:16:31492
493// -----
494
Valentin Clement7f3d2cc2023-06-13 20:39:06495// expected-error@+1 {{expect at least one of num, dim or static values}}
Valentin Clement (バレンタイン クレメン)e4566892024-01-05 00:33:33496acc.loop gang({}) {
Valentin Clement2e699442023-06-13 18:16:31497 "test.openacc_dummy_op"() : () -> ()
498 acc.yield
499}
Valentin Clementc4a63b82023-06-27 18:08:22500
501// -----
502
503%i64value = arith.constant 1 : i64
Valentin Clementa25da1a2023-12-07 22:04:54504// expected-error@+1 {{num_gangs expects a maximum of 3 values per segment}}
505acc.parallel num_gangs({%i64value: i64, %i64value : i64, %i64value : i64, %i64value : i64}) {
Valentin Clementc4a63b82023-06-27 18:08:22506}
Valentin Clement4bac6ed2023-08-23 16:31:49507
508// -----
509
Valentin Clement (バレンタイン クレメン)65bd5ed2024-10-09 20:07:09510%0 = "arith.constant"() <{value = 1 : i64}> : () -> i64
511// expected-error@+1 {{num_gangs operand count does not match count in segments}}
512"acc.parallel"(%0) <{numGangsSegments = array<i32: 1>, operandSegmentSizes = array<i32: 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0>}> ({
513}) : (i64) -> ()
514
515// -----
516
Valentin Clement4bac6ed2023-08-23 16:31:49517%i64value = arith.constant 1 : i64
518acc.parallel {
519// expected-error@+1 {{'acc.set' op cannot be nested in a compute operation}}
Valentin Clement (バレンタイン クレメン)f7068372023-10-30 16:51:42520 acc.set attributes {device_type = #acc.device_type<nvidia>}
Valentin Clement4bac6ed2023-08-23 16:31:49521 acc.yield
522}
523
524// -----
525
526// expected-error@+1 {{'acc.set' op at least one default_async, device_num, or device_type operand must appear}}
527acc.set
Razvan Lupusoru61278ec2023-09-06 20:54:39528
529// -----
530
531func.func @acc_atomic_write(%addr : memref<memref<i32>>, %val : i32) {
532 // expected-error @below {{address must dereference to value type}}
533 acc.atomic.write %addr = %val : memref<memref<i32>>, i32
534 return
535}
536
537// -----
538
539func.func @acc_atomic_update(%x: memref<i32>, %expr: f32) {
540 // expected-error @below {{the type of the operand must be a pointer type whose element type is the same as that of the region argument}}
541 acc.atomic.update %x : memref<i32> {
542 ^bb0(%xval: f32):
543 %newval = llvm.fadd %xval, %expr : f32
544 acc.yield %newval : f32
545 }
546 return
547}
548
549// -----
550
551func.func @acc_atomic_update(%x: memref<i32>, %expr: i32) {
552 // expected-error @+2 {{op expects regions to end with 'acc.yield', found 'acc.terminator'}}
553 // expected-note @below {{in custom textual format, the absence of terminator implies 'acc.yield'}}
554 acc.atomic.update %x : memref<i32> {
555 ^bb0(%xval: i32):
556 %newval = llvm.add %xval, %expr : i32
557 acc.terminator
558 }
559 return
560}
561// -----
562
563func.func @acc_atomic_update(%x: memref<i32>, %expr: i32) {
564 // expected-error @below {{invalid kind of type specified}}
565 acc.atomic.update %x : i32 {
566 ^bb0(%xval: i32):
567 %newval = llvm.add %xval, %expr : i32
568 acc.yield %newval : i32
569 }
570 return
571}
572
573// -----
574
575func.func @acc_atomic_update(%x: memref<i32>, %expr: i32) {
576 // expected-error @below {{only updated value must be returned}}
577 acc.atomic.update %x : memref<i32> {
578 ^bb0(%xval: i32):
579 %newval = llvm.add %xval, %expr : i32
580 acc.yield %newval, %expr : i32, i32
581 }
582 return
583}
584
585// -----
586
587func.func @acc_atomic_update(%x: memref<i32>, %expr: i32, %y: f32) {
588 // expected-error @below {{input and yielded value must have the same type}}
589 acc.atomic.update %x : memref<i32> {
590 ^bb0(%xval: i32):
591 %newval = llvm.add %xval, %expr : i32
592 acc.yield %y: f32
593 }
594 return
595}
596
597// -----
598
599func.func @acc_atomic_update(%x: memref<i32>, %expr: i32) {
600 // expected-error @below {{the region must accept exactly one argument}}
601 acc.atomic.update %x : memref<i32> {
602 ^bb0(%xval: i32, %tmp: i32):
603 %newval = llvm.add %xval, %expr : i32
604 acc.yield %newval : i32
605 }
606 return
607}
608
609// -----
610
611func.func @acc_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {
612 // expected-error @below {{expected three operations in atomic.capture region}}
613 acc.atomic.capture {
khaki3a63f915772024-11-05 15:52:45614 acc.atomic.read %v = %x : memref<i32>, memref<i32>, i32
Razvan Lupusoru61278ec2023-09-06 20:54:39615 acc.terminator
616 }
617 return
618}
619
620// -----
621
622func.func @acc_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {
623 acc.atomic.capture {
624 // expected-error @below {{invalid sequence of operations in the capture region}}
khaki3a63f915772024-11-05 15:52:45625 acc.atomic.read %v = %x : memref<i32>, memref<i32>, i32
626 acc.atomic.read %v = %x : memref<i32>, memref<i32>, i32
Razvan Lupusoru61278ec2023-09-06 20:54:39627 acc.terminator
628 }
629 return
630}
631
632// -----
633
634func.func @acc_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {
635 acc.atomic.capture {
636 // expected-error @below {{invalid sequence of operations in the capture region}}
637 acc.atomic.update %x : memref<i32> {
638 ^bb0(%xval: i32):
639 %newval = llvm.add %xval, %expr : i32
640 acc.yield %newval : i32
641 }
642 acc.atomic.update %x : memref<i32> {
643 ^bb0(%xval: i32):
644 %newval = llvm.add %xval, %expr : i32
645 acc.yield %newval : i32
646 }
647 acc.terminator
648 }
649 return
650}
651
652// -----
653
654func.func @acc_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {
655 acc.atomic.capture {
656 // expected-error @below {{invalid sequence of operations in the capture region}}
657 acc.atomic.write %x = %expr : memref<i32>, i32
658 acc.atomic.write %x = %expr : memref<i32>, i32
659 acc.terminator
660 }
661 return
662}
663
664// -----
665
666func.func @acc_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {
667 acc.atomic.capture {
668 // expected-error @below {{invalid sequence of operations in the capture region}}
669 acc.atomic.write %x = %expr : memref<i32>, i32
670 acc.atomic.update %x : memref<i32> {
671 ^bb0(%xval: i32):
672 %newval = llvm.add %xval, %expr : i32
673 acc.yield %newval : i32
674 }
675 acc.terminator
676 }
677 return
678}
679
680// -----
681
682func.func @acc_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {
683 acc.atomic.capture {
684 // expected-error @below {{invalid sequence of operations in the capture region}}
685 acc.atomic.update %x : memref<i32> {
686 ^bb0(%xval: i32):
687 %newval = llvm.add %xval, %expr : i32
688 acc.yield %newval : i32
689 }
690 acc.atomic.write %x = %expr : memref<i32>, i32
691 acc.terminator
692 }
693 return
694}
695
696// -----
697
698func.func @acc_atomic_capture(%x: memref<i32>, %v: memref<i32>, %expr: i32) {
699 acc.atomic.capture {
700 // expected-error @below {{invalid sequence of operations in the capture region}}
701 acc.atomic.write %x = %expr : memref<i32>, i32
khaki3a63f915772024-11-05 15:52:45702 acc.atomic.read %v = %x : memref<i32>, memref<i32>, i32
Razvan Lupusoru61278ec2023-09-06 20:54:39703 acc.terminator
704 }
705 return
706}
707
708// -----
709
710func.func @acc_atomic_capture(%x: memref<i32>, %y: memref<i32>, %v: memref<i32>, %expr: i32) {
711 acc.atomic.capture {
712 // expected-error @below {{updated variable in atomic.update must be captured in second operation}}
713 acc.atomic.update %x : memref<i32> {
714 ^bb0(%xval: i32):
715 %newval = llvm.add %xval, %expr : i32
716 acc.yield %newval : i32
717 }
khaki3a63f915772024-11-05 15:52:45718 acc.atomic.read %v = %y : memref<i32>, memref<i32>, i32
Razvan Lupusoru61278ec2023-09-06 20:54:39719 acc.terminator
720 }
721}
722
723// -----
724
725func.func @acc_atomic_capture(%x: memref<i32>, %y: memref<i32>, %v: memref<i32>, %expr: i32) {
726 acc.atomic.capture {
727 // expected-error @below {{captured variable in atomic.read must be updated in second operation}}
khaki3a63f915772024-11-05 15:52:45728 acc.atomic.read %v = %y : memref<i32>, memref<i32>, i32
Razvan Lupusoru61278ec2023-09-06 20:54:39729 acc.atomic.update %x : memref<i32> {
730 ^bb0(%xval: i32):
731 %newval = llvm.add %xval, %expr : i32
732 acc.yield %newval : i32
733 }
734 acc.terminator
735 }
736}
737
738// -----
739
740func.func @acc_atomic_capture(%x: memref<i32>, %y: memref<i32>, %v: memref<i32>, %expr: i32) {
741 acc.atomic.capture {
742 // expected-error @below {{captured variable in atomic.read must be updated in second operation}}
khaki3a63f915772024-11-05 15:52:45743 acc.atomic.read %v = %x : memref<i32>, memref<i32>, i32
Razvan Lupusoru61278ec2023-09-06 20:54:39744 acc.atomic.write %y = %expr : memref<i32>, i32
745 acc.terminator
746 }
747}
Razvan Lupusorua435e1f2024-03-07 18:06:47748
749// -----
750
751func.func @acc_combined() {
752 // expected-error @below {{expected 'loop'}}
753 acc.parallel combined() {
754 }
Razvan Lupusorua435e1f2024-03-07 18:06:47755 return
756}
757
758// -----
759
760func.func @acc_combined() {
761 // expected-error @below {{expected compute construct name}}
762 acc.loop combined(loop) {
763 }
Razvan Lupusorua435e1f2024-03-07 18:06:47764 return
765}
766
767// -----
768
769func.func @acc_combined() {
770 // expected-error @below {{expected 'loop'}}
771 acc.parallel combined(parallel loop) {
772 }
Razvan Lupusorua435e1f2024-03-07 18:06:47773 return
774}
775
776// -----
777
778func.func @acc_combined() {
779 // expected-error @below {{expected ')'}}
780 acc.loop combined(parallel loop) {
781 }
Razvan Lupusorue8f590e2025-04-30 20:48:51782 return
783}
Razvan Lupusorua435e1f2024-03-07 18:06:47784
Razvan Lupusorue8f590e2025-04-30 20:48:51785// -----
786
787func.func @acc_loop_container() {
788 %c0 = arith.constant 0 : index
789 %c10 = arith.constant 10 : index
790 %c1 = arith.constant 1 : index
791 // expected-error @below {{found sibling loops inside container-like acc.loop}}
792 acc.loop {
793 scf.for %arg4 = %c0 to %c10 step %c1 {
794 scf.yield
795 }
796 scf.for %arg5 = %c0 to %c10 step %c1 {
797 scf.yield
798 }
799 acc.yield
800 } attributes { collapse = [2], collapseDeviceType = [#acc.device_type<none>] }
801 return
802}
803
804// -----
805
806func.func @acc_loop_container() {
807 %c0 = arith.constant 0 : index
808 %c10 = arith.constant 10 : index
809 %c1 = arith.constant 1 : index
810 // expected-error @below {{failed to find enough loop-like operations inside container-like acc.loop}}
811 acc.loop {
812 scf.for %arg4 = %c0 to %c10 step %c1 {
813 scf.for %arg5 = %c0 to %c10 step %c1 {
814 scf.yield
815 }
816 scf.yield
817 }
818 acc.yield
819 } attributes { collapse = [3], collapseDeviceType = [#acc.device_type<none>] }
Razvan Lupusorua435e1f2024-03-07 18:06:47820 return
821}