diff --git a/paddle/fluid/platform/collective_helper.cc b/paddle/fluid/platform/collective_helper.cc index 95bf7a7aeaab6c93f621a74d68bfbf01a0d8e658..32244f4eb136cf802f08534f8f5f47afefb89574 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 0b037c48f0becc7d2c37f203feedb27292166ad4..174946084a98ff0041a85424cea2823e0f886539 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);