-
Notifications
You must be signed in to change notification settings - Fork 52
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
base: develop
Are you sure you want to change the base?
Changes from all commits
fe6cb12
fafc983
77a662d
2c0ff4d
a6c693b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
std::unordered_map<int, strategy::AllocationStrategy*> m_allocators_by_id; | ||
std::unordered_map<std::string, strategy::AllocationStrategy*> m_allocators_by_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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
}; | ||
|
||
} // end namespace umpire | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,6 +173,24 @@ void mark_event(const std::string& event) | |
[&](auto& e) { e.name("event").category(event::category::metadata).arg("name", event).tag("replay", "true"); }); | ||
} | ||
|
||
std::size_t get_total_memory_allocated() | ||
{ | ||
auto& rm = umpire::ResourceManager::getInstance(); | ||
std::size_t total_memory{0}; | ||
|
||
for (auto s : rm.getResourceNames()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
umpire::Allocator alloc = rm.getAllocator(s); | ||
total_memory += alloc.getActualSize(); | ||
} | ||
|
||
for (auto s : rm.m_shared_allocators_by_name) { | ||
umpire::Allocator alloc = rm.getAllocator(s); | ||
total_memory += alloc.getActualSize(); | ||
} | ||
|
||
return total_memory; | ||
} | ||
|
||
std::size_t get_device_memory_usage(int device_id) | ||
{ | ||
#if defined(UMPIRE_ENABLE_CUDA) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.