diff --git a/source/lib/rocprofiler-sdk/registration.cpp b/source/lib/rocprofiler-sdk/registration.cpp index 1be92e4e6c..48fc5d8645 100644 --- a/source/lib/rocprofiler-sdk/registration.cpp +++ b/source/lib/rocprofiler-sdk/registration.cpp @@ -903,6 +903,7 @@ rocprofiler_set_api_table(const char* name, if(runtime_pc_sampling_table) rocprofiler::pc_sampling::code_object::initialize(hsa_api_table); #endif + rocprofiler::thread_trace::code_object::initialize(hsa_api_table); // install rocprofiler API wrappers rocprofiler::hsa::update_table(hsa_api_table->core_, lib_instance); diff --git a/source/lib/rocprofiler-sdk/thread_trace/att_core.cpp b/source/lib/rocprofiler-sdk/thread_trace/att_core.cpp index 494c573d38..8171a07afe 100644 --- a/source/lib/rocprofiler-sdk/thread_trace/att_core.cpp +++ b/source/lib/rocprofiler-sdk/thread_trace/att_core.cpp @@ -507,8 +507,6 @@ initialize(HsaApiTable* table) { ROCP_FATAL_IF(!table->core_ || !table->amd_ext_); - code_object::initialize(table); - for(auto& ctx : context::get_registered_contexts()) { if(ctx->device_thread_trace) ctx->device_thread_trace->resource_init(); diff --git a/source/lib/rocprofiler-sdk/thread_trace/att_core.hpp b/source/lib/rocprofiler-sdk/thread_trace/att_core.hpp index 36f490358c..317b2acec0 100644 --- a/source/lib/rocprofiler-sdk/thread_trace/att_core.hpp +++ b/source/lib/rocprofiler-sdk/thread_trace/att_core.hpp @@ -94,14 +94,8 @@ public: std::unique_ptr get_control(bool bStart); void iterate_data(aqlprofile_handle_t handle, rocprofiler_user_data_t data); - hsa_queue_t* queue{nullptr}; - - std::mutex trace_resources_mut; - thread_trace_parameter_pack params; - std::atomic active_traces{0}; - - std::unique_ptr control_packet; - std::unique_ptr factory; + thread_trace_parameter_pack params; + const rocprofiler_agent_id_t agent_id; [[nodiscard]] std::unique_ptr Submit(hsa_ext_amd_aql_pm4_packet_t* packet, bool bWait) const; @@ -116,11 +110,15 @@ public: } return nullptr; } + std::unique_ptr factory{nullptr}; private: - std::unique_ptr codeobj_reg{nullptr}; + hsa_queue_t* queue{nullptr}; + std::atomic active_traces{0}; + std::mutex trace_resources_mut{}; - rocprofiler_agent_id_t agent_id; + std::unique_ptr control_packet{nullptr}; + std::unique_ptr codeobj_reg{nullptr}; }; class DispatchThreadTracer @@ -150,8 +148,10 @@ public: rocprofiler_user_data_t* user_data, const context::correlation_id* corr_id); - void post_kernel_call(inst_pkt_t& aql, const hsa::queue_info_session& session); + void post_kernel_call(inst_pkt_t& aql, const hsa::queue_info_session& session); + const auto& get_agents() const { return agents; } +private: std::unordered_map> agents{}; std::unordered_map params{}; @@ -181,6 +181,9 @@ public: return params.find(id) != params.end(); } + const auto& get_agents() const { return agents; } + +private: std::map> agents{}; std::map params{}; diff --git a/source/lib/rocprofiler-sdk/thread_trace/tests/att_packet_test.cpp b/source/lib/rocprofiler-sdk/thread_trace/tests/att_packet_test.cpp index 1b7cd7cb82..1120f9a89b 100644 --- a/source/lib/rocprofiler-sdk/thread_trace/tests/att_packet_test.cpp +++ b/source/lib/rocprofiler-sdk/thread_trace/tests/att_packet_test.cpp @@ -112,7 +112,7 @@ TEST(thread_trace, resource_creation) tracer.resource_init(); - for(auto& [_, agenttracer] : tracer.agents) + for(auto& [_, agenttracer] : tracer.get_agents()) { agenttracer->load_codeobj(1, 0x1000, 0x1000); agenttracer->load_codeobj(2, 0x3000, 0x1000); @@ -222,7 +222,7 @@ TEST(thread_trace, perfcounters_configure_test) auto* tracer = context->dispatch_thread_trace.get(); ASSERT_NE(tracer, nullptr); - for(auto& [id, agent] : tracer->agents) + for(auto& [id, agent] : tracer->get_agents()) { ASSERT_EQ(agent->params.perfcounter_ctrl, 1); ASSERT_EQ(agent->params.perfcounters.size(), 3);