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>
Este cometimento está contido em:
cometido por
GitHub
ascendente
351d598869
cometimento
1f86010ca2
+27
-49
@@ -91,15 +91,17 @@ get_agent_counter_info(const tool_agent_vec_t& _agents)
|
||||
|
||||
for(auto itr : _agents)
|
||||
{
|
||||
ROCPROFILER_CALL(rocprofiler_iterate_agent_supported_counters(
|
||||
itr.agent->id, counters_supported_callback, &_data));
|
||||
const auto& _agent_id = rocprofiler_agent_id_t{ itr.agent->handle };
|
||||
|
||||
std::sort(_data.at(itr.agent->id).begin(), _data.at(itr.agent->id).end(),
|
||||
ROCPROFILER_CALL(rocprofiler_iterate_agent_supported_counters(
|
||||
_agent_id, counters_supported_callback, &_data));
|
||||
|
||||
std::sort(_data.at(_agent_id).begin(), _data.at(_agent_id).end(),
|
||||
[](const auto& lhs, const auto& rhs) {
|
||||
return (lhs.id.handle < rhs.id.handle);
|
||||
});
|
||||
|
||||
for(auto& citr : _data.at(itr.agent->id))
|
||||
for(auto& citr : _data.at(_agent_id))
|
||||
{
|
||||
std::sort(citr.dimension_info.begin(), citr.dimension_info.end(),
|
||||
[](const auto& lhs, const auto& rhs) { return (lhs.id < rhs.id); });
|
||||
@@ -123,38 +125,16 @@ client_data::initialize()
|
||||
buffered_tracing_info = rocprofiler::sdk::get_buffer_tracing_names();
|
||||
callback_tracing_info = rocprofiler::sdk::get_callback_tracing_names();
|
||||
|
||||
static constexpr auto supported_agent_info_version = ROCPROFILER_AGENT_INFO_VERSION_0;
|
||||
|
||||
rocprofiler_query_available_agents_cb_t iterate_cb =
|
||||
[](rocprofiler_agent_version_t version, const void** agents_arr,
|
||||
size_t num_agents, void* user_data) {
|
||||
ROCPROFSYS_CONDITIONAL_ABORT(version != supported_agent_info_version,
|
||||
"rocprofiler agent info version != expected "
|
||||
"agent info version (=%i). value: %i\n",
|
||||
supported_agent_info_version, version);
|
||||
|
||||
auto _agents_v = std::vector<rocprofiler_agent_v0_t>{};
|
||||
for(size_t i = 0; i < num_agents; ++i)
|
||||
{
|
||||
const auto* _agent =
|
||||
static_cast<const rocprofiler_agent_v0_t*>(agents_arr[i]);
|
||||
_agents_v.emplace_back(*_agent);
|
||||
}
|
||||
|
||||
auto* tool_data_v = as_client_data(user_data);
|
||||
tool_data_v->set_agents(std::move(_agents_v));
|
||||
|
||||
return ROCPROFILER_STATUS_SUCCESS;
|
||||
};
|
||||
|
||||
ROCPROFILER_CALL(rocprofiler_query_available_agents(
|
||||
supported_agent_info_version, iterate_cb, sizeof(rocprofiler_agent_t), this));
|
||||
set_agents();
|
||||
}
|
||||
|
||||
void
|
||||
client_data::initialize_event_info()
|
||||
{
|
||||
if(agents.empty()) initialize();
|
||||
if(agent_manager::get_instance().get_agents().empty())
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
if(agent_counter_info.size() != gpu_agents.size())
|
||||
agent_counter_info = get_agent_counter_info(gpu_agents);
|
||||
@@ -166,14 +146,15 @@ client_data::initialize_event_info()
|
||||
|
||||
for(const auto& aitr : gpu_agents)
|
||||
{
|
||||
auto _dev_index = aitr.device_id;
|
||||
auto _device_qualifier_sym = JOIN("", ":device=", _dev_index);
|
||||
auto _device_qualifier =
|
||||
auto _dev_index = aitr.device_id;
|
||||
const auto& _agent_id = rocprofiler_agent_id_t{ aitr.agent->handle };
|
||||
auto _device_qualifier_sym = JOIN("", ":device=", _dev_index);
|
||||
auto _device_qualifier =
|
||||
tim::hardware_counters::qualifier{ true, static_cast<int>(_dev_index),
|
||||
_device_qualifier_sym,
|
||||
JOIN(" ", "Device", _dev_index) };
|
||||
|
||||
auto _counter_info = agent_counter_info.at(aitr.agent->id);
|
||||
auto _counter_info = agent_counter_info.at(_agent_id);
|
||||
std::sort(_counter_info.begin(), _counter_info.end(),
|
||||
[](const rocprofiler_tool_counter_info_t& lhs,
|
||||
const rocprofiler_tool_counter_info_t& rhs) {
|
||||
@@ -248,23 +229,20 @@ client_data::initialize_event_info()
|
||||
}
|
||||
|
||||
void
|
||||
client_data::set_agents(agent_vec_t&& _agents_v)
|
||||
client_data::set_agents()
|
||||
{
|
||||
agents = std::move(_agents_v);
|
||||
auto& agent_mngr = agent_manager::get_instance();
|
||||
|
||||
std::sort(agents.begin(), agents.end(),
|
||||
[](const auto& lhs, const auto& rhs) { return lhs.node_id < rhs.node_id; });
|
||||
auto fill_agents = [&](agent_type type, std::vector<tool_agent>& out) {
|
||||
const auto& _agents = agent_mngr.get_agents_by_type(type);
|
||||
for(const auto& agent : _agents)
|
||||
{
|
||||
out.emplace_back(tool_agent{ agent->device_type_index, agent.get() });
|
||||
}
|
||||
};
|
||||
|
||||
cpu_agents.clear();
|
||||
gpu_agents.clear();
|
||||
|
||||
for(const auto& itr : agents)
|
||||
{
|
||||
if(itr.type == ROCPROFILER_AGENT_TYPE_CPU)
|
||||
cpu_agents.emplace_back(tool_agent{ cpu_agents.size(), &itr });
|
||||
else if(itr.type == ROCPROFILER_AGENT_TYPE_GPU)
|
||||
gpu_agents.emplace_back(tool_agent{ gpu_agents.size(), &itr });
|
||||
}
|
||||
fill_agents(agent_type::GPU, gpu_agents);
|
||||
fill_agents(agent_type::CPU, cpu_agents);
|
||||
}
|
||||
} // namespace rocprofiler_sdk
|
||||
} // namespace rocprofsys
|
||||
|
||||
+45
-11
@@ -23,6 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/synchronized.hpp"
|
||||
#include "core/agent_manager.hpp"
|
||||
#include "core/timemory.hpp"
|
||||
|
||||
#include <rocprofiler-sdk/agent.h>
|
||||
@@ -50,6 +51,8 @@ using kernel_symbol_map_t =
|
||||
std::unordered_map<rocprofiler_kernel_id_t, kernel_symbol_data_t>;
|
||||
using callback_arg_array_t = std::vector<std::pair<std::string, std::string>>;
|
||||
|
||||
using rocprofsys_agent_t = agent;
|
||||
|
||||
struct code_object_callback_record_t
|
||||
{
|
||||
uint64_t timestamp = 0;
|
||||
@@ -88,8 +91,8 @@ struct rocprofiler_tool_counter_info_t : rocprofiler_counter_info_v0_t
|
||||
|
||||
struct tool_agent
|
||||
{
|
||||
uint64_t device_id = 0;
|
||||
const rocprofiler_agent_v0_t* agent = nullptr;
|
||||
uint64_t device_id = 0;
|
||||
const rocprofsys_agent_t* agent = nullptr;
|
||||
};
|
||||
|
||||
struct timing_interval
|
||||
@@ -98,6 +101,16 @@ struct timing_interval
|
||||
rocprofiler_timestamp_t end = 0;
|
||||
};
|
||||
|
||||
struct argument_info
|
||||
{
|
||||
uint32_t arg_number = 0;
|
||||
std::string arg_type = {};
|
||||
std::string arg_name = {};
|
||||
std::string arg_value = {};
|
||||
};
|
||||
|
||||
using function_args_t = std::vector<argument_info>;
|
||||
|
||||
using agent_counter_info_map_t =
|
||||
std::unordered_map<rocprofiler_agent_id_t,
|
||||
std::vector<rocprofiler_tool_counter_info_t>>;
|
||||
@@ -117,7 +130,7 @@ using backtrace_operation_map_t =
|
||||
|
||||
struct client_data
|
||||
{
|
||||
static constexpr size_t num_buffers = 3;
|
||||
static constexpr size_t num_buffers = 4;
|
||||
static constexpr size_t num_contexts = 2;
|
||||
|
||||
using buffer_name_info_t = rocprofiler::sdk::buffer_name_info_t<std::string_view>;
|
||||
@@ -134,8 +147,8 @@ struct client_data
|
||||
rocprofiler_context_id_t counter_ctx = { 0 };
|
||||
rocprofiler_buffer_id_t kernel_dispatch_buffer = { 0 };
|
||||
rocprofiler_buffer_id_t memory_copy_buffer = { 0 };
|
||||
rocprofiler_buffer_id_t memory_alloc_buffer = { 0 };
|
||||
rocprofiler_buffer_id_t counter_collection_buffer = { 0 };
|
||||
std::vector<rocprofiler_agent_v0_t> agents = {};
|
||||
std::vector<tool_agent> cpu_agents = {};
|
||||
std::vector<tool_agent> gpu_agents = {};
|
||||
std::vector<hardware_counter_info> events_info = {};
|
||||
@@ -150,14 +163,16 @@ struct client_data
|
||||
|
||||
void initialize();
|
||||
void initialize_event_info();
|
||||
void set_agents(agent_vec_t&& agents);
|
||||
void set_agents();
|
||||
context_id_vec_t get_contexts() const;
|
||||
buffer_id_vec_t get_buffers() const;
|
||||
const rocprofiler_agent_t* get_agent(rocprofiler_agent_id_t _id) const;
|
||||
const rocprofsys_agent_t* get_agent(rocprofiler_agent_id_t _id) const;
|
||||
const tool_agent* get_gpu_tool_agent(rocprofiler_agent_id_t id) const;
|
||||
const kernel_symbol_data_t* get_kernel_symbol_info(uint64_t _kernel_id) const;
|
||||
const rocprofiler_tool_counter_info_t* get_tool_counter_info(
|
||||
rocprofiler_agent_id_t _agent_id, rocprofiler_counter_id_t _counter_id) const;
|
||||
const rocprofiler_callback_tracing_code_object_load_data_t* get_code_object_info(
|
||||
uint64_t code_object_id) const;
|
||||
};
|
||||
|
||||
inline client_data::context_id_vec_t
|
||||
@@ -175,23 +190,24 @@ client_data::get_buffers() const
|
||||
return buffer_id_vec_t{
|
||||
kernel_dispatch_buffer,
|
||||
memory_copy_buffer,
|
||||
memory_alloc_buffer,
|
||||
counter_collection_buffer,
|
||||
};
|
||||
}
|
||||
|
||||
inline const rocprofiler_agent_t*
|
||||
inline const rocprofsys_agent_t*
|
||||
client_data::get_agent(rocprofiler_agent_id_t _id) const
|
||||
{
|
||||
for(const auto& itr : agents)
|
||||
if(itr.id == _id) return &itr;
|
||||
return nullptr;
|
||||
const auto& agent = agent_manager::get_instance().get_agent_by_handle(_id.handle);
|
||||
|
||||
return &agent;
|
||||
}
|
||||
|
||||
inline const tool_agent*
|
||||
client_data::get_gpu_tool_agent(rocprofiler_agent_id_t id) const
|
||||
{
|
||||
for(const auto& itr : gpu_agents)
|
||||
if(id == itr.agent->id) return &itr;
|
||||
if(id.handle == itr.agent->handle) return &itr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -223,6 +239,24 @@ client_data::get_tool_counter_info(rocprofiler_agent_id_t _agent_id,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline const rocprofiler_callback_tracing_code_object_load_data_t*
|
||||
client_data::get_code_object_info(uint64_t code_object_id) const
|
||||
{
|
||||
return code_object_records.rlock(
|
||||
[code_object_id](const auto& _data)
|
||||
-> const rocprofiler_callback_tracing_code_object_load_data_t* {
|
||||
for(const auto& itr : _data)
|
||||
{
|
||||
if(code_object_id == itr.payload.code_object_id)
|
||||
{
|
||||
return &itr.payload;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
inline constexpr client_data*
|
||||
as_client_data(void* _ptr)
|
||||
{
|
||||
|
||||
Criar uma nova questão referindo esta
Bloquear um utilizador