@@ -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 (" \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));
241249 } else {
242250 GlobalAdapter->ZesResult = ZE_RESULT_ERROR_UNINITIALIZED;
243251 }
0 commit comments