Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper for printing Umpire pool statistics #1179

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/dlaf/memory/memory_chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace dlaf {
namespace memory {

namespace internal {
void print_cuda_stats(std::string_view label);

umpire::Allocator& getUmpireHostAllocator();
void initializeUmpireHostAllocator(std::size_t initial_bytes);
void finalizeUmpireHostAllocator();
Expand Down
45 changes: 45 additions & 0 deletions src/memory/memory_chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,60 @@

#include <cstddef>

#include <mpi.h>

#include <umpire/ResourceManager.hpp>
#include <umpire/strategy/QuickPool.hpp>
#include <umpire/strategy/ThreadSafeAllocator.hpp>

#include <pika/init.hpp>

#include <dlaf/memory/memory_chunk.h>

#include <string_view>

namespace dlaf {
namespace memory {
namespace internal {
static void print_alloc_stats(std::string label, std::ostream& os) {
auto alloc = umpire::ResourceManager::getInstance().getAllocator(label);
os << "name: " << alloc.getName() << ", ";
os << "id: " << alloc.getId() << ", ";
os << "strategy: " << alloc.getStrategyName() << ", ";
os << "high water: " << alloc.getHighWatermark() << ", ";
os << "current size: " << alloc.getCurrentSize() << ", ";
os << "actual size: " << alloc.getActualSize() << ", ";
os << "alloc count: " << alloc.getAllocationCount() << ", ";
os << '\n';
}

void print_cuda_stats(std::string_view label) {
// if (pika::is_runtime_initialized()) { pika::wait(); }
// cudaDeviceSynchronize();
std::size_t cuda_free, cuda_total;
int id = 0;
cudaGetDevice(&id);
cudaMemGetInfo(&cuda_free, &cuda_total);

int rank = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

std::ostringstream os;
os << "### " << label << '\n';
os << "rank: " << rank << ", ";
os << "cuda_free: " << cuda_free << ", ";
os << "cuda_total: " << cuda_total << '\n';

print_alloc_stats("DEVICE", os);
print_alloc_stats("DEVICE_pool", os);
print_alloc_stats("DEVICE_thread_safe_pool", os);
print_alloc_stats("PINNED", os);
print_alloc_stats("PINNED_pool", os);
print_alloc_stats("PINNED_thread_safe_pool", os);

std::cerr << os.str();
}

#ifdef DLAF_WITH_GPU
umpire::Allocator& getUmpireHostAllocator() {
static auto host_allocator = umpire::ResourceManager::getInstance().getAllocator("PINNED");
Expand Down
Loading