[coll] Improve column split tests with named threads. (#10735)
This commit is contained in:
@@ -12,10 +12,11 @@
|
||||
#include <utility> // for move
|
||||
#include <vector> // for vector
|
||||
|
||||
#include "../../../src/collective/comm.h"
|
||||
#include "../../../src/collective/comm.h" // for RabitComm
|
||||
#include "../../../src/collective/communicator-inl.h" // for Init, Finalize
|
||||
#include "../../../src/collective/tracker.h" // for GetHostAddress
|
||||
#include "../../../src/common/cuda_rt_utils.h" // for AllVisibleGPUs
|
||||
#include "../../../src/common/threading_utils.h" // for NameThread
|
||||
#include "../helpers.h" // for FileExists
|
||||
|
||||
#if defined(XGBOOST_USE_FEDERATED)
|
||||
@@ -176,6 +177,9 @@ void TestDistributedGlobal(std::int32_t n_workers, WorkerFn worker_fn, bool need
|
||||
CHECK(status == std::future_status::ready) << "Test timeout";
|
||||
fut.get();
|
||||
});
|
||||
|
||||
std::string name = "tw-" + std::to_string(i);
|
||||
common::NameThread(&workers.back(), name.c_str());
|
||||
}
|
||||
|
||||
for (auto& t : workers) {
|
||||
@@ -199,7 +203,7 @@ class BaseMGPUTest : public ::testing::Test {
|
||||
* available.
|
||||
*/
|
||||
template <typename Fn>
|
||||
auto DoTest(Fn&& fn, bool is_federated, bool emulate_if_single = false) const {
|
||||
auto DoTest(Fn&& fn, bool is_federated, [[maybe_unused]] bool emulate_if_single = false) const {
|
||||
auto n_gpus = common::AllVisibleGPUs();
|
||||
if (is_federated) {
|
||||
#if defined(XGBOOST_USE_FEDERATED)
|
||||
|
||||
@@ -21,7 +21,7 @@ TEST(ThreadPool, Basic) {
|
||||
// 4 is an invalid value, it's only possible to set it by bypassing the parameter
|
||||
// validation.
|
||||
ASSERT_NE(orig, GlobalConfigThreadLocalStore::Get()->verbosity);
|
||||
ThreadPool pool{n_threads, [config = *GlobalConfigThreadLocalStore::Get()] {
|
||||
ThreadPool pool{StringView{"test"}, n_threads, [config = *GlobalConfigThreadLocalStore::Get()] {
|
||||
*GlobalConfigThreadLocalStore::Get() = config;
|
||||
}};
|
||||
GlobalConfigThreadLocalStore::Get()->verbosity = orig; // restore
|
||||
|
||||
@@ -745,8 +745,7 @@ void VerifyColumnSplitWithArgs(std::string const& tree_method, bool use_gpu, Arg
|
||||
std::shared_ptr<DMatrix> sliced{p_fmat->SliceCol(world_size, rank)};
|
||||
std::string device = "cpu";
|
||||
if (use_gpu) {
|
||||
auto gpu_id = common::AllVisibleGPUs() == 1 ? 0 : rank;
|
||||
device = "cuda:" + std::to_string(gpu_id);
|
||||
device = MakeCUDACtx(DistGpuIdx()).DeviceName();
|
||||
}
|
||||
auto model = GetModelWithArgs(sliced, tree_method, device, args);
|
||||
ASSERT_EQ(model, expected_model);
|
||||
@@ -807,44 +806,32 @@ class ColumnSplitTrainingTest
|
||||
}
|
||||
};
|
||||
|
||||
auto MakeParamsForTest() {
|
||||
std::vector<std::tuple<std::string, bool, bool>> configs;
|
||||
for (auto tm : {"hist", "approx"}) {
|
||||
#if defined(XGBOOST_USE_CUDA)
|
||||
std::array<bool, 2> use_gpu{true, false};
|
||||
#else
|
||||
std::array<bool, 1> use_gpu{false};
|
||||
#endif
|
||||
for (auto i : use_gpu) {
|
||||
auto WithFed() {
|
||||
#if defined(XGBOOST_USE_FEDERATED)
|
||||
std::array<bool, 2> fed{true, false};
|
||||
return ::testing::Bool();
|
||||
#else
|
||||
std::array<bool, 1> fed{false};
|
||||
return ::testing::Values(false);
|
||||
#endif
|
||||
for (auto j : fed) {
|
||||
configs.emplace_back(tm, i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
return configs;
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
TEST_P(ColumnSplitTrainingTest, ColumnSampler) {
|
||||
auto param = GetParam();
|
||||
std::apply(TestColumnSplitColumnSampler, param);
|
||||
std::apply(TestColumnSplitColumnSampler, GetParam());
|
||||
}
|
||||
|
||||
TEST_P(ColumnSplitTrainingTest, InteractionConstraints) {
|
||||
auto param = GetParam();
|
||||
std::apply(TestColumnSplitInteractionConstraints, param);
|
||||
std::apply(TestColumnSplitInteractionConstraints, GetParam());
|
||||
}
|
||||
|
||||
TEST_P(ColumnSplitTrainingTest, MonotoneConstraints) {
|
||||
auto param = GetParam();
|
||||
std::apply(TestColumnSplitMonotoneConstraints, param);
|
||||
std::apply(TestColumnSplitMonotoneConstraints, GetParam());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(ColumnSplit, ColumnSplitTrainingTest,
|
||||
::testing::ValuesIn(MakeParamsForTest()));
|
||||
INSTANTIATE_TEST_SUITE_P(Cpu, ColumnSplitTrainingTest,
|
||||
::testing::Combine(::testing::Values("hist", "approx"),
|
||||
::testing::Values(false), WithFed()));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(MGPU, ColumnSplitTrainingTest,
|
||||
::testing::Combine(::testing::Values("hist", "approx"),
|
||||
::testing::Values(true), WithFed()));
|
||||
} // namespace xgboost
|
||||
|
||||
Reference in New Issue
Block a user