@@ -236,18 +236,26 @@ ur_result_t urUSMPoolCreate(
236236
237237ur_result_t
238238urUSMPoolRetain (ur_usm_pool_handle_t hPool // /< [in] pointer to USM memory pool
239- ) {
239+ ) try {
240240 hPool->RefCount .increment ();
241241 return UR_RESULT_SUCCESS;
242+ } catch (umf_result_t e) {
243+ return umf::umf2urResult (e);
244+ } catch (...) {
245+ return exceptionToResult (std::current_exception ());
242246}
243247
244248ur_result_t
245249urUSMPoolRelease (ur_usm_pool_handle_t hPool // /< [in] pointer to USM memory pool
246- ) {
250+ ) try {
247251 if (hPool->RefCount .decrementAndTest ()) {
248252 delete hPool;
249253 }
250254 return UR_RESULT_SUCCESS;
255+ } catch (umf_result_t e) {
256+ return umf::umf2urResult (e);
257+ } catch (...) {
258+ return exceptionToResult (std::current_exception ());
251259}
252260
253261ur_result_t urUSMPoolGetInfo (
@@ -258,7 +266,7 @@ ur_result_t urUSMPoolGetInfo(
258266 // /< property
259267 size_t
260268 *pPropSizeRet // /< [out] size in bytes returned in pool property value
261- ) {
269+ ) try {
262270 UrReturnHelper ReturnValue (propSize, pPropValue, pPropSizeRet);
263271
264272 switch (propName) {
@@ -272,6 +280,10 @@ ur_result_t urUSMPoolGetInfo(
272280 return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
273281 }
274282 }
283+ } catch (umf_result_t e) {
284+ return umf::umf2urResult (e);
285+ } catch (...) {
286+ return exceptionToResult (std::current_exception ());
275287}
276288
277289ur_result_t urUSMDeviceAlloc (
@@ -284,13 +296,17 @@ ur_result_t urUSMDeviceAlloc(
284296 size_t
285297 size, // /< [in] size in bytes of the USM memory object to be allocated
286298 void **ppRetMem // /< [out] pointer to USM device memory object
287- ) {
299+ ) try {
288300 if (!hPool) {
289301 hPool = hContext->getDefaultUSMPool ();
290302 }
291303
292304 return hPool->allocate (hContext, hDevice, pUSMDesc, UR_USM_TYPE_DEVICE, size,
293305 ppRetMem);
306+ } catch (umf_result_t e) {
307+ return umf::umf2urResult (e);
308+ } catch (...) {
309+ return exceptionToResult (std::current_exception ());
294310}
295311
296312ur_result_t urUSMSharedAlloc (
@@ -303,13 +319,17 @@ ur_result_t urUSMSharedAlloc(
303319 size_t
304320 size, // /< [in] size in bytes of the USM memory object to be allocated
305321 void **ppRetMem // /< [out] pointer to USM shared memory object
306- ) {
322+ ) try {
307323 if (!hPool) {
308324 hPool = hContext->getDefaultUSMPool ();
309325 }
310326
311327 return hPool->allocate (hContext, hDevice, pUSMDesc, UR_USM_TYPE_SHARED, size,
312328 ppRetMem);
329+ } catch (umf_result_t e) {
330+ return umf::umf2urResult (e);
331+ } catch (...) {
332+ return exceptionToResult (std::current_exception ());
313333}
314334
315335ur_result_t urUSMHostAlloc (
@@ -321,21 +341,29 @@ ur_result_t urUSMHostAlloc(
321341 size_t
322342 size, // /< [in] size in bytes of the USM memory object to be allocated
323343 void **ppRetMem // /< [out] pointer to USM host memory object
324- ) {
344+ ) try {
325345 if (!hPool) {
326346 hPool = hContext->getDefaultUSMPool ();
327347 }
328348
329349 return hPool->allocate (hContext, nullptr , pUSMDesc, UR_USM_TYPE_HOST, size,
330350 ppRetMem);
351+ } catch (umf_result_t e) {
352+ return umf::umf2urResult (e);
353+ } catch (...) {
354+ return exceptionToResult (std::current_exception ());
331355}
332356
333357ur_result_t
334358urUSMFree (ur_context_handle_t hContext, // /< [in] handle of the context object
335359 void *pMem // /< [in] pointer to USM memory object
336- ) {
360+ ) try {
337361 std::ignore = hContext;
338362 return umf::umf2urResult (umfFree (pMem));
363+ } catch (umf_result_t e) {
364+ return umf::umf2urResult (e);
365+ } catch (...) {
366+ return exceptionToResult (std::current_exception ());
339367}
340368
341369ur_result_t urUSMGetMemAllocInfo (
@@ -348,7 +376,7 @@ ur_result_t urUSMGetMemAllocInfo(
348376 void *pPropValue, // /< [out][optional] value of the USM allocation property
349377 size_t *pPropValueSizeRet // /< [out][optional] bytes returned in USM
350378 // /< allocation property
351- ) {
379+ ) try {
352380 ze_device_handle_t zeDeviceHandle;
353381 ZeStruct<ze_memory_allocation_properties_t > zeMemoryAllocationProperties;
354382
@@ -412,5 +440,9 @@ ur_result_t urUSMGetMemAllocInfo(
412440 }
413441 }
414442 return UR_RESULT_SUCCESS;
443+ } catch (umf_result_t e) {
444+ return umf::umf2urResult (e);
445+ } catch (...) {
446+ return exceptionToResult (std::current_exception ());
415447}
416448} // namespace ur::level_zero
0 commit comments