1 // RUN: mlir-opt %s -async-to-async-runtime \
2 // RUN: -async-runtime-ref-counting \
3 // RUN: -async-runtime-ref-counting-opt \
4 // RUN: -convert-async-to-llvm \
5 // RUN: -convert-arith-to-llvm \
6 // RUN: -convert-vector-to-llvm \
7 // RUN: -convert-memref-to-llvm \
8 // RUN: -convert-std-to-llvm \
9 // RUN: -reconcile-unrealized-casts \
10 // RUN: | mlir-cpu-runner \
11 // RUN: -e main -entry-point-result=void -O0 \
12 // RUN: -shared-libs=%linalg_test_lib_dir/libmlir_c_runner_utils%shlibext \
13 // RUN: -shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
14 // RUN: -shared-libs=%linalg_test_lib_dir/libmlir_async_runtime%shlibext \
15 // RUN: | FileCheck %s --dump-input=always
19 // ------------------------------------------------------------------------ //
20 // Blocking async.await outside of the async.execute.
21 // ------------------------------------------------------------------------ //
22 %token, %result = async.execute -> !async.value<f32> {
23 %0 = arith.constant 123.456 : f32
26 %1 = async.await %result : !async.value<f32>
31 // ------------------------------------------------------------------------ //
32 // Non-blocking async.await inside the async.execute
33 // ------------------------------------------------------------------------ //
34 %token0, %result0 = async.execute -> !async.value<f32> {
35 %token1, %result2 = async.execute -> !async.value<f32> {
36 %2 = arith.constant 456.789 : f32
39 %3 = async.await %result2 : !async.value<f32>
42 %4 = async.await %result0 : !async.value<f32>
47 // ------------------------------------------------------------------------ //
48 // Memref allocated inside async.execute region.
49 // ------------------------------------------------------------------------ //
50 %token2, %result2 = async.execute[%token0] -> !async.value<memref<f32>> {
51 %5 = memref.alloc() : memref<f32>
52 %c0 = arith.constant 0.25 : f32
53 memref.store %c0, %5[]: memref<f32>
54 async.yield %5 : memref<f32>
56 %6 = async.await %result2 : !async.value<memref<f32>>
57 %7 = memref.cast %6 : memref<f32> to memref<*xf32>
59 // CHECK: Unranked Memref
60 // CHECK-SAME: rank = 0 offset = 0 sizes = [] strides = []
62 call @print_memref_f32(%7): (memref<*xf32>) -> ()
64 // ------------------------------------------------------------------------ //
65 // Memref passed as async.execute operand.
66 // ------------------------------------------------------------------------ //
67 %token3 = async.execute(%result2 as %unwrapped : !async.value<memref<f32>>) {
68 %8 = memref.load %unwrapped[]: memref<f32>
69 %9 = arith.addf %8, %8 : f32
70 memref.store %9, %unwrapped[]: memref<f32>
73 async.await %token3 : !async.token
75 // CHECK: Unranked Memref
76 // CHECK-SAME: rank = 0 offset = 0 sizes = [] strides = []
78 call @print_memref_f32(%7): (memref<*xf32>) -> ()
80 memref.dealloc %6 : memref<f32>
85 func private @print_memref_f32(memref<*xf32>)
86 attributes { llvm.emit_c_interface }