Mercurial > hg > CbC > CbC_llvm
comparison mlir/test/mlir-cpu-runner/async.mlir @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | |
children | 5f17cb93ff66 |
comparison
equal
deleted
inserted
replaced
173:0572611fdcc8 | 207:2e18cbf3894f |
---|---|
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-linalg-to-loops \ | |
6 // RUN: -convert-scf-to-std \ | |
7 // RUN: -convert-linalg-to-llvm \ | |
8 // RUN: -convert-std-to-llvm \ | |
9 // RUN: | mlir-cpu-runner \ | |
10 // RUN: -e main -entry-point-result=void -O0 \ | |
11 // RUN: -shared-libs=%linalg_test_lib_dir/libmlir_c_runner_utils%shlibext \ | |
12 // RUN: -shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \ | |
13 // RUN: -shared-libs=%linalg_test_lib_dir/libmlir_async_runtime%shlibext \ | |
14 // RUN: | FileCheck %s | |
15 | |
16 func @main() { | |
17 %i0 = constant 0 : index | |
18 %i1 = constant 1 : index | |
19 %i2 = constant 2 : index | |
20 %i3 = constant 3 : index | |
21 | |
22 %c0 = constant 0.0 : f32 | |
23 %c1 = constant 1.0 : f32 | |
24 %c2 = constant 2.0 : f32 | |
25 %c3 = constant 3.0 : f32 | |
26 %c4 = constant 4.0 : f32 | |
27 | |
28 %A = memref.alloc() : memref<4xf32> | |
29 linalg.fill(%A, %c0) : memref<4xf32>, f32 | |
30 | |
31 // CHECK: [0, 0, 0, 0] | |
32 %U = memref.cast %A : memref<4xf32> to memref<*xf32> | |
33 call @print_memref_f32(%U): (memref<*xf32>) -> () | |
34 | |
35 // CHECK: Current thread id: [[MAIN:.*]] | |
36 // CHECK: [1, 0, 0, 0] | |
37 memref.store %c1, %A[%i0]: memref<4xf32> | |
38 call @mlirAsyncRuntimePrintCurrentThreadId(): () -> () | |
39 call @print_memref_f32(%U): (memref<*xf32>) -> () | |
40 | |
41 %outer = async.execute { | |
42 // CHECK: Current thread id: [[THREAD0:.*]] | |
43 // CHECK: [1, 2, 0, 0] | |
44 memref.store %c2, %A[%i1]: memref<4xf32> | |
45 call @mlirAsyncRuntimePrintCurrentThreadId(): () -> () | |
46 call @print_memref_f32(%U): (memref<*xf32>) -> () | |
47 | |
48 // No op async region to create a token for testing async dependency. | |
49 %noop = async.execute { | |
50 // CHECK: Current thread id: [[THREAD1:.*]] | |
51 call @mlirAsyncRuntimePrintCurrentThreadId(): () -> () | |
52 async.yield | |
53 } | |
54 | |
55 %inner = async.execute [%noop] { | |
56 // CHECK: Current thread id: [[THREAD2:.*]] | |
57 // CHECK: [1, 2, 3, 0] | |
58 memref.store %c3, %A[%i2]: memref<4xf32> | |
59 call @mlirAsyncRuntimePrintCurrentThreadId(): () -> () | |
60 call @print_memref_f32(%U): (memref<*xf32>) -> () | |
61 | |
62 async.yield | |
63 } | |
64 async.await %inner : !async.token | |
65 | |
66 // CHECK: Current thread id: [[THREAD3:.*]] | |
67 // CHECK: [1, 2, 3, 4] | |
68 memref.store %c4, %A[%i3]: memref<4xf32> | |
69 call @mlirAsyncRuntimePrintCurrentThreadId(): () -> () | |
70 call @print_memref_f32(%U): (memref<*xf32>) -> () | |
71 | |
72 async.yield | |
73 } | |
74 async.await %outer : !async.token | |
75 | |
76 // CHECK: Current thread id: [[MAIN]] | |
77 // CHECK: [1, 2, 3, 4] | |
78 call @mlirAsyncRuntimePrintCurrentThreadId(): () -> () | |
79 call @print_memref_f32(%U): (memref<*xf32>) -> () | |
80 | |
81 memref.dealloc %A : memref<4xf32> | |
82 | |
83 return | |
84 } | |
85 | |
86 func private @mlirAsyncRuntimePrintCurrentThreadId() -> () | |
87 | |
88 func private @print_memref_f32(memref<*xf32>) attributes { llvm.emit_c_interface } |