diff --git a/src/communicator.cc b/src/communicator.cc index 02ee7a87..c24b0c5e 100644 --- a/src/communicator.cc +++ b/src/communicator.cc @@ -15,9 +15,6 @@ namespace mscclpp { Communicator::Impl::Impl(std::shared_ptr bootstrap) : bootstrap_(bootstrap) {} Communicator::Impl::~Impl() { - for (auto& entry : ibContexts) { - delete entry.second; - } ibContexts.clear(); } @@ -26,11 +23,10 @@ IbCtx* Communicator::Impl::getIbContext(TransportFlags ibTransport) { auto it = ibContexts.find(ibTransport); if (it == ibContexts.end()) { auto ibDev = getIBDeviceName(ibTransport); - IbCtx* ibCtx = new IbCtx(ibDev); - ibContexts[ibTransport] = ibCtx; - return ibCtx; + ibContexts[ibTransport] = std::make_unique(ibDev); + return ibContexts[ibTransport].get(); } else { - return it->second; + return it->second.get(); } } diff --git a/src/include/communicator.hpp b/src/include/communicator.hpp index 3c3737ae..53d0fd73 100644 --- a/src/include/communicator.hpp +++ b/src/include/communicator.hpp @@ -7,6 +7,7 @@ #include "proxy.hpp" #include "ib.hpp" #include +#include namespace mscclpp { @@ -15,7 +16,7 @@ class ConnectionBase; struct Communicator::Impl { mscclppComm_t comm; std::vector> connections; - std::unordered_map ibContexts; + std::unordered_map> ibContexts; std::shared_ptr bootstrap_; Impl(std::shared_ptr bootstrap);