Skip to content

Commit

Permalink
more review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rongou committed Apr 29, 2019
1 parent ea15c89 commit 3550257
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/common/host_device_vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ template <typename T>
void HostDeviceVector<T>::Shard(GPUSet devices) const { }

template <typename T>
void Reshard(const GPUDistribution &distribution, bool preserve_gpu_data) { }
void Reshard(const GPUDistribution &distribution, bool preserve) { }

// explicit instantiations are required, as HostDeviceVector isn't header-only
template class HostDeviceVector<bst_float>;
Expand Down
8 changes: 4 additions & 4 deletions src/common/host_device_vector.cu
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ struct HostDeviceVectorImpl {
Shard(GPUDistribution::Block(new_devices));
}

void Reshard(const GPUDistribution &distribution, bool preserve_gpu_data) {
void Reshard(const GPUDistribution &distribution, bool preserve) {
if (distribution_ == distribution) { return; }
if (preserve_gpu_data) {
if (preserve) {
LazySyncHost(GPUAccess::kWrite);
}
distribution_ = distribution;
Expand Down Expand Up @@ -604,8 +604,8 @@ void HostDeviceVector<T>::Shard(const GPUDistribution &distribution) const {
}

template <typename T>
void HostDeviceVector<T>::Reshard(const GPUDistribution &distribution, bool preserve_gpu_data) {
impl_->Reshard(distribution, preserve_gpu_data);
void HostDeviceVector<T>::Reshard(const GPUDistribution &distribution, bool preserve) {
impl_->Reshard(distribution, preserve);
}

template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion src/common/host_device_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class HostDeviceVector {
/*!
* \brief Change memory distribution.
*/
void Reshard(const GPUDistribution &distribution, bool preserve_gpu_data=true);
void Reshard(const GPUDistribution &distribution, bool preserve=true);

void Resize(size_t new_size, T v = T());

Expand Down
8 changes: 3 additions & 5 deletions tests/cpp/common/test_host_device_vector.cu
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,11 @@ TEST(HostDeviceVector, Reshard) {
ASSERT_EQ(h_vec_1.at(i), i + 1);
}

vec.Shard(devices);
vec.Reshard(GPUDistribution::Block(devices));
span = vec.DeviceSpan(0); // sync to device
PlusOne(&vec);

// GPU data is discarded.
vec.Reshard(GPUDistribution::Empty(), /*preserve_gpu_data=*/false);
vec.Reshard(GPUDistribution::Empty(), /*preserve=*/false);
ASSERT_EQ(vec.Size(), h_vec.size());
ASSERT_TRUE(vec.Devices().IsEmpty());

Expand Down Expand Up @@ -341,8 +340,7 @@ TEST(HostDeviceVector, MGPU_Reshard) {
}
PlusOne(&vec);

// Reshard again, but discard the GPU data.
vec.Reshard(GPUDistribution::Overlap(devices, 11), /*preserve_gpu_data=*/false);
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);
Expand Down

0 comments on commit 3550257

Please sign in to comment.