[Mlir-commits] [mlir] [mlir][gpu] Fix mgpuLaunchKernel sharedMemBytes type in L0 runtime (PR #206119)
Md Abdullah Shahneous Bari
llvmlistbot at llvm.org
Fri Jun 26 08:59:54 PDT 2026
https://github.com/mshahneo created https://github.com/llvm/llvm-project/pull/206119
The GPU launch lowering in SelectObjectAttr.cpp declares and calls `mgpuLaunchKernel` with the dynamic shared memory size argument typed as `i32`, but the Level Zero runtime wrapper declared the corresponding parameter as `size_t` (8 bytes on 64-bit targets). Since these are positional C-ABI arguments, the 4-byte vs 8-byte mismatch shifts the layout of every following argument (stream, params, extra, paramsCount), corrupting the call and crashing at launch.
Change the parameter to int32_t to match the codegen, consistent with the CUDA and ROCm runtime wrappers which already use int32_t smem.
>From 0259adbd7d653f6a770efab97defecf37592fa56 Mon Sep 17 00:00:00 2001
From: "Shahneous Bari, Md Abdullah" <md.abdullah.shahneous.bari at intel.com>
Date: Fri, 26 Jun 2026 15:50:47 +0000
Subject: [PATCH] [mlir][gpu] Fix mgpuLaunchKernel sharedMemBytes type in L0
runtime
The GPU launch lowering in SelectObjectAttr.cpp declares and calls
mgpuLaunchKernel with the dynamic shared memory size argument typed as
i32, but the Level Zero runtime wrapper declared the corresponding
parameter as size_t (8 bytes on 64-bit targets). Since these are
positional C-ABI arguments, the 4-byte vs 8-byte mismatch shifts the
layout of every following argument (stream, params, extra, paramsCount),
corrupting the call and crashing at launch.
Change the parameter to int32_t to match the codegen, consistent with
the CUDA and ROCm runtime wrappers which already use int32_t smem.
Co-Authored-By: Claude Opus 4.8 <noreply at anthropic.com>
---
mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp b/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp
index 91dab05b5a652..f38bd3275067a 100644
--- a/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp
+++ b/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp
@@ -551,7 +551,7 @@ extern "C" ze_kernel_handle_t mgpuModuleGetFunction(ze_module_handle_t module,
extern "C" void mgpuLaunchKernel(ze_kernel_handle_t kernel, size_t gridX,
size_t gridY, size_t gridZ, size_t blockX,
size_t blockY, size_t blockZ,
- size_t sharedMemBytes, StreamWrapper *stream,
+ int32_t sharedMemBytes, StreamWrapper *stream,
void **params, void ** /*extra*/,
size_t paramsCount) {
More information about the Mlir-commits
mailing list