Remove MGPU cpp tests. (#8276)
Co-authored-by: Hyunsu Philip Cho <chohyu01@cs.washington.edu>
This commit is contained in:
@@ -11,13 +11,14 @@
|
||||
|
||||
namespace xgboost {
|
||||
namespace common {
|
||||
|
||||
void SetDevice(int device) {
|
||||
namespace {
|
||||
void SetDeviceForTest(int device) {
|
||||
int n_devices;
|
||||
dh::safe_cuda(cudaGetDeviceCount(&n_devices));
|
||||
device %= n_devices;
|
||||
dh::safe_cuda(cudaSetDevice(device));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
struct HostDeviceVectorSetDeviceHandler {
|
||||
template <typename Functor>
|
||||
@@ -57,7 +58,7 @@ void InitHostDeviceVector(size_t n, int device, HostDeviceVector<int> *v) {
|
||||
|
||||
void PlusOne(HostDeviceVector<int> *v) {
|
||||
int device = v->DeviceIdx();
|
||||
SetDevice(device);
|
||||
SetDeviceForTest(device);
|
||||
thrust::transform(dh::tcbegin(*v), dh::tcend(*v), dh::tbegin(*v),
|
||||
[=]__device__(unsigned int a){ return a + 1; });
|
||||
ASSERT_TRUE(v->DeviceCanWrite());
|
||||
@@ -68,7 +69,7 @@ void CheckDevice(HostDeviceVector<int>* v,
|
||||
unsigned int first,
|
||||
GPUAccess access) {
|
||||
ASSERT_EQ(v->Size(), size);
|
||||
SetDevice(v->DeviceIdx());
|
||||
SetDeviceForTest(v->DeviceIdx());
|
||||
|
||||
ASSERT_TRUE(thrust::equal(dh::tcbegin(*v), dh::tcend(*v),
|
||||
thrust::make_counting_iterator(first)));
|
||||
@@ -182,16 +183,5 @@ TEST(HostDeviceVector, Empty) {
|
||||
ASSERT_FALSE(another.Empty());
|
||||
ASSERT_TRUE(vec.Empty());
|
||||
}
|
||||
|
||||
TEST(HostDeviceVector, MGPU_Basic) { // NOLINT
|
||||
if (AllVisibleGPUs() < 2) {
|
||||
LOG(WARNING) << "Not testing in multi-gpu environment.";
|
||||
return;
|
||||
}
|
||||
|
||||
size_t n = 1001;
|
||||
int device = 1;
|
||||
TestHostDeviceVector(n, device);
|
||||
}
|
||||
} // namespace common
|
||||
} // namespace xgboost
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*!
|
||||
* Copyright 2018-2022 by XGBoost Contributors
|
||||
* \brief This converts all tests from CPU to GPU.
|
||||
*/
|
||||
#include "test_transform_range.cc"
|
||||
|
||||
namespace xgboost {
|
||||
namespace common {
|
||||
|
||||
TEST(Transform, MGPU_SpecifiedGpuId) { // NOLINT
|
||||
if (AllVisibleGPUs() < 2) {
|
||||
LOG(WARNING) << "Not testing in multi-gpu environment.";
|
||||
return;
|
||||
}
|
||||
// Use 1 GPU, Numbering of GPU starts from 1
|
||||
auto device = 1;
|
||||
auto const size {256};
|
||||
std::vector<bst_float> h_in(size);
|
||||
std::vector<bst_float> h_out(size);
|
||||
std::iota(h_in.begin(), h_in.end(), 0);
|
||||
std::vector<bst_float> h_sol(size);
|
||||
std::iota(h_sol.begin(), h_sol.end(), 0);
|
||||
|
||||
const HostDeviceVector<bst_float> in_vec {h_in, device};
|
||||
HostDeviceVector<bst_float> out_vec {h_out, device};
|
||||
|
||||
ASSERT_NO_THROW(Transform<>::Init(TestTransformRange<bst_float>{}, Range{0, size},
|
||||
common::OmpGetNumThreads(0), device)
|
||||
.Eval(&out_vec, &in_vec));
|
||||
std::vector<bst_float> res = out_vec.HostVector();
|
||||
ASSERT_TRUE(std::equal(h_sol.begin(), h_sol.end(), res.begin()));
|
||||
}
|
||||
|
||||
} // namespace common
|
||||
} // namespace xgboost
|
||||
Reference in New Issue
Block a user