From 4f05850efd3acb398bf59f75d87dfa78bb3bb3d2 Mon Sep 17 00:00:00 2001 From: Benjamin Welton Date: Wed, 2 Oct 2024 16:55:00 -0700 Subject: [PATCH] [SWDEV-484495] Fix int truncation in CSV output (#1098) CSV output truncates doubles to ints when it shouldn't. Derived metrics are (mostly) doubles and lose precision (or become worthless) if treated as an int. Converted these to double to match the format we return from rocprof-sdk. Co-authored-by: Benjamin Welton --- source/lib/rocprofiler-sdk-tool/generateCSV.cpp | 4 ++-- tests/rocprofv3/counter-collection/input2/validate.py | 2 +- tests/rocprofv3/counter-collection/input3/validate.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/lib/rocprofiler-sdk-tool/generateCSV.cpp b/source/lib/rocprofiler-sdk-tool/generateCSV.cpp index 3d91c817cd..5c6379ce55 100644 --- a/source/lib/rocprofiler-sdk-tool/generateCSV.cpp +++ b/source/lib/rocprofiler-sdk-tool/generateCSV.cpp @@ -487,7 +487,7 @@ generate_csv(tool_table* too for(const auto& record : data) { auto kernel_id = record.dispatch_data.dispatch_info.kernel_id; - auto counter_name_value = std::map{}; + auto counter_name_value = std::map{}; for(uint64_t i = 0; i < record.counter_count; i++) { const auto& count = record.records.at(i); @@ -496,7 +496,7 @@ generate_csv(tool_table* too auto search = counter_name_value.find(counter_name); if(search == counter_name_value.end()) counter_name_value.emplace( - std::pair{counter_name, rec.counter_value}); + std::pair{counter_name, rec.counter_value}); else search->second = search->second + rec.counter_value; } diff --git a/tests/rocprofv3/counter-collection/input2/validate.py b/tests/rocprofv3/counter-collection/input2/validate.py index 46d62a92f4..803e7e578f 100644 --- a/tests/rocprofv3/counter-collection/input2/validate.py +++ b/tests/rocprofv3/counter-collection/input2/validate.py @@ -35,7 +35,7 @@ def test_validate_counter_collection_pmc2(counter_input_data): assert len(row["Counter_Value"]) > 0 # assert row["Counter_Name"].contains("SQ_WAVES").all() assert row["Counter_Name"] in counter_names - assert int(row["Counter_Value"]) > 0 + assert float(row["Counter_Value"]) > 0 di_list.append(int(row["Dispatch_Id"])) diff --git a/tests/rocprofv3/counter-collection/input3/validate.py b/tests/rocprofv3/counter-collection/input3/validate.py index 7831874d34..d73a2e7f0c 100644 --- a/tests/rocprofv3/counter-collection/input3/validate.py +++ b/tests/rocprofv3/counter-collection/input3/validate.py @@ -35,7 +35,7 @@ def test_validate_counter_collection_yml_pmc(counter_input_data): assert len(row["Counter_Value"]) > 0 # assert row["Counter_Name"].contains("SQ_WAVES").all() assert row["Counter_Name"] in counter_names - assert int(row["Counter_Value"]) > 0 + assert float(row["Counter_Value"]) > 0 di_list.append(int(row["Dispatch_Id"]))