Utilities and cleanups for socket. (#9576)

- Use c++-17 nodiscard and nested ns.
- Add bind method to socket.
- Remove rabit parameters.
This commit is contained in:
Jiaming Yuan
2023-09-14 01:41:42 +08:00
committed by GitHub
parent 5abe50ff8c
commit b438d684d2
12 changed files with 187 additions and 75 deletions

View File

@@ -11,9 +11,7 @@
#include <limits>
#include <string>
namespace xgboost {
namespace federated {
namespace xgboost::federated {
/**
* @brief A wrapper around the gRPC client.
*/
@@ -112,6 +110,4 @@ class FederatedClient {
int const rank_;
uint64_t sequence_number_{};
};
} // namespace federated
} // namespace xgboost
} // namespace xgboost::federated

View File

@@ -9,9 +9,7 @@
#include "../../src/common/io.h"
#include "federated_client.h"
namespace xgboost {
namespace collective {
namespace xgboost::collective {
/**
* @brief A Federated Learning communicator class that handles collective communication.
*/
@@ -118,13 +116,13 @@ class FederatedCommunicator : public Communicator {
* \brief Get if the communicator is distributed.
* \return True.
*/
bool IsDistributed() const override { return true; }
[[nodiscard]] bool IsDistributed() const override { return true; }
/**
* \brief Get if the communicator is federated.
* \return True.
*/
bool IsFederated() const override { return true; }
[[nodiscard]] bool IsFederated() const override { return true; }
/**
* \brief Perform in-place allgather.
@@ -189,5 +187,4 @@ class FederatedCommunicator : public Communicator {
private:
std::unique_ptr<xgboost::federated::FederatedClient> client_{};
};
} // namespace collective
} // namespace xgboost
} // namespace xgboost::collective

View File

@@ -11,9 +11,7 @@
#include "../../src/common/io.h"
namespace xgboost {
namespace federated {
namespace xgboost::federated {
grpc::Status FederatedService::Allgather(grpc::ServerContext*, AllgatherRequest const* request,
AllgatherReply* reply) {
handler_.Allgather(request->send_buffer().data(), request->send_buffer().size(),
@@ -75,6 +73,4 @@ void RunInsecureServer(int port, int world_size) {
server->Wait();
}
} // namespace federated
} // namespace xgboost
} // namespace xgboost::federated