From d088352ef4b2bba3a341fb450e7e2d6aee4d859e Mon Sep 17 00:00:00 2001 From: Milan Radosavljevic Date: Mon, 5 Oct 2026 11:47:21 +0200 Subject: [PATCH] Add sample processor interface --- .../lib/core/trace_cache/CMakeLists.txt | 1 + .../core/trace_cache/perfetto_processor.cpp | 2 +- .../core/trace_cache/perfetto_processor.hpp | 36 +-- .../lib/core/trace_cache/post_processor.cpp | 11 +- .../lib/core/trace_cache/rocpd_processor.cpp | 2 +- .../lib/core/trace_cache/rocpd_processor.hpp | 36 +-- .../lib/core/trace_cache/sample_processor.hpp | 294 +----------------- .../sample_processor_interface.hpp | 49 +++ .../trace_cache/unified_memory_processor.cpp | 2 +- .../trace_cache/unified_memory_processor.hpp | 40 +-- 10 files changed, 128 insertions(+), 345 deletions(-) create mode 100644 projects/rocprofiler-systems/source/lib/core/trace_cache/sample_processor_interface.hpp diff --git a/projects/rocprofiler-systems/source/lib/core/trace_cache/CMakeLists.txt b/projects/rocprofiler-systems/source/lib/core/trace_cache/CMakeLists.txt index aaee5e532d6d..bd632d886d4e 100644 --- a/projects/rocprofiler-systems/source/lib/core/trace_cache/CMakeLists.txt +++ b/projects/rocprofiler-systems/source/lib/core/trace_cache/CMakeLists.txt @@ -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 ) diff --git a/projects/rocprofiler-systems/source/lib/core/trace_cache/perfetto_processor.cpp b/projects/rocprofiler-systems/source/lib/core/trace_cache/perfetto_processor.cpp index 032d1f993418..97c5a893997e 100644 --- a/projects/rocprofiler-systems/source/lib/core/trace_cache/perfetto_processor.cpp +++ b/projects/rocprofiler-systems/source/lib/core/trace_cache/perfetto_processor.cpp @@ -510,7 +510,7 @@ perfetto_processor_t::perfetto_processor_t( const std::shared_ptr& agent_mngr, int pid, [[maybe_unused]] int ppid, [[maybe_unused]] output_file_registry& output_registry, rocprofsys::track_registry& tracks) -: processor_t() +: sample_processor_interface() , m_metadata(*metadata) , m_process_id(pid) , m_agent_manager(*agent_mngr) diff --git a/projects/rocprofiler-systems/source/lib/core/trace_cache/perfetto_processor.hpp b/projects/rocprofiler-systems/source/lib/core/trace_cache/perfetto_processor.hpp index 1deebdec760d..71ff33b6a7c8 100644 --- a/projects/rocprofiler-systems/source/lib/core/trace_cache/perfetto_processor.hpp +++ b/projects/rocprofiler-systems/source/lib/core/trace_cache/perfetto_processor.hpp @@ -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 @@ -34,7 +34,7 @@ struct pmc_track_info std::function trace_fn; }; -class perfetto_processor_t : public processor_t +class perfetto_processor_t : public sample_processor_interface { public: perfetto_processor_t(const std::shared_ptr& metadata, @@ -42,25 +42,25 @@ class perfetto_processor_t : public processor_t 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, diff --git a/projects/rocprofiler-systems/source/lib/core/trace_cache/post_processor.cpp b/projects/rocprofiler-systems/source/lib/core/trace_cache/post_processor.cpp index bc0ffa39804f..8b8b93bd11ed 100644 --- a/projects/rocprofiler-systems/source/lib/core/trace_cache/post_processor.cpp +++ b/projects/rocprofiler-systems/source/lib/core/trace_cache/post_processor.cpp @@ -70,21 +70,21 @@ configure_processors( storage.rocpd_processor = std::make_shared( _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( _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( _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); } @@ -103,9 +103,8 @@ process_buffered_storage( _config->_pid); auto const _coordinator = std::make_shared(); - // 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); diff --git a/projects/rocprofiler-systems/source/lib/core/trace_cache/rocpd_processor.cpp b/projects/rocprofiler-systems/source/lib/core/trace_cache/rocpd_processor.cpp index 57bc95125363..0ed25ddb0d7d 100644 --- a/projects/rocprofiler-systems/source/lib/core/trace_cache/rocpd_processor.cpp +++ b/projects/rocprofiler-systems/source/lib/core/trace_cache/rocpd_processor.cpp @@ -1078,7 +1078,7 @@ rocpd_processor_t::rocpd_processor_t(const std::shared_ptr& m const std::shared_ptr& agent_mngr, int pid, int ppid, output_file_registry& output_registry) -: processor_t() +: sample_processor_interface() , m_metadata(md) , m_agent_manager(agent_mngr) , m_output_registry(output_registry) diff --git a/projects/rocprofiler-systems/source/lib/core/trace_cache/rocpd_processor.hpp b/projects/rocprofiler-systems/source/lib/core/trace_cache/rocpd_processor.hpp index 43167df7d730..6bc37fa1fd21 100644 --- a/projects/rocprofiler-systems/source/lib/core/trace_cache/rocpd_processor.hpp +++ b/projects/rocprofiler-systems/source/lib/core/trace_cache/rocpd_processor.hpp @@ -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" @@ -23,30 +23,30 @@ namespace rocprofsys::trace_cache { -class rocpd_processor_t : public processor_t +class rocpd_processor_t : public sample_processor_interface { public: rocpd_processor_t(const std::shared_ptr& metadata, const std::shared_ptr& 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(); diff --git a/projects/rocprofiler-systems/source/lib/core/trace_cache/sample_processor.hpp b/projects/rocprofiler-systems/source/lib/core/trace_cache/sample_processor.hpp index 55e62fec5e82..d0522699191b 100644 --- a/projects/rocprofiler-systems/source/lib/core/trace_cache/sample_processor.hpp +++ b/projects/rocprofiler-systems/source/lib/core/trace_cache/sample_processor.hpp @@ -4,321 +4,55 @@ #pragma once #include "common/defines.h" #include "core/trace_cache/cacheable.hpp" +#include "core/trace_cache/sample_processor_interface.hpp" #include "core/trace_cache/sample_type.hpp" -#include "library/pmc/collectors/cpu/sample.hpp" -#include "library/pmc/collectors/gpu/sample.hpp" -#include "library/pmc/collectors/gpu_perf_counter/sample.hpp" -#include "library/pmc/collectors/hipfile/sample.hpp" -#include "library/pmc/collectors/nic/sample.hpp" - #include +#include +#include #include namespace rocprofsys::trace_cache { -template -struct processor_t -{ - void handle(const kernel_dispatch_sample& sample) - { - static_cast(this)->handle(sample); - } - - void handle(const scratch_memory_sample& sample) - { - static_cast(this)->handle(sample); - } - - void handle(const memory_copy_sample& sample) - { - static_cast(this)->handle(sample); - } - -#if(ROCPROFILER_VERSION >= 600) - void handle(const memory_allocate_sample& sample) - { - static_cast(this)->handle(sample); - } -#endif - - void handle(const region_sample& sample) { static_cast(this)->handle(sample); } - - void handle(const in_time_sample& sample) { static_cast(this)->handle(sample); } - - void handle(const pmc_event_with_sample& sample) - { - static_cast(this)->handle(sample); - } - - void handle(const gpu_pmc_sample& sample) { static_cast(this)->handle(sample); } - - void handle(const ainic_pmc_sample& sample) { static_cast(this)->handle(sample); } - - void handle(const cpu_pmc_sample& sample) { static_cast(this)->handle(sample); } - - void handle(const gpu_perf_counter_sample& sample) - { - static_cast(this)->handle(sample); - } - - void handle(const hipfile_pmc_sample& sample) - { - static_cast(this)->handle(sample); - } - - void handle(const backtrace_region_sample& sample) - { - static_cast(this)->handle(sample); - } - - void handle(const kfd_sample& sample) { static_cast(this)->handle(sample); } - - void prepare_for_processing() { static_cast(this)->prepare_for_processing(); } - - void finalize_processing() { static_cast(this)->finalize_processing(); } - -protected: - ~processor_t() = default; -}; - -struct processor_view_t -{ - using kernel_dispatch_fn_t = void (*)(void*, const kernel_dispatch_sample&) noexcept; - using scratch_memory_fn_t = void (*)(void*, const scratch_memory_sample&) noexcept; - using memory_copy_fn_t = void (*)(void*, const memory_copy_sample&) noexcept; -#if(ROCPROFILER_VERSION >= 600) - using memory_allocate_fn_t = void (*)(void*, const memory_allocate_sample&) noexcept; -#endif - using region_fn_t = void (*)(void*, const region_sample&) noexcept; - using in_time_sample_fn_t = void (*)(void*, const in_time_sample&) noexcept; - using pmc_event_fn_t = void (*)(void*, const pmc_event_with_sample&) noexcept; - using gpu_pmc_sample_fn_t = void (*)(void*, const gpu_pmc_sample&) noexcept; - using ainic_pmc_sample_fn_t = void (*)(void*, const ainic_pmc_sample&) noexcept; - using cpu_pmc_sample_fn_t = void (*)(void*, const cpu_pmc_sample&) noexcept; - using gpu_perf_counter_sample_fn_t = - void (*)(void*, const gpu_perf_counter_sample&) noexcept; - using hipfile_pmc_sample_fn_t = void (*)(void*, const hipfile_pmc_sample&) noexcept; - using backtrace_region_fn_t = void (*)(void*, - const backtrace_region_sample&) noexcept; - using kfd_sample_fn_t = void (*)(void*, const kfd_sample&) noexcept; - using prepare_for_processing_fn_t = void (*)(void*) noexcept; - using finalize_processing_fn_t = void (*)(void*) noexcept; - - struct vtable_t - { - kernel_dispatch_fn_t handle_kernel_dispatch; - scratch_memory_fn_t handle_scratch_memory; - memory_copy_fn_t handle_memory_copy; -#if(ROCPROFILER_VERSION >= 600) - memory_allocate_fn_t handle_memory_allocate; -#endif - region_fn_t handle_region; - in_time_sample_fn_t handle_in_time_sample; - pmc_event_fn_t handle_pmc_event; - gpu_pmc_sample_fn_t handle_gpu_pmc_sample; - ainic_pmc_sample_fn_t handle_ainic_pmc_sample; - cpu_pmc_sample_fn_t handle_cpu_pmc_sample; - gpu_perf_counter_sample_fn_t handle_gpu_perf_counter_sample; - hipfile_pmc_sample_fn_t handle_hipfile_pmc_sample; - backtrace_region_fn_t handle_backtrace_region; - kfd_sample_fn_t handle_kfd_sample; - prepare_for_processing_fn_t prepare_for_processing; - finalize_processing_fn_t finalize_processing; - }; - - template - requires std::is_base_of_v, T> - explicit processor_view_t(T& t) noexcept - : m_object{ std::addressof(t) } - , m_vtable{ std::addressof(get_vtable_for_type()) } - {} - - processor_view_t(const processor_view_t&) noexcept = default; - processor_view_t(processor_view_t&&) noexcept = default; - processor_view_t& operator=(const processor_view_t&) noexcept = default; - processor_view_t& operator=(processor_view_t&&) noexcept = default; - - ROCPROFSYS_INLINE void handle(const kernel_dispatch_sample& sample) const noexcept - { - m_vtable->handle_kernel_dispatch(m_object, sample); - } - - ROCPROFSYS_INLINE void handle(const scratch_memory_sample& sample) const noexcept - { - m_vtable->handle_scratch_memory(m_object, sample); - } - - ROCPROFSYS_INLINE void handle(const memory_copy_sample& sample) const noexcept - { - m_vtable->handle_memory_copy(m_object, sample); - } - -#if(ROCPROFILER_VERSION >= 600) - ROCPROFSYS_INLINE void handle(const memory_allocate_sample& sample) const noexcept - { - m_vtable->handle_memory_allocate(m_object, sample); - } -#endif - - ROCPROFSYS_INLINE void handle(const region_sample& sample) const noexcept - { - m_vtable->handle_region(m_object, sample); - } - - ROCPROFSYS_INLINE void handle(const in_time_sample& sample) const noexcept - { - m_vtable->handle_in_time_sample(m_object, sample); - } - - ROCPROFSYS_INLINE void handle(const pmc_event_with_sample& sample) const noexcept - { - m_vtable->handle_pmc_event(m_object, sample); - } - ROCPROFSYS_INLINE void handle(const gpu_pmc_sample& sample) const noexcept - { - m_vtable->handle_gpu_pmc_sample(m_object, sample); - } - - ROCPROFSYS_INLINE void handle(const ainic_pmc_sample& sample) const noexcept - { - m_vtable->handle_ainic_pmc_sample(m_object, sample); - } - - ROCPROFSYS_INLINE void handle(const gpu_perf_counter_sample& sample) const noexcept - { - m_vtable->handle_gpu_perf_counter_sample(m_object, sample); - } - - ROCPROFSYS_INLINE void handle(const cpu_pmc_sample& sample) const noexcept - { - m_vtable->handle_cpu_pmc_sample(m_object, sample); - } - - ROCPROFSYS_INLINE void handle(const hipfile_pmc_sample& sample) const noexcept - { - m_vtable->handle_hipfile_pmc_sample(m_object, sample); - } - - ROCPROFSYS_INLINE void handle(const backtrace_region_sample& sample) const noexcept - { - m_vtable->handle_backtrace_region(m_object, sample); - } - - ROCPROFSYS_INLINE void handle(const kfd_sample& sample) const noexcept - { - m_vtable->handle_kfd_sample(m_object, sample); - } - - ROCPROFSYS_INLINE void prepare_for_processing() const noexcept - { - m_vtable->prepare_for_processing(m_object); - } - - ROCPROFSYS_INLINE void finalize_processing() const noexcept - { - m_vtable->finalize_processing(m_object); - } - -private: - template - static const vtable_t& get_vtable_for_type() noexcept - { - static const vtable_t vtable{ - +[](void* obj, const kernel_dispatch_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj, const scratch_memory_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj, const memory_copy_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, -#if(ROCPROFILER_VERSION >= 600) - +[](void* obj, const memory_allocate_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, -#endif - +[](void* obj, const region_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj, const in_time_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj, const pmc_event_with_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj, const gpu_pmc_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj, const ainic_pmc_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj, const cpu_pmc_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj, const gpu_perf_counter_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj, const hipfile_pmc_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj, const backtrace_region_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj, const kfd_sample& sample) noexcept { - static_cast(obj)->handle(sample); - }, - +[](void* obj) noexcept { static_cast(obj)->prepare_for_processing(); }, - +[](void* obj) noexcept { static_cast(obj)->finalize_processing(); } - }; - return vtable; - } - - void* m_object; - const vtable_t* m_vtable; -}; - struct sample_processor_t { - void clear_handlers() { m_processor_view_list.clear(); } + void clear_handlers() { m_processors.clear(); } - template - void add_handler(T& handler) + void add_handler(std::shared_ptr handler) { - m_processor_view_list.emplace_back(handler); + m_processors.push_back(std::move(handler)); } template ROCPROFSYS_INLINE void handle_sample(const SampleType& sample) const { - for(const auto& view : m_processor_view_list) + for(const auto& processor : m_processors) { - view.handle(sample); + processor->handle(sample); } } ROCPROFSYS_INLINE void prepare_for_processing() const noexcept { - for(const auto& view : m_processor_view_list) + for(const auto& processor : m_processors) { - view.prepare_for_processing(); + processor->prepare_for_processing(); } } ROCPROFSYS_INLINE void finalize_processing() const noexcept { - for(const auto& view : m_processor_view_list) + for(const auto& processor : m_processors) { - view.finalize_processing(); + processor->finalize_processing(); } } [[nodiscard]] ROCPROFSYS_INLINE bool is_empty() const noexcept { - return m_processor_view_list.empty(); + return m_processors.empty(); } ROCPROFSYS_INLINE void execute_sample_processing( @@ -375,7 +109,7 @@ struct sample_processor_t } private: - std::vector m_processor_view_list; + std::vector> m_processors; }; } // namespace rocprofsys::trace_cache diff --git a/projects/rocprofiler-systems/source/lib/core/trace_cache/sample_processor_interface.hpp b/projects/rocprofiler-systems/source/lib/core/trace_cache/sample_processor_interface.hpp new file mode 100644 index 000000000000..058f9a6e5392 --- /dev/null +++ b/projects/rocprofiler-systems/source/lib/core/trace_cache/sample_processor_interface.hpp @@ -0,0 +1,49 @@ +// Copyright (c) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT + +#pragma once +#include "core/trace_cache/sample_type.hpp" + +#include "library/pmc/collectors/cpu/sample.hpp" +#include "library/pmc/collectors/gpu/sample.hpp" +#include "library/pmc/collectors/gpu_perf_counter/sample.hpp" +#include "library/pmc/collectors/hipfile/sample.hpp" +#include "library/pmc/collectors/nic/sample.hpp" + +namespace rocprofsys::trace_cache +{ + +/** + * Consumer of cached samples. One handle() overload per sample type, plus + * prepare/finalize hooks bracketing a parse pass. + */ +class sample_processor_interface +{ +public: + virtual ~sample_processor_interface() = default; + + virtual void handle(const kernel_dispatch_sample& sample) = 0; + virtual void handle(const scratch_memory_sample& sample) = 0; + virtual void handle(const memory_copy_sample& sample) = 0; + virtual void handle(const memory_allocate_sample& sample) = 0; + virtual void handle(const region_sample& sample) = 0; + virtual void handle(const in_time_sample& sample) = 0; + virtual void handle(const pmc_event_with_sample& sample) = 0; + virtual void handle(const gpu_pmc_sample& sample) = 0; + virtual void handle(const ainic_pmc_sample& sample) = 0; + virtual void handle(const cpu_pmc_sample& sample) = 0; + virtual void handle(const gpu_perf_counter_sample& sample) = 0; + virtual void handle(const hipfile_pmc_sample& sample) = 0; + virtual void handle(const backtrace_region_sample& sample) = 0; + virtual void handle(const kfd_sample& sample) = 0; + + virtual void prepare_for_processing() = 0; + virtual void finalize_processing() = 0; + +protected: + sample_processor_interface() = default; + sample_processor_interface(const sample_processor_interface&) = default; + sample_processor_interface& operator=(const sample_processor_interface&) = default; +}; + +} // namespace rocprofsys::trace_cache diff --git a/projects/rocprofiler-systems/source/lib/core/trace_cache/unified_memory_processor.cpp b/projects/rocprofiler-systems/source/lib/core/trace_cache/unified_memory_processor.cpp index 2c30fd25db82..b53a55bde2c7 100644 --- a/projects/rocprofiler-systems/source/lib/core/trace_cache/unified_memory_processor.cpp +++ b/projects/rocprofiler-systems/source/lib/core/trace_cache/unified_memory_processor.cpp @@ -108,7 +108,7 @@ format_time(std::uint64_t nanoseconds) unified_memory_processor_t::unified_memory_processor_t( std::shared_ptr agent_mgr, int pid, output_file_sink_view output_sink) -: processor_t() +: sample_processor_interface() , m_agent_manager(std::move(agent_mgr)) , m_pid(pid) , m_output_dir(config::get_ump_absolute_path()) diff --git a/projects/rocprofiler-systems/source/lib/core/trace_cache/unified_memory_processor.hpp b/projects/rocprofiler-systems/source/lib/core/trace_cache/unified_memory_processor.hpp index e2a0daa4dd55..389e59aaa02a 100644 --- a/projects/rocprofiler-systems/source/lib/core/trace_cache/unified_memory_processor.hpp +++ b/projects/rocprofiler-systems/source/lib/core/trace_cache/unified_memory_processor.hpp @@ -5,7 +5,7 @@ #include "core/agent_manager.hpp" #include "core/output_file_registry.hpp" -#include "core/trace_cache/sample_processor.hpp" +#include "core/trace_cache/sample_processor_interface.hpp" #include "core/trace_cache/sample_type.hpp" #include "library/pmc/collectors/hipfile/sample.hpp" @@ -159,7 +159,7 @@ static_assert(kTriggerTable.back().kfd_name == nullptr, // NOT thread-safe. handle() and finalize_processing() must be called from a // single thread; finalize_processing() is not idempotent. -class unified_memory_processor_t : public processor_t +class unified_memory_processor_t : public sample_processor_interface { public: unified_memory_processor_t(std::shared_ptr agent_mgr, int pid, @@ -171,24 +171,24 @@ class unified_memory_processor_t : public processor_t