Skip to content

Commit

Permalink
Return invalid value from when calling USM alloc with a non-power of …
Browse files Browse the repository at this point in the history
…2 alignment value
  • Loading branch information
lbushi25 committed May 1, 2024
1 parent 5dbfda0 commit b604f08
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions source/adapters/level_zero/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b604f08

Please sign in to comment.