Skip to content

Commit

Permalink
Minor refactor of split evaluation in gpu_hist (#3889)
Browse files Browse the repository at this point in the history
* Refactor evaluate split into shard

* Use span in evaluate split

* Update google tests
  • Loading branch information
RAMitchell authored Nov 13, 2018
1 parent daf77ca commit 926eb65
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 193 deletions.
13 changes: 11 additions & 2 deletions src/common/device_helpers.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ class DVec {

const T *Data() const { return ptr_; }

xgboost::common::Span<const T> GetSpan() const {
return xgboost::common::Span<const T>(ptr_, this->Size());
}

xgboost::common::Span<T> GetSpan() {
return xgboost::common::Span<T>(ptr_, this->Size());
}

std::vector<T> AsVector() const {
std::vector<T> h_vector(Size());
safe_cuda(cudaSetDevice(device_idx_));
Expand Down Expand Up @@ -497,8 +505,9 @@ struct CubMemory {
~CubMemory() { Free(); }

template <typename T>
T *Pointer() {
return static_cast<T *>(d_temp_storage);
xgboost::common::Span<T> GetSpan(size_t size) {
this->LazyAllocate(size * sizeof(T));
return xgboost::common::Span<T>(static_cast<T*>(d_temp_storage), size);
}

void Free() {
Expand Down
Loading

0 comments on commit 926eb65

Please sign in to comment.