From c86d8a03a08a4b2fca2818b71d6ea68ee0919021 Mon Sep 17 00:00:00 2001 From: Xinya Zhang Date: Tue, 15 Oct 2024 16:00:19 -0500 Subject: [PATCH] Move away from Memory management APIs deprecated in ROCM 6.3 --- onnxruntime/core/providers/migraphx/migraphx_allocator.cc | 6 +++++- onnxruntime/core/providers/rocm/rocm_allocator.cc | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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