Lines Matching refs:async

1 // RUN: mlir-opt %s -split-input-file -async-func-to-async-runtime             \
2 // RUN: -async-to-async-runtime | FileCheck %s --dump-input=always
6 %token = async.execute {
9 async.yield
11 async.await %token : !async.token
15 // Function outlined from the async.execute operation.
17 // CHECK-SAME: -> !async.token
20 // CHECK: %[[TOKEN:.*]] = async.runtime.create : !async.token
21 // CHECK: %[[ID:.*]] = async.coro.id
22 // CHECK: %[[HDL:.*]] = async.coro.begin
24 // Pass a suspended coroutine to the async runtime.
25 // CHECK: %[[SAVED:.*]] = async.coro.save %[[HDL]]
26 // CHECK: async.runtime.resume %[[HDL]]
27 // CHECK: async.coro.suspend %[[SAVED]]
33 // CHECK: async.runtime.set_available %[[TOKEN]]
38 // CHECK: async.coro.free %[[ID]], %[[HDL]]
42 // CHECK: async.coro.free %[[ID]], %[[HDL]]
46 // CHECK: async.coro.end %[[HDL]]
54 %token0 = async.execute {
57 %token1 = async.execute {
60 async.yield
62 async.await %token1 : !async.token
65 async.yield
67 // CHECK: async.runtime.await %[[TOKEN]]
68 // CHECK: %[[IS_ERROR:.*]] = async.runtime.is_error %[[TOKEN]]
73 async.await %token0 : !async.token
77 // Function outlined from the inner async.execute operation.
79 // CHECK-SAME: -> !async.token
81 // CHECK: %[[TOKEN:.*]] = async.runtime.create : !async.token
82 // CHECK: %[[ID:.*]] = async.coro.id
83 // CHECK: %[[HDL:.*]] = async.coro.begin
85 // CHECK: async.runtime.resume %[[HDL]]
86 // CHECK: async.coro.suspend
91 // CHECK: async.runtime.set_available %[[TOKEN]]
97 // Function outlined from the outer async.execute operation.
99 // CHECK-SAME: -> !async.token
101 // CHECK: %[[TOKEN:.*]] = async.runtime.create : !async.token
102 // CHECK: %[[ID:.*]] = async.coro.id
103 // CHECK: %[[HDL:.*]] = async.coro.begin
106 // CHECK: async.runtime.resume %[[HDL]]
107 // CHECK: async.coro.suspend
113 // CHECK: %[[SAVED:.*]] = async.coro.save %[[HDL]]
114 // CHECK: async.runtime.await_and_resume %[[INNER_TOKEN]], %[[HDL]]
115 // CHECK: async.coro.suspend %[[SAVED]]
120 // CHECK: %[[ERR:.*]] = async.runtime.is_error %[[INNER_TOKEN]]
126 // CHECK: async.runtime.set_available %[[TOKEN]]
139 %token = async.execute {
142 async.yield
145 %token_0 = async.execute [%token] {
148 async.yield
153 // Function outlined from the first async.execute operation.
155 // CHECK-SAME: -> !async.token
156 // CHECK: %[[TOKEN:.*]] = async.runtime.create : !async.token
157 // CHECK: return %[[TOKEN]] : !async.token
159 // Function outlined from the second async.execute operation with dependency.
161 // CHECK-SAME: %[[ARG0:.*]]: !async.token
164 // CHECK-SAME: -> !async.token
165 // CHECK: %[[TOKEN:.*]] = async.runtime.create : !async.token
166 // CHECK: %[[HDL:.*]] = async.coro.begin
169 // CHECK: async.runtime.resume %[[HDL]]
170 // CHECK: async.coro.suspend
175 // CHECK: %[[SAVED:.*]] = async.coro.save %[[HDL]]
176 // CHECK: async.runtime.await_and_resume %[[ARG0]], %[[HDL]]
177 // CHECK: async.coro.suspend %[[SAVED]]
182 // CHECK: %[[ERR:.*]] = async.runtime.is_error %[[ARG0]]
188 // CHECK: async.runtime.set_available %[[TOKEN]]
199 // CHECK: %[[GROUP:.*]] = async.runtime.create_group %[[C]] : !async.group
200 %0 = async.create_group %c : !async.group
203 %token = async.execute { async.yield }
204 // CHECK: async.runtime.add_to_group %[[TOKEN]], %[[GROUP]]
205 async.add_to_group %token, %0 : !async.token
208 async.execute {
209 async.await_all %0
210 async.yield
213 // CHECK: async.runtime.await %[[GROUP]] : !async.group
214 async.await_all %0
218 // Function outlined from the second async.execute operation.
220 // CHECK-SAME: (%[[ARG:.*]]: !async.group) -> !async.token
222 // CHECK: %[[TOKEN:.*]] = async.runtime.create : !async.token
223 // CHECK: %[[HDL:.*]] = async.coro.begin
226 // CHECK: async.runtime.resume %[[HDL]]
227 // CHECK: async.coro.suspend
232 // CHECK: async.runtime.await_and_resume %[[ARG]], %[[HDL]]
233 // CHECK: async.coro.suspend
238 // CHECK: %[[ERR:.*]] = async.runtime.is_error %[[ARG]]
243 // CHECK: async.runtime.set_available %[[TOKEN]]
253 %token, %result = async.execute -> !async.value<f32> {
255 async.yield %c0 : f32
258 // CHECK: async.runtime.await %[[RET]]#1 : !async.value<f32>
259 // CHECK: %[[VALUE:.*]] = async.runtime.load %[[RET]]#1 : <f32>
260 %0 = async.await %result : !async.value<f32>
266 // Function outlined from the async.execute operation.
268 // CHECK: %[[TOKEN:.*]] = async.runtime.create : !async.token
269 // CHECK: %[[VALUE:.*]] = async.runtime.create : !async.value<f32>
270 // CHECK: %[[HDL:.*]] = async.coro.begin
273 // CHECK: async.runtime.resume %[[HDL]]
274 // CHECK: async.coro.suspend
280 // CHECK: async.runtime.store %cst, %[[VALUE]]
281 // CHECK: async.runtime.set_available %[[VALUE]]
282 // CHECK: async.runtime.set_available %[[TOKEN]]
292 %token, %result = async.execute -> !async.value<f32> {
294 async.yield %c0 : f32
298 %token0 = async.execute(%result as %value: !async.value<f32>) {
300 async.yield
303 // CHECK: async.runtime.await %[[TOKEN]] : !async.token
304 async.await %token0 : !async.token
309 // Function outlined from the first async.execute operation.
312 // Function outlined from the second async.execute operation.
314 // CHECK-SAME: (%[[ARG:.*]]: !async.value<f32>) -> !async.token
316 // CHECK: %[[TOKEN:.*]] = async.runtime.create : !async.token
317 // CHECK: %[[HDL:.*]] = async.coro.begin
320 // CHECK: async.runtime.resume %[[HDL]]
321 // CHECK: async.coro.suspend
324 // Suspend coroutine second time waiting for the async operand.
326 // CHECK: async.runtime.await_and_resume %[[ARG]], %[[HDL]]
327 // CHECK: async.coro.suspend
332 // CHECK: %[[ERR:.*]] = async.runtime.is_error %[[ARG]]
335 // // Load from the async.value argument after error checking.
337 // CHECK: %[[LOADED:.*]] = async.runtime.load %[[ARG]] : <f32
339 // CHECK: async.runtime.set_available %[[TOKEN]]
348 %token = async.execute {
350 async.yield
352 async.await %token : !async.token
356 // Function outlined from the async.execute operation.
359 // CHECK-SAME: -> !async.token
362 // CHECK: %[[TOKEN:.*]] = async.runtime.create : !async.token
363 // CHECK: %[[ID:.*]] = async.coro.id
364 // CHECK: %[[HDL:.*]] = async.coro.begin
367 // CHECK: async.coro.suspend
376 // CHECK: async.runtime.set_available %[[TOKEN]]
381 // CHECK: async.runtime.set_error %[[TOKEN]]
386 // CHECK: async.coro.free %[[ID]], %[[HDL]]
390 // CHECK: async.coro.free %[[ID]], %[[HDL]]
394 // CHECK: async.coro.end %[[HDL]]
398 // Structured control flow operations with async operations in the body must be
403 %token0 = async.execute { async.yield }
404 %token1 = async.execute {
406 async.await %token0 : !async.token
408 async.await %token0 : !async.token
410 async.yield
415 // Function outlined from the first async.execute operation.
417 // CHECK-SAME: -> !async.token
419 // Function outlined from the second async.execute operation.
421 // CHECK: %[[TOKEN:.*]]: !async.token
423 // CHECK-SAME: -> !async.token
430 // Constants captured by the async.execute region should be cloned into the
431 // outline async execute function.
436 %token = async.execute {
438 async.yield
440 async.await %token : !async.token
444 // Function outlined from the async.execute operation.
448 // CHECK-SAME: ) -> !async.token
456 async.func @async_func_await(%arg0: f32, %arg1: !async.value<f32>)
457 -> !async.token {
458 %0 = async.await %arg1 : !async.value<f32>
462 // CHECK: %[[TOKEN:.*]] = async.runtime.create : !async.token
463 // CHECK: %[[ID:.*]] = async.coro.id
464 // CHECK: %[[HDL:.*]] = async.coro.begin
468 // CHECK: %[[SAVED:.*]] = async.coro.save %[[HDL]]
469 // CHECK: async.runtime.await_and_resume %[[arg1:.*]], %[[HDL]] :
470 // CHECK-SAME: !async.value<f32>
471 // CHECK: async.coro.suspend %[[SAVED]]
475 // Async execute inside async func
478 async.func @execute_in_async_func(%arg0: f32, %arg1: memref<1xf32>)
479 -> !async.token {
480 %token = async.execute {
483 async.yield
485 async.await %token : !async.token
488 // Call outlind async execute Function
492 // CHECK-SAME: ) : (f32, memref<1xf32>) -> !async.token
494 // Function outlined from the async.execute operation.
498 // CHECK-SAME: ) -> !async.token