[Mlir-commits] [mlir] [mlir][SYCL] Fail init errors cleanly instead of `abort`ing (PR #192979)
Zmicier Prybysh
llvmlistbot at llvm.org
Tue May 5 09:17:44 PDT 2026
https://github.com/dimp-pl updated https://github.com/llvm/llvm-project/pull/192979
>From e3b4278cb18da1b7005b9e82073e674edc18d5a8 Mon Sep 17 00:00:00 2001
From: Zmicier Prybysh <zprybysh at baylibre.com>
Date: Sun, 19 Apr 2026 15:29:44 +0200
Subject: [PATCH 1/2] [mlir][SYCL] Fail init errors cleanly instead of
`abort`ing
Fixes #182807.
When the SYCL runtime wrapper is loaded on a host without a Level-Zero
backend, `getDefaultDevice()` throws an `std::runtime_error`,
`catchAll` catches it, and calls `abort()`, which results in a
"PLEASE submit a bug report" stack dump, which is not correct for
this kind of crash.
`catchAll` now writes to stderr and terminates via
`std::exit(EXIT_FAILURE)`, yielding a clean exit code 1 with no
crash dump. The "getDefaultDevice failed" message is also
replaced with a (hopefully) better one.
---
mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp b/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp
index d4f557cda9678..932a08b3c22d2 100644
--- a/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp
+++ b/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp
@@ -27,13 +27,13 @@ auto catchAll(F &&func) {
try {
return func();
} catch (const std::exception &e) {
- fprintf(stdout, "An exception was thrown: %s\n", e.what());
- fflush(stdout);
- abort();
+ fprintf(stderr, "SYCL runtime error: %s\n", e.what());
+ fflush(stderr);
+ std::exit(EXIT_FAILURE);
} catch (...) {
- fprintf(stdout, "An unknown exception was thrown\n");
- fflush(stdout);
- abort();
+ fprintf(stderr, "SYCL runtime error: unknown exception was thrown\n");
+ fflush(stderr);
+ std::exit(EXIT_FAILURE);
}
}
@@ -64,7 +64,9 @@ static sycl::device getDefaultDevice() {
isDeviceInitialised = true;
return syclDevice;
}
- throw std::runtime_error("getDefaultDevice failed");
+ throw std::runtime_error(
+ "no Level-Zero SYCL platform found; the MLIR SYCL runtime wrapper "
+ "currently requires a Level-Zero backend");
} else {
return syclDevice;
}
>From dc62337f4fa7b2db0d4c67dd89efd208bf012d05 Mon Sep 17 00:00:00 2001
From: Zmicier Prybysh <zprybysh at baylibre.com>
Date: Tue, 5 May 2026 18:17:09 +0200
Subject: [PATCH 2/2] Address review
---
mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp b/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp
index 932a08b3c22d2..d93aadb098b2e 100644
--- a/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp
+++ b/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp
@@ -10,6 +10,8 @@
//
//===----------------------------------------------------------------------===//
+#include <cstdlib>
+
#include <level_zero/ze_api.h>
#include <sycl/ext/oneapi/backend/level_zero.hpp>
#include <sycl/sycl.hpp>
@@ -41,8 +43,8 @@ auto catchAll(F &&func) {
{ \
ze_result_t status = (call); \
if (status != ZE_RESULT_SUCCESS) { \
- fprintf(stdout, "L0 error %d\n", status); \
- fflush(stdout); \
+ fprintf(stderr, "L0 error %d\n", status); \
+ fflush(stderr); \
abort(); \
} \
}
More information about the Mlir-commits
mailing list