Skip to content

Commit

Permalink
Replace unsupported alignment error code with invalid value error code
Browse files Browse the repository at this point in the history
  • Loading branch information
lbushi25 committed May 29, 2024
1 parent 94012f3 commit 441fdd5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
18 changes: 3 additions & 15 deletions source/adapters/cuda/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,10 @@ ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t hContext,
const bool validAlignment =
(Alignment == 0 ||
reinterpret_cast<std::uintptr_t>(*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;
}

Expand All @@ -171,14 +167,10 @@ ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t hContext,
const bool validAlignment =
(Alignment == 0 ||
reinterpret_cast<std::uintptr_t>(*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;
}

Expand All @@ -194,14 +186,10 @@ ur_result_t USMHostAllocImpl(void **ResultPtr, ur_context_handle_t hContext,
const bool validAlignment =
(Alignment == 0 ||
reinterpret_cast<std::uintptr_t>(*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;
}

Expand Down
6 changes: 3 additions & 3 deletions source/adapters/hip/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions source/adapters/opencl/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ urUSMHostAlloc(ur_context_handle_t hContext, const ur_usm_desc_t *pUSMDesc,
if (!(Alignment == 0 ||
reinterpret_cast<std::uintptr_t>(*ppMem) % Alignment == 0)) {
urUSMFree(hContext, Ptr);
return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT;
return UR_RESULT_ERROR_INVALID_VALUE;
}

return UR_RESULT_SUCCESS;
Expand Down Expand Up @@ -163,7 +163,7 @@ urUSMDeviceAlloc(ur_context_handle_t hContext, ur_device_handle_t hDevice,
if (!(Alignment == 0 ||
reinterpret_cast<std::uintptr_t>(*ppMem) % Alignment == 0)) {
urUSMFree(hContext, Ptr);
return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT;
return UR_RESULT_ERROR_INVALID_VALUE;
}

return UR_RESULT_SUCCESS;
Expand Down Expand Up @@ -208,7 +208,7 @@ urUSMSharedAlloc(ur_context_handle_t hContext, ur_device_handle_t hDevice,
if (!(Alignment == 0 ||
reinterpret_cast<std::uintptr_t>(*ppMem) % Alignment == 0)) {
urUSMFree(hContext, Ptr);
return UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT;
return UR_RESULT_ERROR_INVALID_VALUE;
}
return UR_RESULT_SUCCESS;
}
Expand Down

0 comments on commit 441fdd5

Please sign in to comment.