Skip to content

Commit 94716fc

Browse files
authored
Merge pull request #2449 from nrspruit/improve_l0_init_checking
[L0] Update L0 Init checking to print details in error log
2 parents d9c446b + 64ae812 commit 94716fc

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

source/adapters/level_zero/adapter.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//===----------------------------------------------------------------------===//
1010

1111
#include "adapter.hpp"
12+
#include "common.hpp"
1213
#include "ur_level_zero.hpp"
1314
#include <iomanip>
1415

@@ -162,7 +163,7 @@ ur_result_t initPlatforms(PlatformVec &platforms,
162163
ZE2UR_CALL(zeDriverGet, (&ZeDriverGetCount, ZeDriverGetHandles.data()));
163164
}
164165
if (ZeDriverGetCount == 0 && GlobalAdapter->ZeInitDriversCount == 0) {
165-
logger::debug("\nNo Valid L0 Drivers found.\n");
166+
logger::error("\nNo Valid L0 Drivers found.\n");
166167
return UR_RESULT_SUCCESS;
167168
}
168169

@@ -376,7 +377,9 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
376377
static_cast<int>(L0InitFlags));
377378
GlobalAdapter->ZeInitResult = ZE_CALL_NOCHECK(zeInit, (L0InitFlags));
378379
if (GlobalAdapter->ZeInitResult != ZE_RESULT_SUCCESS) {
379-
logger::debug("\nzeInit failed with {}\n", GlobalAdapter->ZeInitResult);
380+
const char *ErrorString = "Unknown";
381+
zeParseError(GlobalAdapter->ZeInitResult, ErrorString);
382+
logger::error("\nzeInit failed with {}\n", ErrorString);
380383
}
381384

382385
bool useInitDrivers = false;
@@ -422,8 +425,9 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
422425
if (GlobalAdapter->ZeInitDriversResult == ZE_RESULT_SUCCESS) {
423426
GlobalAdapter->InitDriversSupported = true;
424427
} else {
425-
logger::debug("\nzeInitDrivers failed with {}\n",
426-
GlobalAdapter->ZeInitDriversResult);
428+
const char *ErrorString = "Unknown";
429+
zeParseError(GlobalAdapter->ZeInitDriversResult, ErrorString);
430+
logger::error("\nzeInitDrivers failed with {}\n", ErrorString);
427431
}
428432
}
429433
}
@@ -441,6 +445,7 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
441445

442446
// Absorb the ZE_RESULT_ERROR_UNINITIALIZED and just return 0 Platforms.
443447
if (*GlobalAdapter->ZeResult == ZE_RESULT_ERROR_UNINITIALIZED) {
448+
logger::error("Level Zero Uninitialized\n");
444449
result = std::move(platforms);
445450
return;
446451
}

source/adapters/level_zero/common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ZeUSMImportExtension ZeUSMImport;
8888

8989
std::map<std::string, int> *ZeCallCount = nullptr;
9090

91-
inline void zeParseError(ze_result_t ZeError, const char *&ErrorString) {
91+
void zeParseError(ze_result_t ZeError, const char *&ErrorString) {
9292
switch (ZeError) {
9393
#define ZE_ERRCASE(ERR) \
9494
case ERR: \

source/adapters/level_zero/common.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ bool setEnvVar(const char *name, const char *value);
340340
// Map Level Zero runtime error code to UR error code.
341341
ur_result_t ze2urResult(ze_result_t ZeResult);
342342

343+
// Parse Level Zero error code and return the error string.
344+
void zeParseError(ze_result_t ZeError, const char *&ErrorString);
345+
343346
// Trace a call to Level-Zero RT
344347
#define ZE2UR_CALL(ZeName, ZeArgs) \
345348
{ \

0 commit comments

Comments
 (0)