diff --git a/onnxruntime/core/providers/migraphx/migraphx_allocator.cc b/onnxruntime/core/providers/migraphx/migraphx_allocator.cc index 0693eea056416..83e77fccf37ad 100644 --- a/onnxruntime/core/providers/migraphx/migraphx_allocator.cc +++ b/onnxruntime/core/providers/migraphx/migraphx_allocator.cc @@ -71,13 +71,17 @@ void* MIGraphXExternalAllocator::Reserve(size_t size) { void* HIPPinnedAllocator::Alloc(size_t size) { void* p = nullptr; if (size > 0) { +#ifdef hipExtHostAllocCoherent + HIP_CALL_THROW(hipExtHostAlloc((void**)&p, size)); +#else HIP_CALL_THROW(hipHostMalloc((void**)&p, size)); +#endif } return p; } void HIPPinnedAllocator::Free(void* p) { - HIP_CALL_THROW(hipHostFree(p)); + HIP_CALL_THROW(hipFreeHost(p)); } } // namespace onnxruntime diff --git a/onnxruntime/core/providers/rocm/rocm_allocator.cc b/onnxruntime/core/providers/rocm/rocm_allocator.cc index 8645b791d4b0f..905c123b37095 100644 --- a/onnxruntime/core/providers/rocm/rocm_allocator.cc +++ b/onnxruntime/core/providers/rocm/rocm_allocator.cc @@ -89,13 +89,17 @@ void* ROCMExternalAllocator::Reserve(size_t size) { void* ROCMPinnedAllocator::Alloc(size_t size) { void* p = nullptr; if (size > 0) { +#ifdef hipExtHostAllocCoherent + HIP_CALL_THROW(hipExtHostAlloc((void**)&p, size)); +#else HIP_CALL_THROW(hipHostMalloc((void**)&p, size)); +#endif } return p; } void ROCMPinnedAllocator::Free(void* p) { - HIP_CALL_THROW(hipHostFree(p)); + HIP_CALL_THROW(hipFreeHost(p)); } } // namespace onnxruntime diff --git a/tools/ci_build/hipify-perl b/tools/ci_build/hipify-perl index ac1393cf0da7d..dc49df0d2421d 100755 --- a/tools/ci_build/hipify-perl +++ b/tools/ci_build/hipify-perl @@ -3541,14 +3541,14 @@ sub simpleSubstitutions { subst("cuIpcOpenEventHandle", "hipIpcOpenEventHandle", "memory"); subst("cuIpcOpenMemHandle", "hipIpcOpenMemHandle", "memory"); subst("cuMemAlloc", "hipMalloc", "memory"); - subst("cuMemAllocHost", "hipMemAllocHost", "memory"); - subst("cuMemAllocHost_v2", "hipMemAllocHost", "memory"); + subst("cuMemAllocHost", "hipHostAlloc", "memory"); + subst("cuMemAllocHost_v2", "hipHostAlloc", "memory"); subst("cuMemAllocManaged", "hipMallocManaged", "memory"); subst("cuMemAllocPitch", "hipMemAllocPitch", "memory"); subst("cuMemAllocPitch_v2", "hipMemAllocPitch", "memory"); subst("cuMemAlloc_v2", "hipMalloc", "memory"); subst("cuMemFree", "hipFree", "memory"); - subst("cuMemFreeHost", "hipHostFree", "memory"); + subst("cuMemFreeHost", "hipFreeHost", "memory"); subst("cuMemFree_v2", "hipFree", "memory"); subst("cuMemGetAddressRange", "hipMemGetAddressRange", "memory"); subst("cuMemGetAddressRange_v2", "hipMemGetAddressRange", "memory"); @@ -3603,7 +3603,7 @@ sub simpleSubstitutions { subst("cudaFree", "hipFree", "memory"); subst("cudaFreeArray", "hipFreeArray", "memory"); subst("cudaFreeAsync", "hipFreeAsync", "memory"); - subst("cudaFreeHost", "hipHostFree", "memory"); + subst("cudaFreeHost", "hipFreeHost", "memory"); subst("cudaFreeMipmappedArray", "hipFreeMipmappedArray", "memory"); subst("cudaGetMipmappedArrayLevel", "hipGetMipmappedArrayLevel", "memory"); subst("cudaGetSymbolAddress", "hipGetSymbolAddress", "memory"); @@ -3619,7 +3619,7 @@ sub simpleSubstitutions { subst("cudaMallocArray", "hipMallocArray", "memory"); subst("cudaMallocAsync", "hipMallocAsync", "memory"); subst("cudaMallocFromPoolAsync", "hipMallocFromPoolAsync", "memory"); - subst("cudaMallocHost", "hipHostMalloc", "memory"); + subst("cudaMallocHost", "hipExtHostAlloc", "memory"); subst("cudaMallocManaged", "hipMallocManaged", "memory"); subst("cudaMallocMipmappedArray", "hipMallocMipmappedArray", "memory"); subst("cudaMallocPitch", "hipMallocPitch", "memory"); @@ -3649,12 +3649,12 @@ sub simpleSubstitutions { subst("cudaMemcpy3D", "hipMemcpy3D", "memory"); subst("cudaMemcpy3DAsync", "hipMemcpy3DAsync", "memory"); subst("cudaMemcpyAsync", "hipMemcpyAsync", "memory"); - subst("cudaMemcpyFromArray", "hipMemcpyFromArray", "memory"); + subst("cudaMemcpyFromArray", "hipMemcpy2DFromArray", "memory"); subst("cudaMemcpyFromSymbol", "hipMemcpyFromSymbol", "memory"); subst("cudaMemcpyFromSymbolAsync", "hipMemcpyFromSymbolAsync", "memory"); subst("cudaMemcpyPeer", "hipMemcpyPeer", "memory"); subst("cudaMemcpyPeerAsync", "hipMemcpyPeerAsync", "memory"); - subst("cudaMemcpyToArray", "hipMemcpyToArray", "memory"); + subst("cudaMemcpyToArray", "hipMemcpy2DToArray", "memory"); subst("cudaMemcpyToSymbol", "hipMemcpyToSymbol", "memory"); subst("cudaMemcpyToSymbolAsync", "hipMemcpyToSymbolAsync", "memory"); subst("cudaMemset", "hipMemset", "memory");