[Mlir-commits] [mlir] b90d6b2 - [mlir][openacc] Switch deviceType to optional single operand

Valentin Clement llvmlistbot at llvm.org
Wed Aug 23 11:31:30 PDT 2023


Author: Valentin Clement
Date: 2023-08-23T11:31:24-07:00
New Revision: b90d6b237ff67498213059d0d3639ac965d4e5bf

URL: https://github.com/llvm/llvm-project/commit/b90d6b237ff67498213059d0d3639ac965d4e5bf
DIFF: https://github.com/llvm/llvm-project/commit/b90d6b237ff67498213059d0d3639ac965d4e5bf.diff

LOG: [mlir][openacc] Switch deviceType to optional single operand

The standard suggests that the value for the `device_type` clause on the
`set` directive is a list but this does not makes sense. Restrict the number
of value to one so it matches the runtime function.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158644

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
    mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
    mlir/test/Dialect/OpenACC/ops.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
index 5e011370d479cf..5d667bc9e065da 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
@@ -1511,16 +1511,16 @@ def OpenACC_SetOp : OpenACC_Op<"set", [AttrSizedOperandSegments]> {
     ```
   }];
 
-  let arguments = (ins Variadic<IntOrIndex>:$deviceTypeOperands,
+  let arguments = (ins Optional<IntOrIndex>:$deviceType,
                        Optional<IntOrIndex>:$defaultAsync,
-                       Optional<IntOrIndex>:$deviceNumOperand,
+                       Optional<IntOrIndex>:$deviceNum,
                        Optional<I1>:$ifCond);
 
   let assemblyFormat = [{
     oilist(
-      `device_type` `(` $deviceTypeOperands `:` type($deviceTypeOperands) `)`
+      `device_type` `(` $deviceType `:` type($deviceType) `)`
     | `default_async` `(` $defaultAsync `:` type($defaultAsync) `)`
-    | `device_num` `(` $deviceNumOperand `:` type($deviceNumOperand) `)`
+    | `device_num` `(` $deviceNum `:` type($deviceNum) `)`
     | `if` `(` $ifCond `)`
     ) attr-dict-with-keyword
   }];

diff  --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
index a7aae09e0857c5..9b893eeb83c066 100644
--- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
+++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
@@ -1133,8 +1133,7 @@ LogicalResult acc::SetOp::verify() {
   while ((currOp = currOp->getParentOp()))
     if (isComputeOperation(currOp))
       return emitOpError("cannot be nested in a compute operation");
-  if (getDeviceTypeOperands().empty() && !getDefaultAsync() &&
-      !getDeviceNumOperand())
+  if (!getDeviceType() && !getDefaultAsync() && !getDeviceNum())
     return emitOpError("at least one default_async, device_num, or device_type "
                        "operand must appear");
   return success();

diff  --git a/mlir/test/Dialect/OpenACC/ops.mlir b/mlir/test/Dialect/OpenACC/ops.mlir
index d4fc9822a79bd2..16e2e2a1f838f8 100644
--- a/mlir/test/Dialect/OpenACC/ops.mlir
+++ b/mlir/test/Dialect/OpenACC/ops.mlir
@@ -1704,12 +1704,11 @@ func.func @compute3(%a: memref<10x10xf32>, %b: memref<10x10xf32>, %c: memref<10x
 %idxValue = arith.constant 1 : index
 %ifCond = arith.constant true
 acc.set device_type(%i32Value : i32)
-acc.set device_type(%i32Value, %i32Value2 : i32, i32)
+acc.set device_type(%i32Value : i32)
 acc.set device_num(%i64Value : i64)
 acc.set device_num(%i32Value : i32)
 acc.set device_num(%idxValue : index)
 acc.set device_num(%idxValue : index) if(%ifCond)
-acc.set device_num(%idxValue : index) if(%ifCond)
 acc.set default_async(%i32Value : i32)
 
 // CHECK: [[I64VALUE:%.*]] = arith.constant 1 : i64
@@ -1718,10 +1717,9 @@ acc.set default_async(%i32Value : i32)
 // CHECK: [[IDXVALUE:%.*]] = arith.constant 1 : index
 // CHECK: [[IFCOND:%.*]] = arith.constant true
 // CHECK: acc.set device_type([[I32VALUE]] : i32)
-// CHECK: acc.set device_type([[I32VALUE]], [[I32VALUE2]] : i32, i32)
+// CHECK: acc.set device_type([[I32VALUE]] : i32)
 // CHECK: acc.set device_num([[I64VALUE]] : i64)
 // CHECK: acc.set device_num([[I32VALUE]] : i32)
 // CHECK: acc.set device_num([[IDXVALUE]] : index)
 // CHECK: acc.set device_num([[IDXVALUE]] : index) if([[IFCOND]])
-// CHECK: acc.set device_num([[IDXVALUE]] : index) if([[IFCOND]])
 // CHECK: acc.set default_async([[I32VALUE]] : i32)


        


More information about the Mlir-commits mailing list