Files
clang-p2996/mlir/test/Dialect/Async/async-runtime-policy-based-ref-counting.mlir
Eugene Zhulenev f57b2420b2 [mlir:Async] Add an async reference counting pass based on the user defined policy
Depends On D104999

Automatic reference counting based on the liveness analysis can add a lot of reference counting overhead at runtime. If the IR is known to be constrained to few particular "shapes", it's much more efficient to provide a custom reference counting policy that will specify where it is required to update the async value reference count.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D105037
2021-06-29 12:53:09 -07:00

48 lines
1.6 KiB
MLIR

// RUN: mlir-opt %s -async-runtime-policy-based-ref-counting | FileCheck %s
// CHECK-LABEL: @token_await
// CHECK: %[[TOKEN:.*]]: !async.token
func @token_await(%arg0: !async.token) {
// CHECK: async.runtime.await %[[TOKEN]]
// CHECK: async.runtime.drop_ref %[[TOKEN]] {count = 1 : i32}
async.runtime.await %arg0 : !async.token
return
}
// CHECK-LABEL: @group_await
// CHECK: %[[GROUP:.*]]: !async.group
func @group_await(%arg0: !async.group) {
// CHECK: async.runtime.await %[[GROUP]]
// CHECK: async.runtime.drop_ref %[[GROUP]] {count = 1 : i32}
async.runtime.await %arg0 : !async.group
return
}
// CHECK-LABEL: @add_token_to_group
// CHECK: %[[GROUP:.*]]: !async.group
// CHECK: %[[TOKEN:.*]]: !async.token
func @add_token_to_group(%arg0: !async.group, %arg1: !async.token) {
// CHECK: async.runtime.add_to_group %[[TOKEN]], %[[GROUP]]
// CHECK: async.runtime.drop_ref %[[TOKEN]] {count = 1 : i32}
async.runtime.add_to_group %arg1, %arg0 : !async.token
return
}
// CHECK-LABEL: @value_load
// CHECK: %[[VALUE:.*]]: !async.value<f32>
func @value_load(%arg0: !async.value<f32>) {
// CHECK: async.runtime.load %[[VALUE]]
// CHECK: async.runtime.drop_ref %[[VALUE]] {count = 1 : i32}
%0 = async.runtime.load %arg0 : !async.value<f32>
return
}
// CHECK-LABEL: @error_check
// CHECK: %[[TOKEN:.*]]: !async.token
func @error_check(%arg0: !async.token) {
// CHECK: async.runtime.is_error %[[TOKEN]]
// CHECK: async.runtime.drop_ref %[[TOKEN]] {count = 1 : i32}
%0 = async.runtime.is_error %arg0 : !async.token
return
}