diff --git a/sycl/plugins/unified_runtime/ur/adapters/cuda/usm.cpp b/sycl/plugins/unified_runtime/ur/adapters/cuda/usm.cpp index 06b955968f19a..d07b7da77fab1 100644 --- a/sycl/plugins/unified_runtime/ur/adapters/cuda/usm.cpp +++ b/sycl/plugins/unified_runtime/ur/adapters/cuda/usm.cpp @@ -24,15 +24,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMHostAlloc( [[maybe_unused]] ur_usm_pool_handle_t pool, size_t size, void **ppMem) { UR_ASSERT(ppMem, UR_RESULT_ERROR_INVALID_NULL_POINTER); UR_ASSERT(hContext, UR_RESULT_ERROR_INVALID_NULL_HANDLE); - - size_t DeviceMaxMemAllocSize = 0; - UR_ASSERT(urDeviceGetInfo(hContext->getDevice(), - UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE, sizeof(size_t), - static_cast(&DeviceMaxMemAllocSize), - nullptr) == UR_RESULT_SUCCESS, - UR_RESULT_ERROR_INVALID_DEVICE); - UR_ASSERT(size > 0 && size <= DeviceMaxMemAllocSize, - UR_RESULT_ERROR_INVALID_USM_SIZE); + UR_ASSERT(!pUSMDesc || (pUSMDesc->align == 0 || + ((pUSMDesc->align & (pUSMDesc->align - 1)) == 0)), + UR_RESULT_ERROR_INVALID_VALUE); ur_result_t Result = UR_RESULT_SUCCESS; try { @@ -42,13 +36,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMHostAlloc( Result = Err; } - UR_ASSERT(!pUSMDesc || (pUSMDesc->align == 0 || - ((pUSMDesc->align & (pUSMDesc->align - 1)) == 0)), - UR_RESULT_ERROR_INVALID_VALUE); - - assert(Result == UR_RESULT_SUCCESS && - (!pUSMDesc || pUSMDesc->align == 0 || - reinterpret_cast(*ppMem) % pUSMDesc->align == 0)); + if (Result == UR_RESULT_SUCCESS) { + assert((!pUSMDesc || pUSMDesc->align == 0 || + reinterpret_cast(*ppMem) % pUSMDesc->align == 0)); + } return Result; } @@ -66,15 +57,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMDeviceAlloc( ((pUSMDesc->align & (pUSMDesc->align - 1)) == 0)), UR_RESULT_ERROR_INVALID_VALUE); - size_t DeviceMaxMemAllocSize = 0; - UR_ASSERT(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE, - sizeof(size_t), - static_cast(&DeviceMaxMemAllocSize), - nullptr) == UR_RESULT_SUCCESS, - UR_RESULT_ERROR_INVALID_DEVICE); - UR_ASSERT(size > 0 && size <= DeviceMaxMemAllocSize, - UR_RESULT_ERROR_INVALID_USM_SIZE); - ur_result_t Result = UR_RESULT_SUCCESS; try { ScopedContext Active(hContext); @@ -83,9 +65,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMDeviceAlloc( return Err; } - assert(Result == UR_RESULT_SUCCESS && - (!pUSMDesc || pUSMDesc->align == 0 || - reinterpret_cast(*ppMem) % pUSMDesc->align == 0)); + if (Result == UR_RESULT_SUCCESS) { + assert((!pUSMDesc || pUSMDesc->align == 0 || + reinterpret_cast(*ppMem) % pUSMDesc->align == 0)); + } return Result; } @@ -103,15 +86,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMSharedAlloc( ((pUSMDesc->align & (pUSMDesc->align - 1)) == 0)), UR_RESULT_ERROR_INVALID_VALUE); - size_t DeviceMaxMemAllocSize = 0; - UR_ASSERT(urDeviceGetInfo(hDevice, UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE, - sizeof(size_t), - static_cast(&DeviceMaxMemAllocSize), - nullptr) == UR_RESULT_SUCCESS, - UR_RESULT_ERROR_INVALID_DEVICE); - UR_ASSERT(size > 0 && size <= DeviceMaxMemAllocSize, - UR_RESULT_ERROR_INVALID_USM_SIZE); - ur_result_t Result = UR_RESULT_SUCCESS; try { ScopedContext Active(hContext); @@ -121,9 +95,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMSharedAlloc( return Err; } - assert(Result == UR_RESULT_SUCCESS && - (!pUSMDesc || pUSMDesc->align == 0 || - reinterpret_cast(*ppMem) % pUSMDesc->align == 0)); + if (Result == UR_RESULT_SUCCESS) { + assert((!pUSMDesc || pUSMDesc->align == 0 || + reinterpret_cast(*ppMem) % pUSMDesc->align == 0)); + } return Result; }