Skip to content

Commit

Permalink
Initialise pinned memory
Browse files Browse the repository at this point in the history
  • Loading branch information
RAMitchell committed May 6, 2020
1 parent afb55cf commit 5ea93b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/common/device_helpers.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,15 @@ struct PinnedMemory {
return xgboost::common::Span<T>(static_cast<T *>(temp_storage), size);
}

template <typename T>
xgboost::common::Span<T> GetSpan(size_t size, T init) {
auto result = this->GetSpan<T>(size);
for (auto &e : result) {
e = init;
}
return result;
}

void Free() {
if (temp_storage != nullptr) {
safe_cuda(cudaFreeHost(temp_storage));
Expand Down
8 changes: 3 additions & 5 deletions src/tree/updater_gpu_hist.cu
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,9 @@ struct GPUHistMakerDevice {
// The set of leaves that can be expanded asynchronously
auto expand_set = driver.Pop();
while (!expand_set.empty()) {
auto new_candidates = pinned.GetSpan<ExpandEntry>(expand_set.size() * 2);
auto new_candidates =
pinned.GetSpan<ExpandEntry>(expand_set.size() * 2, ExpandEntry());

for (auto i = 0ull; i < expand_set.size(); i++) {
auto candidate = expand_set.at(i);
if (!candidate.IsValid(param, num_leaves)) {
Expand Down Expand Up @@ -659,10 +661,6 @@ struct GPUHistMakerDevice {
right_child_nidx, *p_tree,
new_candidates.subspan(i * 2, 2));
monitor.StopCuda("EvaluateSplits");
} else {
// Set default
new_candidates[i * 2] = ExpandEntry();
new_candidates[i * 2 + 1] = ExpandEntry();
}
}
dh::safe_cuda(cudaDeviceSynchronize());
Expand Down

0 comments on commit 5ea93b8

Please sign in to comment.