Fix memory usage of device sketching (#5407)

This commit is contained in:
Rory Mitchell
2020-03-14 13:43:24 +13:00
committed by GitHub
parent bb8c8df39d
commit b745b7acce
13 changed files with 153 additions and 73 deletions

View File

@@ -378,6 +378,11 @@ public:
{
return stats_.peak_allocated_bytes;
}
void Clear()
{
stats_ = DeviceStats();
}
void Log() {
if (!xgboost::ConsoleLogger::ShouldLog(xgboost::ConsoleLogger::LV::kDebug))
return;
@@ -475,7 +480,8 @@ struct XGBCachingDeviceAllocatorImpl : thrust::device_malloc_allocator<T> {
template <typename T>
using XGBDeviceAllocator = detail::XGBDefaultDeviceAllocatorImpl<T>;
/*! Be careful that the initialization constructor is a no-op, which means calling
* `vec.resize(n, 1)` won't initialize the memory region to 1. */
* `vec.resize(n)` won't initialize the memory region to 0. Instead use
* `vec.resize(n, 0)`*/
template <typename T>
using XGBCachingDeviceAllocator = detail::XGBCachingDeviceAllocatorImpl<T>;
/** \brief Specialisation of thrust device vector using custom allocator. */