1 // RUN: mlir-opt %s -pass-pipeline="builtin.module(async-to-async-runtime,func.func(async-runtime-ref-counting,async-runtime-ref-counting-opt),convert-async-to-llvm,func.func(convert-linalg-to-loops,convert-scf-to-cf),convert-vector-to-llvm,func.func(convert-arith-to-llvm),convert-func-to-llvm,reconcile-unrealized-casts)" \
2 // RUN: | mlir-cpu-runner \
3 // RUN: -e main -entry-point-result=void -O0 \
4 // RUN: -shared-libs=%mlir_c_runner_utils \
5 // RUN: -shared-libs=%mlir_runner_utils \
6 // RUN: -shared-libs=%mlir_async_runtime \
7 // RUN: | FileCheck %s --dump-input=always
9 // FIXME: https://github.com/llvm/llvm-project/issues/57231
10 // UNSUPPORTED: hwasan
11 // FIXME: Windows does not have aligned_alloc
12 // UNSUPPORTED: system-windows
15 %false = arith.constant 0 : i1
17 // ------------------------------------------------------------------------ //
18 // Check that simple async region completes without errors.
19 // ------------------------------------------------------------------------ //
20 %token0 = async.execute {
23 async.runtime.await %token0 : !async.token
26 %err0 = async.runtime.is_error %token0 : !async.token
27 vector.print %err0 : i1
29 // ------------------------------------------------------------------------ //
30 // Check that assertion in the async region converted to async error.
31 // ------------------------------------------------------------------------ //
32 %token1 = async.execute {
33 cf.assert %false, "error"
36 async.runtime.await %token1 : !async.token
39 %err1 = async.runtime.is_error %token1 : !async.token
40 vector.print %err1 : i1
42 // ------------------------------------------------------------------------ //
43 // Check error propagation from the nested region.
44 // ------------------------------------------------------------------------ //
45 %token2 = async.execute {
46 %token = async.execute {
47 cf.assert %false, "error"
50 async.await %token : !async.token
53 async.runtime.await %token2 : !async.token
56 %err2 = async.runtime.is_error %token2 : !async.token
57 vector.print %err2 : i1
59 // ------------------------------------------------------------------------ //
60 // Check error propagation from the nested region with async values.
61 // ------------------------------------------------------------------------ //
62 %token3, %value3 = async.execute -> !async.value<f32> {
63 %token, %value = async.execute -> !async.value<f32> {
64 cf.assert %false, "error"
65 %0 = arith.constant 123.45 : f32
68 %ret = async.await %value : !async.value<f32>
69 async.yield %ret : f32
71 async.runtime.await %token3 : !async.token
72 async.runtime.await %value3 : !async.value<f32>
76 %err3_0 = async.runtime.is_error %token3 : !async.token
77 %err3_1 = async.runtime.is_error %value3 : !async.value<f32>
78 vector.print %err3_0 : i1
79 vector.print %err3_1 : i1
81 // ------------------------------------------------------------------------ //
82 // Check error propagation from a token to the group.
83 // ------------------------------------------------------------------------ //
85 %c2 = arith.constant 2 : index
86 %group0 = async.create_group %c2 : !async.group
88 %token4 = async.execute {
92 %token5 = async.execute {
93 cf.assert %false, "error"
97 %idx0 = async.add_to_group %token4, %group0 : !async.token
98 %idx1 = async.add_to_group %token5, %group0 : !async.token
100 async.runtime.await %group0 : !async.group
103 %err4 = async.runtime.is_error %group0 : !async.group
104 vector.print %err4 : i1