Use fixed size array for serialization (#906)

Co-authored-by: Benjamin Welton <ben@amd.com>

[ROCm/rocprofiler-sdk commit: 2f3a8b05b3]
Dieser Commit ist enthalten in:
Benjamin Welton
2024-06-05 02:02:01 -07:00
committet von GitHub
Ursprung cb69616d46
Commit 29628c5bc5
4 geänderte Dateien mit 26 neuen und 11 gelöschten Zeilen
@@ -30,6 +30,7 @@
#include <rocprofiler-sdk/marker/api_id.h>
#include <unistd.h>
#include <cstdint>
#include <iomanip>
#include <string_view>
#include <utility>
@@ -553,8 +554,9 @@ generate_csv(tool_table* too
{
auto kernel_id = record.dispatch_data.dispatch_info.kernel_id;
auto counter_name_value = std::map<std::string, uint64_t>{};
for(const auto& count : record.records)
for(uint64_t i = 0; i < record.counter_count; i++)
{
const auto& count = record.records.at(i);
auto rec = count.record_counter;
std::string counter_name = tool_functions->tool_get_counter_info_name_fn(rec.id);
auto search = counter_name_value.find(counter_name);
@@ -35,6 +35,7 @@
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <cstdint>
#include <rocprofiler-sdk/cxx/name_info.hpp>
#include <rocprofiler-sdk/cxx/serialization.hpp>
@@ -270,18 +271,22 @@ struct rocprofiler_tool_record_counter_t
struct rocprofiler_tool_counter_collection_record_t
{
rocprofiler_profile_counting_dispatch_data_t dispatch_data = {};
std::vector<rocprofiler_tool_record_counter_t> records = {};
uint64_t thread_id = 0;
uint64_t arch_vgpr_count = 0;
uint64_t sgpr_count = 0;
uint64_t lds_block_size_v = 0;
rocprofiler_profile_counting_dispatch_data_t dispatch_data = {};
std::array<rocprofiler_tool_record_counter_t, 256> records = {};
uint64_t thread_id = 0;
uint64_t arch_vgpr_count = 0;
uint64_t sgpr_count = 0;
uint64_t lds_block_size_v = 0;
uint64_t counter_count = 0;
template <typename ArchiveT>
void save(ArchiveT& ar) const
{
ar(cereal::make_nvp("dispatch_data", dispatch_data));
ar(cereal::make_nvp("records", records));
// should be removed when moving to buffered tracing
std::vector<rocprofiler_tool_record_counter_t> tmp{records.begin(),
records.begin() + counter_count};
ar(cereal::make_nvp("records", tmp));
ar(cereal::make_nvp("thread_id", thread_id));
ar(cereal::make_nvp("arch_vgpr_count", arch_vgpr_count));
ar(cereal::make_nvp("sgpr_count", sgpr_count));
@@ -941,11 +941,19 @@ counter_record_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_da
for(size_t count = 0; count < record_count; count++)
{
// Unlikely to trigger, temporary until we move to buffered callbacks
if(count >= counter_record.records.size())
{
ROCP_WARNING << "Exceeded maximum counter capacity, skipping remaining";
break;
}
auto _counter_id = rocprofiler_counter_id_t{};
ROCPROFILER_CALL(rocprofiler_query_record_counter_id(record_data[count].id, &_counter_id),
"query record counter id");
counter_record.records.emplace_back(
rocprofiler_tool_record_counter_t{_counter_id, record_data[count]});
counter_record.records[count] =
rocprofiler_tool_record_counter_t{_counter_id, record_data[count]};
counter_record.counter_count++;
}
write_ring_buffer(counter_record, domain_type::COUNTER_COLLECTION);
@@ -28,7 +28,7 @@ def test_counter_values(input_data):
counter_data = data["buffer_records"]["counter_collection"]
for itr in counter_info:
if itr["is_constant"] == 1 and itr["name"] == "size":
if itr["is_constant"] == 1:
continue
assert itr["id"]["handle"] > 0, f"{itr}"
assert itr["is_constant"] in (0, 1), f"{itr}"