@@ -90,7 +90,8 @@ ur_result_t initPlatforms(PlatformVec &platforms,
90
90
91
91
ZE2UR_CALL (zeDriverGet, (&ZeDriverCount, ZeDrivers.data ()));
92
92
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 ;
94
95
ze_device_properties_t device_properties{};
95
96
device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
96
97
uint32_t ZeDeviceCount = 0 ;
@@ -102,15 +103,20 @@ ur_result_t initPlatforms(PlatformVec &platforms,
102
103
for (uint32_t D = 0 ; D < ZeDeviceCount; ++D) {
103
104
ZE2UR_CALL (zeDeviceGetProperties, (ZeDevices[D], &device_properties));
104
105
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) {
106
108
// If this Driver is a GPU, save it as a usable platform.
107
109
UR_CALL (platform->initialize ());
108
110
109
111
// Save a copy in the cache for future uses.
110
112
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 ;
112
116
}
113
117
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.
114
120
ur_zes_device_handle_data_t ZesDeviceData;
115
121
zes_uuid_t ZesUUID;
116
122
std::memcpy (&ZesUUID, &device_properties.uuid , sizeof (zes_uuid_t ));
@@ -235,9 +241,11 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
235
241
if (GlobalAdapter->getDeviceByUUIdFunctionPtr &&
236
242
GlobalAdapter->getSysManDriversFunctionPtr &&
237
243
GlobalAdapter->sysManInitFunctionPtr ) {
238
- logger::debug (" \n zesInit 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 (" \n zesInit with flags value of {}\n " ,
246
+ static_cast <int >(L0ZesInitFlags));
247
+ GlobalAdapter->ZesResult = ZE_CALL_NOCHECK (
248
+ GlobalAdapter->sysManInitFunctionPtr , (L0ZesInitFlags));
241
249
} else {
242
250
GlobalAdapter->ZesResult = ZE_RESULT_ERROR_UNINITIALIZED;
243
251
}
0 commit comments