Replace raw pointers for host_interface with shared_ptr to enable automatic memory handling

This commit is contained in:
avinashkethineedi
2025-01-13 20:11:55 +00:00
والد 4a3c3d54fb
کامیت 1ef2d3a6b7
3فایلهای تغییر یافته به همراه7 افزوده شده و 11 حذف شده
+3 -7
مشاهده پرونده
@@ -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<HostInterface>(hdp_proxy_.get(),
thread_comm,
&heap);
default_host_ctx = std::make_unique<IPCHostContext>(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
+2 -2
مشاهده پرونده
@@ -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<HostInterface> host_interface{nullptr};
/**
* @brief Scratchpad for the internal barrier algorithms.
+2 -2
مشاهده پرونده
@@ -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<HostInterface> host_interface{nullptr};
/* An MPI Window implements a context */
WindowInfo *context_window_info{nullptr};