[llvm] [OFFLOAD][L0] Don't return error on initImpl if library/drivers are missing (PR #210083)
Alex Duran via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 16 08:27:07 PDT 2026
https://github.com/adurang created https://github.com/llvm/llvm-project/pull/210083
When a Level Zero driver is not present in the environment the current behavior makes olInit fail if the level_zero plugin is requested. This changes the behavior to match other plugins where it doesn't fail but return 0 supported devices.
>From dcbe2cbb472f946c88e323c0a7bd2eaf45fa08c1 Mon Sep 17 00:00:00 2001
From: "Duran, Alex" <alejandro.duran at intel.com>
Date: Thu, 16 Jul 2026 08:21:57 -0700
Subject: [PATCH] [OFFLOAD][L0] Don't return error on zeInit failure
When a Level Zero driver is not present in a machine the current
behavior makes olInit fail if the level_zero plugin is requested.
This changes the behavior to match other plugins where it doesn't
fail but return 0 supported devices.
---
.../plugins-nextgen/level_zero/src/L0Plugin.cpp | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/offload/plugins-nextgen/level_zero/src/L0Plugin.cpp b/offload/plugins-nextgen/level_zero/src/L0Plugin.cpp
index c5688e574254c..85733255cebd1 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Plugin.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Plugin.cpp
@@ -26,9 +26,21 @@ using namespace llvm::omp::target;
using namespace error;
Expected<int32_t> LevelZeroPluginTy::findDevices() {
- CALL_ZE_RET_ERROR(zeInit, ZE_INIT_FLAG_GPU_ONLY);
+ ze_result_t RC;
+ CALL_ZE(RC, zeInit, ZE_INIT_FLAG_GPU_ONLY);
+ if (RC != ZE_RESULT_SUCCESS) {
+ ODBG(OLDT_Init) << "Cannot initialize Level Zero library. Error: "
+ << getZeErrorName(RC);
+ return 0;
+ }
+
uint32_t NumDrivers = 0;
- CALL_ZE_RET_ERROR(zeDriverGet, &NumDrivers, nullptr);
+ CALL_ZE(RC, zeDriverGet, &NumDrivers, nullptr);
+ if (RC != ZE_RESULT_SUCCESS) {
+ ODBG(OLDT_Init) << "Error getting number of drivers. Error: "
+ << getZeErrorName(RC);
+ return 0;
+ }
if (NumDrivers == 0) {
ODBG(OLDT_Init) << "Cannot find any drivers.";
return 0;
More information about the llvm-commits
mailing list