@@ -692,8 +692,28 @@ uint32_t DeviceImp::getMaxNumHwThreads() const { return maxNumHwThreads; }
692692
693693const NEO::HardwareInfo &DeviceImp::getHwInfo () const { return neoDevice->getHardwareInfo (); }
694694
695+ // Use this method to reinitialize L0::Device *device, that was created during zeInit, with the help of Device::create
696+ Device *Device::deviceReinit (DriverHandle *driverHandle, L0::Device *device, std::unique_ptr<NEO::Device> &neoDevice, ze_result_t *returnValue) {
697+ const auto rootDeviceIndex = neoDevice->getRootDeviceIndex ();
698+ auto rootDeviceEnvironment = neoDevice->getExecutionEnvironment ()->rootDeviceEnvironments [rootDeviceIndex].get ();
699+ auto pNeoDevice = neoDevice.release ();
700+
701+ auto subDevicesMask = static_cast <uint32_t >(rootDeviceEnvironment->deviceAffinityMask .getGenericSubDevicesMask ().to_ulong ());
702+ return Device::create (driverHandle, pNeoDevice, subDevicesMask, false , returnValue, device);
703+ }
704+
695705Device *Device::create (DriverHandle *driverHandle, NEO::Device *neoDevice, uint32_t currentDeviceMask, bool isSubDevice, ze_result_t *returnValue) {
696- auto device = new DeviceImp;
706+ return Device::create (driverHandle, neoDevice, currentDeviceMask, isSubDevice, returnValue, nullptr );
707+ }
708+
709+ Device *Device::create (DriverHandle *driverHandle, NEO::Device *neoDevice, uint32_t currentDeviceMask, bool isSubDevice, ze_result_t *returnValue, L0::Device *deviceL0) {
710+ L0::DeviceImp *device = nullptr ;
711+ if (deviceL0 == nullptr ) {
712+ device = new DeviceImp;
713+ } else {
714+ device = static_cast <L0::DeviceImp *>(deviceL0);
715+ }
716+
697717 UNRECOVERABLE_IF (device == nullptr );
698718
699719 device->setDriverHandle (driverHandle);
@@ -731,7 +751,7 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
731751 ze_device_handle_t subDevice = Device::create (driverHandle,
732752 device->neoDevice ->getSubDevice (i),
733753 0 ,
734- true , returnValue);
754+ true , returnValue, nullptr );
735755 if (subDevice == nullptr ) {
736756 return nullptr ;
737757 }
@@ -783,10 +803,8 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3
783803 ->notifyNewDevice (osInterface ? osInterface->getDriverModel ()->getDeviceHandle () : 0 );
784804 }
785805
786- if (static_cast <DriverHandleImp *>(driverHandle)->enableSysman && !isSubDevice) {
787- device->setSysmanHandle (L0::SysmanDeviceHandleContext::init (device->toHandle ()));
788- }
789-
806+ device->createSysmanHandle (isSubDevice);
807+ device->resourcesReleased = false ;
790808 return device;
791809}
792810
@@ -801,6 +819,7 @@ void DeviceImp::releaseResources() {
801819 for (uint32_t i = 0 ; i < this ->numSubDevices ; i++) {
802820 delete this ->subDevices [i];
803821 }
822+ this ->subDevices .clear ();
804823 this ->numSubDevices = 0 ;
805824
806825 if (this ->pageFaultCommandList ) {
0 commit comments