@@ -192,8 +192,14 @@ static ur_result_t USMDeviceAllocImpl(void **ResultPtr,
192
192
reinterpret_cast <std::uintptr_t >(*ResultPtr) % Alignment == 0 ,
193
193
UR_RESULT_ERROR_INVALID_VALUE);
194
194
195
- USMAllocationMakeResident (USMDeviceAllocationForceResidency, Context, Device,
196
- *ResultPtr, Size);
195
+ // TODO: Return any non-success result from USMAllocationMakeResident once
196
+ // oneapi-src/level-zero-spec#240 is resolved.
197
+ auto Result = USMAllocationMakeResident (USMDeviceAllocationForceResidency,
198
+ Context, Device, *ResultPtr, Size);
199
+ if (Result == UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY ||
200
+ Result == UR_RESULT_ERROR_OUT_OF_HOST_MEMORY) {
201
+ return Result;
202
+ }
197
203
return UR_RESULT_SUCCESS;
198
204
}
199
205
@@ -225,8 +231,14 @@ static ur_result_t USMSharedAllocImpl(void **ResultPtr,
225
231
reinterpret_cast <std::uintptr_t >(*ResultPtr) % Alignment == 0 ,
226
232
UR_RESULT_ERROR_INVALID_VALUE);
227
233
228
- USMAllocationMakeResident (USMSharedAllocationForceResidency, Context, Device,
229
- *ResultPtr, Size);
234
+ // TODO: Return any non-success result from USMAllocationMakeResident once
235
+ // oneapi-src/level-zero-spec#240 is resolved.
236
+ auto Result = USMAllocationMakeResident (USMSharedAllocationForceResidency,
237
+ Context, Device, *ResultPtr, Size);
238
+ if (Result == UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY ||
239
+ Result == UR_RESULT_ERROR_OUT_OF_HOST_MEMORY) {
240
+ return Result;
241
+ }
230
242
231
243
// TODO: Handle PI_MEM_ALLOC_DEVICE_READ_ONLY.
232
244
return UR_RESULT_SUCCESS;
@@ -247,8 +259,14 @@ static ur_result_t USMHostAllocImpl(void **ResultPtr,
247
259
reinterpret_cast <std::uintptr_t >(*ResultPtr) % Alignment == 0 ,
248
260
UR_RESULT_ERROR_INVALID_VALUE);
249
261
250
- USMAllocationMakeResident (USMHostAllocationForceResidency, Context, nullptr ,
251
- *ResultPtr, Size);
262
+ // TODO: Return any non-success result from USMAllocationMakeResident once
263
+ // oneapi-src/level-zero-spec#240 is resolved.
264
+ auto Result = USMAllocationMakeResident (USMHostAllocationForceResidency,
265
+ Context, nullptr , *ResultPtr, Size);
266
+ if (Result == UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY ||
267
+ Result == UR_RESULT_ERROR_OUT_OF_HOST_MEMORY) {
268
+ return Result;
269
+ }
252
270
return UR_RESULT_SUCCESS;
253
271
}
254
272
0 commit comments