Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazily create the context stream #381

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace mscclpp {

Context::Impl::Impl() : ipcStream_(cudaStreamNonBlocking) {}
Context::Impl::Impl() {}

IbCtx* Context::Impl::getIbContext(Transport ibTransport) {
// Find IB context or create it
Expand Down Expand Up @@ -43,7 +43,10 @@ MSCCLPP_API_CPP std::shared_ptr<Connection> Context::connect(Endpoint localEndpo
if (remoteEndpoint.transport() != Transport::CudaIpc) {
throw mscclpp::Error("Local transport is CudaIpc but remote is not", ErrorCode::InvalidUsage);
}
conn = std::make_shared<CudaIpcConnection>(localEndpoint, remoteEndpoint, pimpl_->ipcStream_);
if (!(pimpl_->ipcStream_)) {
pimpl_->ipcStream_ = std::make_shared<CudaStreamWithFlags>(cudaStreamNonBlocking);
}
conn = std::make_shared<CudaIpcConnection>(localEndpoint, remoteEndpoint, cudaStream_t(*(pimpl_->ipcStream_)));
} else if (AllIBTransports.has(localEndpoint.transport())) {
if (!AllIBTransports.has(remoteEndpoint.transport())) {
throw mscclpp::Error("Local transport is IB but remote is not", ErrorCode::InvalidUsage);
Expand Down
2 changes: 1 addition & 1 deletion src/include/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace mscclpp {
struct Context::Impl {
std::vector<std::shared_ptr<Connection>> connections_;
std::unordered_map<Transport, std::unique_ptr<IbCtx>> ibContexts_;
CudaStreamWithFlags ipcStream_;
std::shared_ptr<CudaStreamWithFlags> ipcStream_;
CUmemGenericAllocationHandle mcHandle_;

Impl();
Expand Down
Loading