Skip to content

Commit

Permalink
Merge pull request #2449 from nrspruit/improve_l0_init_checking
Browse files Browse the repository at this point in the history
[L0] Update L0 Init checking to print details in error log
  • Loading branch information
kbenzie committed Dec 16, 2024
1 parent c4b1986 commit 3894890
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
13 changes: 9 additions & 4 deletions source/adapters/level_zero/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//===----------------------------------------------------------------------===//

#include "adapter.hpp"
#include "common.hpp"
#include "ur_level_zero.hpp"
#include <iomanip>

Expand Down Expand Up @@ -162,7 +163,7 @@ ur_result_t initPlatforms(PlatformVec &platforms,
ZE2UR_CALL(zeDriverGet, (&ZeDriverGetCount, ZeDriverGetHandles.data()));
}
if (ZeDriverGetCount == 0 && GlobalAdapter->ZeInitDriversCount == 0) {
logger::debug("\nNo Valid L0 Drivers found.\n");
logger::error("\nNo Valid L0 Drivers found.\n");
return UR_RESULT_SUCCESS;
}

Expand Down Expand Up @@ -376,7 +377,9 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
static_cast<int>(L0InitFlags));
GlobalAdapter->ZeInitResult = ZE_CALL_NOCHECK(zeInit, (L0InitFlags));
if (GlobalAdapter->ZeInitResult != ZE_RESULT_SUCCESS) {
logger::debug("\nzeInit failed with {}\n", GlobalAdapter->ZeInitResult);
const char *ErrorString = "Unknown";
zeParseError(GlobalAdapter->ZeInitResult, ErrorString);
logger::error("\nzeInit failed with {}\n", ErrorString);
}

bool useInitDrivers = false;
Expand Down Expand Up @@ -422,8 +425,9 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
if (GlobalAdapter->ZeInitDriversResult == ZE_RESULT_SUCCESS) {
GlobalAdapter->InitDriversSupported = true;
} else {
logger::debug("\nzeInitDrivers failed with {}\n",
GlobalAdapter->ZeInitDriversResult);
const char *ErrorString = "Unknown";
zeParseError(GlobalAdapter->ZeInitDriversResult, ErrorString);
logger::error("\nzeInitDrivers failed with {}\n", ErrorString);
}
}
}
Expand All @@ -441,6 +445,7 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()

// Absorb the ZE_RESULT_ERROR_UNINITIALIZED and just return 0 Platforms.
if (*GlobalAdapter->ZeResult == ZE_RESULT_ERROR_UNINITIALIZED) {
logger::error("Level Zero Uninitialized\n");
result = std::move(platforms);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ZeUSMImportExtension ZeUSMImport;

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

inline void zeParseError(ze_result_t ZeError, const char *&ErrorString) {
void zeParseError(ze_result_t ZeError, const char *&ErrorString) {
switch (ZeError) {
#define ZE_ERRCASE(ERR) \
case ERR: \
Expand Down
3 changes: 3 additions & 0 deletions source/adapters/level_zero/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ bool setEnvVar(const char *name, const char *value);
// Map Level Zero runtime error code to UR error code.
ur_result_t ze2urResult(ze_result_t ZeResult);

// Parse Level Zero error code and return the error string.
void zeParseError(ze_result_t ZeError, const char *&ErrorString);

// Trace a call to Level-Zero RT
#define ZE2UR_CALL(ZeName, ZeArgs) \
{ \
Expand Down

0 comments on commit 3894890

Please sign in to comment.