[Mlir-commits] [mlir] 550b6f1 - [mlir][openacc] Add acc.declare_action attribute
Valentin Clement
llvmlistbot at llvm.org
Mon Aug 14 10:41:19 PDT 2023
Author: Valentin Clement
Date: 2023-08-14T10:41:13-07:00
New Revision: 550b6f1167c931837cd091c48c72a6736bcf151d
URL: https://github.com/llvm/llvm-project/commit/550b6f1167c931837cd091c48c72a6736bcf151d
DIFF: https://github.com/llvm/llvm-project/commit/550b6f1167c931837cd091c48c72a6736bcf151d.diff
LOG: [mlir][openacc] Add acc.declare_action attribute
iAdd the acc.declare_action attribute to attach pre/post
allocation/deallocation functions to operations.
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D157743
Added:
Modified:
mlir/include/mlir/Dialect/OpenACC/OpenACC.h
mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
mlir/test/Dialect/OpenACC/ops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACC.h b/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
index b469bd83521ae5..602aa505903248 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
@@ -78,6 +78,10 @@ static constexpr StringLiteral getDeclareAttrName() {
return StringLiteral("acc.declare");
}
+static constexpr StringLiteral getDeclareActionAttrName() {
+ return StringLiteral("acc.declare_action");
+}
+
} // namespace acc
} // namespace mlir
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
index 06738634f798d4..a901522749f8d5 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
@@ -135,6 +135,16 @@ def DeclareAttr : OpenACC_Attr<"Declare", "declare"> {
let assemblyFormat = "`<` struct(params) `>`";
}
+// Attribute to attach functions that perform the pre/post allocation actions or
+// pre/post deallocation actions as described in section 2.13.
+def DeclareActionAttr : OpenACC_Attr<"DeclareAction", "declare_action"> {
+ let parameters = (ins OptionalParameter<"SymbolRefAttr">:$preAlloc,
+ OptionalParameter<"SymbolRefAttr">:$postAlloc,
+ OptionalParameter<"SymbolRefAttr">:$preDealloc,
+ OptionalParameter<"SymbolRefAttr">:$postDealloc);
+ let assemblyFormat = "`<` struct(params) `>`";
+}
+
// Used for data specification in data clauses (2.7.1).
// Either (or both) extent and upperbound must be specified.
def OpenACC_DataBoundsOp : OpenACC_Op<"bounds",
diff --git a/mlir/test/Dialect/OpenACC/ops.mlir b/mlir/test/Dialect/OpenACC/ops.mlir
index f308109df43320..789ef8474acb6e 100644
--- a/mlir/test/Dialect/OpenACC/ops.mlir
+++ b/mlir/test/Dialect/OpenACC/ops.mlir
@@ -1664,3 +1664,13 @@ acc.routine @acc_func_rout9 func(@acc_func) bind("acc_func_gpu_gang_dim1") gang(
// CHECK: acc.routine @acc_func_rout7 func(@acc_func) bind("acc_func_gpu_imp_gang") gang implicit
// CHECK: acc.routine @acc_func_rout8 func(@acc_func) bind("acc_func_gpu_vector_nohost") vector nohost
// CHECK: acc.routine @acc_func_rout9 func(@acc_func) bind("acc_func_gpu_gang_dim1") gang(dim = 1 : i32)
+
+// -----
+
+func.func @acc_func() -> () {
+ "test.openacc_dummy_op"() {acc.declare_action = #acc.declare_action<postAlloc = @_QMacc_declareFacc_declare_allocateEa_acc_declare_update_desc_post_alloc>} : () -> ()
+ return
+}
+
+// CHECK-LABEL: func.func @acc_func
+// CHECK: "test.openacc_dummy_op"() {acc.declare_action = #acc.declare_action<postAlloc = @_QMacc_declareFacc_declare_allocateEa_acc_declare_update_desc_post_alloc>}
More information about the Mlir-commits
mailing list