From 1ce5f8bbb6f3fb581fd4c5905e5574c8b9a09268 Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Thu, 29 Oct 2020 09:54:31 -0400 Subject: [PATCH] [mlir][openacc] Add if and device_type to update op Update op is modelling the update directive (2.14.4) from the OpenACC specs. An if condition and a device_type list can be attached to the directive. This patch add these two information to the current op. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D90310 --- mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td | 5 +++++ mlir/test/Dialect/OpenACC/ops.mlir | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td index 7ed8400..ccc6233 100644 --- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td +++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td @@ -482,13 +482,18 @@ def OpenACC_UpdateOp : OpenACC_Op<"update", [AttrSizedOperandSegments]> { Variadic:$waitOperands, UnitAttr:$async, UnitAttr:$wait, + Variadic:$deviceTypeOperands, + Optional:$ifCond, Variadic:$hostOperands, Variadic:$deviceOperands, UnitAttr:$ifPresent); let assemblyFormat = [{ + ( `if` `(` $ifCond^ `)` )? ( `async` `(` $asyncOperand^ `:` type($asyncOperand) `)` )? ( `wait_devnum` `(` $waitDevnum^ `:` type($waitDevnum) `)` )? + ( `device_type` `(` $deviceTypeOperands^ `:` + type($deviceTypeOperands) `)` )? ( `wait` `(` $waitOperands^ `:` type($waitOperands) `)` )? ( `host` `(` $hostOperands^ `:` type($hostOperands) `)` )? ( `device` `(` $deviceOperands^ `:` type($deviceOperands) `)` )? diff --git a/mlir/test/Dialect/OpenACC/ops.mlir b/mlir/test/Dialect/OpenACC/ops.mlir index 01089ff..6e53367 100644 --- a/mlir/test/Dialect/OpenACC/ops.mlir +++ b/mlir/test/Dialect/OpenACC/ops.mlir @@ -531,10 +531,13 @@ func @testupdateop(%a: memref<10xf32>, %b: memref<10xf32>, %c: memref<10x10xf32> %i64Value = constant 1 : i64 %i32Value = constant 1 : i32 %idxValue = constant 1 : index + %ifCond = constant true acc.update async(%i64Value: i64) host(%a: memref<10xf32>) acc.update async(%i32Value: i32) host(%a: memref<10xf32>) acc.update async(%idxValue: index) host(%a: memref<10xf32>) acc.update wait_devnum(%i64Value: i64) wait(%i32Value, %idxValue : i32, index) host(%a: memref<10xf32>) + acc.update if(%ifCond) host(%a: memref<10xf32>) + acc.update device_type(%i32Value : i32) host(%a: memref<10xf32>) acc.update host(%a: memref<10xf32>) device(%b, %c : memref<10xf32>, memref<10x10xf32>) acc.update host(%a: memref<10xf32>) device(%b, %c : memref<10xf32>, memref<10x10xf32>) attributes {async} acc.update host(%a: memref<10xf32>) device(%b, %c : memref<10xf32>, memref<10x10xf32>) attributes {wait} @@ -546,10 +549,13 @@ func @testupdateop(%a: memref<10xf32>, %b: memref<10xf32>, %c: memref<10x10xf32> // CHECK: [[I64VALUE:%.*]] = constant 1 : i64 // CHECK: [[I32VALUE:%.*]] = constant 1 : i32 // CHECK: [[IDXVALUE:%.*]] = constant 1 : index +// CHECK: [[IFCOND:%.*]] = constant true // CHECK: acc.update async([[I64VALUE]] : i64) host([[ARGA]] : memref<10xf32>) // CHECK: acc.update async([[I32VALUE]] : i32) host([[ARGA]] : memref<10xf32>) // CHECK: acc.update async([[IDXVALUE]] : index) host([[ARGA]] : memref<10xf32>) // CHECK: acc.update wait_devnum([[I64VALUE]] : i64) wait([[I32VALUE]], [[IDXVALUE]] : i32, index) host([[ARGA]] : memref<10xf32>) +// CHECK: acc.update if([[IFCOND]]) host([[ARGA]] : memref<10xf32>) +// CHECK: acc.update device_type([[I32VALUE]] : i32) host([[ARGA]] : memref<10xf32>) // CHECK: acc.update host([[ARGA]] : memref<10xf32>) device([[ARGB]], [[ARGC]] : memref<10xf32>, memref<10x10xf32>) // CHECK: acc.update host([[ARGA]] : memref<10xf32>) device([[ARGB]], [[ARGC]] : memref<10xf32>, memref<10x10xf32>) attributes {async} // CHECK: acc.update host([[ARGA]] : memref<10xf32>) device([[ARGB]], [[ARGC]] : memref<10xf32>, memref<10x10xf32>) attributes {wait} -- 2.7.4