From e8b8722190a29fe0867bde73c1eec247b8973cdf Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Wed, 1 May 2024 09:46:16 -0700 Subject: [PATCH 1/9] Return invalid value from USM when alignment not power of 2 --- source/adapters/level_zero/usm.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/source/adapters/level_zero/usm.cpp b/source/adapters/level_zero/usm.cpp index 09e340dfe0..e6dafdecbc 100644 --- a/source/adapters/level_zero/usm.cpp +++ b/source/adapters/level_zero/usm.cpp @@ -381,7 +381,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMDeviceAlloc( // L0 supports alignment up to 64KB and silently ignores higher values. // We flag alignment > 64KB as an invalid value. - if (Alignment > 65536) + // L0 spec says that alignment values that are not powers of 2 are invalid. + if (Alignment > 65536 || Alignment & (Alignment - 1) != 0) return UR_RESULT_ERROR_INVALID_VALUE; ur_platform_handle_t Plt = Device->Platform; @@ -408,11 +409,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMDeviceAlloc( } umf_memory_pool_handle_t hPoolInternal = nullptr; - if (!UseUSMAllocator || - // L0 spec says that allocation fails if Alignment != 2^n, in order to - // keep the same behavior for the allocator, just call L0 API directly and - // return the error code. - ((Alignment & (Alignment - 1)) != 0)) { + if (!UseUSMAllocator) { auto It = Context->DeviceMemProxyPools.find(Device->ZeDevice); if (It == Context->DeviceMemProxyPools.end()) return UR_RESULT_ERROR_INVALID_VALUE; @@ -485,7 +482,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMSharedAlloc( // L0 supports alignment up to 64KB and silently ignores higher values. // We flag alignment > 64KB as an invalid value. - if (Alignment > 65536) + // L0 spec says that alignment values that are not powers of 2 are invalid. + if (Alignment > 65536 || Alignment && (Alignment - 1) != 0) return UR_RESULT_ERROR_INVALID_VALUE; ur_platform_handle_t Plt = Device->Platform; @@ -508,11 +506,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMSharedAlloc( } umf_memory_pool_handle_t hPoolInternal = nullptr; - if (!UseUSMAllocator || - // L0 spec says that allocation fails if Alignment != 2^n, in order to - // keep the same behavior for the allocator, just call L0 API directly and - // return the error code. - ((Alignment & (Alignment - 1)) != 0)) { + if (!UseUSMAllocator) { auto &Allocator = (DeviceReadOnly ? Context->SharedReadOnlyMemProxyPools : Context->SharedMemProxyPools); auto It = Allocator.find(Device->ZeDevice); From 5dbfda03c288d5f22f3354b1abf5da3482a939c2 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Wed, 1 May 2024 11:28:19 -0700 Subject: [PATCH 2/9] Return invalid value from when calling USM alloc with a non-power of 2 alignment value --- source/adapters/level_zero/usm.cpp | 45 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/source/adapters/level_zero/usm.cpp b/source/adapters/level_zero/usm.cpp index e6dafdecbc..c8b71cdfd1 100644 --- a/source/adapters/level_zero/usm.cpp +++ b/source/adapters/level_zero/usm.cpp @@ -308,7 +308,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMHostAlloc( uint32_t Align = USMDesc ? USMDesc->align : 0; // L0 supports alignment up to 64KB and silently ignores higher values. // We flag alignment > 64KB as an invalid value. - if (Align > 65536) + // L0 spec says alignment values that are not powers of 2 are invalid. + if (Align > 65536 || Align && (Align - 1) != 0) return UR_RESULT_ERROR_INVALID_VALUE; ur_platform_handle_t Plt = Context->getPlatform(); @@ -337,32 +338,30 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMHostAlloc( // find the allocator depending on context as we do for Shared and Device // allocations. umf_memory_pool_handle_t hPoolInternal = nullptr; - if (!UseUSMAllocator || - // L0 spec says that allocation fails if Alignment != 2^n, in order to - // keep the same behavior for the allocator, just call L0 API directly and - // return the error code. - ((Align & (Align - 1)) != 0)) { + if (!UseUSMAllocator) hPoolInternal = Context->HostMemProxyPool.get(); - } else if (Pool) { - hPoolInternal = Pool->HostMemPool.get(); - } else { - hPoolInternal = Context->HostMemPool.get(); - } +} +else if (Pool) { + hPoolInternal = Pool->HostMemPool.get(); +} +else { + hPoolInternal = Context->HostMemPool.get(); +} - *RetMem = umfPoolAlignedMalloc(hPoolInternal, Size, Align); - if (*RetMem == nullptr) { - auto umfRet = umfPoolGetLastAllocationError(hPoolInternal); - return umf2urResult(umfRet); - } +*RetMem = umfPoolAlignedMalloc(hPoolInternal, Size, Align); +if (*RetMem == nullptr) { + auto umfRet = umfPoolGetLastAllocationError(hPoolInternal); + return umf2urResult(umfRet); +} - if (IndirectAccessTrackingEnabled) { - // Keep track of all memory allocations in the context - Context->MemAllocs.emplace(std::piecewise_construct, - std::forward_as_tuple(*RetMem), - std::forward_as_tuple(Context)); - } +if (IndirectAccessTrackingEnabled) { + // Keep track of all memory allocations in the context + Context->MemAllocs.emplace(std::piecewise_construct, + std::forward_as_tuple(*RetMem), + std::forward_as_tuple(Context)); +} - return UR_RESULT_SUCCESS; +return UR_RESULT_SUCCESS; } UR_APIEXPORT ur_result_t UR_APICALL urUSMDeviceAlloc( From b604f08177ad7c13153ac862fe34b0848abf60b3 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Wed, 1 May 2024 11:30:03 -0700 Subject: [PATCH 3/9] Return invalid value from when calling USM alloc with a non-power of 2 alignment value --- source/adapters/level_zero/usm.cpp | 38 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/source/adapters/level_zero/usm.cpp b/source/adapters/level_zero/usm.cpp index c8b71cdfd1..76be0cd3c7 100644 --- a/source/adapters/level_zero/usm.cpp +++ b/source/adapters/level_zero/usm.cpp @@ -338,30 +338,28 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMHostAlloc( // find the allocator depending on context as we do for Shared and Device // allocations. umf_memory_pool_handle_t hPoolInternal = nullptr; - if (!UseUSMAllocator) + if (!UseUSMAllocator) { hPoolInternal = Context->HostMemProxyPool.get(); -} -else if (Pool) { - hPoolInternal = Pool->HostMemPool.get(); -} -else { - hPoolInternal = Context->HostMemPool.get(); -} + } else if (Pool) { + hPoolInternal = Pool->HostMemPool.get(); + } else { + hPoolInternal = Context->HostMemPool.get(); + } -*RetMem = umfPoolAlignedMalloc(hPoolInternal, Size, Align); -if (*RetMem == nullptr) { - auto umfRet = umfPoolGetLastAllocationError(hPoolInternal); - return umf2urResult(umfRet); -} + *RetMem = umfPoolAlignedMalloc(hPoolInternal, Size, Align); + if (*RetMem == nullptr) { + auto umfRet = umfPoolGetLastAllocationError(hPoolInternal); + return umf2urResult(umfRet); + } -if (IndirectAccessTrackingEnabled) { - // Keep track of all memory allocations in the context - Context->MemAllocs.emplace(std::piecewise_construct, - std::forward_as_tuple(*RetMem), - std::forward_as_tuple(Context)); -} + if (IndirectAccessTrackingEnabled) { + // Keep track of all memory allocations in the context + Context->MemAllocs.emplace(std::piecewise_construct, + std::forward_as_tuple(*RetMem), + std::forward_as_tuple(Context)); + } -return UR_RESULT_SUCCESS; + return UR_RESULT_SUCCESS; } UR_APIEXPORT ur_result_t UR_APICALL urUSMDeviceAlloc( From cd29bd7ed575b176a2b5be1ff752d41ff16c9a77 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Mon, 27 May 2024 09:24:30 -0700 Subject: [PATCH 4/9] Remove assertions to instead return error code --- source/adapters/opencl/usm.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/source/adapters/opencl/usm.cpp b/source/adapters/opencl/usm.cpp index 3f4382fc0d..ea11bb8752 100644 --- a/source/adapters/opencl/usm.cpp +++ b/source/adapters/opencl/usm.cpp @@ -116,9 +116,11 @@ urUSMHostAlloc(ur_context_handle_t hContext, const ur_usm_desc_t *pUSMDesc, *ppMem = Ptr; - assert((Alignment == 0 || - reinterpret_cast(*ppMem) % Alignment == 0) && - "Allocation not aligned correctly!"); + if (!(Alignment == 0 || + reinterpret_cast(*ppMem) % Alignment == 0)) { + urUSMFree(hContext, Ptr); + return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + } return UR_RESULT_SUCCESS; } @@ -159,9 +161,11 @@ urUSMDeviceAlloc(ur_context_handle_t hContext, ur_device_handle_t hDevice, *ppMem = Ptr; - assert((Alignment == 0 || - reinterpret_cast(*ppMem) % Alignment == 0) && - "Allocation not aligned correctly!"); + if (!(Alignment == 0 || + reinterpret_cast(*ppMem) % Alignment == 0)) { + urUSMFree(hContext, Ptr); + return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + } return UR_RESULT_SUCCESS; } @@ -202,9 +206,11 @@ urUSMSharedAlloc(ur_context_handle_t hContext, ur_device_handle_t hDevice, *ppMem = Ptr; - assert((Alignment == 0 || - reinterpret_cast(*ppMem) % Alignment == 0) && - "Allocation not aligned correctly!"); + if (!(Alignment == 0 || + reinterpret_cast(*ppMem) % Alignment == 0)) { + urUSMFree(hContext, Ptr); + return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + } return UR_RESULT_SUCCESS; } From b8c73e2243fd171ee7da4cb93669763f5e772f2a Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Mon, 27 May 2024 14:15:40 -0700 Subject: [PATCH 5/9] Remove assertions in HIP adapter --- source/adapters/hip/usm.cpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/source/adapters/hip/usm.cpp b/source/adapters/hip/usm.cpp index e871f394f2..440b46763c 100644 --- a/source/adapters/hip/usm.cpp +++ b/source/adapters/hip/usm.cpp @@ -103,7 +103,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMFree(ur_context_handle_t hContext, } } -ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t, +ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t hContext, ur_device_handle_t Device, ur_usm_device_mem_flags_t, size_t Size, [[maybe_unused]] uint32_t Alignment) { @@ -114,7 +114,11 @@ ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t, return Err; } - assert(checkUSMImplAlignment(Alignment, ResultPtr)); + if (!checkUSMImplAlignment(Alignment, ResultPtr)) { + urUSMFree(hContext, *ResultPtr); + return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + } + return UR_RESULT_SUCCESS; } @@ -130,8 +134,11 @@ ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t, return Err; } - assert(checkUSMImplAlignment(Alignment, ResultPtr)); - return UR_RESULT_SUCCESS; + if (!checkUSMImplAlignment(Alignment, ResultPtr)) { + urUSMFree(hContext, *ResultPtr); + return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + } + | return UR_RESULT_SUCCESS; } ur_result_t USMHostAllocImpl(void **ResultPtr, @@ -144,7 +151,10 @@ ur_result_t USMHostAllocImpl(void **ResultPtr, return Err; } - assert(checkUSMImplAlignment(Alignment, ResultPtr)); + if (!checkUSMImplAlignment(Alignment, ResultPtr)) { + urUSMFree(hContext, *ResultPtr); + return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + } return UR_RESULT_SUCCESS; } @@ -166,8 +176,8 @@ urUSMGetMemAllocInfo(ur_context_handle_t hContext, const void *pMem, // pointer not known to the HIP subsystem return ReturnValue(UR_USM_TYPE_UNKNOWN); } - // Direct usage of the function, instead of UR_CHECK_ERROR, so we can get - // the line offset. + // Direct usage of the function, instead of UR_CHECK_ERROR, so we can + // get the line offset. checkErrorUR(Ret, __func__, __LINE__ - 5, __FILE__); // ROCm 6.0.0 introduces hipMemoryTypeUnregistered in the hipMemoryType // enum to mark unregistered allocations (i.e., via system allocators). @@ -376,11 +386,11 @@ bool ur_usm_pool_handle_t_::hasUMFPool(umf_memory_pool_t *umf_pool) { } UR_APIEXPORT ur_result_t UR_APICALL urUSMPoolCreate( - ur_context_handle_t Context, ///< [in] handle of the context object - ur_usm_pool_desc_t - *PoolDesc, ///< [in] pointer to USM pool descriptor. Can be chained with - ///< ::ur_usm_pool_limits_desc_t - ur_usm_pool_handle_t *Pool ///< [out] pointer to USM memory pool + ur_context_handle_t Context, ///< [in] handle of the context object + ur_usm_pool_desc_t *PoolDesc, ///< [in] pointer to USM pool descriptor. + ///< Can be chained with + ///< ::ur_usm_pool_limits_desc_t + ur_usm_pool_handle_t *Pool ///< [out] pointer to USM memory pool ) { // Without pool tracking we can't free pool allocations. #ifdef UMF_ENABLE_POOL_TRACKING From 293565236c0ed775b03e253e4b7189b8acdd1851 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Mon, 27 May 2024 14:18:57 -0700 Subject: [PATCH 6/9] Remove assertions in HIP adapter --- source/adapters/hip/usm.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/adapters/hip/usm.cpp b/source/adapters/hip/usm.cpp index 440b46763c..72a575a6fc 100644 --- a/source/adapters/hip/usm.cpp +++ b/source/adapters/hip/usm.cpp @@ -118,7 +118,6 @@ ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t hContext, urUSMFree(hContext, *ResultPtr); return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; } - return UR_RESULT_SUCCESS; } @@ -138,7 +137,7 @@ ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t, urUSMFree(hContext, *ResultPtr); return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; } - | return UR_RESULT_SUCCESS; + return UR_RESULT_SUCCESS; } ur_result_t USMHostAllocImpl(void **ResultPtr, From e3f526cce70aa29628145c0e8ffe01211d2dbc9e Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Mon, 27 May 2024 14:40:07 -0700 Subject: [PATCH 7/9] Fix compilation errors --- source/adapters/hip/usm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/adapters/hip/usm.cpp b/source/adapters/hip/usm.cpp index 72a575a6fc..d093f4c6f9 100644 --- a/source/adapters/hip/usm.cpp +++ b/source/adapters/hip/usm.cpp @@ -121,7 +121,7 @@ ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t hContext, return UR_RESULT_SUCCESS; } -ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t, +ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t hContext, ur_device_handle_t Device, ur_usm_host_mem_flags_t, ur_usm_device_mem_flags_t, size_t Size, @@ -141,7 +141,7 @@ ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t, } ur_result_t USMHostAllocImpl(void **ResultPtr, - [[maybe_unused]] ur_context_handle_t Context, + [[maybe_unused]] ur_context_handle_t hContext, ur_usm_host_mem_flags_t, size_t Size, [[maybe_unused]] uint32_t Alignment) { try { From 1530cf9d44512e55b326231b8d6118f90224755c Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Mon, 27 May 2024 21:36:40 -0700 Subject: [PATCH 8/9] Update CUDA allocations --- source/adapters/cuda/usm.cpp | 39 +++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/source/adapters/cuda/usm.cpp b/source/adapters/cuda/usm.cpp index 4e6c6898d5..faef029d4d 100644 --- a/source/adapters/cuda/usm.cpp +++ b/source/adapters/cuda/usm.cpp @@ -130,7 +130,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMFree(ur_context_handle_t hContext, return USMFreeImpl(hContext, pMem); } -ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t, +ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t hContext, ur_device_handle_t Device, ur_usm_device_mem_flags_t, size_t Size, uint32_t Alignment) { @@ -141,16 +141,21 @@ ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t, return Err; } + const bool validAlignment = + (Alignment == 0 || + reinterpret_cast(*ResultPtr) % Alignment == 0); #ifdef NDEBUG - std::ignore = Alignment; + if (!validAlignment) { + urUSMFree(hContext, *ResultPtr); + return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + } #else - assert((Alignment == 0 || - reinterpret_cast(*ResultPtr) % Alignment == 0)); + assert(validAlignment); #endif return UR_RESULT_SUCCESS; } -ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t, +ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t hContext, ur_device_handle_t Device, ur_usm_host_mem_flags_t, ur_usm_device_mem_flags_t, size_t Size, @@ -163,16 +168,21 @@ ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t, return Err; } + const bool validAlignment = + (Alignment == 0 || + reinterpret_cast(*ResultPtr) % Alignment == 0); #ifdef NDEBUG - std::ignore = Alignment; + if (!validAlignment) { + urUSMFree(hContext, *ResultPtr); + return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + } #else - assert((Alignment == 0 || - reinterpret_cast(*ResultPtr) % Alignment == 0)); + assert(validAlignment); #endif return UR_RESULT_SUCCESS; } -ur_result_t USMHostAllocImpl(void **ResultPtr, ur_context_handle_t, +ur_result_t USMHostAllocImpl(void **ResultPtr, ur_context_handle_t hContext, ur_usm_host_mem_flags_t, size_t Size, uint32_t Alignment) { try { @@ -181,11 +191,16 @@ ur_result_t USMHostAllocImpl(void **ResultPtr, ur_context_handle_t, return Err; } + const bool validAlignment = + (Alignment == 0 || + reinterpret_cast(*ResultPtr) % Alignment == 0); #ifdef NDEBUG - std::ignore = Alignment; + if (!validAlignment) { + urUSMFree(hContext, *ResultPtr); + return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + } #else - assert((Alignment == 0 || - reinterpret_cast(*ResultPtr) % Alignment == 0)); + assert(validAlignment); #endif return UR_RESULT_SUCCESS; } From 441fdd5b3ecbd1c8ed5e47506a491731c27071e2 Mon Sep 17 00:00:00 2001 From: Lorenc Bushi Date: Wed, 29 May 2024 09:03:09 -0700 Subject: [PATCH 9/9] Replace unsupported alignment error code with invalid value error code --- source/adapters/cuda/usm.cpp | 18 +++--------------- source/adapters/hip/usm.cpp | 6 +++--- source/adapters/opencl/usm.cpp | 6 +++--- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/source/adapters/cuda/usm.cpp b/source/adapters/cuda/usm.cpp index faef029d4d..c0035052d8 100644 --- a/source/adapters/cuda/usm.cpp +++ b/source/adapters/cuda/usm.cpp @@ -144,14 +144,10 @@ ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t hContext, const bool validAlignment = (Alignment == 0 || reinterpret_cast(*ResultPtr) % Alignment == 0); -#ifdef NDEBUG if (!validAlignment) { urUSMFree(hContext, *ResultPtr); - return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + return UR_RESULT_ERROR_INVALID_VALUE; } -#else - assert(validAlignment); -#endif return UR_RESULT_SUCCESS; } @@ -171,14 +167,10 @@ ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t hContext, const bool validAlignment = (Alignment == 0 || reinterpret_cast(*ResultPtr) % Alignment == 0); -#ifdef NDEBUG if (!validAlignment) { urUSMFree(hContext, *ResultPtr); - return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + return UR_RESULT_ERROR_INVALID_VALUE; } -#else - assert(validAlignment); -#endif return UR_RESULT_SUCCESS; } @@ -194,14 +186,10 @@ ur_result_t USMHostAllocImpl(void **ResultPtr, ur_context_handle_t hContext, const bool validAlignment = (Alignment == 0 || reinterpret_cast(*ResultPtr) % Alignment == 0); -#ifdef NDEBUG if (!validAlignment) { urUSMFree(hContext, *ResultPtr); - return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + return UR_RESULT_ERROR_INVALID_VALUE; } -#else - assert(validAlignment); -#endif return UR_RESULT_SUCCESS; } diff --git a/source/adapters/hip/usm.cpp b/source/adapters/hip/usm.cpp index d093f4c6f9..7c4f43c4ac 100644 --- a/source/adapters/hip/usm.cpp +++ b/source/adapters/hip/usm.cpp @@ -116,7 +116,7 @@ ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t hContext, if (!checkUSMImplAlignment(Alignment, ResultPtr)) { urUSMFree(hContext, *ResultPtr); - return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; } @@ -135,7 +135,7 @@ ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t hContext, if (!checkUSMImplAlignment(Alignment, ResultPtr)) { urUSMFree(hContext, *ResultPtr); - return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; } @@ -152,7 +152,7 @@ ur_result_t USMHostAllocImpl(void **ResultPtr, if (!checkUSMImplAlignment(Alignment, ResultPtr)) { urUSMFree(hContext, *ResultPtr); - return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; } diff --git a/source/adapters/opencl/usm.cpp b/source/adapters/opencl/usm.cpp index 6661fd4fa1..8ab868e679 100644 --- a/source/adapters/opencl/usm.cpp +++ b/source/adapters/opencl/usm.cpp @@ -118,7 +118,7 @@ urUSMHostAlloc(ur_context_handle_t hContext, const ur_usm_desc_t *pUSMDesc, if (!(Alignment == 0 || reinterpret_cast(*ppMem) % Alignment == 0)) { urUSMFree(hContext, Ptr); - return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; @@ -163,7 +163,7 @@ urUSMDeviceAlloc(ur_context_handle_t hContext, ur_device_handle_t hDevice, if (!(Alignment == 0 || reinterpret_cast(*ppMem) % Alignment == 0)) { urUSMFree(hContext, Ptr); - return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; @@ -208,7 +208,7 @@ urUSMSharedAlloc(ur_context_handle_t hContext, ur_device_handle_t hDevice, if (!(Alignment == 0 || reinterpret_cast(*ppMem) % Alignment == 0)) { urUSMFree(hContext, Ptr); - return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT; + return UR_RESULT_ERROR_INVALID_VALUE; } return UR_RESULT_SUCCESS; }