[all-commits] [llvm/llvm-project] ac7cf4: [mlir][ROCDL] Improve block/grid_dim handling, fix...

Krzysztof Drewniak via All-commits all-commits at lists.llvm.org
Fri Mar 13 09:58:14 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ac7cf4c8638f4fa0ebd5efeddc13fef00ed85e46
      https://github.com/llvm/llvm-project/commit/ac7cf4c8638f4fa0ebd5efeddc13fef00ed85e46
  Author: Krzysztof Drewniak <Krzysztof.Drewniak at amd.com>
  Date:   2026-03-13 (Fri, 13 Mar 2026)

  Changed paths:
    M mlir/include/mlir/Dialect/LLVMIR/ROCDLOps.td
    M mlir/lib/Conversion/GPUCommon/CMakeLists.txt
    A mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.cpp
    M mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h
    M mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
    M mlir/lib/Target/LLVMIR/Dialect/ROCDL/ROCDLToLLVMIRTranslation.cpp
    M mlir/test/Conversion/GPUCommon/lower-global-id.mlir
    M mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl-subgroup-id.mlir
    M mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
    M mlir/test/Dialect/LLVMIR/rocdl.mlir
    M mlir/test/Target/LLVMIR/rocdl.mlir

  Log Message:
  -----------
  [mlir][ROCDL] Improve block/grid_dim handling, fix subgroup ID (#186235)

This began as me chasing down the fact that the subgroup_id pattern
introduced lately was causing crashes in translation because of
mismatches between the i64 type of the ockl functions being called and
the i32 type they'd been assigned, and spilled out into a refactor of
how we handle these dimension-lookup functions.

This commit removes the {Block,Grid}Dim{X,Y,Z} ops from the rocdl
dialect, since they were translating to library calls and not
intrinsics, which meant they don't fit into the dialect. Therefore, we
instead add a new pattern that rewrites block/grid dimensions to library
calls. While I'm there, I go ahead and implement support for upper
bounds on these dimensions accessors, adding a fallback bound of 1 <=
size < 1024 to those calls.

This also meant updating the lowering of subgroup_id to use that same
call-generation logic.

While I was here, I factored out the "get block/grid bounds from the
context" logic from the index op lowering template into a separate
function that would be reusable in the new patterns.

This also makes the subgroup_id tests stricter.

---------

Co-authored-by: Claude Opus 4.6 <noreply at anthropic.com>
Co-authored-by: Tim Gymnich <tim at gymni.ch>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list