921 lines · plain
1// RUN: mlir-opt -split-input-file -verify-diagnostics %s2 3%1 = arith.constant 1 : i324%2 = arith.constant 10 : i325// expected-error@+1 {{gang, worker or vector cannot appear with seq}}6acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {7 "test.openacc_dummy_op"() : () -> ()8 acc.yield9} attributes {seq = [#acc.device_type<none>], gang = [#acc.device_type<none>]}10 11// -----12 13%1 = arith.constant 1 : i3214%2 = arith.constant 10 : i3215// expected-error@+1 {{gang, worker or vector cannot appear with seq}}16acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {17 "test.openacc_dummy_op"() : () -> ()18 acc.yield19} attributes {seq = [#acc.device_type<none>], worker = [#acc.device_type<none>]}20 21// -----22 23%1 = arith.constant 1 : i3224%2 = arith.constant 10 : i3225// expected-error@+1 {{gang, worker or vector cannot appear with seq}}26acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {27 "test.openacc_dummy_op"() : () -> ()28 acc.yield29} attributes {seq = [#acc.device_type<none>], vector = [#acc.device_type<none>]}30 31// -----32 33%1 = arith.constant 1 : i3234%2 = arith.constant 10 : i3235// expected-error@+1 {{gang, worker or vector cannot appear with seq}}36acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {37 "test.openacc_dummy_op"() : () -> ()38 acc.yield39} attributes {seq = [#acc.device_type<none>], worker = [#acc.device_type<none>], gang = [#acc.device_type<none>]}40 41// -----42 43%1 = arith.constant 1 : i3244%2 = arith.constant 10 : i3245// expected-error@+1 {{gang, worker or vector cannot appear with seq}}46acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {47 "test.openacc_dummy_op"() : () -> ()48 acc.yield49} attributes {seq = [#acc.device_type<none>], vector = [#acc.device_type<none>], gang = [#acc.device_type<none>]}50 51// -----52 53%1 = arith.constant 1 : i3254%2 = arith.constant 10 : i3255// expected-error@+1 {{gang, worker or vector cannot appear with seq}}56acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {57 "test.openacc_dummy_op"() : () -> ()58 acc.yield59} attributes {seq = [#acc.device_type<none>], vector = [#acc.device_type<none>], worker = [#acc.device_type<none>]}60 61// -----62 63%1 = arith.constant 1 : i3264%2 = arith.constant 10 : i3265// expected-error@+1 {{gang, worker or vector cannot appear with seq}}66acc.loop {67 "test.openacc_dummy_op"() : () -> ()68 acc.yield69} attributes {seq = [#acc.device_type<none>], vector = [#acc.device_type<none>], worker = [#acc.device_type<none>], gang = [#acc.device_type<none>]}70 71// -----72 73// expected-error@+1 {{expected non-empty body.}}74acc.loop {75} attributes {independent = [#acc.device_type<none>]}76 77// -----78 79// expected-error@+1 {{'acc.loop' op duplicate device_type found in gang attribute}}80acc.loop {81 acc.yield82} 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.yield89} 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.yield96} attributes {vector = [#acc.device_type<none>, #acc.device_type<none>]}97 98// -----99 100%1 = arith.constant 1 : i32101%2 = arith.constant 10 : i32102// expected-error@+1 {{only one of auto, independent, seq can be present at the same time}}103acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {104 acc.yield105} attributes {auto_ = [#acc.device_type<none>], seq = [#acc.device_type<none>], inclusiveUpperbound = array<i1: true>}106 107// -----108 109// expected-error@+1 {{at least one operand or the default attribute must appear on the data operation}}110acc.data {111 acc.yield112}113 114// -----115 116%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.yield120}121 122// -----123 124// expected-error@+1 {{at least one value must be present in dataOperands}}125acc.update126 127// -----128 129%cst = arith.constant 1 : index130%value = memref.alloc() : memref<f32>131%0 = acc.update_device varPtr(%value : memref<f32>) -> memref<f32>132// expected-error@+1 {{asyncOnly attribute cannot appear with asyncOperand}}133acc.update async(%cst: index) dataOperands(%0 : memref<f32>) attributes {asyncOnly = [#acc.device_type<none>]}134 135// -----136 137%cst = arith.constant 1 : index138%value = memref.alloc() : memref<f32>139%0 = acc.update_device varPtr(%value : memref<f32>) -> memref<f32>140// expected-error@+1 {{wait attribute cannot appear with waitOperands}}141acc.update wait({%cst: index}) dataOperands(%0: memref<f32>) attributes {waitOnly = [#acc.device_type<none>]}142 143// -----144 145%cst = arith.constant 1 : index146// expected-error@+1 {{wait_devnum cannot appear without waitOperands}}147acc.wait wait_devnum(%cst: index)148 149// -----150 151%cst = arith.constant 1 : index152// expected-error@+1 {{async attribute cannot appear with asyncOperand}}153acc.wait async(%cst: index) attributes {async}154 155// -----156 157acc.parallel {158// expected-error@+1 {{'acc.init' op cannot be nested in a compute operation}}159 acc.init160 acc.yield161}162 163// -----164 165%1 = arith.constant 1 : i32166%2 = arith.constant 10 : i32167acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32){168// expected-error@+1 {{'acc.init' op cannot be nested in a compute operation}}169 acc.init170 acc.yield171} attributes {inclusiveUpperbound = array<i1: true>, independent = [#acc.device_type<none>]}172 173// -----174 175acc.parallel {176// expected-error@+1 {{'acc.shutdown' op cannot be nested in a compute operation}}177 acc.shutdown178 acc.yield179}180 181// -----182 183%1 = arith.constant 1 : i32184%2 = arith.constant 10 : i32185acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {186// expected-error@+1 {{'acc.shutdown' op cannot be nested in a compute operation}}187 acc.shutdown188 acc.yield189} attributes {inclusiveUpperbound = array<i1: true>, independent = [#acc.device_type<none>]}190 191// -----192 193%1 = arith.constant 1 : i32194%2 = arith.constant 10 : i32195acc.loop control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {196 "test.openacc_dummy_op"() ({197 // expected-error@+1 {{'acc.shutdown' op cannot be nested in a compute operation}}198 acc.shutdown199 }) : () -> ()200 acc.yield201} attributes {inclusiveUpperbound = array<i1: true>, independent = [#acc.device_type<none>]}202 203// -----204 205// expected-error@+1 {{at least one operand must be present in dataOperands on the exit data operation}}206acc.exit_data attributes {async}207 208// -----209 210%cst = arith.constant 1 : index211%value = memref.alloc() : memref<f32>212%0 = acc.getdeviceptr varPtr(%value : memref<f32>) -> memref<f32>213// expected-error@+1 {{async attribute cannot appear with asyncOperand}}214acc.exit_data async(%cst: index) dataOperands(%0 : memref<f32>) attributes {async}215acc.delete accPtr(%0 : memref<f32>)216 217// -----218 219%cst = arith.constant 1 : index220%value = memref.alloc() : memref<f32>221%0 = acc.getdeviceptr varPtr(%value : memref<f32>) -> memref<f32>222// expected-error@+1 {{wait_devnum cannot appear without waitOperands}}223acc.exit_data wait_devnum(%cst: index) dataOperands(%0 : memref<f32>)224acc.delete accPtr(%0 : memref<f32>)225 226// -----227 228// expected-error@+1 {{at least one operand must be present in dataOperands on the enter data operation}}229acc.enter_data attributes {async}230 231// -----232 233%cst = arith.constant 1 : index234%value = memref.alloc() : memref<f32>235%0 = acc.create varPtr(%value : memref<f32>) -> memref<f32>236// expected-error@+1 {{async attribute cannot appear with asyncOperand}}237acc.enter_data async(%cst: index) dataOperands(%0 : memref<f32>) attributes {async}238 239// -----240 241%cst = arith.constant 1 : index242%value = memref.alloc() : memref<f32>243%0 = acc.create varPtr(%value : memref<f32>) -> memref<f32>244// expected-error@+1 {{wait attribute cannot appear with waitOperands}}245acc.enter_data wait(%cst: index) dataOperands(%0 : memref<f32>) attributes {wait}246 247// -----248 249%cst = arith.constant 1 : index250%value = memref.alloc() : memref<f32>251%0 = acc.create varPtr(%value : memref<f32>) -> memref<f32>252// expected-error@+1 {{wait_devnum cannot appear without waitOperands}}253acc.enter_data wait_devnum(%cst: index) dataOperands(%0 : memref<f32>)254 255// -----256 257%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 263%0 = arith.constant 1.0 : f32264// expected-error@+1 {{operand #0 must be integer or index, but got 'f32'}}265%1 = acc.bounds lowerbound(%0 : f32)266 267// -----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>)272 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.yield279}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.yield287}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.yield295}296 297// -----298 299// expected-error@+1 {{expects non-empty init region}}300acc.private.recipe @privatization_i32 : !llvm.ptr init {301}302 303// -----304 305// expected-error@+1 {{expects init region first argument of the privatization type}}306acc.private.recipe @privatization_i32 : !llvm.ptr init {307^bb0(%arg0 : i32):308 %c1 = arith.constant 1 : i32309 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr310 acc.yield %0 : !llvm.ptr311}312 313// -----314 315// expected-error@+1 {{expects destroy region first argument of the privatization type}}316acc.private.recipe @privatization_i32 : !llvm.ptr init {317^bb0(%arg0 : !llvm.ptr):318 %c1 = arith.constant 1 : i32319 %c0 = arith.constant 0 : i32320 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr321 llvm.store %c0, %0 : i32, !llvm.ptr322 acc.yield %0 : !llvm.ptr323} destroy {324^bb0(%arg0 : f32):325 "test.openacc_dummy_op"(%arg0) : (f32) -> ()326}327 328// -----329 330// expected-error@+1 {{expects non-empty init region}}331acc.firstprivate.recipe @privatization_i32 : !llvm.ptr init {332} copy {}333 334// -----335 336// expected-error@+1 {{expects init region first argument of the privatization type}}337acc.firstprivate.recipe @privatization_i32 : !llvm.ptr init {338^bb0(%arg0 : i32):339 %c1 = arith.constant 1 : i32340 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr341 acc.yield %0 : !llvm.ptr342} copy {}343 344// -----345 346// expected-error@+1 {{expects non-empty copy region}}347acc.firstprivate.recipe @privatization_i32 : !llvm.ptr init {348^bb0(%arg0 : !llvm.ptr):349 %c1 = arith.constant 1 : i32350 %c0 = arith.constant 0 : i32351 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr352 llvm.store %c0, %0 : i32, !llvm.ptr353 acc.yield %0 : !llvm.ptr354} copy {355}356 357// -----358 359// expected-error@+1 {{expects copy region with two arguments of the privatization type}}360acc.firstprivate.recipe @privatization_i32 : !llvm.ptr init {361^bb0(%arg0 : !llvm.ptr):362 %c1 = arith.constant 1 : i32363 %c0 = arith.constant 0 : i32364 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr365 llvm.store %c0, %0 : i32, !llvm.ptr366 acc.yield %0 : !llvm.ptr367} 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}}375acc.firstprivate.recipe @privatization_i32 : !llvm.ptr init {376^bb0(%arg0 : !llvm.ptr):377 %c1 = arith.constant 1 : i32378 %c0 = arith.constant 0 : i32379 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr380 llvm.store %c0, %0 : i32, !llvm.ptr381 acc.yield %0 : !llvm.ptr382} copy {383^bb0(%arg0 : f32, %arg1 : i32):384 "test.openacc_dummy_op"(%arg0) : (f32) -> ()385}386 387// -----388 389// expected-error@+1 {{expects destroy region first argument of the privatization type}}390acc.firstprivate.recipe @privatization_i32 : i32 init {391^bb0(%arg0 : i32):392 %0 = arith.constant 1 : i32393 acc.yield %0 : i32394} copy {395^bb0(%arg0 : i32, %arg1 : !llvm.ptr):396 llvm.store %arg0, %arg1 : i32, !llvm.ptr397 acc.yield398} destroy {399^bb0(%arg0 : f32):400 acc.yield401}402 403// -----404 405%1 = arith.constant 1 : i32406%2 = arith.constant 10 : i32407// expected-error@+1 {{expected ')'}}408acc.loop gang({static=%i64Value: i64, num=%i64Value: i64} control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {409 "test.openacc_dummy_op"() : () -> ()410 acc.yield411}412 413// -----414 415// expected-error@+1 {{expects non-empty init region}}416acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {417} combiner {}418 419// -----420 421// expected-error@+1 {{expects init region first argument of the reduction type}}422acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {423^bb0(%0: i32):424 %1 = arith.constant 0 : i64425 acc.yield %1 : i64426} combiner {}427 428// -----429 430// 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 : i64434 acc.yield %1 : i64435} combiner {}436 437// -----438 439// expected-error@+1 {{expects combiner region with the first two arguments of the reduction type}}440acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {441^bb0(%0: i64):442 %1 = arith.constant 0 : i64443 acc.yield %1 : i64444} combiner {445^bb0(%0: i32):446 acc.yield %0 : i32447}448 449// -----450 451// expected-error@+1 {{expects combiner region with the first two arguments of the reduction type}}452acc.reduction.recipe @reduction_i64 : i64 reduction_operator<add> init {453^bb0(%0: i64):454 %1 = arith.constant 0 : i64455 acc.yield %1 : i64456} combiner {457^bb0(%0: i64):458 acc.yield %0 : i64459}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 : i64467 acc.yield %1 : i64468} combiner {469^bb0(%0: i64, %1: i64):470 %2 = arith.constant 0 : i32471 acc.yield %2 : i32472}473 474// -----475 476%1 = arith.constant 1 : i32477%2 = arith.constant 10 : i32478// expected-error@+1 {{new value expected after comma}}479acc.loop gang({static=%i64Value: i64, ) control(%iv : i32) = (%1 : i32) to (%2 : i32) step (%1 : i32) {480 "test.openacc_dummy_op"() : () -> ()481 acc.yield482}483 484// -----485 486%i1 = arith.constant 1 : i32487%i2 = arith.constant 10 : i32488// expected-error@+1 {{unstructured acc.loop must not have induction variables}}489acc.loop control(%iv : i32) = (%i1 : i32) to (%i2 : i32) step (%i1 : i32) {490 acc.yield491} attributes {independent = [#acc.device_type<none>], unstructured}492 493// -----494 495// expected-error@+1 {{expect at least one of num, dim or static values}}496acc.loop gang({}) {497 "test.openacc_dummy_op"() : () -> ()498 acc.yield499}500 501// -----502 503%i64value = arith.constant 1 : i64504// 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}) {506}507 508// -----509 510%0 = "arith.constant"() <{value = 1 : i64}> : () -> i64511// 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 517%i64value = arith.constant 1 : i64518acc.parallel {519// expected-error@+1 {{'acc.set' op cannot be nested in a compute operation}}520 acc.set attributes {device_type = #acc.device_type<nvidia>}521 acc.yield522}523 524// -----525 526// expected-error@+1 {{'acc.set' op at least one default_async, device_num, or device_type operand must appear}}527acc.set528 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>>, i32534 return535}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 : f32544 acc.yield %newval : f32545 }546 return547}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 : i32557 acc.terminator558 }559 return560}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 : i32568 acc.yield %newval : i32569 }570 return571}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 : i32580 acc.yield %newval, %expr : i32, i32581 }582 return583}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 : i32592 acc.yield %y: f32593 }594 return595}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 : i32604 acc.yield %newval : i32605 }606 return607}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 {614 acc.atomic.read %v = %x : memref<i32>, memref<i32>, i32615 acc.terminator616 }617 return618}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}}625 acc.atomic.read %v = %x : memref<i32>, memref<i32>, i32626 acc.atomic.read %v = %x : memref<i32>, memref<i32>, i32627 acc.terminator628 }629 return630}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 : i32640 acc.yield %newval : i32641 }642 acc.atomic.update %x : memref<i32> {643 ^bb0(%xval: i32):644 %newval = llvm.add %xval, %expr : i32645 acc.yield %newval : i32646 }647 acc.terminator648 }649 return650}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>, i32658 acc.atomic.write %x = %expr : memref<i32>, i32659 acc.terminator660 }661 return662}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>, i32670 acc.atomic.update %x : memref<i32> {671 ^bb0(%xval: i32):672 %newval = llvm.add %xval, %expr : i32673 acc.yield %newval : i32674 }675 acc.terminator676 }677 return678}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 : i32688 acc.yield %newval : i32689 }690 acc.atomic.write %x = %expr : memref<i32>, i32691 acc.terminator692 }693 return694}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>, i32702 acc.atomic.read %v = %x : memref<i32>, memref<i32>, i32703 acc.terminator704 }705 return706}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 : i32716 acc.yield %newval : i32717 }718 acc.atomic.read %v = %y : memref<i32>, memref<i32>, i32719 acc.terminator720 }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}}728 acc.atomic.read %v = %y : memref<i32>, memref<i32>, i32729 acc.atomic.update %x : memref<i32> {730 ^bb0(%xval: i32):731 %newval = llvm.add %xval, %expr : i32732 acc.yield %newval : i32733 }734 acc.terminator735 }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}}743 acc.atomic.read %v = %x : memref<i32>, memref<i32>, i32744 acc.atomic.write %y = %expr : memref<i32>, i32745 acc.terminator746 }747}748 749// -----750 751func.func @acc_combined() {752 // expected-error @below {{expected 'loop'}}753 acc.parallel combined() {754 }755 return756}757 758// -----759 760func.func @acc_combined() {761 // expected-error @below {{expected compute construct name}}762 acc.loop combined(loop) {763 }764 return765}766 767// -----768 769func.func @acc_combined() {770 // expected-error @below {{expected 'loop'}}771 acc.parallel combined(parallel loop) {772 }773 return774}775 776// -----777 778func.func @acc_combined() {779 // expected-error @below {{expected ')'}}780 acc.loop combined(parallel loop) {781 }782 return783}784 785// -----786 787func.func @acc_loop_container() {788 %c0 = arith.constant 0 : index789 %c10 = arith.constant 10 : index790 %c1 = arith.constant 1 : index791 // 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.yield795 }796 scf.for %arg5 = %c0 to %c10 step %c1 {797 scf.yield798 }799 acc.yield800 } attributes { collapse = [2], collapseDeviceType = [#acc.device_type<none>], independent = [#acc.device_type<none>]}801 return802}803 804// -----805 806func.func @acc_loop_container() {807 %c0 = arith.constant 0 : index808 %c10 = arith.constant 10 : index809 %c1 = arith.constant 1 : index810 // 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.yield815 }816 scf.yield817 }818 acc.yield819 } attributes { collapse = [3], collapseDeviceType = [#acc.device_type<none>], independent = [#acc.device_type<none>]}820 return821}822 823// -----824 825%value = memref.alloc() : memref<f32>826// expected-error @below {{no data clause modifiers are allowed}}827%0 = acc.private varPtr(%value : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier zero>}828 829// -----830 831%value = memref.alloc() : memref<f32>832// expected-error @below {{invalid data clause modifiers: readonly}}833%0 = acc.create varPtr(%value : memref<f32>) -> memref<f32> {modifiers = #acc<data_clause_modifier readonly,zero,capture,always>}834 835// -----836 837func.func @fct1(%0 : !llvm.ptr) -> () {838 // expected-error @below {{expected symbol reference @privatization_i32 to point to a private declaration}}839 %priv = acc.private varPtr(%0 : !llvm.ptr) varType(i32) recipe(@privatization_i32) -> !llvm.ptr840 return841}842 843// -----844 845acc.private.recipe @privatization_i32 : !llvm.ptr init {846^bb0(%arg0: !llvm.ptr):847 %c1 = arith.constant 1 : i32848 %c0 = arith.constant 0 : i32849 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr850 llvm.store %c0, %0 : i32, !llvm.ptr851 acc.yield %0 : !llvm.ptr852}853 854func.func @fct1(%0 : !llvm.ptr) -> () {855 %priv = acc.private varPtr(%0 : !llvm.ptr) varType(i32) recipe(@privatization_i32) -> !llvm.ptr856 // expected-error @below {{expected firstprivate as defining op}}857 acc.serial firstprivate(%priv : !llvm.ptr) {858 }859 return860}861 862// -----863 864acc.private.recipe @privatization_i32 : !llvm.ptr init {865^bb0(%arg0: !llvm.ptr):866 %c1 = arith.constant 1 : i32867 %c0 = arith.constant 0 : i32868 %0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr869 llvm.store %c0, %0 : i32, !llvm.ptr870 acc.yield %0 : !llvm.ptr871}872 873func.func @fct1(%0 : !llvm.ptr) -> () {874 %priv = acc.private varPtr(%0 : !llvm.ptr) varType(i32) recipe(@privatization_i32) -> !llvm.ptr875 // expected-error @below {{op private operand appears more than once}}876 acc.serial private(%priv, %priv : !llvm.ptr, !llvm.ptr) {877 }878 return879}880 881// -----882 883func.func @fct1(%0 : !llvm.ptr) -> () {884 // expected-error @below {{op recipe expected for private}}885 %priv = acc.private varPtr(%0 : !llvm.ptr) varType(i32) -> !llvm.ptr886 return887}888 889// -----890 891func.func @fct1(%0 : !llvm.ptr) -> () {892 // expected-error @below {{op recipe expected for firstprivate}}893 %priv = acc.firstprivate varPtr(%0 : !llvm.ptr) varType(i32) -> !llvm.ptr894 return895}896 897// -----898 899func.func @fct1(%0 : !llvm.ptr) -> () {900 // expected-error @below {{op recipe expected for reduction}}901 %priv = acc.reduction varPtr(%0 : !llvm.ptr) varType(i32) -> !llvm.ptr902 return903}904 905// -----906 907func.func @verify_declare_enter(%arg0 : memref<i32>) {908// expected-error @below {{expect valid declare data entry operation or acc.getdeviceptr as defining op}}909 %0 = acc.declare_enter dataOperands(%arg0 : memref<i32>)910 acc.declare_exit token(%0) dataOperands(%arg0 : memref<i32>)911 return912}913 914func.func @verify_data(%arg0 : memref<i32>) {915// expected-error @below {{expect data entry/exit operation or acc.getdeviceptr as defining op}}916 acc.data dataOperands(%arg0 : memref<i32>) {917 acc.terminator918 }919 return920}921