diff --git a/source/adapters/level_zero/v2/memory.cpp b/source/adapters/level_zero/v2/memory.cpp index 4de2a588a3..3ec16e8352 100644 --- a/source/adapters/level_zero/v2/memory.cpp +++ b/source/adapters/level_zero/v2/memory.cpp @@ -115,10 +115,7 @@ ur_integrated_mem_handle_t::ur_integrated_mem_handle_t( if (!ownHostPtr) { return; } - auto ret = hContext->getDefaultUSMPool()->free(ptr); - if (ret != UR_RESULT_SUCCESS) { - logger::error("Failed to free host memory: {}", ret); - } + ZE_CALL_NOCHECK(zeMemFree, (hContext->getZeHandle(), ptr)); }); } @@ -234,10 +231,7 @@ ur_discrete_mem_handle_t::ur_discrete_mem_handle_t( if (!ownZePtr) { return; } - auto ret = hContext->getDefaultUSMPool()->free(ptr); - if (ret != UR_RESULT_SUCCESS) { - logger::error("Failed to free device memory: {}", ret); - } + ZE_CALL_NOCHECK(zeMemFree, (hContext->getZeHandle(), ptr)); }); } } @@ -310,7 +304,10 @@ void *ur_discrete_mem_handle_t::mapHostPtr( usm_unique_ptr_t mappedPtr = usm_unique_ptr_t(ptr, [ownsAlloc = bool(mapToPtr), this](void *p) { if (ownsAlloc) { - UR_CALL_THROWS(hContext->getDefaultUSMPool()->free(p)); + auto ret = hContext->getDefaultUSMPool()->free(p); + if (ret != UR_RESULT_SUCCESS) { + logger::error("Failed to mapped memory: {}", ret); + } } }); diff --git a/source/adapters/level_zero/v2/usm.cpp b/source/adapters/level_zero/v2/usm.cpp index 4e9c264182..4f22221562 100644 --- a/source/adapters/level_zero/v2/usm.cpp +++ b/source/adapters/level_zero/v2/usm.cpp @@ -231,7 +231,13 @@ ur_result_t ur_usm_pool_handle_t_::allocate( } ur_result_t ur_usm_pool_handle_t_::free(void *ptr) { - return umf::umf2urResult(umfFree(ptr)); + auto umfPool = umfPoolByPtr(ptr); + if (umfPool) { + return umf::umf2urResult(umfPoolFree(umfPool, ptr)); + } else { + logger::error("Failed to find pool for pointer: {}", ptr); + return UR_RESULT_ERROR_INVALID_VALUE; + } } namespace ur::level_zero {