[Mlir-commits] [mlir] 3944056 - [mlir][gpu] Fix L0_SAFE_CALL in LevelZero runtime (#215308)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Aug 17 02:07:40 PDT 2026
Author: Frank Schlimbach
Date: 2026-08-17T11:07:35+02:00
New Revision: 39440565ffd98a811f2e17086494a5d28d36ac28
URL: https://github.com/llvm/llvm-project/commit/39440565ffd98a811f2e17086494a5d28d36ac28
DIFF: https://github.com/llvm/llvm-project/commit/39440565ffd98a811f2e17086494a5d28d36ac28.diff
LOG: [mlir][gpu] Fix L0_SAFE_CALL in LevelZero runtime (#215308)
Using NULL as `RTContext` can lead to crashes when calling
`zeDriverGetLastErrorDescription`.
Now using `getRtContext()` instead.
Added:
Modified:
mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp
Removed:
################################################################################
diff --git a/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp b/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp
index f38bd3275067a..0ae7f0b0f3ef3 100644
--- a/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp
+++ b/mlir/lib/ExecutionEngine/LevelZeroRuntimeWrappers.cpp
@@ -42,13 +42,23 @@ auto catchAll(F &&func) {
ze_result_t status = (call); \
if (status != ZE_RESULT_SUCCESS) { \
const char *errorString; \
- zeDriverGetLastErrorDescription(NULL, &errorString); \
- std::cerr << "L0 error " << status << ": " << errorString << std::endl; \
+ ze_result_t descriptionStatus = \
+ zeDriverGetLastErrorDescriptionWrapper(&errorString); \
+ if (descriptionStatus == ZE_RESULT_SUCCESS && errorString) \
+ std::cerr << "L0 error " << status << ": " << errorString \
+ << std::endl; \
+ else \
+ std::cerr << "Level Zero call failed: " << #call << ", status=0x" \
+ << std::hex << static_cast<uint32_t>(status) << std::dec \
+ << std::endl; \
std::abort(); \
} \
}
} // namespace
+static ze_result_t
+zeDriverGetLastErrorDescriptionWrapper(const char **errorString);
+
//===----------------------------------------------------------------------===//
// L0 RT context & device setters
//===----------------------------------------------------------------------===//
@@ -338,6 +348,11 @@ static DynamicEventPool &getDynamicEventPool() {
return dynEventPool;
}
+static ze_result_t
+zeDriverGetLastErrorDescriptionWrapper(const char **errorString) {
+ return zeDriverGetLastErrorDescription(getRtContext().driver, errorString);
+}
+
struct StreamWrapper {
// avoid event pointer invalidations
std::deque<ze_event_handle_t> implicitEventStack;
More information about the Mlir-commits
mailing list