From 7b71c18cef7c643c2af2019a19acea2e5f4f0912 Mon Sep 17 00:00:00 2001 From: Benjamin Welton Date: Fri, 17 Nov 2023 15:15:39 -0800 Subject: [PATCH] Rename functioanl counter client, fix crash if no counters present on system (#242) * Rename functioanl counter client, fix crash if no counters Lack of counters for an agent should not crash this sample. * source formatting (clang-format v11) (#243) Co-authored-by: bwelton --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bwelton [ROCm/rocprofiler-sdk commit: d40fc59703f39d2b81e1770b1b9695b13331cf2f] --- .../samples/counter_collection/CMakeLists.txt | 23 ++++++++++--------- ...ient.cpp => print_functional_counters.cpp} | 5 +++- 2 files changed, 16 insertions(+), 12 deletions(-) rename projects/rocprofiler-sdk/samples/counter_collection/{test_counter_client.cpp => print_functional_counters.cpp} (98%) diff --git a/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt b/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt index 66302525cb..9229cccf39 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt +++ b/projects/rocprofiler-sdk/samples/counter_collection/CMakeLists.txt @@ -52,21 +52,22 @@ set_tests_properties( FAIL_REGULAR_EXPRESSION "threw an exception") -add_library(counter-collection-test-counter-client SHARED) -target_sources(counter-collection-test-counter-client PRIVATE test_counter_client.cpp - client.hpp) -target_link_libraries(counter-collection-test-counter-client +add_library(counter-collection-functional-counter-client SHARED) +target_sources(counter-collection-functional-counter-client + PRIVATE print_functional_counters.cpp client.hpp) +target_link_libraries(counter-collection-functional-counter-client PRIVATE rocprofiler::rocprofiler) -add_executable(counter-collection-test-counters) -target_sources(counter-collection-test-counters PRIVATE main.cpp) -target_link_libraries(counter-collection-test-counters - PRIVATE counter-collection-test-counter-client Threads::Threads) +add_executable(counter-collection-print-functional-counters) +target_sources(counter-collection-print-functional-counters PRIVATE main.cpp) +target_link_libraries( + counter-collection-print-functional-counters + PRIVATE counter-collection-functional-counter-client Threads::Threads) -add_test(NAME counter-collection-test-counters - COMMAND $) +add_test(NAME counter-collection-print-functional-counters + COMMAND $) set_tests_properties( - counter-collection-test-counters + counter-collection-print-functional-counters PROPERTIES TIMEOUT 300 diff --git a/projects/rocprofiler-sdk/samples/counter_collection/test_counter_client.cpp b/projects/rocprofiler-sdk/samples/counter_collection/print_functional_counters.cpp similarity index 98% rename from projects/rocprofiler-sdk/samples/counter_collection/test_counter_client.cpp rename to projects/rocprofiler-sdk/samples/counter_collection/print_functional_counters.cpp index 7ebcfdf5c2..6ff9d243a3 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/test_counter_client.cpp +++ b/projects/rocprofiler-sdk/samples/counter_collection/print_functional_counters.cpp @@ -148,7 +148,10 @@ dispatch_callback(rocprofiler_queue_id_t queue_id, "Could not query name"); cap.expected_counter_names.emplace(found_counter.handle, std::string(name)); } - if(cap.expected.empty()) throw std::runtime_error("No counters found for agent"); + if(cap.expected.empty()) + { + std::clog << "No counters found for agent - " << agent->name; + } } if(cap.remaining.empty()) return;