Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ set(trace_cache_headers
${CMAKE_CURRENT_LIST_DIR}/unified_memory_processor.hpp
${CMAKE_CURRENT_LIST_DIR}/post_processor.hpp
${CMAKE_CURRENT_LIST_DIR}/sample_processor.hpp
${CMAKE_CURRENT_LIST_DIR}/sample_processor_interface.hpp
${CMAKE_CURRENT_LIST_DIR}/sample_type.hpp
${CMAKE_CURRENT_LIST_DIR}/storage_parser_alias.hpp
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ perfetto_processor_t::perfetto_processor_t(
const std::shared_ptr<agent_manager>& agent_mngr, int pid, [[maybe_unused]] int ppid,
[[maybe_unused]] output_file_registry& output_registry,
rocprofsys::track_registry& tracks)
: processor_t<perfetto_processor_t>()
: sample_processor_interface()
, m_metadata(*metadata)
, m_process_id(pid)
, m_agent_manager(*agent_mngr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "core/output_file_registry.hpp"
#include "core/perfetto/fwd.hpp"
#include "core/trace_cache/metadata_registry.hpp"
#include "core/trace_cache/sample_processor.hpp"
#include "core/trace_cache/sample_processor_interface.hpp"
#include "library/pmc/collectors/hipfile/sample.hpp"
#include <cstdint>

Expand All @@ -34,33 +34,33 @@ struct pmc_track_info
std::function<void(std::uint64_t, std::uint64_t, std::uint64_t, double)> trace_fn;
};

class perfetto_processor_t : public processor_t<perfetto_processor_t>
class perfetto_processor_t : public sample_processor_interface
{
public:
perfetto_processor_t(const std::shared_ptr<metadata_registry>& metadata,
const std::shared_ptr<agent_manager>& agent_mngr, int pid,
int ppid, output_file_registry& output_registry,
rocprofsys::track_registry& tracks);

void prepare_for_processing();
void prepare_for_processing() override;
// Cached-mode drain runs at cache_manager scope (engine.stop());
// per-pid finalize has nothing to do.
void finalize_processing() {}
void finalize_processing() override {}

void handle(const kernel_dispatch_sample& sample);
void handle(const scratch_memory_sample& sample);
void handle(const memory_copy_sample& sample);
void handle(const memory_allocate_sample& sample);
void handle(const region_sample& sample);
void handle(const in_time_sample& sample);
void handle(const pmc_event_with_sample& sample);
void handle(const gpu_pmc_sample& sample);
void handle(const ainic_pmc_sample& sample);
void handle(const cpu_pmc_sample& sample);
void handle(const gpu_perf_counter_sample& sample);
void handle(const hipfile_pmc_sample& sample);
void handle(const backtrace_region_sample& sample);
void handle(const kfd_sample& sample);
void handle(const kernel_dispatch_sample& sample) override;
void handle(const scratch_memory_sample& sample) override;
void handle(const memory_copy_sample& sample) override;
void handle(const memory_allocate_sample& sample) override;
void handle(const region_sample& sample) override;
void handle(const in_time_sample& sample) override;
void handle(const pmc_event_with_sample& sample) override;
void handle(const gpu_pmc_sample& sample) override;
void handle(const ainic_pmc_sample& sample) override;
void handle(const cpu_pmc_sample& sample) override;
void handle(const gpu_perf_counter_sample& sample) override;
void handle(const hipfile_pmc_sample& sample) override;
void handle(const backtrace_region_sample& sample) override;
void handle(const kfd_sample& sample) override;

private:
// Returns a cached ::perfetto::Track for the given (category, args...) key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ configure_processors(
storage.rocpd_processor = std::make_shared<rocpd_processor_t>(
_config->_metadata_registry, _config->_agent_manager, _config->_pid,
_config->_ppid, _registry);
_coordinator->add_handler(*storage.rocpd_processor);
_coordinator->add_handler(storage.rocpd_processor);
}
if(_formats.is_perfetto_enabled() && _engine.has_value() && _tracks.has_value())
{
storage.perfetto_processor = std::make_shared<perfetto_processor_t>(
_config->_metadata_registry, _config->_agent_manager, _config->_pid,
_config->_ppid, _registry, _tracks->get());
_coordinator->add_handler(*storage.perfetto_processor);
_coordinator->add_handler(storage.perfetto_processor);
}

if(_formats.is_unified_memory_enabled())
{
storage.unified_memory_processor = std::make_shared<unified_memory_processor_t>(
_config->_agent_manager, _config->_pid, output_file_sink_view{ _registry });
_coordinator->add_handler(*storage.unified_memory_processor);
_coordinator->add_handler(storage.unified_memory_processor);
LOG_DEBUG("Unified memory processor enabled for PID {}", _config->_pid);
}

Expand All @@ -103,9 +103,8 @@ process_buffered_storage(
_config->_pid);

auto const _coordinator = std::make_shared<sample_processor_t>();
// RAII lifetime guard: configure_processors registers raw references to the
// returned processors as handlers on _coordinator. Holding _storage in scope
// keeps those processors alive until the parse + finalize is done.
// _storage keeps the concrete processors reachable (the coordinator shares
// ownership of them as sample_processor_interface).
[[maybe_unused]] auto const _storage = configure_processors(
_coordinator, _config, _formats, _registry, _engine, _tracks);
storage_parser_t _parser(_storage_filename);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ rocpd_processor_t::rocpd_processor_t(const std::shared_ptr<metadata_registry>& m
const std::shared_ptr<agent_manager>& agent_mngr,
int pid, int ppid,
output_file_registry& output_registry)
: processor_t<rocpd_processor_t>()
: sample_processor_interface()
, m_metadata(md)
, m_agent_manager(agent_mngr)
, m_output_registry(output_registry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "core/node_info.hpp"
#include "core/output_file_registry.hpp"
#include "core/trace_cache/metadata_registry.hpp"
#include "core/trace_cache/sample_processor.hpp"
#include "core/trace_cache/sample_processor_interface.hpp"

#include "library/pmc/collectors/hipfile/sample.hpp"
#include "trace_cache/sample_type.hpp"
Expand All @@ -23,30 +23,30 @@
namespace rocprofsys::trace_cache
{

class rocpd_processor_t : public processor_t<rocpd_processor_t>
class rocpd_processor_t : public sample_processor_interface
{
public:
rocpd_processor_t(const std::shared_ptr<metadata_registry>& metadata,
const std::shared_ptr<agent_manager>& agent_mngr, int pid, int ppid,
output_file_registry& output_registry);

void prepare_for_processing();
void finalize_processing();
void prepare_for_processing() override;
void finalize_processing() override;

void handle(const kernel_dispatch_sample& sample);
void handle(const scratch_memory_sample& sample);
void handle(const memory_copy_sample& sample);
void handle(const memory_allocate_sample& sample);
void handle(const region_sample& sample);
void handle(const in_time_sample& sample);
void handle(const pmc_event_with_sample& sample);
void handle(const backtrace_region_sample& sample);
void handle(const gpu_pmc_sample& sample);
void handle(const ainic_pmc_sample& sample);
void handle(const cpu_pmc_sample& sample);
void handle(const gpu_perf_counter_sample& sample);
void handle(const hipfile_pmc_sample& sample);
void handle(const kfd_sample& sample);
void handle(const kernel_dispatch_sample& sample) override;
void handle(const scratch_memory_sample& sample) override;
void handle(const memory_copy_sample& sample) override;
void handle(const memory_allocate_sample& sample) override;
void handle(const region_sample& sample) override;
void handle(const in_time_sample& sample) override;
void handle(const pmc_event_with_sample& sample) override;
void handle(const backtrace_region_sample& sample) override;
void handle(const gpu_pmc_sample& sample) override;
void handle(const ainic_pmc_sample& sample) override;
void handle(const cpu_pmc_sample& sample) override;
void handle(const gpu_perf_counter_sample& sample) override;
void handle(const hipfile_pmc_sample& sample) override;
void handle(const kfd_sample& sample) override;

private:
void post_process_metadata();
Expand Down
Loading
Loading