108 lines · plain
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,convert-cf-to-llvm,reconcile-unrealized-casts)" \2// RUN: | mlir-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=always8 9// FIXME: https://github.com/llvm/llvm-project/issues/5723110// UNSUPPORTED: hwasan11// FIXME: Windows does not have aligned_alloc12// UNSUPPORTED: system-windows13 14func.func @main() {15 %false = arith.constant 0 : i116 17 // ------------------------------------------------------------------------ //18 // Check that simple async region completes without errors.19 // ------------------------------------------------------------------------ //20 %token0 = async.execute {21 async.yield22 }23 async.runtime.await %token0 : !async.token24 25 // CHECK: 026 %err0 = async.runtime.is_error %token0 : !async.token27 vector.print %err0 : i128 29 // ------------------------------------------------------------------------ //30 // Check that assertion in the async region converted to async error.31 // ------------------------------------------------------------------------ //32 %token1 = async.execute {33 cf.assert %false, "error"34 async.yield35 }36 async.runtime.await %token1 : !async.token37 38 // CHECK: 139 %err1 = async.runtime.is_error %token1 : !async.token40 vector.print %err1 : i141 42 // ------------------------------------------------------------------------ //43 // Check error propagation from the nested region.44 // ------------------------------------------------------------------------ //45 %token2 = async.execute {46 %token = async.execute {47 cf.assert %false, "error"48 async.yield49 }50 async.await %token : !async.token51 async.yield52 }53 async.runtime.await %token2 : !async.token54 55 // CHECK: 156 %err2 = async.runtime.is_error %token2 : !async.token57 vector.print %err2 : i158 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 : f3266 async.yield %0 : f3267 }68 %ret = async.await %value : !async.value<f32>69 async.yield %ret : f3270 }71 async.runtime.await %token3 : !async.token72 async.runtime.await %value3 : !async.value<f32>73 74 // CHECK: 175 // CHECK: 176 %err3_0 = async.runtime.is_error %token3 : !async.token77 %err3_1 = async.runtime.is_error %value3 : !async.value<f32>78 vector.print %err3_0 : i179 vector.print %err3_1 : i180 81 // ------------------------------------------------------------------------ //82 // Check error propagation from a token to the group.83 // ------------------------------------------------------------------------ //84 85 %c2 = arith.constant 2 : index86 %group0 = async.create_group %c2 : !async.group87 88 %token4 = async.execute {89 async.yield90 }91 92 %token5 = async.execute {93 cf.assert %false, "error"94 async.yield95 }96 97 %idx0 = async.add_to_group %token4, %group0 : !async.token98 %idx1 = async.add_to_group %token5, %group0 : !async.token99 100 async.runtime.await %group0 : !async.group101 102 // CHECK: 1103 %err4 = async.runtime.is_error %group0 : !async.group104 vector.print %err4 : i1105 106 return107}108