forked from OSchip/llvm-project
[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.
This commit is contained in:
parent
a67949913a
commit
603b974cf7
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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} : () -> ()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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} : () -> ()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue