Skip to content

Commit fb11f80

Browse files
committed
[SYCL][UR][Bindless][L0] Fix cherry-pick of linear mem interop patch
This patch fixes the bad cherry pick of intel#18353.
1 parent 65489c8 commit fb11f80

File tree

1 file changed

+5
-11
lines changed
  • unified-runtime/source/adapters/level_zero

1 file changed

+5
-11
lines changed

unified-runtime/source/adapters/level_zero/image.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,6 @@ ur_result_t urBindlessImagesMapExternalArrayExp(
723723
(hContext->ZeContext, hDevice->ZeDevice, ZeImage));
724724
UR_CALL(createUrMemFromZeImage(hContext, ZeImage, /*OwnZeMemHandle*/ true,
725725
ZeImageDesc, phImageMem));
726-
externalMemoryData->urMemoryHandle =
727-
reinterpret_cast<ur_mem_handle_t>(*phImageMem);
728726
return UR_RESULT_SUCCESS;
729727
}
730728

@@ -733,7 +731,7 @@ ur_result_t urBindlessImagesMapExternalLinearMemoryExp(
733731
uint64_t size, ur_exp_external_mem_handle_t hExternalMem, void **phRetMem) {
734732
UR_ASSERT(hContext && hDevice && hExternalMem,
735733
UR_RESULT_ERROR_INVALID_NULL_HANDLE);
736-
UR_ASSERT(offset && size, UR_RESULT_ERROR_INVALID_BUFFER_SIZE);
734+
UR_ASSERT(size, UR_RESULT_ERROR_INVALID_BUFFER_SIZE);
737735

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

749-
ze_result_t zeResult = zeMemAllocDevice(hContext->ZeContext, &allocDesc, size,
750-
1, hDevice->ZeDevice, &mappedMemory);
747+
ze_result_t zeResult = ZE_CALL_NOCHECK(
748+
zeMemAllocDevice, (hContext->getZeHandle(), &allocDesc, size, 0,
749+
hDevice->ZeDevice, &mappedMemory));
751750
if (zeResult != ZE_RESULT_SUCCESS) {
752751
return UR_RESULT_ERROR_OUT_OF_RESOURCES;
753752
}
754753

755754
zeResult = zeContextMakeMemoryResident(hContext->ZeContext, hDevice->ZeDevice,
756755
mappedMemory, size);
757756
if (zeResult != ZE_RESULT_SUCCESS) {
758-
zeMemFree(hContext->ZeContext, mappedMemory);
757+
ZE_CALL_NOCHECK(zeMemFree, (hContext->getZeHandle(), mappedMemory));
759758
return UR_RESULT_ERROR_UNKNOWN;
760759
}
761760
*phRetMem = reinterpret_cast<void *>(
762761
reinterpret_cast<uintptr_t>(mappedMemory) + offset);
763762

764-
externalMemoryData->urMemoryHandle =
765-
reinterpret_cast<ur_mem_handle_t>(*phRetMem);
766-
767763
return UR_RESULT_SUCCESS;
768764
}
769765

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

790-
UR_CALL(ur::level_zero::urMemRelease(externalMemoryData->urMemoryHandle));
791-
792786
switch (externalMemoryData->type) {
793787
case UR_ZE_EXTERNAL_OPAQUE_FD:
794788
delete (reinterpret_cast<ze_external_memory_import_fd_t *>(

0 commit comments

Comments
 (0)