Reduce device synchronisation (#5631)

* Reduce device synchronisation

* Initialise pinned memory
This commit is contained in:
Rory Mitchell
2020-05-07 21:19:46 +12:00
committed by GitHub
parent 9910265064
commit fcf57823b6
7 changed files with 260 additions and 118 deletions

View File

@@ -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));