[coll] Allow using local host for testing. (#10526)

- Don't try to retrieve the IP address if a host is specified.
- Fix compiler deprecation warning.
This commit is contained in:
Jiaming Yuan 2024-07-02 15:34:38 +08:00 committed by GitHub
parent a39fef2c67
commit d33043a348
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -111,12 +111,14 @@ RabitTracker::WorkerProxy::WorkerProxy(std::int32_t world, TCPSocket sock, SockA
} }
RabitTracker::RabitTracker(Json const& config) : Tracker{config} { RabitTracker::RabitTracker(Json const& config) : Tracker{config} {
std::string self;
auto rc = Success() << [&] { auto rc = Success() << [&] {
return collective::GetHostAddress(&self); host_.clear();
host_ = OptionalArg<String>(config, "host", std::string{});
if (host_.empty()) {
return collective::GetHostAddress(&host_);
}
return Success();
} << [&] { } << [&] {
host_ = OptionalArg<String>(config, "host", self);
auto addr = MakeSockAddress(xgboost::StringView{host_}, 0); auto addr = MakeSockAddress(xgboost::StringView{host_}, 0);
listener_ = TCPSocket::Create(addr.IsV4() ? SockDomain::kV4 : SockDomain::kV6); listener_ = TCPSocket::Create(addr.IsV4() ? SockDomain::kV4 : SockDomain::kV6);
return listener_.Bind(host_, &this->port_); return listener_.Bind(host_, &this->port_);

View File

@ -61,6 +61,8 @@ class pinned_allocator {
XGBOOST_DEVICE inline ~pinned_allocator() {} // NOLINT: host/device markup ignored on defaulted functions XGBOOST_DEVICE inline ~pinned_allocator() {} // NOLINT: host/device markup ignored on defaulted functions
XGBOOST_DEVICE inline pinned_allocator(pinned_allocator const&) {} // NOLINT: host/device markup ignored on defaulted functions XGBOOST_DEVICE inline pinned_allocator(pinned_allocator const&) {} // NOLINT: host/device markup ignored on defaulted functions
pinned_allocator& operator=(pinned_allocator const& that) = default;
pinned_allocator& operator=(pinned_allocator&& that) = default;
template <typename U> template <typename U>
XGBOOST_DEVICE inline pinned_allocator(pinned_allocator<U> const&) {} // NOLINT XGBOOST_DEVICE inline pinned_allocator(pinned_allocator<U> const&) {} // NOLINT