From 1ef2d3a6b79197679c7a43494c8e6f206fa85e26 Mon Sep 17 00:00:00 2001 From: avinashkethineedi Date: Mon, 13 Jan 2025 20:11:55 +0000 Subject: [PATCH] Replace raw pointers for `host_interface` with shared_ptr to enable automatic memory handling --- src/ipc/backend_ipc.cpp | 10 +++------- src/ipc/backend_ipc.hpp | 4 ++-- src/ipc/context_ipc_host.hpp | 4 ++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/ipc/backend_ipc.cpp b/src/ipc/backend_ipc.cpp index 645ad160eb..9f4e69857f 100644 --- a/src/ipc/backend_ipc.cpp +++ b/src/ipc/backend_ipc.cpp @@ -77,8 +77,9 @@ IPCBackend::IPCBackend(MPI_Comm comm) bp->heap_ptr = &heap; /* Initialize the host interface */ - host_interface = - new HostInterface(hdp_proxy_.get(), thread_comm, &heap); + host_interface = std::make_shared(hdp_proxy_.get(), + thread_comm, + &heap); default_host_ctx = std::make_unique(this, 0); @@ -117,11 +118,6 @@ IPCBackend::~IPCBackend() { */ CHECK_HIP(hipFree(bp->atomic_ret->atomic_base_ptr)); - // TODO(Avinash) Free g_ret - - // delete host_interface; - // host_interface = nullptr; - /** * Destroy teams infrastructure * and team world diff --git a/src/ipc/backend_ipc.hpp b/src/ipc/backend_ipc.hpp index 9d80f030c7..046eb9e941 100644 --- a/src/ipc/backend_ipc.hpp +++ b/src/ipc/backend_ipc.hpp @@ -124,9 +124,9 @@ class IPCBackend : public Backend { /** * @brief The host-facing interface that will be used - * by all contexts of the ROBackend + * by all contexts of the IPCBackend */ - HostInterface *host_interface{nullptr}; + std::shared_ptr host_interface{nullptr}; /** * @brief Scratchpad for the internal barrier algorithms. diff --git a/src/ipc/context_ipc_host.hpp b/src/ipc/context_ipc_host.hpp index 506fa52258..a5b1993c55 100644 --- a/src/ipc/context_ipc_host.hpp +++ b/src/ipc/context_ipc_host.hpp @@ -136,8 +136,8 @@ class IPCHostContext : public Context { __host__ int test(T *ivars, int cmp, T val); public: - /* Pointer to the backend's host interface */ - HostInterface *host_interface{nullptr}; + /* Shared pointer to the backend's host interface */ + std::shared_ptr host_interface{nullptr}; /* An MPI Window implements a context */ WindowInfo *context_window_info{nullptr};