Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions unified-runtime/source/adapters/level_zero/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,25 +178,41 @@ ur_result_t initPlatforms(ur_adapter_handle_t_ *adapter, PlatformVec &platforms,
ZeDrivers.assign(ZeInitDriversHandles.begin(), ZeInitDriversHandles.end());
if (ZeDriverGetCount > 0 && adapter->ZeInitDriversCount > 0) {
for (uint32_t X = 0; X < adapter->ZeInitDriversCount; ++X) {
// zeDriverGet and zeInitDrivers can return the driver handles in
// reverse order based on driver ordering causing an issue if the
// drivers are expected to be in the same order. To resolve, this loop
// checks if the driver from zeDriverGet already exists in zeInitDrivers
// and only adds it if it is not found.
bool unMatchedDriverHandle = false;
ze_driver_handle_t driverGetHandle = nullptr;
for (uint32_t Y = 0; Y < ZeDriverGetCount; ++Y) {
unMatchedDriverHandle = true;
ZeStruct<ze_driver_properties_t> ZeDriverGetProperties;
ZeStruct<ze_driver_properties_t> ZeInitDriverProperties;
ZE2UR_CALL(zeDriverGetProperties,
(ZeDriverGetHandles[Y], &ZeDriverGetProperties));
ZE2UR_CALL(zeDriverGetProperties,
(ZeInitDriversHandles[X], &ZeInitDriverProperties));
// If zeDriverGet driver is different from zeInitDriver driver, add it
// to the list. This allows for older drivers to be used alongside
// newer drivers.
if (ZeDriverGetProperties.driverVersion !=
driverGetHandle = ZeDriverGetHandles[Y];
// If zeDriverGet driver is the same version as zeInitDriver driver,
// then do not add it again.
if (ZeDriverGetProperties.driverVersion ==
ZeInitDriverProperties.driverVersion) {
UR_LOG(DEBUG,
"\nzeDriverHandle {} added to the zeInitDrivers list "
"of possible handles.\n",
"\nzeDriverHandle {} matched between zeDriverGet and "
"zeInitDrivers. Not adding duplicate driver to list\n",
ZeDriverGetHandles[Y]);
ZeDrivers.push_back(ZeDriverGetHandles[Y]);
unMatchedDriverHandle = false;
break;
}
}
if (unMatchedDriverHandle) {
UR_LOG(DEBUG,
"\nzeDriverHandle {} not found in zeInitDrivers. Adding to "
"driver list.\n",
driverGetHandle);
ZeDrivers.push_back(driverGetHandle);
}
}
}
} else {
Expand Down