ROCpd support [Part 2] (#109)

* Rocpd part 2, caching

* Fix shadowed variables

* backward compatibility

* Fixed designated initializers

* Fix timemory include

* Remove benchmark & Fix build issues for rhel

* Add missing bracket

* Fix shadowing and pedantic

* Fix pedantic pt2

* Fix duplicated SDK calls

* Add decay in get_size_impl

* Rename sample cache to trace cache

* Add cache storage supported types

* Resolving track naming in sampling module

* fix sampling of flushing thread

* fix sampling of flushing thread 2

* throw exception upon store while buffer storage is not running

* Prevent fork crashing

* Fix rebase issue

* Applied suggestions from code review

* Change flushing thread to use PTL

* Fix agent creation order

* Fix stream id ci throw

* Remove force setup of rocprofiler-sdk

* Code cleanup

* Change initialization for agent

* Add missing namespace

* Fix the mismatch within the tool_agent->device_id

* Switch from using handle to use agent type index

* Fix pmc info comparator in metadata registry

---------

Co-authored-by: Aleksandar <aleksandar.djordjevic@amd.com>
Co-authored-by: Milan Radosavljevic <milan.radosavljevic@amd.com>
Co-authored-by: Marjan Antic <marantic@amd.com>
This commit is contained in:
systems-assistant[bot]
2025-08-19 22:01:04 -04:00
gecommit door GitHub
bovenliggende 351d598869
commit 1f86010ca2
40 gewijzigde bestanden met toevoegingen van 3432 en 1184 verwijderingen
@@ -44,6 +44,7 @@
#include "core/perfetto_fwd.hpp"
#include "core/rocpd/data_processor.hpp"
#include "core/timemory.hpp"
#include "core/trace_cache/cache_manager.hpp"
#include "core/utility.hpp"
#include "library/causal/data.hpp"
#include "library/causal/experiment.hpp"
@@ -328,37 +329,17 @@ read_command_line(pid_t _pid)
}
void
rocprofsys_preinit_rocpd()
rocprofsys_preinit_cache()
{
auto& _data_processor = rocpd::data_processor::get_instance();
const auto& _n_info = node_info::get_instance();
auto _cmd_line = read_command_line(getpid());
auto& _agent_manager = agent_manager::get_instance();
auto _cmd_line = read_command_line(getpid());
if(_cmd_line.empty())
{
_cmd_line.emplace_back("rocprofiler-systems");
}
_data_processor.insert_node_info(
_n_info.id, _n_info.hash, _n_info.machine_id.c_str(), _n_info.system_name.c_str(),
_n_info.node_name.c_str(), _n_info.release.c_str(), _n_info.version.c_str(),
_n_info.machine.c_str(), _n_info.domain_name.c_str());
_data_processor.insert_process_info(_n_info.id, getppid(), getpid(), 0, 0, 0, 0,
_cmd_line[0].c_str(), "{}");
const auto& agents = _agent_manager.get_agents();
for(const auto& rocpd_agent : agents)
{
auto _base_id = rocpd::data_processor::get_instance().insert_agent(
_n_info.id, getpid(),
((rocpd_agent->type == agent_type::GPU) ? "GPU" : "CPU"),
rocpd_agent->node_id, rocpd_agent->logical_node_id,
rocpd_agent->logical_node_type_id, rocpd_agent->id, rocpd_agent->name.c_str(),
rocpd_agent->model_name.c_str(), rocpd_agent->vendor_name.c_str(),
rocpd_agent->product_name.c_str(), "");
rocpd_agent->base_id = _base_id;
}
trace_cache::get_metadata_registry().set_process(
{ getpid(), getppid(), _cmd_line.at(0) });
}
void
@@ -534,7 +515,7 @@ rocprofsys_init_tooling_hidden(void)
#if !(ROCPROFSYS_USE_ROCM > 0)
rocprofsys_preinit_cpu_agents();
#endif
if(get_use_rocpd()) rocprofsys_preinit_rocpd();
rocprofsys_preinit_cache();
if(get_use_process_sampling())
{
@@ -776,10 +757,16 @@ rocprofsys_finalize_hidden(void)
rocprofiler_sdk::shutdown();
}
#endif
auto& _manager = rocprofsys::trace_cache::cache_manager::get_instance();
_manager.shutdown();
_manager.post_process();
#if ROCPROFSYS_USE_ROCM > 0
if(get_use_rocpd())
{
rocpd::data_processor::get_instance().flush();
}
#endif
set_state(State::Finalized);
std::quick_exit(EXIT_SUCCESS);
return;
@@ -880,6 +867,12 @@ rocprofsys_finalize_hidden(void)
}
#endif
{
auto& _manager = rocprofsys::trace_cache::cache_manager::get_instance();
_manager.shutdown();
_manager.post_process();
}
ROCPROFSYS_DEBUG_F("Stopping and destroying instrumentation bundles...\n");
for(size_t i = 0; i < thread_info::get_peak_num_threads(); ++i)
{
@@ -1070,10 +1063,12 @@ rocprofsys_finalize_hidden(void)
[](int) {});
common::destroy_static_objects();
#if ROCPROFSYS_USE_ROCM > 0
if(get_use_rocpd())
{
rocpd::data_processor::get_instance().flush();
}
#endif
}
//======================================================================================//