xref: /llvm-project/mlir/test/Dialect/SCF/transform-op-forall-to-parallel.mlir (revision 0b665c3dd206abb3deab4c3af9dfeb43000ab0c7)
1// RUN: mlir-opt %s --transform-interpreter --split-input-file --verify-diagnostics | FileCheck %s
2
3func.func private @callee(%i: index, %j: index)
4
5// CHECK-LABEL: @two_iters
6// CHECK-SAME: %[[UB1:.+]]: index, %[[UB2:.+]]: index
7func.func @two_iters(%ub1: index, %ub2: index) {
8  scf.forall (%i, %j) in (%ub1, %ub2) {
9    func.call @callee(%i, %j) : (index, index) -> ()
10  }
11  // CHECK: scf.parallel (%[[IV1:.+]], %[[IV2:.+]]) = (%{{.*}}, %{{.*}}) to (%[[UB1]], %[[UB2]])
12  // CHECK:   func.call @callee(%[[IV1]], %[[IV2]]) : (index, index) -> ()
13  // CHECK:   scf.reduce
14  return
15}
16
17module attributes {transform.with_named_sequence} {
18  transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {
19    %0 = transform.structured.match ops{["scf.forall"]} in %arg0 : (!transform.any_op) -> !transform.any_op
20    transform.loop.forall_to_parallel %0 : (!transform.any_op) -> (!transform.any_op)
21    transform.yield
22  }
23}
24
25// -----
26
27func.func private @callee(%i: index, %j: index)
28
29func.func @repeated(%ub1: index, %ub2: index) {
30  scf.forall (%i, %j) in (%ub1, %ub2) {
31    func.call @callee(%i, %j) : (index, index) -> ()
32  }
33  scf.forall (%i, %j) in (%ub1, %ub2) {
34    func.call @callee(%i, %j) : (index, index) -> ()
35  }
36  return
37}
38
39module attributes {transform.with_named_sequence} {
40  transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {
41    %0 = transform.structured.match ops{["scf.forall"]} in %arg0 : (!transform.any_op) -> !transform.any_op
42    // expected-error @below {{expected a single payload op}}
43    transform.loop.forall_to_parallel %0 : (!transform.any_op) -> (!transform.any_op)
44    transform.yield
45  }
46}
47
48// -----
49
50// expected-note @below {{payload op}}
51func.func private @callee(%i: index, %j: index)
52
53module attributes {transform.with_named_sequence} {
54  transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {
55    %0 = transform.structured.match ops{["func.func"]} in %arg0 : (!transform.any_op) -> !transform.any_op
56    // expected-error @below {{expected the payload to be scf.forall}}
57    transform.loop.forall_to_for %0 : (!transform.any_op) -> !transform.any_op
58    transform.yield
59  }
60}
61