未验证 提交 7fe7eebc 编写于 作者: L LiYuRio 提交者: GitHub

remove global var (#47659)

上级 f53e920d
...@@ -92,7 +92,7 @@ class ProcessGroup { ...@@ -92,7 +92,7 @@ class ProcessGroup {
int GetSize() const { return size_; } int GetSize() const { return size_; }
virtual const std::string GetBackendName() const = 0; virtual std::string GetBackendName() const = 0;
virtual const phi::DeviceContext& GetDeviceContext(const Place& place) const { virtual const phi::DeviceContext& GetDeviceContext(const Place& place) const {
PADDLE_THROW(platform::errors::InvalidArgument( PADDLE_THROW(platform::errors::InvalidArgument(
"Does not support to get device_context from ProcessGroup%s.", "Does not support to get device_context from ProcessGroup%s.",
......
...@@ -69,9 +69,7 @@ class ProcessGroupCustom : public ProcessGroup { ...@@ -69,9 +69,7 @@ class ProcessGroupCustom : public ProcessGroup {
const platform::Place& place, const platform::Place& place,
int gid); int gid);
const std::string GetBackendName() const override { std::string GetBackendName() const override { return "XCCL_" + device_type_; }
return "XCCL_" + device_type_;
}
std::shared_ptr<ProcessGroup::Task> AllGather( std::shared_ptr<ProcessGroup::Task> AllGather(
std::vector<phi::DenseTensor>& in_tensors, std::vector<phi::DenseTensor>& in_tensors,
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
#include "paddle/fluid/distributed/store/store.h" #include "paddle/fluid/distributed/store/store.h"
#include "paddle/fluid/distributed/store/tcp_store.h" #include "paddle/fluid/distributed/store/tcp_store.h"
constexpr const char* GLOO_BACKEND_NAME = "GLOO";
namespace paddle { namespace paddle {
namespace distributed { namespace distributed {
...@@ -146,9 +144,7 @@ class ProcessGroupGloo : public ProcessGroup { ...@@ -146,9 +144,7 @@ class ProcessGroupGloo : public ProcessGroup {
std::shared_ptr<::gloo::Context> get_context() { return _context; } std::shared_ptr<::gloo::Context> get_context() { return _context; }
uint64_t next_tag() { return _tag++; } uint64_t next_tag() { return _tag++; }
const std::string GetBackendName() const override { std::string GetBackendName() const override { return "GLOO"; }
return GLOO_BACKEND_NAME;
}
const phi::DeviceContext& GetDeviceContext( const phi::DeviceContext& GetDeviceContext(
const Place& place) const override { const Place& place) const override {
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include "paddle/fluid/platform/gen_comm_id_helper.h" #include "paddle/fluid/platform/gen_comm_id_helper.h"
#include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/place.h"
constexpr const char* HCCL_BACKEND_NAME = "HCCL";
namespace paddle { namespace paddle {
namespace distributed { namespace distributed {
...@@ -77,9 +75,7 @@ class ProcessGroupHCCL : public ProcessGroup { ...@@ -77,9 +75,7 @@ class ProcessGroupHCCL : public ProcessGroup {
const platform::Place& place, const platform::Place& place,
int gid); int gid);
const std::string GetBackendName() const override { std::string GetBackendName() const override { return "HCCL"; }
return std::string(HCCL_BACKEND_NAME);
}
std::shared_ptr<ProcessGroup::Task> AllReduce( std::shared_ptr<ProcessGroup::Task> AllReduce(
std::vector<phi::DenseTensor>& in_tensors, std::vector<phi::DenseTensor>& in_tensors,
...@@ -114,8 +110,8 @@ class ProcessGroupHCCL : public ProcessGroup { ...@@ -114,8 +110,8 @@ class ProcessGroupHCCL : public ProcessGroup {
std::set<int> used_place_ids_; std::set<int> used_place_ids_;
private: private:
void BcastHCCLId(std::vector<HcclRootInfo>& hccl_ids, void BcastHCCLId(std::vector<HcclRootInfo>& hccl_ids, // NOLINT
int root, // NOLINT int root, // NOLINT
int server_fd); int server_fd);
void BroadcastUniqueHCCLID(std::vector<HcclRootInfo>& hccl_ids); // NOLINT void BroadcastUniqueHCCLID(std::vector<HcclRootInfo>& hccl_ids); // NOLINT
......
...@@ -58,8 +58,6 @@ ...@@ -58,8 +58,6 @@
#include "paddle/fluid/distributed/collective/Common.h" #include "paddle/fluid/distributed/collective/Common.h"
constexpr const char* HETER_BACKEND_NAME = "HETER_BACKEND";
namespace paddle { namespace paddle {
namespace distributed { namespace distributed {
...@@ -99,9 +97,7 @@ class ProcessGroupHeter : public ProcessGroup { ...@@ -99,9 +97,7 @@ class ProcessGroupHeter : public ProcessGroup {
int src_rank, int src_rank,
int dst_rank); int dst_rank);
const std::string GetBackendName() const override { std::string GetBackendName() const override { return "HETER_BACKEND"; }
return std::string(HETER_BACKEND_NAME);
}
std::shared_ptr<ProcessGroup::Task> AllReduce( std::shared_ptr<ProcessGroup::Task> AllReduce(
std::vector<phi::DenseTensor>&, std::vector<phi::DenseTensor>&,
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
#include "paddle/fluid/distributed/collective/MPITools.h" #include "paddle/fluid/distributed/collective/MPITools.h"
#endif #endif
constexpr const char* MPI_BACKEND_NAME = "MPI";
namespace paddle { namespace paddle {
namespace distributed { namespace distributed {
...@@ -137,9 +135,7 @@ class ProcessGroupMPI : public ProcessGroup { ...@@ -137,9 +135,7 @@ class ProcessGroupMPI : public ProcessGroup {
virtual ~ProcessGroupMPI(); virtual ~ProcessGroupMPI();
const std::string GetBackendName() const override { std::string GetBackendName() const override { return "MPI"; }
return std::string(MPI_BACKEND_NAME);
}
std::shared_ptr<ProcessGroup::Task> AllReduce( std::shared_ptr<ProcessGroup::Task> AllReduce(
std::vector<phi::DenseTensor>& in_tensors, std::vector<phi::DenseTensor>& in_tensors,
......
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
#include "paddle/fluid/platform/dynload/nccl.h" #include "paddle/fluid/platform/dynload/nccl.h"
#endif #endif
constexpr const char* NCCL_BACKEND_NAME = "NCCL";
namespace paddle { namespace paddle {
namespace distributed { namespace distributed {
...@@ -94,9 +92,7 @@ class ProcessGroupNCCL : public ProcessGroupStream { ...@@ -94,9 +92,7 @@ class ProcessGroupNCCL : public ProcessGroupStream {
const platform::Place& place, const platform::Place& place,
int gid); int gid);
const std::string GetBackendName() const override { std::string GetBackendName() const override { return "NCCL"; }
return std::string(NCCL_BACKEND_NAME);
}
const phi::DeviceContext& GetDeviceContext(const Place& place) const override; const phi::DeviceContext& GetDeviceContext(const Place& place) const override;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册