diff --git a/src/common/host_device_vector.cc b/src/common/host_device_vector.cc index a3e3ca3c50f0..6ccb1a661739 100644 --- a/src/common/host_device_vector.cc +++ b/src/common/host_device_vector.cc @@ -160,7 +160,7 @@ template void HostDeviceVector::Shard(GPUSet devices) const { } template -void Reshard(const GPUDistribution &distribution, bool preserve) { } +void Reshard(const GPUDistribution &distribution) { } // explicit instantiations are required, as HostDeviceVector isn't header-only template class HostDeviceVector; diff --git a/src/common/host_device_vector.cu b/src/common/host_device_vector.cu index bb4ff95fdb90..7ed173188dd1 100644 --- a/src/common/host_device_vector.cu +++ b/src/common/host_device_vector.cu @@ -370,14 +370,11 @@ struct HostDeviceVectorImpl { Shard(GPUDistribution::Block(new_devices)); } - void Reshard(const GPUDistribution &distribution, bool preserve) { + void Reshard(const GPUDistribution &distribution) { if (distribution_ == distribution) { return; } - if (preserve) { - LazySyncHost(GPUAccess::kWrite); - } + LazySyncHost(GPUAccess::kWrite); distribution_ = distribution; shards_.clear(); - perm_h_.Grant(kWrite); InitShards(); } @@ -604,8 +601,8 @@ void HostDeviceVector::Shard(const GPUDistribution &distribution) const { } template -void HostDeviceVector::Reshard(const GPUDistribution &distribution, bool preserve) { - impl_->Reshard(distribution, preserve); +void HostDeviceVector::Reshard(const GPUDistribution &distribution) { + impl_->Reshard(distribution); } template diff --git a/src/common/host_device_vector.h b/src/common/host_device_vector.h index e019a90ea30f..db27832b623e 100644 --- a/src/common/host_device_vector.h +++ b/src/common/host_device_vector.h @@ -259,7 +259,7 @@ class HostDeviceVector { /*! * \brief Change memory distribution. */ - void Reshard(const GPUDistribution &distribution, bool preserve = true); + void Reshard(const GPUDistribution &distribution); void Resize(size_t new_size, T v = T()); diff --git a/tests/cpp/common/test_host_device_vector.cu b/tests/cpp/common/test_host_device_vector.cu index 1abcdadf0d68..6aca78c81455 100644 --- a/tests/cpp/common/test_host_device_vector.cu +++ b/tests/cpp/common/test_host_device_vector.cu @@ -213,7 +213,6 @@ TEST(HostDeviceVector, Reshard) { auto span = vec.DeviceSpan(0); // sync to device PlusOne(&vec); - // GPU data is preserved. vec.Reshard(GPUDistribution::Empty()); ASSERT_EQ(vec.Size(), h_vec.size()); ASSERT_TRUE(vec.Devices().IsEmpty()); @@ -222,20 +221,6 @@ TEST(HostDeviceVector, Reshard) { for (size_t i = 0; i < h_vec_1.size(); ++i) { ASSERT_EQ(h_vec_1.at(i), i + 1); } - - vec.Reshard(GPUDistribution::Block(devices)); - span = vec.DeviceSpan(0); // sync to device - PlusOne(&vec); - - vec.Reshard(GPUDistribution::Empty(), /*preserve=*/false); - ASSERT_EQ(vec.Size(), h_vec.size()); - ASSERT_TRUE(vec.Devices().IsEmpty()); - - auto h_vec_2 = vec.HostVector(); - for (size_t i = 0; i < h_vec_2.size(); ++i) { - // The second `PlusOne()` has no effect. - ASSERT_EQ(h_vec_2.at(i), i + 1); - } } TEST(HostDeviceVector, Span) { @@ -334,27 +319,6 @@ TEST(HostDeviceVector, MGPU_Reshard) { for (size_t i = 0; i < h_vec_1.size(); ++i) { ASSERT_EQ(h_vec_1.at(i), i + 1); } - - for (size_t i = 0; i < devices.Size(); ++i) { - auto span = vec.DeviceSpan(i); // sync to device - } - PlusOne(&vec); - - vec.Reshard(GPUDistribution::Overlap(devices, 11), /*preserve=*/false); - total_size = 0; - for (size_t i = 0; i < devices.Size(); ++i) { - total_size += vec.DeviceSize(i); - devices_size[i] = vec.DeviceSize(i); - } - overlap = 11 * (devices.Size() - 1); - ASSERT_EQ(total_size, h_vec.size() + overlap); - ASSERT_EQ(total_size, vec.Size() + overlap); - - auto h_vec_2 = vec.HostVector(); - for (size_t i = 0; i < h_vec_2.size(); ++i) { - // The second `PlusOne()` has no effect. - ASSERT_EQ(h_vec_2.at(i), i + 1); - } } #endif