@@ -236,18 +236,26 @@ ur_result_t urUSMPoolCreate(
236
236
237
237
ur_result_t
238
238
urUSMPoolRetain (ur_usm_pool_handle_t hPool // /< [in] pointer to USM memory pool
239
- ) {
239
+ ) try {
240
240
hPool->RefCount .increment ();
241
241
return UR_RESULT_SUCCESS;
242
+ } catch (umf_result_t e) {
243
+ return umf::umf2urResult (e);
244
+ } catch (...) {
245
+ return exceptionToResult (std::current_exception ());
242
246
}
243
247
244
248
ur_result_t
245
249
urUSMPoolRelease (ur_usm_pool_handle_t hPool // /< [in] pointer to USM memory pool
246
- ) {
250
+ ) try {
247
251
if (hPool->RefCount .decrementAndTest ()) {
248
252
delete hPool;
249
253
}
250
254
return UR_RESULT_SUCCESS;
255
+ } catch (umf_result_t e) {
256
+ return umf::umf2urResult (e);
257
+ } catch (...) {
258
+ return exceptionToResult (std::current_exception ());
251
259
}
252
260
253
261
ur_result_t urUSMPoolGetInfo (
@@ -258,7 +266,7 @@ ur_result_t urUSMPoolGetInfo(
258
266
// /< property
259
267
size_t
260
268
*pPropSizeRet // /< [out] size in bytes returned in pool property value
261
- ) {
269
+ ) try {
262
270
UrReturnHelper ReturnValue (propSize, pPropValue, pPropSizeRet);
263
271
264
272
switch (propName) {
@@ -272,6 +280,10 @@ ur_result_t urUSMPoolGetInfo(
272
280
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
273
281
}
274
282
}
283
+ } catch (umf_result_t e) {
284
+ return umf::umf2urResult (e);
285
+ } catch (...) {
286
+ return exceptionToResult (std::current_exception ());
275
287
}
276
288
277
289
ur_result_t urUSMDeviceAlloc (
@@ -284,13 +296,17 @@ ur_result_t urUSMDeviceAlloc(
284
296
size_t
285
297
size, // /< [in] size in bytes of the USM memory object to be allocated
286
298
void **ppRetMem // /< [out] pointer to USM device memory object
287
- ) {
299
+ ) try {
288
300
if (!hPool) {
289
301
hPool = hContext->getDefaultUSMPool ();
290
302
}
291
303
292
304
return hPool->allocate (hContext, hDevice, pUSMDesc, UR_USM_TYPE_DEVICE, size,
293
305
ppRetMem);
306
+ } catch (umf_result_t e) {
307
+ return umf::umf2urResult (e);
308
+ } catch (...) {
309
+ return exceptionToResult (std::current_exception ());
294
310
}
295
311
296
312
ur_result_t urUSMSharedAlloc (
@@ -303,13 +319,17 @@ ur_result_t urUSMSharedAlloc(
303
319
size_t
304
320
size, // /< [in] size in bytes of the USM memory object to be allocated
305
321
void **ppRetMem // /< [out] pointer to USM shared memory object
306
- ) {
322
+ ) try {
307
323
if (!hPool) {
308
324
hPool = hContext->getDefaultUSMPool ();
309
325
}
310
326
311
327
return hPool->allocate (hContext, hDevice, pUSMDesc, UR_USM_TYPE_SHARED, size,
312
328
ppRetMem);
329
+ } catch (umf_result_t e) {
330
+ return umf::umf2urResult (e);
331
+ } catch (...) {
332
+ return exceptionToResult (std::current_exception ());
313
333
}
314
334
315
335
ur_result_t urUSMHostAlloc (
@@ -321,21 +341,29 @@ ur_result_t urUSMHostAlloc(
321
341
size_t
322
342
size, // /< [in] size in bytes of the USM memory object to be allocated
323
343
void **ppRetMem // /< [out] pointer to USM host memory object
324
- ) {
344
+ ) try {
325
345
if (!hPool) {
326
346
hPool = hContext->getDefaultUSMPool ();
327
347
}
328
348
329
349
return hPool->allocate (hContext, nullptr , pUSMDesc, UR_USM_TYPE_HOST, size,
330
350
ppRetMem);
351
+ } catch (umf_result_t e) {
352
+ return umf::umf2urResult (e);
353
+ } catch (...) {
354
+ return exceptionToResult (std::current_exception ());
331
355
}
332
356
333
357
ur_result_t
334
358
urUSMFree (ur_context_handle_t hContext, // /< [in] handle of the context object
335
359
void *pMem // /< [in] pointer to USM memory object
336
- ) {
360
+ ) try {
337
361
std::ignore = hContext;
338
362
return umf::umf2urResult (umfFree (pMem));
363
+ } catch (umf_result_t e) {
364
+ return umf::umf2urResult (e);
365
+ } catch (...) {
366
+ return exceptionToResult (std::current_exception ());
339
367
}
340
368
341
369
ur_result_t urUSMGetMemAllocInfo (
@@ -348,7 +376,7 @@ ur_result_t urUSMGetMemAllocInfo(
348
376
void *pPropValue, // /< [out][optional] value of the USM allocation property
349
377
size_t *pPropValueSizeRet // /< [out][optional] bytes returned in USM
350
378
// /< allocation property
351
- ) {
379
+ ) try {
352
380
ze_device_handle_t zeDeviceHandle;
353
381
ZeStruct<ze_memory_allocation_properties_t > zeMemoryAllocationProperties;
354
382
@@ -412,5 +440,9 @@ ur_result_t urUSMGetMemAllocInfo(
412
440
}
413
441
}
414
442
return UR_RESULT_SUCCESS;
443
+ } catch (umf_result_t e) {
444
+ return umf::umf2urResult (e);
445
+ } catch (...) {
446
+ return exceptionToResult (std::current_exception ());
415
447
}
416
448
} // namespace ur::level_zero
0 commit comments