Skip to content

Commit

Permalink
Don't copy.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Sep 25, 2020
1 parent b4fba09 commit cca9ec0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/common/device_helpers.cuh
Expand Up @@ -538,6 +538,10 @@ void CopyDeviceSpanToVector(std::vector<T> *dst, xgboost::common::Span<const T>

template <class HContainer, class DContainer>
void CopyToD(HContainer const &h, DContainer *d) {
if (h.empty()) {
d->clear();
return;
}
d->resize(h.size());
using HVT = std::remove_cv_t<typename HContainer::value_type>;
using DVT = std::remove_cv_t<typename DContainer::value_type>;
Expand Down
8 changes: 5 additions & 3 deletions src/tree/updater_gpu_hist.cu
Expand Up @@ -457,9 +457,11 @@ struct GPUHistMakerDevice {
dh::caching_device_vector<uint32_t> d_categories;
dh::caching_device_vector<RegTree::Segment> d_categories_segments;

dh::CopyToD(h_split_types, &d_split_types);
dh::CopyToD(categories, &d_categories);
dh::CopyToD(categories_segments, &d_categories_segments);
if (!categories.empty()) {
dh::CopyToD(h_split_types, &d_split_types);
dh::CopyToD(categories, &d_categories);
dh::CopyToD(categories_segments, &d_categories_segments);
}

if (row_partitioner->GetRows().size() != p_fmat->Info().num_row_) {
row_partitioner.reset(); // Release the device memory first before reallocating
Expand Down

0 comments on commit cca9ec0

Please sign in to comment.