Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenCL] Fix USM alignment error check to occur always and return nulllptr #2011

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions source/adapters/opencl/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ urUSMHostAlloc(ur_context_handle_t hContext, const ur_usm_desc_t *pUSMDesc,
void *Ptr = nullptr;
uint32_t Alignment = pUSMDesc ? pUSMDesc->align : 0;

if (pUSMDesc && pUSMDesc->align != 0 &&
((pUSMDesc->align & (pUSMDesc->align - 1)) != 0)) {
return UR_RESULT_ERROR_INVALID_VALUE;
}

std::vector<cl_mem_properties_intel> AllocProperties;
if (pUSMDesc && pUSMDesc->pNext) {
UR_RETURN_ON_FAILURE(usmDescToCLMemProperties(
Expand Down Expand Up @@ -130,6 +135,11 @@ urUSMDeviceAlloc(ur_context_handle_t hContext, ur_device_handle_t hDevice,
void *Ptr = nullptr;
uint32_t Alignment = pUSMDesc ? pUSMDesc->align : 0;

if (pUSMDesc && pUSMDesc->align != 0 &&
((pUSMDesc->align & (pUSMDesc->align - 1)) != 0)) {
return UR_RESULT_ERROR_INVALID_VALUE;
}

std::vector<cl_mem_properties_intel> AllocProperties;
if (pUSMDesc && pUSMDesc->pNext) {
UR_RETURN_ON_FAILURE(usmDescToCLMemProperties(
Expand Down Expand Up @@ -173,6 +183,11 @@ urUSMSharedAlloc(ur_context_handle_t hContext, ur_device_handle_t hDevice,
void *Ptr = nullptr;
uint32_t Alignment = pUSMDesc ? pUSMDesc->align : 0;

if (pUSMDesc && pUSMDesc->align != 0 &&
((pUSMDesc->align & (pUSMDesc->align - 1)) != 0)) {
return UR_RESULT_ERROR_INVALID_VALUE;
}

std::vector<cl_mem_properties_intel> AllocProperties;
if (pUSMDesc && pUSMDesc->pNext) {
UR_RETURN_ON_FAILURE(usmDescToCLMemProperties(
Expand Down