Skip to content

Commit df87c03

Browse files
authored
[UR][CUDA][HIP] Remove unnecessary USM exception wrapper (#18013)
There's no need for a wrapper here we can directly throw `ur_result_t`.
1 parent e9544da commit df87c03

File tree

4 files changed

+10
-28
lines changed

4 files changed

+10
-28
lines changed

unified-runtime/source/adapters/cuda/usm.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context,
301301
break;
302302
}
303303
default: {
304-
throw UsmAllocationException(UR_RESULT_ERROR_INVALID_ARGUMENT);
304+
throw UR_RESULT_ERROR_INVALID_ARGUMENT;
305305
}
306306
}
307307
pNext = BaseDesc->pNext;
@@ -353,8 +353,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMPoolCreate(
353353
try {
354354
*Pool = reinterpret_cast<ur_usm_pool_handle_t>(
355355
new ur_usm_pool_handle_t_(Context, PoolDesc));
356-
} catch (const UsmAllocationException &Ex) {
357-
return Ex.getError();
356+
} catch (ur_result_t e) {
357+
return e;
358358
} catch (umf_result_t e) {
359359
return umf::umf2urResult(e);
360360
} catch (...) {
@@ -412,7 +412,7 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context,
412412
ur_usm_pool_desc_t *PoolDesc)
413413
: Context{Context}, Device{Device} {
414414
if (!(PoolDesc->flags & UR_USM_POOL_FLAG_USE_NATIVE_MEMORY_POOL_EXP))
415-
throw UsmAllocationException(UR_RESULT_ERROR_INVALID_ARGUMENT);
415+
throw UR_RESULT_ERROR_INVALID_ARGUMENT;
416416

417417
CUmemPoolProps MemPoolProps{};
418418
size_t threshold = 0;
@@ -451,7 +451,7 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context,
451451
break;
452452
}
453453
default: {
454-
throw UsmAllocationException(UR_RESULT_ERROR_INVALID_ARGUMENT);
454+
throw UR_RESULT_ERROR_INVALID_ARGUMENT;
455455
}
456456
}
457457
pNext = BaseDesc->pNext;
@@ -487,8 +487,8 @@ urUSMPoolCreateExp(ur_context_handle_t Context, ur_device_handle_t Device,
487487
try {
488488
*pPool = reinterpret_cast<ur_usm_pool_handle_t>(
489489
new ur_usm_pool_handle_t_(Context, Device, pPoolDesc));
490-
} catch (const UsmAllocationException &Ex) {
491-
return Ex.getError();
490+
} catch (ur_result_t e) {
491+
return e;
492492
} catch (...) {
493493
return UR_RESULT_ERROR_UNKNOWN;
494494
}

unified-runtime/source/adapters/cuda/usm.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ struct ur_usm_pool_handle_t_ {
5757
CUmemoryPool getCudaPool() { return CUmemPool; };
5858
};
5959

60-
// Exception type to pass allocation errors
61-
class UsmAllocationException {
62-
const ur_result_t Error;
63-
64-
public:
65-
UsmAllocationException(ur_result_t Err) : Error{Err} {}
66-
ur_result_t getError() const { return Error; }
67-
};
68-
6960
ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t Context,
7061
ur_device_handle_t Device,
7162
ur_usm_device_mem_flags_t Flags, size_t Size,

unified-runtime/source/adapters/hip/usm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ ur_usm_pool_handle_t_::ur_usm_pool_handle_t_(ur_context_handle_t Context,
363363
break;
364364
}
365365
default: {
366-
throw UsmAllocationException(UR_RESULT_ERROR_INVALID_ARGUMENT);
366+
throw UR_RESULT_ERROR_INVALID_ARGUMENT;
367367
}
368368
}
369369
pNext = BaseDesc->pNext;
@@ -424,8 +424,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMPoolCreate(
424424
try {
425425
*Pool = reinterpret_cast<ur_usm_pool_handle_t>(
426426
new ur_usm_pool_handle_t_(Context, PoolDesc));
427-
} catch (const UsmAllocationException &Ex) {
428-
return Ex.getError();
427+
} catch (ur_result_t e) {
428+
return e;
429429
} catch (umf_result_t e) {
430430
return umf::umf2urResult(e);
431431
} catch (...) {

unified-runtime/source/adapters/hip/usm.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ struct ur_usm_pool_handle_t_ {
3939
bool hasUMFPool(umf_memory_pool_t *umf_pool);
4040
};
4141

42-
// Exception type to pass allocation errors
43-
class UsmAllocationException {
44-
const ur_result_t Error;
45-
46-
public:
47-
UsmAllocationException(ur_result_t Err) : Error{Err} {}
48-
ur_result_t getError() const { return Error; }
49-
};
50-
5142
// Implements memory allocation via driver API for USM allocator interface
5243
class USMMemoryProvider {
5344
private:

0 commit comments

Comments
 (0)