1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
// RUN: mlir-opt %s | FileCheck %s
// CHECK-LABEL: @identity_token
func.func @identity_token(%arg0: !async.token) -> !async.token {
// CHECK: return %arg0 : !async.token
return %arg0 : !async.token
}
// CHECK-LABEL: @identity_value
func.func @identity_value(%arg0 : !async.value<f32>) -> !async.value<f32> {
// CHECK: return %arg0 : !async.value<f32>
return %arg0 : !async.value<f32>
}
// CHECK-LABEL: @empty_async_execute
func.func @empty_async_execute() -> !async.token {
// CHECK: async.execute
%token = async.execute {
async.yield
}
// CHECK: return %token : !async.token
return %token : !async.token
}
// CHECK-LABEL: @return_async_value
func.func @return_async_value() -> !async.value<f32> {
// CHECK: async.execute -> !async.value<f32>
%token, %bodyResults = async.execute -> !async.value<f32> {
%cst = arith.constant 1.000000e+00 : f32
async.yield %cst : f32
}
// CHECK: return %bodyResults : !async.value<f32>
return %bodyResults : !async.value<f32>
}
// CHECK-LABEL: @return_captured_value
func.func @return_captured_value() -> !async.token {
%cst = arith.constant 1.000000e+00 : f32
// CHECK: async.execute -> !async.value<f32>
%token, %results = async.execute -> !async.value<f32> {
async.yield %cst : f32
}
// CHECK: return %token : !async.token
return %token : !async.token
}
// CHECK-LABEL: @return_async_values
func.func @return_async_values() -> (!async.value<f32>, !async.value<f32>) {
%token, %bodyResults:2 = async.execute -> (!async.value<f32>, !async.value<f32>) {
%cst1 = arith.constant 1.000000e+00 : f32
%cst2 = arith.constant 2.000000e+00 : f32
async.yield %cst1, %cst2 : f32, f32
}
// CHECK: return %bodyResults#0, %bodyResults#1 : !async.value<f32>, !async.value<f32>
return %bodyResults#0, %bodyResults#1 : !async.value<f32>, !async.value<f32>
}
// CHECK-LABEL: @async_token_dependencies
func.func @async_token_dependencies(%arg0: !async.token) -> !async.token {
// CHECK: async.execute [%arg0]
%token = async.execute [%arg0] {
async.yield
}
// CHECK: return %token : !async.token
return %token : !async.token
}
// CHECK-LABEL: @async_value_operands
func.func @async_value_operands(%arg0: !async.value<f32>) -> !async.token {
// CHECK: async.execute (%arg0 as %arg1: !async.value<f32>) -> !async.value<f32>
%token, %results = async.execute (%arg0 as %arg1: !async.value<f32>) -> !async.value<f32> {
async.yield %arg1 : f32
}
// CHECK: return %token : !async.token
return %token : !async.token
}
// CHECK-LABEL: @async_token_and_value_operands
func.func @async_token_and_value_operands(%arg0: !async.token, %arg1: !async.value<f32>) -> !async.token {
// CHECK: async.execute [%arg0] (%arg1 as %arg2: !async.value<f32>) -> !async.value<f32>
%token, %results = async.execute [%arg0] (%arg1 as %arg2: !async.value<f32>) -> !async.value<f32> {
async.yield %arg2 : f32
}
// CHECK: return %token : !async.token
return %token : !async.token
}
// CHECK-LABEL: @empty_tokens_or_values_operands
func.func @empty_tokens_or_values_operands() {
// CHECK: async.execute {
%token0 = async.execute [] () -> () { async.yield }
// CHECK: async.execute {
%token1 = async.execute () -> () { async.yield }
// CHECK: async.execute {
%token2 = async.execute -> () { async.yield }
// CHECK: async.execute {
%token3 = async.execute () { async.yield }
// CHECK: async.execute {
%token4 = async.execute [] { async.yield }
return
}
// CHECK-LABEL: @await_token
func.func @await_token(%arg0: !async.token) {
// CHECK: async.await %arg0
async.await %arg0 : !async.token
return
}
// CHECK-LABEL: @await_value
func.func @await_value(%arg0: !async.value<f32>) -> f32 {
// CHECK: async.await %arg0
%0 = async.await %arg0 : !async.value<f32>
return %0 : f32
}
// CHECK-LABEL: @create_group_and_await_all
func.func @create_group_and_await_all(%arg0: !async.token,
%arg1: !async.value<f32>) -> index {
%c = arith.constant 2 : index
%0 = async.create_group %c : !async.group
// CHECK: async.add_to_group %arg0
// CHECK: async.add_to_group %arg1
%1 = async.add_to_group %arg0, %0 : !async.token
%2 = async.add_to_group %arg1, %0 : !async.value<f32>
async.await_all %0
%3 = arith.addi %1, %2 : index
return %3 : index
}
// CHECK-LABEL: @async_func_return_token
async.func @async_func_return_token() -> !async.token {
// CHECK: return
return
}
// CHECK-LABEL: @async_func_return_value
async.func @async_func_return_value() -> !async.value<i32> {
%0 = arith.constant 42 : i32
// CHECK: return %[[value:.*]] : i32
return %0 : i32
}
// CHECK-LABEL: @async_func_return_optional_token
async.func @async_func_return_optional_token() -> (!async.token, !async.value<i32>) {
%0 = arith.constant 42 : i32
// CHECK: return %[[value:.*]] : i32
return %0 : i32
}
// CHECK-LABEL: @async_call
func.func @async_call() {
// CHECK: async.call @async_func_return_token
// CHECK: async.call @async_func_return_value
// CHECK: async.call @async_func_return_optional_token
%0 = async.call @async_func_return_token() : () -> !async.token
%1 = async.call @async_func_return_value() : () -> !async.value<i32>
%2, %3 = async.call @async_func_return_optional_token() : () -> (!async.token, !async.value<i32>)
return
}
|