xref: /llvm-project/mlir/test/Dialect/Async/async-parallel-for-seq-dispatch.mlir (revision 5e7dea225be10d3ba0d01e87fb36e80c6764bd83)
1// RUN: mlir-opt %s -split-input-file -async-parallel-for=async-dispatch=false  \
2// RUN: | FileCheck %s --dump-input=always
3
4// The structure of @parallel_compute_fn checked in the async dispatch test.
5// Here we only check the structure of the sequential dispatch loop.
6
7// CHECK-LABEL: @loop_1d
8func.func @loop_1d(%arg0: index, %arg1: index, %arg2: index, %arg3: memref<?xf32>) {
9  // CHECK: %[[GROUP:.*]] = async.create_group
10  // CHECK: scf.for
11  // CHECK:   %[[TOKEN:.*]] = async.execute
12  // CHECK:     call @parallel_compute_fn
13  // CHECK:     async.yield
14  // CHECK:   async.add_to_group %[[TOKEN]], %[[GROUP]]
15  // CHECK: call @parallel_compute_fn
16  // CHECK: async.await_all %[[GROUP]]
17  scf.parallel (%i) = (%arg0) to (%arg1) step (%arg2) {
18    %one = arith.constant 1.0 : f32
19    memref.store %one, %arg3[%i] : memref<?xf32>
20  }
21  return
22}
23
24// CHECK-LABEL: func private @parallel_compute_fn
25// CHECK:       scf.for
26// CHECK:         memref.store
27
28// -----
29
30// CHECK-LABEL: @loop_2d
31func.func @loop_2d(%arg0: index, %arg1: index, %arg2: index, // lb, ub, step
32              %arg3: index, %arg4: index, %arg5: index, // lb, ub, step
33              %arg6: memref<?x?xf32>) {
34  // CHECK: %[[GROUP:.*]] = async.create_group
35  // CHECK: scf.for
36  // CHECK:   %[[TOKEN:.*]] = async.execute
37  // CHECK:     call @parallel_compute_fn
38  // CHECK:     async.yield
39  // CHECK:   async.add_to_group %[[TOKEN]], %[[GROUP]]
40  // CHECK: call @parallel_compute_fn
41  // CHECK: async.await_all %[[GROUP]]
42  scf.parallel (%i0, %i1) = (%arg0, %arg3) to (%arg1, %arg4)
43                            step (%arg2, %arg5) {
44    %one = arith.constant 1.0 : f32
45    memref.store %one, %arg6[%i0, %i1] : memref<?x?xf32>
46  }
47  return
48}
49
50// CHECK-LABEL: func private @parallel_compute_fn
51// CHECK:       scf.for
52// CHECK:         scf.for
53// CHECK:           memref.store
54