more logging
This commit is contained in:
parent
4a10135006
commit
c964dd62b4
@ -441,12 +441,11 @@ struct XGBCachingDeviceAllocatorImpl : XGBBaseDeviceAllocator<T> {
|
||||
std::make_unique<hipcub::CachingDeviceAllocator>(2, 9, 29)};
|
||||
return *allocator;
|
||||
}
|
||||
pointer allocate(size_t n) { // NOLINT
|
||||
pointer allocate(size_t n) {
|
||||
pointer thrust_ptr;
|
||||
if (use_cub_allocator_) {
|
||||
T* raw_ptr{nullptr};
|
||||
auto errc = GetGlobalCachingAllocator().DeviceAllocate(reinterpret_cast<void **>(&raw_ptr),
|
||||
n * sizeof(T));
|
||||
auto errc = GetGlobalCachingAllocator().DeviceAllocate(reinterpret_cast<void **>(&raw_ptr), n * sizeof(T));
|
||||
if (errc != hipSuccess) {
|
||||
ThrowOOMError("Caching allocator", n * sizeof(T));
|
||||
}
|
||||
@ -459,10 +458,14 @@ struct XGBCachingDeviceAllocatorImpl : XGBBaseDeviceAllocator<T> {
|
||||
ThrowOOMError(e.what(), n * sizeof(T));
|
||||
}
|
||||
}
|
||||
std::cerr << "XGBCachingDeviceAllocatorImpl: Allocated " << n * sizeof(T)
|
||||
<< " bytes at " << thrust_ptr.get() << std::endl;
|
||||
GlobalMemoryLogger().RegisterAllocation(thrust_ptr.get(), n * sizeof(T));
|
||||
return thrust_ptr;
|
||||
}
|
||||
void deallocate(pointer ptr, size_t n) { // NOLINT
|
||||
void deallocate(pointer ptr, size_t n) {
|
||||
std::cerr << "XGBCachingDeviceAllocatorImpl: Deallocating " << n * sizeof(T)
|
||||
<< " bytes at " << ptr.get() << std::endl;
|
||||
GlobalMemoryLogger().RegisterDeallocation(ptr.get(), n * sizeof(T));
|
||||
if (use_cub_allocator_) {
|
||||
GetGlobalCachingAllocator().DeviceFree(ptr.get());
|
||||
@ -574,6 +577,8 @@ xgboost::common::Span<T> LazyResize(xgboost::Context const *ctx,
|
||||
template <typename T>
|
||||
void CopyDeviceSpanToVector(std::vector<T> *dst, xgboost::common::Span<T> src) {
|
||||
CHECK_EQ(dst->size(), src.size());
|
||||
std::cerr << "CopyDeviceSpanToVector: Copying " << src.size() * sizeof(T)
|
||||
<< " bytes from device to host" << std::endl;
|
||||
dh::safe_cuda(hipMemcpyAsync(dst->data(), src.data(), dst->size() * sizeof(T),
|
||||
hipMemcpyDeviceToHost));
|
||||
}
|
||||
@ -601,8 +606,9 @@ void CopyToD(HContainer const &h, DContainer *d) {
|
||||
d->resize(h.size());
|
||||
using HVT = std::remove_cv_t<typename HContainer::value_type>;
|
||||
using DVT = std::remove_cv_t<typename DContainer::value_type>;
|
||||
static_assert(std::is_same<HVT, DVT>::value,
|
||||
"Host and device containers must have same value type.");
|
||||
static_assert(std::is_same<HVT, DVT>::value, "Host and device containers must have same value type.");
|
||||
std::cerr << "CopyToD: Copying " << h.size() * sizeof(HVT)
|
||||
<< " bytes from host to device" << std::endl;
|
||||
dh::safe_cuda(hipMemcpyAsync(d->data().get(), h.data(), h.size() * sizeof(HVT),
|
||||
hipMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user