From f0924c6aa77ac2d978fb586c866dde553d03307a Mon Sep 17 00:00:00 2001 From: Benjamin Welton Date: Tue, 26 Mar 2024 15:19:04 -0700 Subject: [PATCH] Make dimension error message print the counter name (#658) * temp * source formatting (clang-format v11) (#659) Co-authored-by: bwelton <1683479+bwelton@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bwelton <1683479+bwelton@users.noreply.github.com> --- source/lib/rocprofiler-sdk/counters/core.cpp | 11 ++++++++++- source/lib/rocprofiler-sdk/counters/dimensions.cpp | 12 ++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/source/lib/rocprofiler-sdk/counters/core.cpp b/source/lib/rocprofiler-sdk/counters/core.cpp index a8b07cd0cc..912fc0c05e 100644 --- a/source/lib/rocprofiler-sdk/counters/core.cpp +++ b/source/lib/rocprofiler-sdk/counters/core.cpp @@ -206,7 +206,16 @@ counter_callback_info::setup_profile_config(const hsa::AgentCache& age return ROCPROFILER_STATUS_ERROR_AST_NOT_FOUND; } config.asts.push_back(*counter_ast); - config.asts.back().set_dimensions(); + + try + { + config.asts.back().set_dimensions(); + } catch(std::runtime_error& e) + { + LOG(ERROR) << metric.name() << " has improper dimensions" + << " " << e.what(); + return ROCPROFILER_STATUS_ERROR_AST_NOT_FOUND; + } } profile->pkt_generator = std::make_unique( diff --git a/source/lib/rocprofiler-sdk/counters/dimensions.cpp b/source/lib/rocprofiler-sdk/counters/dimensions.cpp index 792182f8f5..db7ce834da 100644 --- a/source/lib/rocprofiler-sdk/counters/dimensions.cpp +++ b/source/lib/rocprofiler-sdk/counters/dimensions.cpp @@ -117,10 +117,18 @@ get_dimension_cache() const auto& asts = counters::get_ast_map(); for(const auto& [gfx, metrics] : asts) { - for(const auto& [_, ast] : metrics) + for(const auto& [metric, ast] : metrics) { auto ast_copy = ast; - dims.emplace(ast.out_id().handle, ast_copy.set_dimensions()); + try + { + dims.emplace(ast.out_id().handle, ast_copy.set_dimensions()); + } catch(std::runtime_error& e) + { + LOG(ERROR) << metric << " has improper dimensions" + << " " << e.what(); + throw; + } } } return dims;