[Mlir-commits] [mlir] 603b974 - [mlir][gpu] Fix logic error in D79508 computing number of private attributions.
Wen-Heng Chung
llvmlistbot at llvm.org
Mon Jun 8 05:40:45 PDT 2020
Author: Wen-Heng (Jack) Chung
Date: 2020-06-08T07:40:34-05:00
New Revision: 603b974cf7103766a0e5e4a0320fedb7c4b570f9
URL: https://github.com/llvm/llvm-project/commit/603b974cf7103766a0e5e4a0320fedb7c4b570f9
DIFF: https://github.com/llvm/llvm-project/commit/603b974cf7103766a0e5e4a0320fedb7c4b570f9.diff
LOG: [mlir][gpu] Fix logic error in D79508 computing number of private attributions.
Fix logic error in D79508. The old logic would make the first check in
`GPUFuncOp::verifyBody` always pass.
Added:
Modified:
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/test/Dialect/GPU/invalid.mlir
mlir/test/Dialect/GPU/ops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td
index ab81ad7d33b4..281696d0eb98 100644
--- a/mlir/include/mlir/Dialect/GPU/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td
@@ -249,7 +249,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [HasParent<"GPUModuleOp">,
/// Returns the number of buffers located in the private memory.
unsigned getNumPrivateAttributions() {
- return getOperation()->getNumOperands() - getType().getNumInputs() -
+ return getBody().front().getNumArguments() - getType().getNumInputs() -
getNumWorkgroupAttributions();
}
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index 9a5f6fcefbca..b14f7688bbf5 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -675,13 +675,10 @@ static LogicalResult verifyAttributions(Operation *op,
LogicalResult GPUFuncOp::verifyBody() {
unsigned numFuncArguments = getNumArguments();
unsigned numWorkgroupAttributions = getNumWorkgroupAttributions();
- unsigned numPrivateAttributions = getNumPrivateAttributions();
unsigned numBlockArguments = front().getNumArguments();
- if (numBlockArguments <
- numFuncArguments + numWorkgroupAttributions + numPrivateAttributions)
+ if (numBlockArguments < numFuncArguments + numWorkgroupAttributions)
return emitOpError() << "expected at least "
- << numFuncArguments + numWorkgroupAttributions +
- numPrivateAttributions
+ << numFuncArguments + numWorkgroupAttributions
<< " arguments to body region";
ArrayRef<Type> funcArgTypes = getType().getInputs();
diff --git a/mlir/test/Dialect/GPU/invalid.mlir b/mlir/test/Dialect/GPU/invalid.mlir
index 36b2ee9b5a8a..43b2434a2cdf 100644
--- a/mlir/test/Dialect/GPU/invalid.mlir
+++ b/mlir/test/Dialect/GPU/invalid.mlir
@@ -423,3 +423,15 @@ module {
}
}
}
+
+// -----
+
+module {
+ gpu.module @gpu_funcs {
+ // expected-error @+1 {{'gpu.func' op expected at least 5 arguments to body region}}
+ "gpu.func"() ( {
+ ^bb0(%arg0: f32, %arg1: memref<?xf32>, %arg2: memref<5xf32, 3>, %arg3: memref<5xf32, 5>):
+ "gpu.return"() : () -> ()
+ } ) {gpu.kernel, sym_name = "kernel_1", type = (f32, memref<?xf32>) -> (), workgroup_attributions = 3: i64} : () -> ()
+ }
+}
diff --git a/mlir/test/Dialect/GPU/ops.mlir b/mlir/test/Dialect/GPU/ops.mlir
index 691b3d9ba319..2c4cdeeae891 100644
--- a/mlir/test/Dialect/GPU/ops.mlir
+++ b/mlir/test/Dialect/GPU/ops.mlir
@@ -136,4 +136,11 @@ module attributes {gpu.container_module} {
}
}
+ gpu.module @explicit_attributions {
+ // CHECK-LABEL: gpu.func @kernel_1({{.*}}: f32, {{.*}}: memref<?xf32>) workgroup({{.*}}: memref<5xf32, 3>) private({{.*}}: memref<5xf32, 5>)
+ "gpu.func"() ( {
+ ^bb0(%arg0: f32, %arg1: memref<?xf32>, %arg2: memref<5xf32, 3>, %arg3: memref<5xf32, 5>):
+ "gpu.return"() : () -> ()
+ } ) {gpu.kernel, sym_name = "kernel_1", type = (f32, memref<?xf32>) -> (), workgroup_attributions = 1: i64} : () -> ()
+ }
}
More information about the Mlir-commits
mailing list