Skip to content

[SYCL][UR][Bindless][L0] Fix cherry-pick of linear mem interop patch #19194

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

Open
wants to merge 1 commit into
base: sycl-rel-6_2
Choose a base branch
from
Open
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
16 changes: 5 additions & 11 deletions unified-runtime/source/adapters/level_zero/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,6 @@ ur_result_t urBindlessImagesMapExternalArrayExp(
(hContext->ZeContext, hDevice->ZeDevice, ZeImage));
UR_CALL(createUrMemFromZeImage(hContext, ZeImage, /*OwnZeMemHandle*/ true,
ZeImageDesc, phImageMem));
externalMemoryData->urMemoryHandle =
reinterpret_cast<ur_mem_handle_t>(*phImageMem);
return UR_RESULT_SUCCESS;
}

Expand All @@ -733,7 +731,7 @@ ur_result_t urBindlessImagesMapExternalLinearMemoryExp(
uint64_t size, ur_exp_external_mem_handle_t hExternalMem, void **phRetMem) {
UR_ASSERT(hContext && hDevice && hExternalMem,
UR_RESULT_ERROR_INVALID_NULL_HANDLE);
UR_ASSERT(offset && size, UR_RESULT_ERROR_INVALID_BUFFER_SIZE);
UR_ASSERT(size, UR_RESULT_ERROR_INVALID_BUFFER_SIZE);

struct ur_ze_external_memory_data *externalMemoryData =
reinterpret_cast<ur_ze_external_memory_data *>(hExternalMem);
Expand All @@ -746,24 +744,22 @@ ur_result_t urBindlessImagesMapExternalLinearMemoryExp(
allocDesc.pNext = externalMemoryData->importExtensionDesc;
void *mappedMemory;

ze_result_t zeResult = zeMemAllocDevice(hContext->ZeContext, &allocDesc, size,
1, hDevice->ZeDevice, &mappedMemory);
ze_result_t zeResult = ZE_CALL_NOCHECK(
zeMemAllocDevice, (hContext->getZeHandle(), &allocDesc, size, 0,
hDevice->ZeDevice, &mappedMemory));
if (zeResult != ZE_RESULT_SUCCESS) {
return UR_RESULT_ERROR_OUT_OF_RESOURCES;
}

zeResult = zeContextMakeMemoryResident(hContext->ZeContext, hDevice->ZeDevice,
mappedMemory, size);
if (zeResult != ZE_RESULT_SUCCESS) {
zeMemFree(hContext->ZeContext, mappedMemory);
ZE_CALL_NOCHECK(zeMemFree, (hContext->getZeHandle(), mappedMemory));
return UR_RESULT_ERROR_UNKNOWN;
}
*phRetMem = reinterpret_cast<void *>(
reinterpret_cast<uintptr_t>(mappedMemory) + offset);

externalMemoryData->urMemoryHandle =
reinterpret_cast<ur_mem_handle_t>(*phRetMem);

return UR_RESULT_SUCCESS;
}

Expand All @@ -787,8 +783,6 @@ ur_result_t urBindlessImagesReleaseExternalMemoryExp(
struct ur_ze_external_memory_data *externalMemoryData =
reinterpret_cast<ur_ze_external_memory_data *>(hExternalMem);

UR_CALL(ur::level_zero::urMemRelease(externalMemoryData->urMemoryHandle));

switch (externalMemoryData->type) {
case UR_ZE_EXTERNAL_OPAQUE_FD:
delete (reinterpret_cast<ze_external_memory_import_fd_t *>(
Expand Down
Loading