Skip to content

Commit

Permalink
Move away from Memory management APIs deprecated in ROCM 6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyazhang committed Oct 15, 2024
1 parent 65ffb0e commit c86d8a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion onnxruntime/core/providers/migraphx/migraphx_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Check warning on line 75 in onnxruntime/core/providers/migraphx/migraphx_allocator.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/migraphx/migraphx_allocator.cc#L75

Using C-style cast. Use reinterpret_cast<void**>(...) instead [readability/casting] [4]
Raw output
onnxruntime/core/providers/migraphx/migraphx_allocator.cc:75:  Using C-style cast.  Use reinterpret_cast<void**>(...) instead  [readability/casting] [4]
#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
6 changes: 5 additions & 1 deletion onnxruntime/core/providers/rocm/rocm_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Check warning on line 93 in onnxruntime/core/providers/rocm/rocm_allocator.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/rocm/rocm_allocator.cc#L93

Using C-style cast. Use reinterpret_cast<void**>(...) instead [readability/casting] [4]
Raw output
onnxruntime/core/providers/rocm/rocm_allocator.cc:93:  Using C-style cast.  Use reinterpret_cast<void**>(...) instead  [readability/casting] [4]
#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

0 comments on commit c86d8a0

Please sign in to comment.