From bd10211c786671d79fd764229aa81c3c9d78ba58 Mon Sep 17 00:00:00 2001 From: sneaxiy <32832641+sneaxiy@users.noreply.github.com> Date: Wed, 28 Sep 2022 20:49:38 +0800 Subject: [PATCH] fix collective helper (#46582) --- paddle/fluid/platform/collective_helper.cc | 5 +++++ paddle/fluid/platform/collective_helper.h | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/platform/collective_helper.cc b/paddle/fluid/platform/collective_helper.cc index 95bf7a7aeaa..32244f4eb13 100644 --- a/paddle/fluid/platform/collective_helper.cc +++ b/paddle/fluid/platform/collective_helper.cc @@ -73,6 +73,11 @@ class NCCLCommImpl : public NCCLComm { std::shared_ptr comm_event_; }; +NCCLCommContext& NCCLCommContext::Instance() { + static NCCLCommContext comm_ctx; + return comm_ctx; +} + NCCLComm* NCCLCommContext::CreateComm( ncclUniqueId* nccl_id, int nranks, int rank, int dev_id, int ring_id) { PADDLE_ENFORCE_NOT_NULL(nccl_id, diff --git a/paddle/fluid/platform/collective_helper.h b/paddle/fluid/platform/collective_helper.h index 0b037c48f0b..174946084a9 100644 --- a/paddle/fluid/platform/collective_helper.h +++ b/paddle/fluid/platform/collective_helper.h @@ -69,10 +69,7 @@ class NCCLComm { // A singleton NCCL communicator context reserves communication ring ids class NCCLCommContext { public: - static NCCLCommContext& Instance() { - static NCCLCommContext comm_ctx; - return comm_ctx; - } + static NCCLCommContext& Instance(); NCCLComm* CreateComm( ncclUniqueId* nccl_id, int nranks, int rank, int dev_id, int ring_id = 0); -- GitLab