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)};
|
std::make_unique<hipcub::CachingDeviceAllocator>(2, 9, 29)};
|
||||||
return *allocator;
|
return *allocator;
|
||||||
}
|
}
|
||||||
pointer allocate(size_t n) { // NOLINT
|
pointer allocate(size_t n) {
|
||||||
pointer thrust_ptr;
|
pointer thrust_ptr;
|
||||||
if (use_cub_allocator_) {
|
if (use_cub_allocator_) {
|
||||||
T* raw_ptr{nullptr};
|
T* raw_ptr{nullptr};
|
||||||
auto errc = GetGlobalCachingAllocator().DeviceAllocate(reinterpret_cast<void **>(&raw_ptr),
|
auto errc = GetGlobalCachingAllocator().DeviceAllocate(reinterpret_cast<void **>(&raw_ptr), n * sizeof(T));
|
||||||
n * sizeof(T));
|
|
||||||
if (errc != hipSuccess) {
|
if (errc != hipSuccess) {
|
||||||
ThrowOOMError("Caching allocator", n * sizeof(T));
|
ThrowOOMError("Caching allocator", n * sizeof(T));
|
||||||
}
|
}
|
||||||
@ -459,10 +458,14 @@ struct XGBCachingDeviceAllocatorImpl : XGBBaseDeviceAllocator<T> {
|
|||||||
ThrowOOMError(e.what(), n * sizeof(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));
|
GlobalMemoryLogger().RegisterAllocation(thrust_ptr.get(), n * sizeof(T));
|
||||||
return thrust_ptr;
|
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));
|
GlobalMemoryLogger().RegisterDeallocation(ptr.get(), n * sizeof(T));
|
||||||
if (use_cub_allocator_) {
|
if (use_cub_allocator_) {
|
||||||
GetGlobalCachingAllocator().DeviceFree(ptr.get());
|
GetGlobalCachingAllocator().DeviceFree(ptr.get());
|
||||||
@ -574,6 +577,8 @@ xgboost::common::Span<T> LazyResize(xgboost::Context const *ctx,
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void CopyDeviceSpanToVector(std::vector<T> *dst, xgboost::common::Span<T> src) {
|
void CopyDeviceSpanToVector(std::vector<T> *dst, xgboost::common::Span<T> src) {
|
||||||
CHECK_EQ(dst->size(), src.size());
|
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),
|
dh::safe_cuda(hipMemcpyAsync(dst->data(), src.data(), dst->size() * sizeof(T),
|
||||||
hipMemcpyDeviceToHost));
|
hipMemcpyDeviceToHost));
|
||||||
}
|
}
|
||||||
@ -601,10 +606,11 @@ void CopyToD(HContainer const &h, DContainer *d) {
|
|||||||
d->resize(h.size());
|
d->resize(h.size());
|
||||||
using HVT = std::remove_cv_t<typename HContainer::value_type>;
|
using HVT = std::remove_cv_t<typename HContainer::value_type>;
|
||||||
using DVT = std::remove_cv_t<typename DContainer::value_type>;
|
using DVT = std::remove_cv_t<typename DContainer::value_type>;
|
||||||
static_assert(std::is_same<HVT, DVT>::value,
|
static_assert(std::is_same<HVT, DVT>::value, "Host and device containers must have same value type.");
|
||||||
"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),
|
dh::safe_cuda(hipMemcpyAsync(d->data().get(), h.data(), h.size() * sizeof(HVT),
|
||||||
hipMemcpyHostToDevice));
|
hipMemcpyHostToDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of pinned memory allocation
|
// Keep track of pinned memory allocation
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user