Additional 1.0.0 changes (#317)

* Additional 1.0.0 changes

- Update VERSION
- Add beta compatibility for rocprofiler_agent_set_profile_callback_t

* Fix location of deprecated typedef rocprofiler_agent_set_profile_callback_t

* rocprofiler_record_counter_t -> rocprofiler_counter_record_t

* Experimental + deprecated annotations

* rocprofiler_record_dimension_info_t -> rocprofiler_counter_record_dimension_info_t

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>

[ROCm/rocprofiler-sdk commit: a1fcdf7f83]
This commit is contained in:
Meserve, Mark
2025-03-26 02:12:03 -05:00
committed by GitHub
parent 146169577b
commit d80c047fd2
23 changed files with 144 additions and 126 deletions
@@ -197,7 +197,7 @@ as_pointer()
using targeted_kernels_map_t =
std::unordered_map<rocprofiler_kernel_id_t, std::unordered_set<size_t>>;
using counter_dimension_info_map_t =
std::unordered_map<uint64_t, std::vector<rocprofiler_record_dimension_info_t>>;
std::unordered_map<uint64_t, std::vector<rocprofiler_counter_record_dimension_info_t>>;
using agent_info_map_t = std::unordered_map<rocprofiler_agent_id_t, rocprofiler_agent_t>;
using kernel_iteration_t = std::unordered_map<rocprofiler_kernel_id_t, size_t>;
using kernel_rename_map_t = std::unordered_map<uint64_t, uint64_t>;
@@ -1313,7 +1313,7 @@ dispatch_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
void
counter_record_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
rocprofiler_record_counter_t* record_data,
rocprofiler_counter_record_t* record_data,
size_t record_count,
rocprofiler_user_data_t user_data,
void* /*callback_data_args*/)
@@ -2163,11 +2163,11 @@ tool_fini(void* /*tool_data*/)
#endif
}
std::vector<rocprofiler_record_dimension_info_t>
std::vector<rocprofiler_counter_record_dimension_info_t>
get_tool_counter_dimension_info()
{
auto _data = get_agent_counter_info();
auto _ret = std::vector<rocprofiler_record_dimension_info_t>{};
auto _ret = std::vector<rocprofiler_counter_record_dimension_info_t>{};
for(const auto& itr : _data)
{
for(const auto& iitr : itr.second)
@@ -2175,12 +2175,12 @@ get_tool_counter_dimension_info()
_ret.emplace_back(ditr);
}
auto _sorter = [](const rocprofiler_record_dimension_info_t& lhs,
const rocprofiler_record_dimension_info_t& rhs) {
auto _sorter = [](const rocprofiler_counter_record_dimension_info_t& lhs,
const rocprofiler_counter_record_dimension_info_t& rhs) {
return std::tie(lhs.id, lhs.instance_size) < std::tie(rhs.id, rhs.instance_size);
};
auto _equiv = [](const rocprofiler_record_dimension_info_t& lhs,
const rocprofiler_record_dimension_info_t& rhs) {
auto _equiv = [](const rocprofiler_counter_record_dimension_info_t& lhs,
const rocprofiler_counter_record_dimension_info_t& rhs) {
return std::tie(lhs.id, lhs.instance_size) == std::tie(rhs.id, rhs.instance_size);
};
@@ -287,7 +287,7 @@ rocprofiler_iterate_agent_supported_counters(rocprofiler_agent_id_t
/**
* @brief Query counter id information from record_id
*
* @param [in] id record id from rocprofiler_record_counter_t
* @param [in] id record id from rocprofiler_counter_record_t
* @param [out] counter_id counter id associated with the record
* @return ::rocprofiler_status_t
*/
@@ -321,7 +321,8 @@ rocprofiler_iterate_counter_dimensions(rocprofiler_counter_id_t id,
if(!dims) return ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND;
// This is likely faster than a map lookup given the limited number of dims.
auto user_dims = common::container::small_vector<rocprofiler_record_dimension_info_t, 6>{};
auto user_dims =
common::container::small_vector<rocprofiler_counter_record_dimension_info_t, 6>{};
for(const auto& internal_dim : *dims)
{
auto& dim = user_dims.emplace_back();
@@ -154,7 +154,7 @@ agent_async_handler(hsa_signal_value_t /*signal_v*/, void* data)
// Write out the AQL data to the buffer
for(auto& ast : prof_config->asts)
{
std::vector<std::unique_ptr<std::vector<rocprofiler_record_counter_t>>> cache;
std::vector<std::unique_ptr<std::vector<rocprofiler_counter_record_t>>> cache;
auto* ret = CHECK_NOTNULL(ast.evaluate(decoded_pkt, cache));
ast.set_out_id(*ret);
for(auto& val : *ret)
@@ -266,7 +266,7 @@ rocprofiler_status_t
read_agent_ctx(const context::context* ctx,
rocprofiler_user_data_t user_data,
rocprofiler_counter_flag_t flags,
std::vector<rocprofiler_record_counter_t>* out_counters)
std::vector<rocprofiler_counter_record_t>* out_counters)
{
rocprofiler_status_t status = ROCPROFILER_STATUS_SUCCESS;
if(!ctx->device_counter_collection)
@@ -61,7 +61,7 @@ struct agent_callback_data
rocprofiler_device_counting_service_cb_t cb = nullptr;
rocprofiler_buffer_id_t buffer = {.handle = 0};
bool set_profile = false;
std::vector<rocprofiler_record_counter_t>* cached_counters = nullptr;
std::vector<rocprofiler_counter_record_t>* cached_counters = nullptr;
agent_callback_data() = default;
agent_callback_data(agent_callback_data&& rhs) noexcept
@@ -120,7 +120,7 @@ rocprofiler_status_t
read_agent_ctx(const context::context* ctx,
rocprofiler_user_data_t user_data,
rocprofiler_counter_flag_t flags,
std::vector<rocprofiler_record_counter_t>* out_counters);
std::vector<rocprofiler_counter_record_t>* out_counters);
uint64_t
submitPacket(hsa_queue_t* queue, const void* packet);
@@ -64,8 +64,8 @@ get_reduce_op_type_from_string(const std::string& op)
void
perform_reduction_to_single_instance(ReduceOperation reduce_op,
std::vector<rocprofiler_record_counter_t>* input_array,
rocprofiler_record_counter_t* result)
std::vector<rocprofiler_counter_record_t>* input_array,
rocprofiler_counter_record_t* result)
{
switch(reduce_op)
{
@@ -92,13 +92,13 @@ perform_reduction_to_single_instance(ReduceOperation
*result = std::accumulate(
input_array->begin(),
input_array->end(),
rocprofiler_record_counter_t{.id = input_array->begin()->id,
rocprofiler_counter_record_t{.id = input_array->begin()->id,
.counter_value = 0,
.dispatch_id = input_array->begin()->dispatch_id,
.user_data = input_array->begin()->user_data,
.agent_id = input_array->begin()->agent_id},
[](auto& a, auto& b) {
return rocprofiler_record_counter_t{
return rocprofiler_counter_record_t{
.id = a.id,
.counter_value = a.counter_value + b.counter_value,
.dispatch_id = a.dispatch_id,
@@ -114,17 +114,17 @@ perform_reduction_to_single_instance(ReduceOperation
}
}
std::vector<rocprofiler_record_counter_t>*
std::vector<rocprofiler_counter_record_t>*
perform_reduction(
ReduceOperation reduce_op,
std::vector<rocprofiler_record_counter_t>* input_array,
std::vector<rocprofiler_counter_record_t>* input_array,
const std::unordered_set<rocprofiler_profile_counter_instance_types>& _reduce_dimension_set)
{
if(input_array->empty()) return input_array;
if(_reduce_dimension_set.empty() ||
_reduce_dimension_set.size() == ROCPROFILER_DIMENSION_LAST - 1)
{
rocprofiler_record_counter_t result{.id = 0,
rocprofiler_counter_record_t result{.id = 0,
.counter_value = 0,
.dispatch_id = 0,
.user_data = {.value = 0},
@@ -136,7 +136,7 @@ perform_reduction(
return input_array;
}
std::unordered_map<int64_t, std::vector<rocprofiler_record_counter_t>> rec_groups;
std::unordered_map<int64_t, std::vector<rocprofiler_counter_record_t>> rec_groups;
size_t bit_length = DIM_BIT_LENGTH / ROCPROFILER_DIMENSION_LAST;
for(auto& rec : *input_array)
@@ -154,7 +154,7 @@ perform_reduction(
input_array->clear();
for(auto& rec_pair : rec_groups)
{
rocprofiler_record_counter_t result{.id = 0,
rocprofiler_counter_record_t result{.id = 0,
.counter_value = 0,
.dispatch_id = 0,
.user_data = {.value = 0},
@@ -208,9 +208,9 @@ get_int_encoded_dimensions_from_string(const std::string& rangeStr)
return result;
}
std::vector<rocprofiler_record_counter_t>*
std::vector<rocprofiler_counter_record_t>*
perform_selection(std::map<rocprofiler_profile_counter_instance_types, std::string>& dimension_map,
std::vector<rocprofiler_record_counter_t>* input_array)
std::vector<rocprofiler_counter_record_t>* input_array)
{
if(input_array->empty()) return input_array;
for(auto& dim_pair : dimension_map)
@@ -221,7 +221,7 @@ perform_selection(std::map<rocprofiler_profile_counter_instance_types, std::stri
input_array->erase(std::remove_if(input_array->begin(),
input_array->end(),
[&](rocprofiler_record_counter_t& rec) {
[&](rocprofiler_counter_record_t& rec) {
bool should_remove =
(encoded_dim_values &
(1 << rocprofiler::counters::rec_to_dim_pos(
@@ -692,7 +692,7 @@ void
EvaluateAST::read_special_counters(
const rocprofiler_agent_t& agent,
const std::set<counters::Metric>& required_special_counters,
std::unordered_map<uint64_t, std::vector<rocprofiler_record_counter_t>>& out_map)
std::unordered_map<uint64_t, std::vector<rocprofiler_counter_record_t>>& out_map)
{
for(const auto& metric : required_special_counters)
{
@@ -705,19 +705,19 @@ EvaluateAST::read_special_counters(
}
}
std::unordered_map<uint64_t, std::vector<rocprofiler_record_counter_t>>
std::unordered_map<uint64_t, std::vector<rocprofiler_counter_record_t>>
EvaluateAST::read_pkt(const aql::CounterPacketConstruct* pkt_gen, hsa::AQLPacket& pkt)
{
struct it_data
{
std::unordered_map<uint64_t, std::vector<rocprofiler_record_counter_t>>* data;
std::unordered_map<uint64_t, std::vector<rocprofiler_counter_record_t>>* data;
const aql::CounterPacketConstruct* pkt_gen;
aqlprofile_agent_handle_t agent;
};
auto aql_agent = *CHECK_NOTNULL(rocprofiler::agent::get_aql_agent(pkt_gen->agent()));
std::unordered_map<uint64_t, std::vector<rocprofiler_record_counter_t>> ret;
std::unordered_map<uint64_t, std::vector<rocprofiler_counter_record_t>> ret;
if(pkt.empty) return ret;
it_data aql_data{.data = &ret, .pkt_gen = pkt_gen, .agent = aql_agent};
@@ -730,7 +730,7 @@ EvaluateAST::read_pkt(const aql::CounterPacketConstruct* pkt_gen, hsa::AQLPacket
if(!metric) return HSA_STATUS_SUCCESS;
auto& vec = it.data->emplace(metric->id(), std::vector<rocprofiler_record_counter_t>{})
auto& vec = it.data->emplace(metric->id(), std::vector<rocprofiler_counter_record_t>{})
.first->second;
auto& next_rec = vec.emplace_back();
set_counter_in_rec(next_rec.id, {.handle = metric->id()});
@@ -754,7 +754,7 @@ EvaluateAST::read_pkt(const aql::CounterPacketConstruct* pkt_gen, hsa::AQLPacket
}
void
EvaluateAST::set_out_id(std::vector<rocprofiler_record_counter_t>& results) const
EvaluateAST::set_out_id(std::vector<rocprofiler_counter_record_t>& results) const
{
for(auto& record : results)
{
@@ -799,10 +799,10 @@ EvaluateAST::expand_derived(std::unordered_map<std::string, EvaluateAST>& asts)
}
// convert to buffer at some point
std::vector<rocprofiler_record_counter_t>*
std::vector<rocprofiler_counter_record_t>*
EvaluateAST::evaluate(
std::unordered_map<uint64_t, std::vector<rocprofiler_record_counter_t>>& results_map,
std::vector<std::unique_ptr<std::vector<rocprofiler_record_counter_t>>>& cache)
std::unordered_map<uint64_t, std::vector<rocprofiler_counter_record_t>>& results_map,
std::vector<std::unique_ptr<std::vector<rocprofiler_counter_record_t>>>& cache)
{
auto perform_op = [&](auto&& op) {
auto* r1 = _children.at(0).evaluate(results_map, cache);
@@ -842,13 +842,13 @@ EvaluateAST::evaluate(
case RANGE_NODE: break;
case NUMBER_NODE:
{
cache.emplace_back(std::make_unique<std::vector<rocprofiler_record_counter_t>>());
cache.emplace_back(std::make_unique<std::vector<rocprofiler_counter_record_t>>());
*cache.back() = _static_value;
return cache.back().get();
}
case ADDITION_NODE:
return perform_op([](auto& a, auto& b) {
return rocprofiler_record_counter_t{
return rocprofiler_counter_record_t{
.id = a.id,
.counter_value = a.counter_value + b.counter_value,
.dispatch_id = a.dispatch_id,
@@ -857,7 +857,7 @@ EvaluateAST::evaluate(
});
case SUBTRACTION_NODE:
return perform_op([](auto& a, auto& b) {
return rocprofiler_record_counter_t{
return rocprofiler_counter_record_t{
.id = a.id,
.counter_value = a.counter_value - b.counter_value,
.dispatch_id = a.dispatch_id,
@@ -866,7 +866,7 @@ EvaluateAST::evaluate(
});
case MULTIPLY_NODE:
return perform_op([](auto& a, auto& b) {
return rocprofiler_record_counter_t{
return rocprofiler_counter_record_t{
.id = a.id,
.counter_value = a.counter_value * b.counter_value,
.dispatch_id = a.dispatch_id,
@@ -875,7 +875,7 @@ EvaluateAST::evaluate(
});
case DIVIDE_NODE:
return perform_op([](auto& a, auto& b) {
return rocprofiler_record_counter_t{
return rocprofiler_counter_record_t{
.id = a.id,
.counter_value = (b.counter_value == 0 ? 0 : a.counter_value / b.counter_value),
.dispatch_id = a.dispatch_id,
@@ -891,7 +891,7 @@ EvaluateAST::evaluate(
throw std::runtime_error(
fmt::format("Unable to lookup results for metric {}", _metric.name()));
cache.emplace_back(std::make_unique<std::vector<rocprofiler_record_counter_t>>());
cache.emplace_back(std::make_unique<std::vector<rocprofiler_counter_record_t>>());
*cache.back() = *result;
result = cache.back().get();
return result;
@@ -82,12 +82,12 @@ public:
* computations. This is needed to avoid destroying data
* in the result map that may be used by other evaluate calls.
*
* @return std::vector<rocprofiler_record_counter_t>* A pointer to the output records.
* @return std::vector<rocprofiler_counter_record_t>* A pointer to the output records.
* This pointer SHOULD NOT BE FREE'D/DELETED BY THE CALLER.
*/
std::vector<rocprofiler_record_counter_t>* evaluate(
std::unordered_map<uint64_t, std::vector<rocprofiler_record_counter_t>>& results_map,
std::vector<std::unique_ptr<std::vector<rocprofiler_record_counter_t>>>& cache);
std::vector<rocprofiler_counter_record_t>* evaluate(
std::unordered_map<uint64_t, std::vector<rocprofiler_counter_record_t>>& results_map,
std::vector<std::unique_ptr<std::vector<rocprofiler_counter_record_t>>>& cache);
/**
* @brief Expand derived counter ASTs contained within this AST to full hardware counter
@@ -120,20 +120,20 @@ public:
std::set<Metric>& counters) const;
/**
* @brief Read the AQL packet and construct rocprofiler_record_counter_t. This call
* @brief Read the AQL packet and construct rocprofiler_counter_record_t. This call
* does not perform any evaluation, only dumping the packet contents into
* rocprofiler_record_counter_t.
* rocprofiler_counter_record_t.
*
* @param [in] pkt_gen packet generator used to generate the AQL packet. This packet
* generator contains information, such as the ordering of instances
* contained in the return packet, that is required to decode what
* data goes with what base counters.
* @param [in] pkt AQL packet structure to decode
* @return std::unordered_map<uint64_t, std::vector<rocprofiler_record_counter_t>> map of
* @return std::unordered_map<uint64_t, std::vector<rocprofiler_counter_record_t>> map of
* {metric->id(), vector<records>}
*
*/
static std::unordered_map<uint64_t, std::vector<rocprofiler_record_counter_t>> read_pkt(
static std::unordered_map<uint64_t, std::vector<rocprofiler_counter_record_t>> read_pkt(
const aql::CounterPacketConstruct* pkt_gen,
hsa::AQLPacket& pkt);
@@ -148,7 +148,7 @@ public:
static void read_special_counters(
const rocprofiler_agent_t& agent,
const std::set<counters::Metric>& required_special_counters,
std::unordered_map<uint64_t, std::vector<rocprofiler_record_counter_t>>& out_map);
std::unordered_map<uint64_t, std::vector<rocprofiler_counter_record_t>>& out_map);
NodeType type() const { return _type; }
ReduceOperation reduce_op() const { return _reduce_op; }
@@ -162,7 +162,7 @@ public:
*
* @param [in] results computed results that will have their id modified to be counter _out_id
*/
void set_out_id(std::vector<rocprofiler_record_counter_t>& results) const;
void set_out_id(std::vector<rocprofiler_counter_record_t>& results) const;
const rocprofiler_counter_id_t& out_id() const { return _out_id; }
@@ -174,7 +174,7 @@ private:
std::vector<EvaluateAST> _children;
std::string _agent;
std::vector<MetricDimension> _dimension_types{};
std::vector<rocprofiler_record_counter_t> _static_value;
std::vector<rocprofiler_counter_record_t> _static_value;
std::unordered_set<rocprofiler_profile_counter_instance_types> _reduce_dimension_set;
std::map<rocprofiler_profile_counter_instance_types, std::string> _select_dimension_map;
bool _expanded{false};
@@ -214,7 +214,7 @@ get_agent_property(std::string_view property, const rocprofiler_agent_t& agent);
namespace fmt
{
template <>
struct formatter<rocprofiler_record_counter_t>
struct formatter<rocprofiler_counter_record_t>
{
template <typename ParseContext>
constexpr auto parse(ParseContext& ctx)
@@ -223,7 +223,7 @@ struct formatter<rocprofiler_record_counter_t>
}
template <typename Ctx>
auto format(rocprofiler_record_counter_t const& data, Ctx& ctx) const
auto format(rocprofiler_counter_record_t const& data, Ctx& ctx) const
{
return fmt::format_to(ctx.out(),
"(CounterId: {}, Dimension: {:x}, Value [D]: {})",
@@ -68,7 +68,7 @@ proccess_completed_cb(completed_cb_params_t&& params)
prof_config->packets.wlock([&](auto& pkt_vector) { pkt_vector.emplace_back(std::move(pkt)); });
common::container::small_vector<rocprofiler_record_counter_t, 128> out;
common::container::small_vector<rocprofiler_counter_record_t, 128> out;
rocprofiler::buffer::instance* buf = nullptr;
if(info->buffer)
@@ -92,7 +92,7 @@ proccess_completed_cb(completed_cb_params_t&& params)
auto _dispatch_id = session.callback_record.dispatch_info.dispatch_id;
for(auto& ast : prof_config->asts)
{
std::vector<std::unique_ptr<std::vector<rocprofiler_record_counter_t>>> cache;
std::vector<std::unique_ptr<std::vector<rocprofiler_counter_record_t>>> cache;
auto* ret = ast.evaluate(decoded_pkt, cache);
CHECK(ret);
ast.set_out_id(*ret);
@@ -51,7 +51,7 @@ rocprofiler_status_t
rocprofiler_sample_device_counting_service(rocprofiler_context_id_t context_id,
rocprofiler_user_data_t user_data,
rocprofiler_counter_flag_t flags,
rocprofiler_record_counter_t* output_records,
rocprofiler_counter_record_t* output_records,
size_t* rec_count)
{
if(context_id == rocprofiler_context_none) return ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND;
@@ -72,7 +72,7 @@ rocprofiler_sample_device_counting_service(rocprofiler_context_id_t context
if(*rec_count == 0) return ROCPROFILER_STATUS_ERROR_OUT_OF_RESOURCES;
auto recs = std::vector<rocprofiler_record_counter_t>{};
auto recs = std::vector<rocprofiler_counter_record_t>{};
auto status = rocprofiler::counters::read_agent_ctx(ctx, user_data, flags, &recs);
if(status == ROCPROFILER_STATUS_SUCCESS)
{
@@ -83,7 +83,7 @@ rocprofiler_sample_device_counting_service(rocprofiler_context_id_t context
}
*rec_count = recs.size();
std::memcpy(
output_records, recs.data(), sizeof(rocprofiler_record_counter_t) * recs.size());
output_records, recs.data(), sizeof(rocprofiler_counter_record_t) * recs.size());
}
return status;
}