Clean up MGPU C++ tests (#9430)

This commit is contained in:
Rong Ou
2023-08-01 23:31:18 -07:00
committed by GitHub
parent a9da2e244a
commit c2b85ab68a
28 changed files with 200 additions and 194 deletions

View File

@@ -60,7 +60,7 @@ void VerifyBasicColumnSplit(std::array<std::vector<float>, 32> const& expected_r
auto const world_size = collective::GetWorldSize();
auto const rank = collective::GetRank();
auto ctx = MakeCUDACtx(rank);
auto ctx = MakeCUDACtx(GetGPUId());
std::unique_ptr<Predictor> predictor =
std::unique_ptr<Predictor>(Predictor::Create("gpu_predictor", &ctx));
predictor->Configure({});
@@ -85,12 +85,9 @@ void VerifyBasicColumnSplit(std::array<std::vector<float>, 32> const& expected_r
}
} // anonymous namespace
TEST(GPUPredictor, MGPUBasicColumnSplit) {
auto const n_gpus = common::AllVisibleGPUs();
if (n_gpus <= 1) {
GTEST_SKIP() << "Skipping MGPUIBasicColumnSplit test with # GPUs = " << n_gpus;
}
class MGPUPredictorTest : public BaseMGPUTest {};
TEST_F(MGPUPredictorTest, BasicColumnSplit) {
auto ctx = MakeCUDACtx(0);
std::unique_ptr<Predictor> predictor =
std::unique_ptr<Predictor>(Predictor::Create("gpu_predictor", &ctx));
@@ -114,7 +111,7 @@ TEST(GPUPredictor, MGPUBasicColumnSplit) {
result[i - 1] = out_predictions_h;
}
RunWithInMemoryCommunicator(n_gpus, VerifyBasicColumnSplit, result);
DoTest(VerifyBasicColumnSplit, result);
}
TEST(GPUPredictor, EllpackBasic) {
@@ -286,7 +283,7 @@ TEST(GPUPredictor, CategoricalPredictLeaf) {
TEST(GPUPredictor, PredictLeafBasic) {
size_t constexpr kRows = 5, kCols = 5;
auto dmat = RandomDataGenerator(kRows, kCols, 0).Device(0).GenerateDMatrix();
auto lparam = MakeCUDACtx(GPUIDX);
auto lparam = MakeCUDACtx(GetGPUId());
std::unique_ptr<Predictor> gpu_predictor =
std::unique_ptr<Predictor>(Predictor::Create("gpu_predictor", &lparam));
gpu_predictor->Configure({});