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

remove global var (#47659)

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