SWDEV-492625 memory free functions (#11)
* SWDEV-492625: Track free memory HSA functions to help determine total amount of memory allocated on the system at any one time
* Minor fixes to address comments
* Update allocation size description
* Moved get function back to specialization, minor typo fixes
* Removed memory_operation_type field, removed memory_pool allocation enum, converted starting address to hex string for json format.
* Made conversion to hex_string a function, changed address to use union rocprofiler_address_t type, changed VMEM descriptors
* Removed as_hex from the global namespace
* Formatting
* Removed TRACK_EVENT for memory allocation, now TRACK_COUNTER for memory allocation is being performed
* Check if address was recorded before retrieving allocation size in generate Perfetto
* Formatting
* Update source/lib/output/generatePerfetto.cpp
* Explicitly disable app-abort tests
* Remove excluding app-abort test from workflow CI
- redundant bc these tests are explicitly marked as disabled now
---------
Co-authored-by: Madsen, Jonathan <Jonathan.Madsen@amd.com>
Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
[ROCm/rocprofiler-sdk commit: 79006bb896]
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
#include <rocprofiler-sdk/internal_threading.h>
|
||||
#include <rocprofiler-sdk/registration.h>
|
||||
#include <rocprofiler-sdk/rocprofiler.h>
|
||||
#include <rocprofiler-sdk/cxx/utility.hpp>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <algorithm>
|
||||
@@ -1843,6 +1844,7 @@ write_perfetto()
|
||||
|
||||
auto tids = std::set<rocprofiler_thread_id_t>{};
|
||||
auto agent_ids = std::set<uint64_t>{};
|
||||
auto agent_ids_alloc = std::set<uint64_t>{};
|
||||
auto agent_queue_ids = std::map<uint64_t, std::set<uint64_t>>{};
|
||||
|
||||
auto _get_agent = [](uint64_t id_handle) -> const rocprofiler_agent_t* {
|
||||
@@ -1875,7 +1877,7 @@ write_perfetto()
|
||||
for(auto itr : memory_allocation_bf_records)
|
||||
{
|
||||
tids.emplace(itr.thread_id);
|
||||
agent_ids.emplace(itr.agent_id.handle);
|
||||
agent_ids_alloc.emplace(itr.agent_id.handle);
|
||||
}
|
||||
|
||||
for(auto itr : kernel_dispatch_bf_records)
|
||||
@@ -1934,6 +1936,36 @@ write_perfetto()
|
||||
agent_tracks.emplace(itr, _track);
|
||||
}
|
||||
|
||||
for(auto itr : agent_ids_alloc)
|
||||
{
|
||||
const auto* _agent = _get_agent(itr);
|
||||
auto _namess = std::stringstream{};
|
||||
|
||||
if(_agent != nullptr)
|
||||
{
|
||||
if(_agent->type == ROCPROFILER_AGENT_TYPE_CPU)
|
||||
_namess << "CPU MEMORY OPERATION [" << itr << "] ";
|
||||
else if(_agent->type == ROCPROFILER_AGENT_TYPE_GPU)
|
||||
_namess << "GPU MEMORY OPERATION [" << itr << "] ";
|
||||
|
||||
if(!std::string_view{_agent->model_name}.empty())
|
||||
_namess << _agent->model_name;
|
||||
else
|
||||
_namess << _agent->product_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
_namess << "UNKNOWN MEMORY OPERATION [" << itr << "] ";
|
||||
}
|
||||
auto _track = ::perfetto::Track{get_hash_id(_namess.str())};
|
||||
auto _desc = _track.Serialize();
|
||||
_desc.set_name(_namess.str());
|
||||
|
||||
perfetto::TrackEvent::SetTrackDescriptor(_track, _desc);
|
||||
|
||||
agent_tracks.emplace(itr, _track);
|
||||
}
|
||||
|
||||
auto agent_queue_tracks =
|
||||
std::unordered_map<uint64_t, std::unordered_map<uint64_t, ::perfetto::Track>>{};
|
||||
|
||||
@@ -2155,35 +2187,6 @@ write_perfetto()
|
||||
itr.end_timestamp);
|
||||
}
|
||||
|
||||
for(auto itr : memory_allocation_bf_records)
|
||||
{
|
||||
auto name = buffer_names.at(itr.kind, itr.operation);
|
||||
auto& track = agent_tracks.at(itr.agent_id.handle);
|
||||
|
||||
TRACE_EVENT_BEGIN(sdk::perfetto_category<sdk::category::memory_allocation>::name,
|
||||
::perfetto::StaticString(name.data()),
|
||||
track,
|
||||
itr.start_timestamp,
|
||||
::perfetto::Flow::ProcessScoped(itr.correlation_id.internal),
|
||||
"begin_ns",
|
||||
itr.start_timestamp,
|
||||
"kind",
|
||||
itr.kind,
|
||||
"operation",
|
||||
itr.operation,
|
||||
"agent",
|
||||
agents_map.at(itr.agent_id).logical_node_id,
|
||||
"Allocation_size",
|
||||
itr.allocation_size,
|
||||
"Starting_address",
|
||||
itr.starting_address);
|
||||
TRACE_EVENT_END(sdk::perfetto_category<sdk::category::memory_allocation>::name,
|
||||
track,
|
||||
itr.end_timestamp,
|
||||
"end_ns",
|
||||
itr.end_timestamp);
|
||||
}
|
||||
|
||||
auto demangled = std::unordered_map<std::string_view, std::string>{};
|
||||
for(auto itr : kernel_dispatch_bf_records)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user