brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · d5251a9 Raw
84 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-arith-to-llvm),convert-vector-to-llvm,finalize-memref-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 16  // ------------------------------------------------------------------------ //17  // Blocking async.await outside of the async.execute.18  // ------------------------------------------------------------------------ //19  %token, %result = async.execute -> !async.value<f32> {20    %0 = arith.constant 123.456 : f3221    async.yield %0 : f3222  }23  %1 = async.await %result : !async.value<f32>24 25  // CHECK: 123.45626  vector.print %1 : f3227 28  // ------------------------------------------------------------------------ //29  // Non-blocking async.await inside the async.execute30  // ------------------------------------------------------------------------ //31  %token0, %result0 = async.execute -> !async.value<f32> {32    %token1, %result2 = async.execute -> !async.value<f32> {33      %2 = arith.constant 456.789 : f3234      async.yield %2 : f3235    }36    %3 = async.await %result2 : !async.value<f32>37    async.yield %3 : f3238  }39  %4 = async.await %result0 : !async.value<f32>40 41  // CHECK: 456.78942  vector.print %4 : f3243 44  // ------------------------------------------------------------------------ //45  // Memref allocated inside async.execute region.46  // ------------------------------------------------------------------------ //47  %token2, %result2 = async.execute[%token0] -> !async.value<memref<f32>> {48    %5 = memref.alloc() : memref<f32>49    %c0 = arith.constant 0.25 : f3250    memref.store %c0, %5[]: memref<f32>51    async.yield %5 : memref<f32>52  }53  %6 = async.await %result2 : !async.value<memref<f32>>54  %7 = memref.cast %6 :  memref<f32> to memref<*xf32>55 56  // CHECK: Unranked Memref57  // CHECK-SAME: rank = 0 offset = 0 sizes = [] strides = []58  // CHECK-NEXT: [0.25]59  call @printMemrefF32(%7): (memref<*xf32>) -> ()60 61  // ------------------------------------------------------------------------ //62  // Memref passed as async.execute operand.63  // ------------------------------------------------------------------------ //64  %token3 = async.execute(%result2 as %unwrapped : !async.value<memref<f32>>) {65    %8 = memref.load %unwrapped[]: memref<f32>66    %9 = arith.addf %8, %8 : f3267    memref.store %9, %unwrapped[]: memref<f32>68    async.yield69  }70  async.await %token3 : !async.token71 72  // CHECK: Unranked Memref73  // CHECK-SAME: rank = 0 offset = 0 sizes = [] strides = []74  // CHECK-NEXT: [0.5]75  call @printMemrefF32(%7): (memref<*xf32>) -> ()76 77  memref.dealloc %6 : memref<f32>78 79  return80}81 82func.func private @printMemrefF32(memref<*xf32>)83  attributes { llvm.emit_c_interface }84