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

Get the Total Amount of Umpire Memory Allocated #929

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

kab163
Copy link
Contributor

@kab163 kab163 commented Jan 17, 2025

No description provided.

auto& rm = umpire::ResourceManager::getInstance();
std::size_t total_memory{0};

for (auto s : rm.getResourceNames()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this limited to the base resources (PINNED, UNIFIED_MEMORY, DEVICE, HOST, etc...)? Or does it include the pools built on top of them? Just want to make sure we're not double counting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just resources - this is the correct way to get everything (including any alignment adjustments) without double counting.

@@ -328,6 +328,7 @@ class ResourceManager {
util::AllocationMap m_allocations;

std::list<std::unique_ptr<strategy::AllocationStrategy>> m_allocators;
std::vector<std::string> m_shared_allocators_by_name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::vector<std::string> m_shared_allocators_by_name;
std::vector<std::string> m_shared_allocator_names;

The by_name suggests it's a structure to access the allocators by their names (like a map). This isn't the case, so I suggest a slightly different name.

@@ -347,6 +348,7 @@ class ResourceManager {
friend std::vector<util::AllocationRecord> get_allocator_records(Allocator);
friend strategy::ZeroByteHandler;
friend strategy::mixins::AllocateNull;
friend std::size_t get_total_memory_allocated();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a method to the get the names, rather than having this be a friend and accessing the data structure directly

auto& rm = umpire::ResourceManager::getInstance();
std::size_t total_memory{0};

for (auto s : rm.getResourceNames()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just resources - this is the correct way to get everything (including any alignment adjustments) without double counting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants