@@ -136,8 +136,6 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
136
136
return ZE_RESULT_SUCCESS;
137
137
}
138
138
139
- neoDevice = this ->driverHandle ->devices [0 ]->getNEODevice ();
140
-
141
139
if (lookupTable.relaxedSizeAllowed == false &&
142
140
(size > neoDevice->getDeviceInfo ().maxMemAllocSize )) {
143
141
*ptr = nullptr ;
@@ -155,8 +153,6 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
155
153
return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
156
154
}
157
155
158
- neoDevice = Device::fromHandle (hDevice)->getNEODevice ();
159
-
160
156
deviceBitfields[rootDeviceIndex] = neoDevice->getDeviceBitfield ();
161
157
162
158
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,
183
179
size_t size,
184
180
size_t alignment,
185
181
void **ptr) {
182
+
183
+ auto neoDevice = this ->devices .begin ()->second ->getNEODevice ();
184
+ if (hDevice != nullptr ) {
185
+ neoDevice = Device::fromHandle (hDevice)->getNEODevice ();
186
+ }
187
+
186
188
bool relaxedSizeAllowed = NEO::DebugManager.flags .AllowUnrestrictedSize .get ();
187
189
if (deviceDesc->pNext ) {
188
190
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,
196
198
}
197
199
}
198
200
199
- auto neoDevice = this ->devices .begin ()->second ->getNEODevice ();
200
201
if (relaxedSizeAllowed == false &&
201
202
(size > neoDevice->getDeviceInfo ().maxMemAllocSize )) {
202
203
*ptr = nullptr ;
203
204
return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
204
205
}
205
206
206
- neoDevice = this ->driverHandle ->devices [0 ]->getNEODevice ();
207
207
uint64_t globalMemSize = neoDevice->getDeviceInfo ().globalMemSize ;
208
208
209
209
uint32_t numSubDevices = neoDevice->getNumGenericSubDevices ();
@@ -216,7 +216,6 @@ ze_result_t ContextImp::allocSharedMem(ze_device_handle_t hDevice,
216
216
return ZE_RESULT_ERROR_UNSUPPORTED_SIZE;
217
217
}
218
218
219
- neoDevice = this ->devices .begin ()->second ->getNEODevice ();
220
219
auto deviceBitfields = this ->deviceBitfields ;
221
220
NEO::Device *unifiedMemoryPropertiesDevice = nullptr ;
222
221
if (hDevice) {
0 commit comments