[Mlir-commits] [mlir] [mlir] Let GPU ID bounds work on any FunctionOpInterfaces (PR #95166)

Krzysztof Drewniak llvmlistbot at llvm.org
Tue Jun 11 14:26:45 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:

I think that functions have, in practice, stronger semantics re discardability, similarly to how modules do. That is, while `dlti.dl_spec` is "discardable" (even on `builtin.module`), it's expected that passes will preserve attributes like those unless they're something like an inliner that you know won't handle that universe of discardable information.

But that overall point aside ... `gpu.known_block_size` is discardable. It's an optimization hint. Dropping it halfway down your pipeline could cause optimization issues but shouldn't cause miscompilation.


https://github.com/llvm/llvm-project/pull/95166


More information about the Mlir-commits mailing list