// This converts all tests from CPU to GPU. #include "test_transform_range.cc" #if defined(XGBOOST_USE_NCCL) namespace xgboost { namespace common { // Test here is multi gpu specific TEST(Transform, MGPU_Basic) { auto devices = GPUSet::AllVisible(); CHECK_GT(devices.Size(), 1); const size_t size {256}; std::vector h_in(size); std::vector h_out(size); InitializeRange(h_in.begin(), h_in.end()); std::vector h_sol(size); InitializeRange(h_sol.begin(), h_sol.end()); const HostDeviceVector in_vec {h_in, GPUDistribution::Block(GPUSet::Empty())}; HostDeviceVector out_vec {h_out, GPUDistribution::Block(GPUSet::Empty())}; out_vec.Fill(0); in_vec.Reshard(GPUDistribution::Granular(devices, 8)); out_vec.Reshard(GPUDistribution::Block(devices)); // Granularity is different, resharding will throw. EXPECT_ANY_THROW( Transform<>::Init(TestTransformRange{}, Range{0, size}, devices) .Eval(&out_vec, &in_vec)); Transform<>::Init(TestTransformRange{}, Range{0, size}, devices, false).Eval(&out_vec, &in_vec); std::vector res = out_vec.HostVector(); ASSERT_TRUE(std::equal(h_sol.begin(), h_sol.end(), res.begin())); } } // namespace xgboost } // namespace common #endif