From d80c047fd240f896aa0dc65170b1e07f7941a718 Mon Sep 17 00:00:00 2001 From: "Meserve, Mark" Date: Wed, 26 Mar 2025 02:12:03 -0500 Subject: [PATCH] Additional 1.0.0 changes (#317) * Additional 1.0.0 changes - Update VERSION - Add beta compatibility for rocprofiler_agent_set_profile_callback_t * Fix location of deprecated typedef rocprofiler_agent_set_profile_callback_t * rocprofiler_record_counter_t -> rocprofiler_counter_record_t * Experimental + deprecated annotations * rocprofiler_record_dimension_info_t -> rocprofiler_counter_record_dimension_info_t --------- Co-authored-by: Jonathan R. Madsen [ROCm/rocprofiler-sdk commit: a1fcdf7f83409a3435ad33a86f26d0343c514a47] --- projects/rocprofiler-sdk/VERSION | 2 +- .../counter_collection/buffered_client.cpp | 18 ++++--- .../counter_collection/callback_client.cpp | 2 +- .../device_counting_async_client.cpp | 2 +- .../device_counting_sync_client.cpp | 20 +++---- .../print_functional_counters_client.cpp | 19 +++---- .../counter_collection_services.rst | 2 +- .../source/include/rocprofiler-sdk/counters.h | 4 +- .../rocprofiler-sdk/cxx/serialization.hpp | 4 +- .../rocprofiler-sdk/deprecated/counters.h | 8 +-- .../rocprofiler-sdk/device_counting_service.h | 12 ++++- .../dispatch_counting_service.h | 4 +- .../source/include/rocprofiler-sdk/fwd.h | 28 ++++------ .../source/include/rocprofiler-sdk/spm.h | 14 +++++ .../source/lib/rocprofiler-sdk-tool/tool.cpp | 16 +++--- .../source/lib/rocprofiler-sdk/counters.cpp | 5 +- .../counters/device_counting.cpp | 4 +- .../counters/device_counting.hpp | 4 +- .../rocprofiler-sdk/counters/evaluate_ast.cpp | 54 +++++++++---------- .../rocprofiler-sdk/counters/evaluate_ast.hpp | 26 ++++----- .../counters/sample_processing.cpp | 4 +- .../device_counting_service.cpp | 6 +-- .../rocprofiler-avail/rocprofv3_avail.cpp | 12 ++--- 23 files changed, 144 insertions(+), 126 deletions(-) diff --git a/projects/rocprofiler-sdk/VERSION b/projects/rocprofiler-sdk/VERSION index faef31a435..3eefcb9dd5 100644 --- a/projects/rocprofiler-sdk/VERSION +++ b/projects/rocprofiler-sdk/VERSION @@ -1 +1 @@ -0.7.0 +1.0.0 diff --git a/projects/rocprofiler-sdk/samples/counter_collection/buffered_client.cpp b/projects/rocprofiler-sdk/samples/counter_collection/buffered_client.cpp index ba011943e4..058eb13a91 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/buffered_client.cpp +++ b/projects/rocprofiler-sdk/samples/counter_collection/buffered_client.cpp @@ -74,10 +74,11 @@ get_buffer() return buf; } -std::unordered_map>** +std::unordered_map>** dimension_cache() { - static std::unordered_map>* cache; + static std::unordered_map>* + cache; return &cache; } @@ -85,7 +86,7 @@ dimension_cache() * For a given counter, query the dimensions that it has. Typically you will * want to call this function once to get the dimensions and cache them. */ -std::vector +std::vector counter_dimensions(rocprofiler_counter_id_t counter) { if(*dimension_cache() == nullptr) return {}; @@ -102,15 +103,15 @@ void fill_dimension_cache(rocprofiler_counter_id_t counter) { assert(*dimension_cache() != nullptr); - std::vector dims; - rocprofiler_counter_info_v1_t info; + std::vector dims; + rocprofiler_counter_info_v1_t info; ROCPROFILER_CALL(rocprofiler_query_counter_info( counter, ROCPROFILER_COUNTER_INFO_VERSION_1, static_cast(&info)), "Could not query info for counter"); (*dimension_cache()) ->emplace(counter.handle, - std::vector{ + std::vector{ info.dimensions, info.dimensions + info.dimensions_count}); } @@ -149,7 +150,7 @@ buffered_callback(rocprofiler_context_id_t, header->kind == ROCPROFILER_COUNTER_RECORD_VALUE) { // Print the returned counter data. - auto* record = static_cast(header->payload); + auto* record = static_cast(header->payload); rocprofiler_counter_id_t counter_id = {.handle = 0}; rocprofiler_query_record_counter_id(record->id, &counter_id); @@ -436,7 +437,8 @@ rocprofiler_configure(uint32_t version, static_cast(output_stream)}; *dimension_cache() = - new std::unordered_map>(); + new std::unordered_map>(); // return pointer to configure data return &cfg; diff --git a/projects/rocprofiler-sdk/samples/counter_collection/callback_client.cpp b/projects/rocprofiler-sdk/samples/counter_collection/callback_client.cpp index 0b5321096b..e0eb147e33 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/callback_client.cpp +++ b/projects/rocprofiler-sdk/samples/counter_collection/callback_client.cpp @@ -74,7 +74,7 @@ get_client_ctx() void record_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data, - rocprofiler_record_counter_t* record_data, + rocprofiler_counter_record_t* record_data, size_t record_count, rocprofiler_user_data_t /* user_data */, void* callback_data_args) diff --git a/projects/rocprofiler-sdk/samples/counter_collection/device_counting_async_client.cpp b/projects/rocprofiler-sdk/samples/counter_collection/device_counting_async_client.cpp index 0d2077d1f8..0712e43155 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/device_counting_async_client.cpp +++ b/projects/rocprofiler-sdk/samples/counter_collection/device_counting_async_client.cpp @@ -107,7 +107,7 @@ buffered_callback(rocprofiler_context_id_t, header->kind == ROCPROFILER_COUNTER_RECORD_VALUE) { // Print the returned counter data. - auto* record = static_cast(header->payload); + auto* record = static_cast(header->payload); ss << " (Id: " << record->id << " Value [D]: " << record->counter_value << "," << " user_data: " << record->user_data.value << "),"; diff --git a/projects/rocprofiler-sdk/samples/counter_collection/device_counting_sync_client.cpp b/projects/rocprofiler-sdk/samples/counter_collection/device_counting_sync_client.cpp index ab386d55af..d31cb7247c 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/device_counting_sync_client.cpp +++ b/projects/rocprofiler-sdk/samples/counter_collection/device_counting_sync_client.cpp @@ -75,16 +75,16 @@ public: counter_sampler(rocprofiler_agent_id_t agent); // Decode the counter name of a record - std::string decode_record_name(const rocprofiler_record_counter_t& rec) const; + std::string decode_record_name(const rocprofiler_counter_record_t& rec) const; // Get the dimensions of a record (what CU/SE/etc the counter is for). High cost operation // should be cached if possible. static std::unordered_map get_record_dimensions( - const rocprofiler_record_counter_t& rec); + const rocprofiler_counter_record_t& rec); // Sample the counter values for a set of counters, returns the records in the out parameter. rocprofiler_status_t sample_counter_values(const std::vector& counters, - std::vector& out); + std::vector& out); // Get the available agents on the system static std::vector get_available_agents(); @@ -113,7 +113,7 @@ private: rocprofiler_agent_id_t agent); // Get the dimensions of a counter - static std::vector get_counter_dimensions( + static std::vector get_counter_dimensions( rocprofiler_counter_id_t counter); }; @@ -162,7 +162,7 @@ counter_sampler::counter_sampler(rocprofiler_agent_id_t agent) } std::string -counter_sampler::decode_record_name(const rocprofiler_record_counter_t& rec) const +counter_sampler::decode_record_name(const rocprofiler_counter_record_t& rec) const { if(id_to_name_.empty()) { @@ -184,7 +184,7 @@ counter_sampler::decode_record_name(const rocprofiler_record_counter_t& rec) con } std::unordered_map -counter_sampler::get_record_dimensions(const rocprofiler_record_counter_t& rec) +counter_sampler::get_record_dimensions(const rocprofiler_counter_record_t& rec) { std::unordered_map out; rocprofiler_counter_id_t counter_id = {.handle = 0}; @@ -202,7 +202,7 @@ counter_sampler::get_record_dimensions(const rocprofiler_record_counter_t& rec) rocprofiler_status_t counter_sampler::sample_counter_values(const std::vector& counters, - std::vector& out) + std::vector& out) { auto profile_cached = cached_profiles_.find(counters); if(profile_cached == cached_profiles_.end()) @@ -330,14 +330,14 @@ counter_sampler::get_supported_counters(rocprofiler_agent_id_t agent) return out; } -std::vector +std::vector counter_sampler::get_counter_dimensions(rocprofiler_counter_id_t counter) { rocprofiler_counter_info_v1_t info; ROCPROFILER_CALL(rocprofiler_query_counter_info( counter, ROCPROFILER_COUNTER_INFO_VERSION_1, static_cast(&info)), "Could not query info for counter"); - return std::vector{ + return std::vector{ info.dimensions, info.dimensions + info.dimensions_count}; } @@ -376,7 +376,7 @@ tool_init(rocprofiler_client_finalize_t fini_func, void*) sampler_thread = new std::thread{[=]() { size_t count = 1; - std::vector records; + std::vector records; while(sampler && exit_toggle().load() == false) { auto status = sampler->sample_counter_values({"SQ_WAVES"}, records); diff --git a/projects/rocprofiler-sdk/samples/counter_collection/print_functional_counters_client.cpp b/projects/rocprofiler-sdk/samples/counter_collection/print_functional_counters_client.cpp index 7986844c3f..6a23895ada 100644 --- a/projects/rocprofiler-sdk/samples/counter_collection/print_functional_counters_client.cpp +++ b/projects/rocprofiler-sdk/samples/counter_collection/print_functional_counters_client.cpp @@ -85,7 +85,7 @@ struct validate_dim_presence { validate_dim_presence() {} - void maybe_forward(const rocprofiler_record_dimension_info_t& dim) + void maybe_forward(const rocprofiler_counter_record_dimension_info_t& dim) { if(sub_vectors.empty()) { @@ -118,8 +118,9 @@ struct validate_dim_presence sub_vectors.at(pos)->mark_seen(id); } - bool check_seen(std::stringstream& out, - std::vector>& pos_stack) + bool check_seen( + std::stringstream& out, + std::vector>& pos_stack) { bool ret = true; if(sub_vectors.empty()) @@ -150,9 +151,9 @@ struct validate_dim_presence return ret; } - std::pair vector_pos; - std::vector> sub_vectors; - bool has_value{false}; + std::pair vector_pos; + std::vector> sub_vectors; + bool has_value{false}; }; struct CaptureRecords @@ -197,7 +198,7 @@ buffered_callback(rocprofiler_context_id_t, // Record the counters we have in the buffer and the number of instances of // the counter we have seen. rocprofiler_counter_id_t counter; - auto* record = static_cast(header->payload); + auto* record = static_cast(header->payload); rocprofiler_query_record_counter_id(record->id, &counter); cap.expected_data_dims.at(counter.handle).mark_seen(record->id); seen_counters.emplace(counter.handle, 0).first->second++; @@ -406,8 +407,8 @@ tool_fini(void*) else { // Counter collected OK - std::stringstream ss; - std::vector> stack; + std::stringstream ss; + std::vector> stack; bool passed = cap.expected_data_dims.at(counter_id).check_seen(ss, stack); if(!PRINT_ONLY_FAILING || !passed) { diff --git a/projects/rocprofiler-sdk/source/docs/api-reference/counter_collection_services.rst b/projects/rocprofiler-sdk/source/docs/api-reference/counter_collection_services.rst index 37afa21ce4..248a19369c 100644 --- a/projects/rocprofiler-sdk/source/docs/api-reference/counter_collection_services.rst +++ b/projects/rocprofiler-sdk/source/docs/api-reference/counter_collection_services.rst @@ -228,7 +228,7 @@ Data from collected counter values is returned through a buffered callback. The header->kind == ROCPROFILER_COUNTER_RECORD_VALUE) { // Print the returned counter data. - auto* record = static_cast(header->payload); + auto* record = static_cast(header->payload); rocprofiler_counter_id_t counter_id = {.handle = 0}; rocprofiler_query_record_counter_id(record->id, &counter_id); diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/counters.h b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/counters.h index cea7050b98..291f046a10 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/counters.h +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/counters.h @@ -85,7 +85,7 @@ typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_info_v1_t /** * @brief (experimental) Query counter id information from record_id. * - * @param [in] id record id from rocprofiler_record_counter_t + * @param [in] id record id from rocprofiler_counter_record_t * @param [out] counter_id counter id associated with the record * @return ::rocprofiler_status_t * @retval ROCPROFILER_STATUS_SUCCESS if id decoded @@ -99,7 +99,7 @@ rocprofiler_query_record_counter_id(rocprofiler_counter_instance_id_t id, * @brief (experimental) Query dimension position from record_id. If the dimension does not exist * in the counter, the return will be 0. * - * @param [in] id record id from @ref rocprofiler_record_counter_t + * @param [in] id record id from @ref rocprofiler_counter_record_t * @param [in] dim dimension for which positional info is requested (currently only * 0 is allowed, i.e. flat array without dimension). * @param [out] pos value of the dimension in id diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/cxx/serialization.hpp b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/cxx/serialization.hpp index d385f34a58..d744643340 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/cxx/serialization.hpp +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/cxx/serialization.hpp @@ -560,7 +560,7 @@ save(ArchiveT& ar, rocprofiler_buffer_tracing_hsa_api_record_t data) template void -save(ArchiveT& ar, rocprofiler_record_counter_t data) +save(ArchiveT& ar, rocprofiler_counter_record_t data) { ROCP_SDK_SAVE_DATA_FIELD(id); ROCP_SDK_SAVE_DATA_FIELD(counter_value); @@ -1261,7 +1261,7 @@ save(ArchiveT& ar, rocprofiler_counter_info_v1_t data) template void -save(ArchiveT& ar, rocprofiler_record_dimension_info_t data) +save(ArchiveT& ar, rocprofiler_counter_record_dimension_info_t data) { ROCP_SDK_SAVE_DATA_FIELD(id); ROCP_SDK_SAVE_DATA_FIELD(instance_size); diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/deprecated/counters.h b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/deprecated/counters.h index a95ca04a3c..5b7119f534 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/deprecated/counters.h +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/deprecated/counters.h @@ -41,10 +41,10 @@ ROCPROFILER_EXTERN_C_INIT ROCPROFILER_SDK_DEPRECATED( "Function using this alias has been deprecated. See rocprofiler_iterate_counter_dimensions") typedef rocprofiler_status_t (*rocprofiler_available_dimensions_cb_t)( - rocprofiler_counter_id_t id, - const rocprofiler_record_dimension_info_t* dim_info, - size_t num_dims, - void* user_data); + rocprofiler_counter_id_t id, + const rocprofiler_counter_record_dimension_info_t* dim_info, + size_t num_dims, + void* user_data); /** * @brief (deprecated) Return information about the dimensions that exists for a specific counter diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/device_counting_service.h b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/device_counting_service.h index 4d05e6440c..170abd27c7 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/device_counting_service.h +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/device_counting_service.h @@ -132,9 +132,19 @@ rocprofiler_status_t rocprofiler_sample_device_counting_service(rocprofiler_context_id_t context_id, rocprofiler_user_data_t user_data, rocprofiler_counter_flag_t flags, - rocprofiler_record_counter_t* output_records, + rocprofiler_counter_record_t* output_records, size_t* rec_count) ROCPROFILER_API; +#if defined(ROCPROFILER_SDK_BETA_COMPAT) && ROCPROFILER_SDK_BETA_COMPAT > 0 + +// "rocprofiler_agent_set_profile_callback_t" renamed to +// "rocprofiler_device_counting_agent_cb_t" +ROCPROFILER_SDK_DEPRECATED( + "rocprofiler_agent_set_profile_callback_t renamed to rocprofiler_device_counting_agent_cb_t") +typedef rocprofiler_device_counting_agent_cb_t rocprofiler_agent_set_profile_callback_t; + +#endif + /** @} */ ROCPROFILER_EXTERN_C_FINI diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/dispatch_counting_service.h b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/dispatch_counting_service.h index dfb1fe8c31..d5ee3b53f7 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/dispatch_counting_service.h +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/dispatch_counting_service.h @@ -58,7 +58,7 @@ typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_dispatch_counting_servic typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_dispatch_counting_service_record_t { uint64_t size; ///< Size of this struct - uint64_t num_records; ///< number of ::rocprofiler_record_counter_t records + uint64_t num_records; ///< number of ::rocprofiler_counter_record_t records rocprofiler_async_correlation_id_t correlation_id; ///< Correlation ID for this dispatch rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds @@ -98,7 +98,7 @@ typedef void (*rocprofiler_dispatch_counting_service_cb_t)( ROCPROFILER_SDK_EXPERIMENTAL typedef void (*rocprofiler_dispatch_counting_record_cb_t)( rocprofiler_dispatch_counting_service_data_t dispatch_data, - rocprofiler_record_counter_t* record_data, + rocprofiler_counter_record_t* record_data, size_t record_count, rocprofiler_user_data_t user_data, void* callback_data_args); diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/fwd.h b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/fwd.h index a97eea9dba..7cda8e77c1 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/fwd.h +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/fwd.h @@ -806,9 +806,9 @@ typedef struct rocprofiler_kernel_dispatch_info_t } rocprofiler_kernel_dispatch_info_t; /** - * @brief Details for the dimension, including its size, for a counter record. + * @brief (experimental) Details for the dimension, including its size, for a counter record. */ -typedef struct rocprofiler_counter_record_dimension_info_t +typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_record_dimension_info_t { const char* name; size_t instance_size; @@ -818,12 +818,14 @@ typedef struct rocprofiler_counter_record_dimension_info_t /// @brief Id for this dimension used by ::rocprofiler_query_record_dimension_position } rocprofiler_counter_record_dimension_info_t; +ROCPROFILER_SDK_DEPRECATED("rocprofiler_counter_record_dimension_info_t was renamed to " + "rocprofiler_counter_record_dimension_info_t") typedef rocprofiler_counter_record_dimension_info_t rocprofiler_record_dimension_info_t; /** - * @brief ROCProfiler Profile Counting Counter Record per instance. + * @brief (experimental) ROCProfiler Profile Counting Counter Record per instance. */ -typedef struct rocprofiler_counter_record_t +typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_record_t { rocprofiler_counter_instance_id_t id; ///< counter identifier double counter_value; ///< counter value @@ -839,25 +841,13 @@ typedef struct rocprofiler_counter_record_t /// ::rocprofiler_kernel_dispatch_info_t) of a ::rocprofiler_dispatch_counting_service_data_t /// instance (provided during callback for profile config) or a /// ::rocprofiler_dispatch_counting_service_record_t records (which will be insert into the - /// buffer prior to the associated ::rocprofiler_record_counter_t records). + /// buffer prior to the associated ::rocprofiler_counter_record_t records). } rocprofiler_counter_record_t; +ROCPROFILER_SDK_DEPRECATED( + "rocprofiler_record_counter_t was renamed to rocprofiler_counter_record_t") typedef rocprofiler_counter_record_t rocprofiler_record_counter_t; -/** - * @brief ROCProfiler SPM Record. - * - */ -typedef struct rocprofiler_spm_record_t -{ - /** - * Counters, including identifiers to get counter information and Counters - * values - */ - rocprofiler_record_counter_t* counters; - uint64_t counters_count; -} rocprofiler_spm_record_t; - #if defined(ROCPROFILER_SDK_BETA_COMPAT) && ROCPROFILER_SDK_BETA_COMPAT > 0 // "profile_config" renamed to "counter_config" diff --git a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/spm.h b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/spm.h index 85887bed72..314e329949 100644 --- a/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/spm.h +++ b/projects/rocprofiler-sdk/source/include/rocprofiler-sdk/spm.h @@ -34,6 +34,20 @@ ROCPROFILER_EXTERN_C_INIT * @{ */ +/** + * @brief (experimental) ROCProfiler SPM Record. + * + */ +typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_spm_record_t +{ + /** + * Counters, including identifiers to get counter information and Counters + * values + */ + rocprofiler_counter_record_t* counters; + uint64_t counters_count; +} rocprofiler_spm_record_t; + /** * @brief Configure SPM Service. * 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 9214406d0f..c24b7a2243 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/tool.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk-tool/tool.cpp @@ -197,7 +197,7 @@ as_pointer() using targeted_kernels_map_t = std::unordered_map>; using counter_dimension_info_map_t = - std::unordered_map>; + std::unordered_map>; using agent_info_map_t = std::unordered_map; using kernel_iteration_t = std::unordered_map; using kernel_rename_map_t = std::unordered_map; @@ -1313,7 +1313,7 @@ dispatch_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data, void counter_record_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data, - rocprofiler_record_counter_t* record_data, + rocprofiler_counter_record_t* record_data, size_t record_count, rocprofiler_user_data_t user_data, void* /*callback_data_args*/) @@ -2163,11 +2163,11 @@ tool_fini(void* /*tool_data*/) #endif } -std::vector +std::vector get_tool_counter_dimension_info() { auto _data = get_agent_counter_info(); - auto _ret = std::vector{}; + auto _ret = std::vector{}; for(const auto& itr : _data) { for(const auto& iitr : itr.second) @@ -2175,12 +2175,12 @@ get_tool_counter_dimension_info() _ret.emplace_back(ditr); } - auto _sorter = [](const rocprofiler_record_dimension_info_t& lhs, - const rocprofiler_record_dimension_info_t& rhs) { + auto _sorter = [](const rocprofiler_counter_record_dimension_info_t& lhs, + const rocprofiler_counter_record_dimension_info_t& rhs) { return std::tie(lhs.id, lhs.instance_size) < std::tie(rhs.id, rhs.instance_size); }; - auto _equiv = [](const rocprofiler_record_dimension_info_t& lhs, - const rocprofiler_record_dimension_info_t& rhs) { + auto _equiv = [](const rocprofiler_counter_record_dimension_info_t& lhs, + const rocprofiler_counter_record_dimension_info_t& rhs) { return std::tie(lhs.id, lhs.instance_size) == std::tie(rhs.id, rhs.instance_size); }; diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters.cpp index 409fd5fe74..ee736b7bf4 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters.cpp @@ -287,7 +287,7 @@ rocprofiler_iterate_agent_supported_counters(rocprofiler_agent_id_t /** * @brief Query counter id information from record_id * - * @param [in] id record id from rocprofiler_record_counter_t + * @param [in] id record id from rocprofiler_counter_record_t * @param [out] counter_id counter id associated with the record * @return ::rocprofiler_status_t */ @@ -321,7 +321,8 @@ rocprofiler_iterate_counter_dimensions(rocprofiler_counter_id_t id, if(!dims) return ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND; // This is likely faster than a map lookup given the limited number of dims. - auto user_dims = common::container::small_vector{}; + auto user_dims = + common::container::small_vector{}; for(const auto& internal_dim : *dims) { auto& dim = user_dims.emplace_back(); diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/device_counting.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/device_counting.cpp index 91cb0c2c87..60f74814f5 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/device_counting.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/device_counting.cpp @@ -154,7 +154,7 @@ agent_async_handler(hsa_signal_value_t /*signal_v*/, void* data) // Write out the AQL data to the buffer for(auto& ast : prof_config->asts) { - std::vector>> cache; + std::vector>> cache; auto* ret = CHECK_NOTNULL(ast.evaluate(decoded_pkt, cache)); ast.set_out_id(*ret); for(auto& val : *ret) @@ -266,7 +266,7 @@ rocprofiler_status_t read_agent_ctx(const context::context* ctx, rocprofiler_user_data_t user_data, rocprofiler_counter_flag_t flags, - std::vector* out_counters) + std::vector* out_counters) { rocprofiler_status_t status = ROCPROFILER_STATUS_SUCCESS; if(!ctx->device_counter_collection) diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/device_counting.hpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/device_counting.hpp index 9e8f61aa11..e716f0536b 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/device_counting.hpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/device_counting.hpp @@ -61,7 +61,7 @@ struct agent_callback_data rocprofiler_device_counting_service_cb_t cb = nullptr; rocprofiler_buffer_id_t buffer = {.handle = 0}; bool set_profile = false; - std::vector* cached_counters = nullptr; + std::vector* cached_counters = nullptr; agent_callback_data() = default; agent_callback_data(agent_callback_data&& rhs) noexcept @@ -120,7 +120,7 @@ rocprofiler_status_t read_agent_ctx(const context::context* ctx, rocprofiler_user_data_t user_data, rocprofiler_counter_flag_t flags, - std::vector* out_counters); + std::vector* out_counters); uint64_t submitPacket(hsa_queue_t* queue, const void* packet); diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/evaluate_ast.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/evaluate_ast.cpp index acd7cdeb88..25cad9b1d9 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/evaluate_ast.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/evaluate_ast.cpp @@ -64,8 +64,8 @@ get_reduce_op_type_from_string(const std::string& op) void perform_reduction_to_single_instance(ReduceOperation reduce_op, - std::vector* input_array, - rocprofiler_record_counter_t* result) + std::vector* input_array, + rocprofiler_counter_record_t* result) { switch(reduce_op) { @@ -92,13 +92,13 @@ perform_reduction_to_single_instance(ReduceOperation *result = std::accumulate( input_array->begin(), input_array->end(), - rocprofiler_record_counter_t{.id = input_array->begin()->id, + rocprofiler_counter_record_t{.id = input_array->begin()->id, .counter_value = 0, .dispatch_id = input_array->begin()->dispatch_id, .user_data = input_array->begin()->user_data, .agent_id = input_array->begin()->agent_id}, [](auto& a, auto& b) { - return rocprofiler_record_counter_t{ + return rocprofiler_counter_record_t{ .id = a.id, .counter_value = a.counter_value + b.counter_value, .dispatch_id = a.dispatch_id, @@ -114,17 +114,17 @@ perform_reduction_to_single_instance(ReduceOperation } } -std::vector* +std::vector* perform_reduction( ReduceOperation reduce_op, - std::vector* input_array, + std::vector* input_array, const std::unordered_set& _reduce_dimension_set) { if(input_array->empty()) return input_array; if(_reduce_dimension_set.empty() || _reduce_dimension_set.size() == ROCPROFILER_DIMENSION_LAST - 1) { - rocprofiler_record_counter_t result{.id = 0, + rocprofiler_counter_record_t result{.id = 0, .counter_value = 0, .dispatch_id = 0, .user_data = {.value = 0}, @@ -136,7 +136,7 @@ perform_reduction( return input_array; } - std::unordered_map> rec_groups; + std::unordered_map> rec_groups; size_t bit_length = DIM_BIT_LENGTH / ROCPROFILER_DIMENSION_LAST; for(auto& rec : *input_array) @@ -154,7 +154,7 @@ perform_reduction( input_array->clear(); for(auto& rec_pair : rec_groups) { - rocprofiler_record_counter_t result{.id = 0, + rocprofiler_counter_record_t result{.id = 0, .counter_value = 0, .dispatch_id = 0, .user_data = {.value = 0}, @@ -208,9 +208,9 @@ get_int_encoded_dimensions_from_string(const std::string& rangeStr) return result; } -std::vector* +std::vector* perform_selection(std::map& dimension_map, - std::vector* input_array) + std::vector* input_array) { if(input_array->empty()) return input_array; for(auto& dim_pair : dimension_map) @@ -221,7 +221,7 @@ perform_selection(std::maperase(std::remove_if(input_array->begin(), input_array->end(), - [&](rocprofiler_record_counter_t& rec) { + [&](rocprofiler_counter_record_t& rec) { bool should_remove = (encoded_dim_values & (1 << rocprofiler::counters::rec_to_dim_pos( @@ -692,7 +692,7 @@ void EvaluateAST::read_special_counters( const rocprofiler_agent_t& agent, const std::set& required_special_counters, - std::unordered_map>& out_map) + std::unordered_map>& out_map) { for(const auto& metric : required_special_counters) { @@ -705,19 +705,19 @@ EvaluateAST::read_special_counters( } } -std::unordered_map> +std::unordered_map> EvaluateAST::read_pkt(const aql::CounterPacketConstruct* pkt_gen, hsa::AQLPacket& pkt) { struct it_data { - std::unordered_map>* data; + std::unordered_map>* data; const aql::CounterPacketConstruct* pkt_gen; aqlprofile_agent_handle_t agent; }; auto aql_agent = *CHECK_NOTNULL(rocprofiler::agent::get_aql_agent(pkt_gen->agent())); - std::unordered_map> ret; + std::unordered_map> ret; if(pkt.empty) return ret; it_data aql_data{.data = &ret, .pkt_gen = pkt_gen, .agent = aql_agent}; @@ -730,7 +730,7 @@ EvaluateAST::read_pkt(const aql::CounterPacketConstruct* pkt_gen, hsa::AQLPacket if(!metric) return HSA_STATUS_SUCCESS; - auto& vec = it.data->emplace(metric->id(), std::vector{}) + auto& vec = it.data->emplace(metric->id(), std::vector{}) .first->second; auto& next_rec = vec.emplace_back(); set_counter_in_rec(next_rec.id, {.handle = metric->id()}); @@ -754,7 +754,7 @@ EvaluateAST::read_pkt(const aql::CounterPacketConstruct* pkt_gen, hsa::AQLPacket } void -EvaluateAST::set_out_id(std::vector& results) const +EvaluateAST::set_out_id(std::vector& results) const { for(auto& record : results) { @@ -799,10 +799,10 @@ EvaluateAST::expand_derived(std::unordered_map& asts) } // convert to buffer at some point -std::vector* +std::vector* EvaluateAST::evaluate( - std::unordered_map>& results_map, - std::vector>>& cache) + std::unordered_map>& results_map, + std::vector>>& cache) { auto perform_op = [&](auto&& op) { auto* r1 = _children.at(0).evaluate(results_map, cache); @@ -842,13 +842,13 @@ EvaluateAST::evaluate( case RANGE_NODE: break; case NUMBER_NODE: { - cache.emplace_back(std::make_unique>()); + cache.emplace_back(std::make_unique>()); *cache.back() = _static_value; return cache.back().get(); } case ADDITION_NODE: return perform_op([](auto& a, auto& b) { - return rocprofiler_record_counter_t{ + return rocprofiler_counter_record_t{ .id = a.id, .counter_value = a.counter_value + b.counter_value, .dispatch_id = a.dispatch_id, @@ -857,7 +857,7 @@ EvaluateAST::evaluate( }); case SUBTRACTION_NODE: return perform_op([](auto& a, auto& b) { - return rocprofiler_record_counter_t{ + return rocprofiler_counter_record_t{ .id = a.id, .counter_value = a.counter_value - b.counter_value, .dispatch_id = a.dispatch_id, @@ -866,7 +866,7 @@ EvaluateAST::evaluate( }); case MULTIPLY_NODE: return perform_op([](auto& a, auto& b) { - return rocprofiler_record_counter_t{ + return rocprofiler_counter_record_t{ .id = a.id, .counter_value = a.counter_value * b.counter_value, .dispatch_id = a.dispatch_id, @@ -875,7 +875,7 @@ EvaluateAST::evaluate( }); case DIVIDE_NODE: return perform_op([](auto& a, auto& b) { - return rocprofiler_record_counter_t{ + return rocprofiler_counter_record_t{ .id = a.id, .counter_value = (b.counter_value == 0 ? 0 : a.counter_value / b.counter_value), .dispatch_id = a.dispatch_id, @@ -891,7 +891,7 @@ EvaluateAST::evaluate( throw std::runtime_error( fmt::format("Unable to lookup results for metric {}", _metric.name())); - cache.emplace_back(std::make_unique>()); + cache.emplace_back(std::make_unique>()); *cache.back() = *result; result = cache.back().get(); return result; diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/evaluate_ast.hpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/evaluate_ast.hpp index 7eed89bf48..0d3a5492b9 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/evaluate_ast.hpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/evaluate_ast.hpp @@ -82,12 +82,12 @@ public: * computations. This is needed to avoid destroying data * in the result map that may be used by other evaluate calls. * - * @return std::vector* A pointer to the output records. + * @return std::vector* A pointer to the output records. * This pointer SHOULD NOT BE FREE'D/DELETED BY THE CALLER. */ - std::vector* evaluate( - std::unordered_map>& results_map, - std::vector>>& cache); + std::vector* evaluate( + std::unordered_map>& results_map, + std::vector>>& cache); /** * @brief Expand derived counter ASTs contained within this AST to full hardware counter @@ -120,20 +120,20 @@ public: std::set& counters) const; /** - * @brief Read the AQL packet and construct rocprofiler_record_counter_t. This call + * @brief Read the AQL packet and construct rocprofiler_counter_record_t. This call * does not perform any evaluation, only dumping the packet contents into - * rocprofiler_record_counter_t. + * rocprofiler_counter_record_t. * * @param [in] pkt_gen packet generator used to generate the AQL packet. This packet * generator contains information, such as the ordering of instances * contained in the return packet, that is required to decode what * data goes with what base counters. * @param [in] pkt AQL packet structure to decode - * @return std::unordered_map> map of + * @return std::unordered_map> map of * {metric->id(), vector} * */ - static std::unordered_map> read_pkt( + static std::unordered_map> read_pkt( const aql::CounterPacketConstruct* pkt_gen, hsa::AQLPacket& pkt); @@ -148,7 +148,7 @@ public: static void read_special_counters( const rocprofiler_agent_t& agent, const std::set& required_special_counters, - std::unordered_map>& out_map); + std::unordered_map>& out_map); NodeType type() const { return _type; } ReduceOperation reduce_op() const { return _reduce_op; } @@ -162,7 +162,7 @@ public: * * @param [in] results computed results that will have their id modified to be counter _out_id */ - void set_out_id(std::vector& results) const; + void set_out_id(std::vector& results) const; const rocprofiler_counter_id_t& out_id() const { return _out_id; } @@ -174,7 +174,7 @@ private: std::vector _children; std::string _agent; std::vector _dimension_types{}; - std::vector _static_value; + std::vector _static_value; std::unordered_set _reduce_dimension_set; std::map _select_dimension_map; bool _expanded{false}; @@ -214,7 +214,7 @@ get_agent_property(std::string_view property, const rocprofiler_agent_t& agent); namespace fmt { template <> -struct formatter +struct formatter { template constexpr auto parse(ParseContext& ctx) @@ -223,7 +223,7 @@ struct formatter } template - auto format(rocprofiler_record_counter_t const& data, Ctx& ctx) const + auto format(rocprofiler_counter_record_t const& data, Ctx& ctx) const { return fmt::format_to(ctx.out(), "(CounterId: {}, Dimension: {:x}, Value [D]: {})", diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/sample_processing.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/sample_processing.cpp index 0f942c745b..bc2b4f96e5 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/sample_processing.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/sample_processing.cpp @@ -68,7 +68,7 @@ proccess_completed_cb(completed_cb_params_t&& params) prof_config->packets.wlock([&](auto& pkt_vector) { pkt_vector.emplace_back(std::move(pkt)); }); - common::container::small_vector out; + common::container::small_vector out; rocprofiler::buffer::instance* buf = nullptr; if(info->buffer) @@ -92,7 +92,7 @@ proccess_completed_cb(completed_cb_params_t&& params) auto _dispatch_id = session.callback_record.dispatch_info.dispatch_id; for(auto& ast : prof_config->asts) { - std::vector>> cache; + std::vector>> cache; auto* ret = ast.evaluate(decoded_pkt, cache); CHECK(ret); ast.set_out_id(*ret); diff --git a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/device_counting_service.cpp b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/device_counting_service.cpp index 8d1897517d..d1f31bcf4d 100644 --- a/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/device_counting_service.cpp +++ b/projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/device_counting_service.cpp @@ -51,7 +51,7 @@ rocprofiler_status_t rocprofiler_sample_device_counting_service(rocprofiler_context_id_t context_id, rocprofiler_user_data_t user_data, rocprofiler_counter_flag_t flags, - rocprofiler_record_counter_t* output_records, + rocprofiler_counter_record_t* output_records, size_t* rec_count) { if(context_id == rocprofiler_context_none) return ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND; @@ -72,7 +72,7 @@ rocprofiler_sample_device_counting_service(rocprofiler_context_id_t context if(*rec_count == 0) return ROCPROFILER_STATUS_ERROR_OUT_OF_RESOURCES; - auto recs = std::vector{}; + auto recs = std::vector{}; auto status = rocprofiler::counters::read_agent_ctx(ctx, user_data, flags, &recs); if(status == ROCPROFILER_STATUS_SUCCESS) { @@ -83,7 +83,7 @@ rocprofiler_sample_device_counting_service(rocprofiler_context_id_t context } *rec_count = recs.size(); std::memcpy( - output_records, recs.data(), sizeof(rocprofiler_record_counter_t) * recs.size()); + output_records, recs.data(), sizeof(rocprofiler_counter_record_t) * recs.size()); } return status; } diff --git a/projects/rocprofiler-sdk/source/libexec/rocprofiler-sdk/rocprofiler-avail/rocprofv3_avail.cpp b/projects/rocprofiler-sdk/source/libexec/rocprofiler-sdk/rocprofiler-avail/rocprofv3_avail.cpp index 008ac06a02..b67b76a2b5 100644 --- a/projects/rocprofiler-sdk/source/libexec/rocprofiler-sdk/rocprofiler-avail/rocprofv3_avail.cpp +++ b/projects/rocprofiler-sdk/source/libexec/rocprofiler-sdk/rocprofiler-avail/rocprofv3_avail.cpp @@ -180,12 +180,12 @@ pc_configuration_callback(const rocprofiler_pc_sampling_configuration_t* configs rocprofiler_status_t dimensions_info_callback(rocprofiler_counter_id_t /*id*/, - const rocprofiler_record_dimension_info_t* dim_info, - long unsigned int num_dims, - void* user_data) + const rocprofiler_counter_record_dimension_info_t* dim_info, + long unsigned int num_dims, + void* user_data) { auto* dimensions_info = - static_cast*>(user_data); + static_cast*>(user_data); dimensions_info->reserve(num_dims); for(size_t j = 0; j < num_dims; j++) dimensions_info->emplace_back(dim_info[j]); @@ -202,13 +202,13 @@ iterate_agent_counters_callback(rocprofiler_agent_id_t, for(size_t i = 0; i < num_counters; i++) { auto _info = rocprofiler_counter_info_v1_t{}; - auto dimensions_data = std::vector{}; + auto dimensions_data = std::vector{}; ROCPROFILER_CALL( rocprofiler_query_counter_info( counters[i], ROCPROFILER_COUNTER_INFO_VERSION_1, static_cast(&_info)), "Could not query counter_id"); - dimensions_data = std::vector{ + dimensions_data = std::vector{ _info.dimensions, _info.dimensions + _info.dimensions_count}; auto dimensions_info = std::vector>{}; dimensions_info.reserve(dimensions_data.size());