From 0af9c06968a78b01338c2ca05c576b04b3cd536d Mon Sep 17 00:00:00 2001 From: Chauncey Hui Date: Thu, 14 May 2020 03:00:03 -0400 Subject: [PATCH] Modified IpcDetach to return status instead of void. Change-Id: I68ed94b93f0383babe25eb046b4047d249a0fdc1 --- rocclr/device/device.hpp | 2 +- rocclr/device/rocm/rocdevice.cpp | 5 +++-- rocclr/device/rocm/rocdevice.hpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rocclr/device/device.hpp b/rocclr/device/device.hpp index c474d07e30..1a3cc4744f 100644 --- a/rocclr/device/device.hpp +++ b/rocclr/device/device.hpp @@ -1404,7 +1404,7 @@ class Device : public RuntimeObject { return nullptr; } - virtual void IpcDetach(amd::Memory& memory) const { ShouldNotReachHere(); } + virtual bool IpcDetach(amd::Memory& memory) const { ShouldNotReachHere(); } //! Return private global device context for P2P allocations amd::Context& GlbCtx() const { return *glb_ctx_; } diff --git a/rocclr/device/rocm/rocdevice.cpp b/rocclr/device/rocm/rocdevice.cpp index 1f867fecbb..519c68f072 100644 --- a/rocclr/device/rocm/rocdevice.cpp +++ b/rocclr/device/rocm/rocdevice.cpp @@ -1817,7 +1817,7 @@ amd::Memory *Device::IpcAttach(const void* handle, size_t mem_size, unsigned int return amd_mem_obj; } -void Device::IpcDetach (amd::Memory& memory) const { +bool Device::IpcDetach (amd::Memory& memory) const { void* dev_ptr = nullptr; hsa_status_t hsa_status = HSA_STATUS_SUCCESS; @@ -1833,10 +1833,11 @@ void Device::IpcDetach (amd::Memory& memory) const { hsa_status = hsa_amd_ipc_memory_detach(dev_ptr); if (hsa_status != HSA_STATUS_SUCCESS) { LogPrintfError("HSA failed to detach memory with status: %d \n", hsa_status); - return; + return false; } memory.release(); + return true; } void* Device::svmAlloc(amd::Context& context, size_t size, size_t alignment, cl_svm_mem_flags flags, diff --git a/rocclr/device/rocm/rocdevice.hpp b/rocclr/device/rocm/rocdevice.hpp index dd623a2d28..33d55162d5 100644 --- a/rocclr/device/rocm/rocdevice.hpp +++ b/rocclr/device/rocm/rocdevice.hpp @@ -411,7 +411,7 @@ class Device : public NullDevice { void updateFreeMemory(size_t size, bool free); virtual amd::Memory* IpcAttach(const void* handle, size_t mem_size, unsigned int flags, void** dev_ptr) const; - virtual void IpcDetach (amd::Memory& memory) const; + virtual bool IpcDetach (amd::Memory& memory) const; bool AcquireExclusiveGpuAccess(); void ReleaseExclusiveGpuAccess(VirtualGPU& vgpu) const;