[Mlir-commits] [mlir] [mlir] Let GPU ID bounds work on any FunctionOpInterfaces (PR #95166)
Krzysztof Drewniak
llvmlistbot at llvm.org
Tue Jun 11 13:46:42 PDT 2024
================
@@ -73,12 +85,16 @@ static std::optional<uint64_t> getKnownLaunchDim(Op op, LaunchDims type) {
return value.getZExtValue();
}
- if (auto func = op->template getParentOfType<GPUFuncOp>()) {
+ if (auto func = op->template getParentOfType<FunctionOpInterface>()) {
switch (type) {
case LaunchDims::Block:
- return llvm::transformOptional(func.getKnownBlockSize(dim), zext);
+ return llvm::transformOptional(
+ getKnownLaunchAttr(func, GPUFuncOp::getKnownBlockSizeAttrName(), dim),
+ zext);
case LaunchDims::Grid:
- return llvm::transformOptional(func.getKnownGridSize(dim), zext);
+ return llvm::transformOptional(
+ getKnownLaunchAttr(func, GPUFuncOp::getKnownGridSizeAttrName(), dim),
+ zext);
----------------
krzysz00 wrote:
It's house style for `gpu.func` (see also the `kernel` attribute, last I checked)
And I found my cute for "GPU code doesn't have to be in a GPU func" https://discourse.llvm.org/t/mlir-gpu-calling-gpu-func-that-is-not-a-kernel-a-k-a-device-function/79285 .
And so there could be a pass that propagates these annotations from kernels to the `func.func`s they call, which is an argument against making them inherent properties of GPU functions only.
So I'd argue that the known block size annotations are dialect-level metadata and that the fix here it to move the name to GPUDialect (and probably to go to a new-style attribute helper)
https://github.com/llvm/llvm-project/pull/95166
More information about the Mlir-commits
mailing list