Skip to content

Commit c6ce113

Browse files
committed
[L0] Address comments and add detail for SysMan init
Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
1 parent cb7feb1 commit c6ce113

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

source/adapters/level_zero/adapter.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ ur_result_t initPlatforms(PlatformVec &platforms,
9090

9191
ZE2UR_CALL(zeDriverGet, (&ZeDriverCount, ZeDrivers.data()));
9292
for (uint32_t I = 0; I < ZeDriverCount; ++I) {
93-
bool DriverInit = false;
93+
// Keep track of the first platform init for this Driver
94+
bool DriverPlatformInit = false;
9495
ze_device_properties_t device_properties{};
9596
device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
9697
uint32_t ZeDeviceCount = 0;
@@ -102,15 +103,20 @@ ur_result_t initPlatforms(PlatformVec &platforms,
102103
for (uint32_t D = 0; D < ZeDeviceCount; ++D) {
103104
ZE2UR_CALL(zeDeviceGetProperties, (ZeDevices[D], &device_properties));
104105
if (ZE_DEVICE_TYPE_GPU == device_properties.type) {
105-
if (!DriverInit) {
106+
// Check if this driver's platform has already been init.
107+
if (!DriverPlatformInit) {
106108
// If this Driver is a GPU, save it as a usable platform.
107109
UR_CALL(platform->initialize());
108110

109111
// Save a copy in the cache for future uses.
110112
platforms.push_back(std::move(platform));
111-
DriverInit = true;
113+
// Mark this driver's platform as init to prevent additional platforms
114+
// from being created per driver.
115+
DriverPlatformInit = true;
112116
}
113117
if (ZesResult == ZE_RESULT_SUCCESS) {
118+
// Populate the Zes/Ze device mapping for this Ze Device into the last
119+
// added platform which represents the current driver being queried.
114120
ur_zes_device_handle_data_t ZesDeviceData;
115121
zes_uuid_t ZesUUID;
116122
std::memcpy(&ZesUUID, &device_properties.uuid, sizeof(zes_uuid_t));
@@ -235,9 +241,11 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
235241
if (GlobalAdapter->getDeviceByUUIdFunctionPtr &&
236242
GlobalAdapter->getSysManDriversFunctionPtr &&
237243
GlobalAdapter->sysManInitFunctionPtr) {
238-
logger::debug("\nzesInit with flags value of {}\n", static_cast<int>(0));
239-
GlobalAdapter->ZesResult =
240-
ZE_CALL_NOCHECK(GlobalAdapter->sysManInitFunctionPtr, (0));
244+
ze_init_flags_t L0ZesInitFlags = 0;
245+
logger::debug("\nzesInit with flags value of {}\n",
246+
static_cast<int>(L0ZesInitFlags));
247+
GlobalAdapter->ZesResult = ZE_CALL_NOCHECK(
248+
GlobalAdapter->sysManInitFunctionPtr, (L0ZesInitFlags));
241249
} else {
242250
GlobalAdapter->ZesResult = ZE_RESULT_ERROR_UNINITIALIZED;
243251
}

source/adapters/level_zero/device.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,8 @@ ur_result_t urDeviceGetInfo(
749749
case UR_DEVICE_INFO_GLOBAL_MEM_FREE: {
750750
bool SysManEnv = getenv_tobool("ZES_ENABLE_SYSMAN", false);
751751
if ((Device->Platform->ZedeviceToZesDeviceMap.size() == 0) && !SysManEnv) {
752-
setErrorMessage("SysMan support is unavailable on this system. Please "
753-
"check your level zero driver installation.",
754-
UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION,
755-
static_cast<int32_t>(ZE_RESULT_ERROR_UNINITIALIZED));
752+
logger::error("SysMan support is unavailable on this system. Please "
753+
"check your level zero driver installation.");
756754
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
757755
}
758756
// Calculate the global memory size as the max limit that can be reported as

0 commit comments

Comments
 (0)