Remove RABIT CMake targets. (#6275)

* Now it's built as part of libxgboost.
* Set correct C API error in RABIT initialization and finalization.
* Remove redundant message.
* Guard the tracker print C API.
This commit is contained in:
Jiaming Yuan
2020-10-27 01:30:20 +08:00
committed by GitHub
parent 2686d32a36
commit d61b628bf5
11 changed files with 50 additions and 120 deletions

View File

@@ -123,7 +123,9 @@ bool AllreduceBase::Init(int argc, char* argv[]) {
bool AllreduceBase::Shutdown() {
try {
for (auto & all_link : all_links) {
all_link.sock.Close();
if (!all_link.sock.IsClosed()) {
all_link.sock.Close();
}
}
all_links.clear();
tree_links.plinks.clear();
@@ -136,7 +138,7 @@ bool AllreduceBase::Shutdown() {
utils::TCPSocket::Finalize();
return true;
} catch (const std::exception& e) {
fprintf(stderr, "failed to shutdown due to %s\n", e.what());
LOG(WARNING) << "Failed to shutdown due to" << e.what();
return false;
}
}
@@ -217,7 +219,7 @@ void AllreduceBase::SetParam(const char *name, const char *val) {
rabit_enable_tcp_no_delay = true;
} else {
rabit_enable_tcp_no_delay = false;
}
}
}
}
/*!
@@ -586,7 +588,7 @@ AllreduceBase::TryAllreduceTree(void *sendrecvbuf_,
// eachreduce size
if (max_reduce < total_size) {
max_reduce = max_reduce - max_reduce % eachreduce;
}
}
// peform reduce, can be at most two rounds
while (size_up_reduce < max_reduce) {

View File

@@ -6,6 +6,8 @@
#include "rabit/rabit.h"
#include "rabit/c_api.h"
#include "../../src/c_api/c_api_error.h"
namespace rabit {
namespace c_api {
// helper use to avoid BitOR operator
@@ -219,11 +221,19 @@ struct WriteWrapper : public Serializable {
} // namespace rabit
RABIT_DLL bool RabitInit(int argc, char *argv[]) {
return rabit::Init(argc, argv);
auto ret = rabit::Init(argc, argv);
if (!ret) {
XGBAPISetLastError("Failed to initialize RABIT.");
}
return ret;
}
RABIT_DLL bool RabitFinalize() {
return rabit::Finalize();
auto ret = rabit::Finalize();
if (!ret) {
XGBAPISetLastError("Failed to shutdown RABIT worker.");
}
return ret;
}
RABIT_DLL int RabitGetRingPrevRank() {
@@ -242,9 +252,11 @@ RABIT_DLL int RabitIsDistributed() {
return rabit::IsDistributed();
}
RABIT_DLL void RabitTrackerPrint(const char *msg) {
RABIT_DLL int RabitTrackerPrint(const char *msg) {
API_BEGIN()
std::string m(msg);
rabit::TrackerPrint(m);
API_END()
}
RABIT_DLL void RabitGetProcessorName(char *out_name,