diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/generateCSV.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/generateCSV.cpp index ca72d0075a..d06cf79029 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/generateCSV.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/generateCSV.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -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{}; - 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); diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/helper.hpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/helper.hpp index ce6d3135f5..ac8c9d34e9 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/helper.hpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/helper.hpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -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 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 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 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 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)); diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/tool.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/tool.cpp index f1616e2426..70d547846d 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/tool.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/tool.cpp @@ -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); diff --git a/projects/rocprofiler-sdk/tests/counter-collection/validate.py b/projects/rocprofiler-sdk/tests/counter-collection/validate.py index 9d187c49f8..43a31eb62c 100644 --- a/projects/rocprofiler-sdk/tests/counter-collection/validate.py +++ b/projects/rocprofiler-sdk/tests/counter-collection/validate.py @@ -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}"