@@ -136,8 +136,6 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
136136 return ZE_RESULT_SUCCESS;
137137 }
138138
139- neoDevice = this ->driverHandle ->devices [0 ]->getNEODevice ();
140-
141139 if (lookupTable.relaxedSizeAllowed == false &&
142140 (size > neoDevice->getDeviceInfo ().maxMemAllocSize )) {
143141 *ptr = nullptr ;
@@ -155,8 +153,6 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
155153 return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
156154 }
157155
158- neoDevice = Device::fromHandle (hDevice)->getNEODevice ();
159-
160156 deviceBitfields[rootDeviceIndex] = neoDevice->getDeviceBitfield ();
161157
162158 NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties (InternalMemoryType::DEVICE_UNIFIED_MEMORY, this ->driverHandle ->rootDeviceIndices , deviceBitfields);
@@ -183,6 +179,12 @@ ze_result_t ContextImp::allocSharedMem(ze_device_handle_t hDevice,
183179 size_t size,
184180 size_t alignment,
185181 void **ptr) {
182+
183+ auto neoDevice = this ->devices .begin ()->second ->getNEODevice ();
184+ if (hDevice != nullptr ) {
185+ neoDevice = Device::fromHandle (hDevice)->getNEODevice ();
186+ }
187+
186188 bool relaxedSizeAllowed = NEO::DebugManager.flags .AllowUnrestrictedSize .get ();
187189 if (deviceDesc->pNext ) {
188190 const ze_base_desc_t *extendedDesc = reinterpret_cast <const ze_base_desc_t *>(deviceDesc->pNext );
@@ -196,14 +198,12 @@ ze_result_t ContextImp::allocSharedMem(ze_device_handle_t hDevice,
196198 }
197199 }
198200
199- auto neoDevice = this ->devices .begin ()->second ->getNEODevice ();
200201 if (relaxedSizeAllowed == false &&
201202 (size > neoDevice->getDeviceInfo ().maxMemAllocSize )) {
202203 *ptr = nullptr ;
203204 return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
204205 }
205206
206- neoDevice = this ->driverHandle ->devices [0 ]->getNEODevice ();
207207 uint64_t globalMemSize = neoDevice->getDeviceInfo ().globalMemSize ;
208208
209209 uint32_t numSubDevices = neoDevice->getNumGenericSubDevices ();
@@ -216,7 +216,6 @@ ze_result_t ContextImp::allocSharedMem(ze_device_handle_t hDevice,
216216 return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
217217 }
218218
219- neoDevice = this ->devices .begin ()->second ->getNEODevice ();
220219 auto deviceBitfields = this ->deviceBitfields ;
221220 NEO::Device *unifiedMemoryPropertiesDevice = nullptr ;
222221 if (hDevice) {
0 commit comments