From 2e2bcee05876305cb9b21b6b5e8e48dc6da58ede Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Mon, 21 Sep 2020 11:24:43 -0400 Subject: [PATCH] [mlir][openacc] Add attributes to parallel op async, wait and self clauses Add attributes for the async, wait and self clauses. These clauses can be present without values. When this is the case they are modelled with an attribute instead of operands. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D87991 --- mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td | 7 ++++++- mlir/test/Dialect/OpenACC/ops.mlir | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td index f0bf71c..7f1f5ac 100644 --- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td +++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td @@ -94,12 +94,15 @@ def OpenACC_ParallelOp : OpenACC_Op<"parallel", }]; let arguments = (ins Optional:$async, + UnitAttr:$asyncAttr, Variadic:$waitOperands, + UnitAttr:$waitAttr, Optional:$numGangs, Optional:$numWorkers, Optional:$vectorLength, Optional:$ifCond, Optional:$selfCond, + UnitAttr:$selfAttr, OptionalAttr:$reductionOp, Variadic:$reductionOperands, Variadic:$copyOperands, @@ -121,12 +124,15 @@ def OpenACC_ParallelOp : OpenACC_Op<"parallel", let extraClassDeclaration = [{ static StringRef getAsyncKeyword() { return "async"; } + static StringRef getAsyncAttrName() { return "asyncAttr"; } static StringRef getWaitKeyword() { return "wait"; } + static StringRef getWaitAttrName() { return "waitAttr"; } static StringRef getNumGangsKeyword() { return "num_gangs"; } static StringRef getNumWorkersKeyword() { return "num_workers"; } static StringRef getVectorLengthKeyword() { return "vector_length"; } static StringRef getIfKeyword() { return "if"; } static StringRef getSelfKeyword() { return "self"; } + static StringRef getSelfAttrName() { return "selfAttr"; } static StringRef getReductionKeyword() { return "reduction"; } static StringRef getCopyKeyword() { return "copy"; } static StringRef getCopyinKeyword() { return "copyin"; } @@ -310,4 +316,3 @@ def OpenACC_YieldOp : OpenACC_Op<"yield", [Terminator, } #endif // OPENACC_OPS - diff --git a/mlir/test/Dialect/OpenACC/ops.mlir b/mlir/test/Dialect/OpenACC/ops.mlir index 48ca1a6..3371609 100644 --- a/mlir/test/Dialect/OpenACC/ops.mlir +++ b/mlir/test/Dialect/OpenACC/ops.mlir @@ -379,6 +379,12 @@ func @testparallelop(%a: memref<10xf32>, %b: memref<10xf32>, %c: memref<10x10xf3 } attributes {defaultAttr = "none"} acc.parallel { } attributes {defaultAttr = "present"} + acc.parallel { + } attributes {asyncAttr} + acc.parallel { + } attributes {waitAttr} + acc.parallel { + } attributes {selfAttr} return } @@ -438,6 +444,12 @@ func @testparallelop(%a: memref<10xf32>, %b: memref<10xf32>, %c: memref<10x10xf3 // CHECK-NEXT: } attributes {defaultAttr = "none"} // CHECK: acc.parallel { // CHECK-NEXT: } attributes {defaultAttr = "present"} +// CHECK: acc.parallel { +// CHECK-NEXT: } attributes {asyncAttr} +// CHECK: acc.parallel { +// CHECK-NEXT: } attributes {waitAttr} +// CHECK: acc.parallel { +// CHECK-NEXT: } attributes {selfAttr} // ----- -- 2.7.4