Skip to content

Commit

Permalink
Fix unspecified alignment
Browse files Browse the repository at this point in the history
It's plausible that a user will pass a non-null `ur_usm_desc_t` argument
that itself has a zero `align` member. We need to gracefully accept such
a case.
  • Loading branch information
ldrumm committed Aug 29, 2024
1 parent c9999a7 commit 60c9791
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/adapters/native_cpu/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace native_cpu {
static ur_result_t alloc_helper(ur_context_handle_t hContext,
const ur_usm_desc_t *pUSMDesc, size_t size,
void **ppMem, ur_usm_type_t type) {
auto alignment = pUSMDesc ? pUSMDesc->align : 1u;
UR_ASSERT((alignment & (alignment - 1)) == 0, UR_RESULT_ERROR_INVALID_VALUE);
auto alignment = (pUSMDesc && pUSMDesc->align) ? pUSMDesc->align : 1u;
UR_ASSERT(isPowerOf2(alignment), UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT);
UR_ASSERT(ppMem, UR_RESULT_ERROR_INVALID_NULL_POINTER);
// TODO: Check Max size when UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE is implemented
UR_ASSERT(size > 0, UR_RESULT_ERROR_INVALID_USM_SIZE);
Expand Down

0 comments on commit 60c9791

Please sign in to comment.