[SDK] Release 1.0 Public API Modifications (#277)

* Make sure all structs/enums can be forward declared

* Updates to counter collection

- consistency updates and cleanup

* Conversion of dimension information to info struct

* Added deprecated folder

* Testing changes

* merge changes

* Fix shadowed variable

* Source code formatting

* Fix shadowed variable

* Update rocprofiler_counter_info_v1_t member names

* Split version.h into version.h and ext_version.h

- ext_version.h contains external version info, e.g. ROCPROFILER_HSA_API_TABLE_MAJOR_VERSION, ROCPROFILER_HSA_RUNTIME_VERSION
- this reduces amount of recompilation after a commit since version.h gets updated with the git revision

* profile_config -> counter_config

* EOF new line

* [Samples] Reduce header includes + reorg counter collection samples

* Misc compilation fixes

- shadowed variables
- use of [[deprecated("...")]] in C code
- unused variables

* Minor misc modifications

- use common:: instead of rocprofiler::common:: when inside rocprofiler namespace
- counters.cpp
  - move local anon namespace functions into rocprofiler::counters:: anon namespace
  - use std::string_view for get_static_string
  - const ref for get_static_ptr
  - misc namespace shortening

* [Public API] rocprofiler_get_version_triplet + rocprofiler_version_triplet_t

- struct rocprofiler_version_triplet_t containing fields for the major, minor, and patch version
- public API function: rocprofiler_get_version_triplet
- define C++ operators for rocprofiler_version_triplet_t
- C++ function compute_version_triplet

* [Tests] Improve async-copy-testing test

- relax constraints
- improve logging

* Update counter_config.h doxygen docs

* ROCPROFILER_SDK_BETA_COMPAT

- ppdef which helps with renaming when set to 1

* Remove spurious include

* Fix includes for cxx/version.hpp

* Doxygen fixes for rocprofiler_get_version and rocprofiler_get_version_triplet

* Public API Experimental Designation

- ROCPROFILER_SDK_EXPERIMENTAL added to experimental function
- "(experimental)" added to doxygen @brief entries

* Fix use of assert instead of static_assert in hip/stream.cpp

* Use typedef instead of define for rocprofiler_profile_config_id_t

* Use inline rocprofiler_{create,destroy}_profile_config instead of ppdef

- added <rocprofiler-sdk/deprecated/profile_config.h>

* Doxygen for rocprofiler_{create,destroy}_profile_config

* ROCPROFILER_SDK_DEPRECATED_WARNINGS

* Temporarily comment out ROCPROFILER_SDK_DEPRECATED_WARNINGS=1

* cmake formatting

* Misc variable renaming in samples and tests

* Fix declarations of types

* Fix hip stream tracing service struct name

- rocprofiler_callback_tracing_stream_handle_data_t renamed to rocprofiler_callback_tracing_hip_stream_api_data_t

* Rename "HIP_STREAM_API" to "HIP_STREAM"

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
Co-authored-by: Benjamin Welton <bewelton@amd.com>
Este commit está contenido en:
authored and GitHub committed 2025-03-24 12:07:33 +05:30
1 padre cd4676ae6f
commit 4cd121e27b
127 files changed
+1629 -988

No files matched your search

-6
Ver fichero
@@ -33,12 +33,6 @@
#include "client.hpp"
#include <rocprofiler-sdk/buffer.h>
#include <rocprofiler-sdk/buffer_tracing.h>
#include <rocprofiler-sdk/callback_tracing.h>
#include <rocprofiler-sdk/external_correlation.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/internal_threading.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
+14 -10
Ver fichero
@@ -33,11 +33,10 @@
#include "client.hpp"
#include <rocprofiler-sdk/context.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/marker/api_id.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <rocprofiler-sdk/cxx/operators.hpp>
#include <rocprofiler-sdk/cxx/version.hpp>
#include "common/call_stack.hpp"
#include "common/defines.hpp"
@@ -318,7 +317,7 @@ stop()
extern "C" rocprofiler_tool_configure_result_t*
rocprofiler_configure(uint32_t version,
const char* runtime_version,
const char* version_string,
uint32_t priority,
rocprofiler_client_id_t* id)
{
@@ -336,21 +335,26 @@ rocprofiler_configure(uint32_t version,
// generate info string
auto info = std::stringstream{};
info << id->name << " (priority=" << priority << ") is using rocprofiler-sdk v" << major << "."
<< minor << "." << patch << " (" << runtime_version << ")";
<< minor << "." << patch << " (" << version_string << ")";
std::clog << info.str() << std::endl;
// demonstration of alternative way to get the version info
{
auto version_info = std::array<uint32_t, 3>{};
ROCPROFILER_CALL(
rocprofiler_get_version(&version_info.at(0), &version_info.at(1), &version_info.at(2)),
"failed to get version info");
auto runtime_version = rocprofiler_version_triplet_t{};
ROCPROFILER_CALL(rocprofiler_get_version_triplet(&runtime_version),
"failed to get version info");
if(std::array<uint32_t, 3>{major, minor, patch} != version_info)
if(rocprofiler_version_triplet_t{major, minor, patch} != runtime_version)
{
throw std::runtime_error{"version info mismatch"};
}
if(rocprofiler_version_triplet_t{major, minor, patch} !=
rocprofiler::sdk::version::compute_version_triplet<100>(version))
{
throw std::runtime_error{"version triplet incorrectly calculated"};
}
}
// data passed around all the callbacks
-3
Ver fichero
@@ -33,9 +33,6 @@
* @brief Example rocprofiler client (tool)
*/
#include <rocprofiler-sdk/buffer.h>
#include <rocprofiler-sdk/callback_tracing.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <rocprofiler-sdk/cxx/codeobj/code_printing.hpp>
-3
Ver fichero
@@ -31,9 +31,6 @@
* @brief Example rocprofiler client (tool)
*/
#include <rocprofiler-sdk/buffer.h>
#include <rocprofiler-sdk/callback_tracing.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
+7 -7
Ver fichero
@@ -34,7 +34,7 @@ endif()
find_package(rocprofiler-sdk REQUIRED)
add_library(counter-collection-buffer-client SHARED)
target_sources(counter-collection-buffer-client PRIVATE client.cpp client.hpp)
target_sources(counter-collection-buffer-client PRIVATE buffered_client.cpp client.hpp)
target_link_libraries(
counter-collection-buffer-client
PUBLIC rocprofiler-sdk::samples-build-flags
@@ -59,10 +59,10 @@ set_tests_properties(
"${counter-collection-buffer-env}" FAIL_REGULAR_EXPRESSION
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
set_source_files_properties(per_dev_serialization.cpp PROPERTIES LANGUAGE HIP)
set_source_files_properties(device_serialized_main.cpp PROPERTIES LANGUAGE HIP)
add_executable(counter-collection-buffer-device-serialization)
target_sources(counter-collection-buffer-device-serialization
PRIVATE per_dev_serialization.cpp)
PRIVATE device_serialized_main.cpp)
target_link_libraries(counter-collection-buffer-device-serialization
PRIVATE counter-collection-buffer-client Threads::Threads)
@@ -109,7 +109,7 @@ set_tests_properties(
add_library(counter-collection-functional-counter-client SHARED)
target_sources(counter-collection-functional-counter-client
PRIVATE print_functional_counters.cpp client.hpp)
PRIVATE print_functional_counters_client.cpp client.hpp)
target_link_libraries(
counter-collection-functional-counter-client
PUBLIC rocprofiler-sdk::samples-build-flags
@@ -136,8 +136,8 @@ set_tests_properties(
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
add_library(counter-collection-device-profiling-client SHARED)
target_sources(counter-collection-device-profiling-client PRIVATE device_counting.cpp
client.hpp)
target_sources(counter-collection-device-profiling-client
PRIVATE device_counting_async_client.cpp client.hpp)
target_link_libraries(
counter-collection-device-profiling-client
PUBLIC rocprofiler-sdk::samples-build-flags
@@ -171,7 +171,7 @@ set_tests_properties(
add_library(counter-collection-device-profiling-sync-client SHARED)
target_sources(counter-collection-device-profiling-sync-client
PRIVATE device_counting_synchronous.cpp client.hpp)
PRIVATE device_counting_sync_client.cpp client.hpp)
target_link_libraries(
counter-collection-device-profiling-sync-client
PUBLIC rocprofiler-sdk::samples-build-flags
@@ -22,6 +22,9 @@
#include "client.hpp"
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <cstdint>
#include <fstream>
#include <functional>
@@ -33,10 +36,6 @@
#include <unordered_map>
#include <vector>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#define ROCPROFILER_CALL(result, msg) \
{ \
rocprofiler_status_t CHECKSTATUS = result; \
@@ -104,22 +103,15 @@ fill_dimension_cache(rocprofiler_counter_id_t counter)
{
assert(*dimension_cache() != nullptr);
std::vector<rocprofiler_record_dimension_info_t> dims;
rocprofiler_available_dimensions_cb_t cb =
[](rocprofiler_counter_id_t,
const rocprofiler_record_dimension_info_t* dim_info,
size_t num_dims,
void* user_data) {
std::vector<rocprofiler_record_dimension_info_t>* vec =
static_cast<std::vector<rocprofiler_record_dimension_info_t>*>(user_data);
for(size_t i = 0; i < num_dims; i++)
{
vec->push_back(dim_info[i]);
}
return ROCPROFILER_STATUS_SUCCESS;
};
ROCPROFILER_CALL(rocprofiler_iterate_counter_dimensions(counter, cb, &dims),
"Could not iterate counter dimensions");
(*dimension_cache())->emplace(counter.handle, dims);
rocprofiler_counter_info_v1_t info;
ROCPROFILER_CALL(rocprofiler_query_counter_info(
counter, ROCPROFILER_COUNTER_INFO_VERSION_1, static_cast<void*>(&info)),
"Could not query info for counter");
(*dimension_cache())
->emplace(counter.handle,
std::vector<rocprofiler_record_dimension_info_t>{
info.dimensions, info.dimensions + info.dimensions_count});
}
/**
@@ -187,22 +179,22 @@ buffered_callback(rocprofiler_context_id_t,
* to select the profile config (and in turn counters) to use when a kernel dispatch
* is received.
*/
std::unordered_map<uint64_t, rocprofiler_profile_config_id_t>&
std::unordered_map<uint64_t, rocprofiler_counter_config_id_t>&
get_profile_cache()
{
static std::unordered_map<uint64_t, rocprofiler_profile_config_id_t> profile_cache;
static std::unordered_map<uint64_t, rocprofiler_counter_config_id_t> profile_cache;
return profile_cache;
}
/**
* Callback from rocprofiler when an kernel dispatch is enqueued into the HSA queue.
* rocprofiler_profile_config_id_t* is a return to specify what counters to collect
* rocprofiler_counter_config_id_t* is a return to specify what counters to collect
* for this dispatch (dispatch_packet). This example function creates a profile
* to collect the counter SQ_WAVES for all kernel dispatch packets.
*/
void
dispatch_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
rocprofiler_profile_config_id_t* config,
rocprofiler_counter_config_id_t* config,
rocprofiler_user_data_t* /*user_data*/,
void* /*callback_data_args*/)
{
@@ -236,7 +228,7 @@ dispatch_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
* to consturct them once in advance (i.e. in tool_init()) since there are non-trivial
* costs associated with constructing the profile.
*/
rocprofiler_profile_config_id_t
rocprofiler_counter_config_id_t
build_profile_for_agent(rocprofiler_agent_id_t agent,
const std::set<std::string>& counters_to_collect)
{
@@ -264,22 +256,22 @@ build_profile_for_agent(rocprofiler_agent_id_t agent,
std::vector<rocprofiler_counter_id_t> collect_counters;
for(auto& counter : gpu_counters)
{
rocprofiler_counter_info_v0_t version;
rocprofiler_counter_info_v0_t info;
ROCPROFILER_CALL(
rocprofiler_query_counter_info(
counter, ROCPROFILER_COUNTER_INFO_VERSION_0, static_cast<void*>(&version)),
counter, ROCPROFILER_COUNTER_INFO_VERSION_0, static_cast<void*>(&info)),
"Could not query info for counter");
if(counters_to_collect.count(std::string(version.name)) > 0)
if(counters_to_collect.count(std::string(info.name)) > 0)
{
std::clog << "Counter: " << counter.handle << " " << version.name << "\n";
std::clog << "Counter: " << counter.handle << " " << info.name << "\n";
collect_counters.push_back(counter);
fill_dimension_cache(counter);
}
}
// Create and return the profile
rocprofiler_profile_config_id_t profile = {.handle = 0};
ROCPROFILER_CALL(rocprofiler_create_profile_config(
rocprofiler_counter_config_id_t profile = {.handle = 0};
ROCPROFILER_CALL(rocprofiler_create_counter_config(
agent, collect_counters.data(), collect_counters.size(), &profile),
"Could not construct profile cfg");
@@ -375,7 +367,7 @@ tool_init(rocprofiler_client_finalize_t, void* user_data)
// counters to collect by returning a profile config id. In this example, we create the profile
// configs above and store them in the map get_profile_cache() so we can look them up at
// dispatch.
ROCPROFILER_CALL(rocprofiler_configure_buffered_dispatch_counting_service(
ROCPROFILER_CALL(rocprofiler_configure_buffer_dispatch_counting_service(
get_client_ctx(), get_buffer(), dispatch_callback, nullptr),
"Could not setup buffered service");
+12 -12
Ver fichero
@@ -22,6 +22,9 @@
#include "client.hpp"
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <fstream>
#include <functional>
#include <iostream>
@@ -32,9 +35,6 @@
#include <unordered_map>
#include <vector>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#define ROCPROFILER_CALL(result, msg) \
{ \
rocprofiler_status_t CHECKSTATUS = result; \
@@ -96,13 +96,13 @@ record_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
/**
* Callback from rocprofiler when an kernel dispatch is enqueued into the HSA queue.
* rocprofiler_profile_config_id_t* is a return to specify what counters to collect
* rocprofiler_counter_config_id_t* is a return to specify what counters to collect
* for this dispatch (dispatch_packet). This example function creates a profile
* to collect the counter SQ_WAVES for all kernel dispatch packets.
*/
void
dispatch_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
rocprofiler_profile_config_id_t* config,
rocprofiler_counter_config_id_t* config,
rocprofiler_user_data_t* /*user_data*/,
void* /*callback_data_args*/)
{
@@ -114,7 +114,7 @@ dispatch_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
* set.
*/
static std::shared_mutex m_mutex = {};
static std::unordered_map<uint64_t, rocprofiler_profile_config_id_t> profile_cache = {};
static std::unordered_map<uint64_t, rocprofiler_counter_config_id_t> profile_cache = {};
auto search_cache = [&]() {
if(auto pos = profile_cache.find(dispatch_data.dispatch_info.agent_id.handle);
@@ -161,21 +161,21 @@ dispatch_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
// Look for the counters contained in counters_to_collect in gpu_counters
for(auto& counter : gpu_counters)
{
rocprofiler_counter_info_v0_t version;
rocprofiler_counter_info_v0_t info;
ROCPROFILER_CALL(
rocprofiler_query_counter_info(
counter, ROCPROFILER_COUNTER_INFO_VERSION_0, static_cast<void*>(&version)),
counter, ROCPROFILER_COUNTER_INFO_VERSION_0, static_cast<void*>(&info)),
"Could not query info");
if(counters_to_collect.count(std::string(version.name)) > 0)
if(counters_to_collect.count(std::string(info.name)) > 0)
{
std::clog << "Counter: " << counter.handle << " " << version.name << "\n";
std::clog << "Counter: " << counter.handle << " " << info.name << "\n";
collect_counters.push_back(counter);
}
}
// Create a colleciton profile for the counters
rocprofiler_profile_config_id_t profile = {.handle = 0};
ROCPROFILER_CALL(rocprofiler_create_profile_config(dispatch_data.dispatch_info.agent_id,
rocprofiler_counter_config_id_t profile = {.handle = 0};
ROCPROFILER_CALL(rocprofiler_create_counter_config(dispatch_data.dispatch_info.agent_id,
collect_counters.data(),
collect_counters.size(),
&profile),
@@ -22,6 +22,9 @@
#include "client.hpp"
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <atomic>
#include <chrono>
#include <fstream>
@@ -35,10 +38,6 @@
#include <unordered_map>
#include <vector>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#define ROCPROFILER_CALL(result, msg) \
{ \
rocprofiler_status_t CHECKSTATUS = result; \
@@ -128,23 +127,23 @@ buffered_callback(rocprofiler_context_id_t,
*output_stream << "[" << __FUNCTION__ << "] " << ss.str() << "\n";
}
std::unordered_map<uint64_t, rocprofiler_profile_config_id_t>&
std::unordered_map<uint64_t, rocprofiler_counter_config_id_t>&
get_profile_cache()
{
static std::unordered_map<uint64_t, rocprofiler_profile_config_id_t> profile_cache;
static std::unordered_map<uint64_t, rocprofiler_counter_config_id_t> profile_cache;
return profile_cache;
}
/**
* Callback from rocprofiler when an kernel dispatch is enqueued into the HSA queue.
* rocprofiler_profile_config_id_t* is a return to specify what counters to collect
* rocprofiler_counter_config_id_t* is a return to specify what counters to collect
* for this dispatch (dispatch_packet). This example function creates a profile
* to collect the counter SQ_WAVES for all kernel dispatch packets.
*/
void
set_profile(rocprofiler_context_id_t context_id,
rocprofiler_agent_id_t agent,
rocprofiler_agent_set_profile_callback_t set_config,
set_profile(rocprofiler_context_id_t context_id,
rocprofiler_agent_id_t agent,
rocprofiler_device_counting_agent_cb_t set_config,
void*)
{
/**
@@ -170,7 +169,7 @@ set_profile(rocprofiler_context_id_t context_id,
}
}
rocprofiler_profile_config_id_t
rocprofiler_counter_config_id_t
build_profile_for_agent(rocprofiler_agent_id_t agent)
{
std::set<std::string> counters_to_collect = {"SQ_WAVES"};
@@ -196,20 +195,20 @@ build_profile_for_agent(rocprofiler_agent_id_t agent)
std::vector<rocprofiler_counter_id_t> collect_counters;
for(auto& counter : gpu_counters)
{
rocprofiler_counter_info_v0_t version;
rocprofiler_counter_info_v0_t info;
ROCPROFILER_CALL(
rocprofiler_query_counter_info(
counter, ROCPROFILER_COUNTER_INFO_VERSION_0, static_cast<void*>(&version)),
counter, ROCPROFILER_COUNTER_INFO_VERSION_0, static_cast<void*>(&info)),
"Could not query info for counter");
if(counters_to_collect.count(std::string(version.name)) > 0)
if(counters_to_collect.count(std::string(info.name)) > 0)
{
std::clog << "Counter: " << counter.handle << " " << version.name << "\n";
std::clog << "Counter: " << counter.handle << " " << info.name << "\n";
collect_counters.push_back(counter);
}
}
rocprofiler_profile_config_id_t profile = {.handle = 0};
ROCPROFILER_CALL(rocprofiler_create_profile_config(
rocprofiler_counter_config_id_t profile = {.handle = 0};
ROCPROFILER_CALL(rocprofiler_create_counter_config(
agent, collect_counters.data(), collect_counters.size(), &profile),
"Could not construct profile cfg");
@@ -22,6 +22,9 @@
#include "client.hpp"
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <atomic>
#include <chrono>
#include <cstdlib>
@@ -38,12 +41,6 @@
#include <unordered_map>
#include <vector>
#include <rocprofiler-sdk/buffer.h>
#include <rocprofiler-sdk/context.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#define ROCPROFILER_CALL(result, msg) \
{ \
rocprofiler_status_t CHECKSTATUS = result; \
@@ -99,15 +96,14 @@ private:
rocprofiler_agent_id_t agent_ = {};
rocprofiler_context_id_t ctx_ = {};
rocprofiler_buffer_id_t buf_ = {};
rocprofiler_profile_config_id_t profile_ = {.handle = 0};
rocprofiler_counter_config_id_t profile_ = {.handle = 0};
std::map<std::vector<std::string>, rocprofiler_profile_config_id_t> cached_profiles_;
std::map<std::vector<std::string>, rocprofiler_counter_config_id_t> cached_profiles_;
std::map<uint64_t, uint64_t> profile_sizes_;
mutable std::map<uint64_t, std::string> id_to_name_;
// Internal function used to set the profile for the agent when start_context is called
void set_profile(rocprofiler_context_id_t ctx,
rocprofiler_agent_set_profile_callback_t cb) const;
void set_profile(rocprofiler_context_id_t ctx, rocprofiler_device_counting_agent_cb_t cb) const;
// Get the size of a counter in number of records
static size_t get_counter_size(rocprofiler_counter_id_t counter);
@@ -153,8 +149,8 @@ counter_sampler::counter_sampler(rocprofiler_agent_id_t agent)
agent,
[](rocprofiler_context_id_t context_id,
rocprofiler_agent_id_t,
rocprofiler_agent_set_profile_callback_t set_config,
void* user_data) {
rocprofiler_device_counting_agent_cb_t set_config,
void* user_data) {
if(user_data)
{
auto* sampler = static_cast<counter_sampler*>(user_data);
@@ -212,7 +208,7 @@ counter_sampler::sample_counter_values(const std::vector<std::string>&
if(profile_cached == cached_profiles_.end())
{
size_t expected_size = 0;
rocprofiler_profile_config_id_t profile = {};
rocprofiler_counter_config_id_t profile = {};
std::vector<rocprofiler_counter_id_t> gpu_counters;
auto roc_counters = get_supported_counters(agent_);
for(const auto& counter : counters)
@@ -226,7 +222,7 @@ counter_sampler::sample_counter_values(const std::vector<std::string>&
gpu_counters.push_back(it->second);
expected_size += get_counter_size(it->second);
}
ROCPROFILER_CALL(rocprofiler_create_profile_config(
ROCPROFILER_CALL(rocprofiler_create_counter_config(
agent_, gpu_counters.data(), gpu_counters.size(), &profile),
"Could not create profile");
cached_profiles_.emplace(counters, profile);
@@ -281,8 +277,8 @@ counter_sampler::get_available_agents()
}
void
counter_sampler::set_profile(rocprofiler_context_id_t ctx,
rocprofiler_agent_set_profile_callback_t cb) const
counter_sampler::set_profile(rocprofiler_context_id_t ctx,
rocprofiler_device_counting_agent_cb_t cb) const
{
if(profile_.handle != 0)
{
@@ -293,22 +289,11 @@ counter_sampler::set_profile(rocprofiler_context_id_t ctx,
size_t
counter_sampler::get_counter_size(rocprofiler_counter_id_t counter)
{
size_t size = 1;
rocprofiler_iterate_counter_dimensions(
counter,
[](rocprofiler_counter_id_t,
const rocprofiler_record_dimension_info_t* dim_info,
size_t num_dims,
void* user_data) {
size_t* s = static_cast<size_t*>(user_data);
for(size_t i = 0; i < num_dims; i++)
{
*s *= dim_info[i].instance_size;
}
return ROCPROFILER_STATUS_SUCCESS;
},
static_cast<void*>(&size));
return size;
rocprofiler_counter_info_v1_t info;
ROCPROFILER_CALL(rocprofiler_query_counter_info(
counter, ROCPROFILER_COUNTER_INFO_VERSION_1, static_cast<void*>(&info)),
"Could not query info for counter");
return info.instance_ids_count;
}
std::unordered_map<std::string, rocprofiler_counter_id_t>
@@ -335,12 +320,12 @@ counter_sampler::get_supported_counters(rocprofiler_agent_id_t agent)
"Could not fetch supported counters");
for(auto& counter : gpu_counters)
{
rocprofiler_counter_info_v0_t version;
rocprofiler_counter_info_v0_t info;
ROCPROFILER_CALL(
rocprofiler_query_counter_info(
counter, ROCPROFILER_COUNTER_INFO_VERSION_0, static_cast<void*>(&version)),
counter, ROCPROFILER_COUNTER_INFO_VERSION_0, static_cast<void*>(&info)),
"Could not query info for counter");
out.emplace(version.name, counter);
out.emplace(info.name, counter);
}
return out;
}
@@ -348,23 +333,12 @@ counter_sampler::get_supported_counters(rocprofiler_agent_id_t agent)
std::vector<rocprofiler_record_dimension_info_t>
counter_sampler::get_counter_dimensions(rocprofiler_counter_id_t counter)
{
std::vector<rocprofiler_record_dimension_info_t> dims;
rocprofiler_available_dimensions_cb_t cb =
[](rocprofiler_counter_id_t,
const rocprofiler_record_dimension_info_t* dim_info,
size_t num_dims,
void* user_data) {
std::vector<rocprofiler_record_dimension_info_t>* vec =
static_cast<std::vector<rocprofiler_record_dimension_info_t>*>(user_data);
for(size_t i = 0; i < num_dims; i++)
{
vec->push_back(dim_info[i]);
}
return ROCPROFILER_STATUS_SUCCESS;
};
ROCPROFILER_CALL(rocprofiler_iterate_counter_dimensions(counter, cb, &dims),
"Could not iterate counter dimensions");
return dims;
rocprofiler_counter_info_v1_t info;
ROCPROFILER_CALL(rocprofiler_query_counter_info(
counter, ROCPROFILER_COUNTER_INFO_VERSION_1, static_cast<void*>(&info)),
"Could not query info for counter");
return std::vector<rocprofiler_record_dimension_info_t>{
info.dimensions, info.dimensions + info.dimensions_count};
}
std::atomic<bool>&
@@ -22,7 +22,11 @@
#include "client.hpp"
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <unistd.h>
#include <cstdint>
#include <map>
#include <mutex>
#include <optional>
@@ -30,10 +34,6 @@
#include <sstream>
#include <vector>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#define PRINT_ONLY_FAILING false
/**
@@ -245,7 +245,7 @@ get_agent_info()
void
dispatch_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
rocprofiler_profile_config_id_t* config,
rocprofiler_counter_config_id_t* config,
rocprofiler_user_data_t* /*user_data*/,
void* /*callback_data_args*/)
{
@@ -282,40 +282,24 @@ dispatch_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
for(auto& found_counter : counters_needed)
{
rocprofiler_counter_info_v0_t version;
rocprofiler_counter_info_v1_t info;
ROCPROFILER_CALL(rocprofiler_query_counter_info(found_counter,
ROCPROFILER_COUNTER_INFO_VERSION_0,
static_cast<void*>(&version)),
"Could not query counter_id");
cap.expected_counter_names.emplace(found_counter.handle, std::string(version.name));
size_t expected = 0;
ROCPROFILER_CALL(rocprofiler_query_counter_instance_count(
dispatch_data.dispatch_info.agent_id, found_counter, &expected),
"COULD NOT QUERY INSTANCES");
ROCPROFILER_CALL(
rocprofiler_query_counter_info(
found_counter, ROCPROFILER_COUNTER_INFO_VERSION_1, static_cast<void*>(&info)),
"Could not query counter_id");
cap.expected_counter_names.emplace(found_counter.handle, std::string(info.name));
cap.remaining.push_back(found_counter);
cap.expected.emplace(found_counter.handle, expected);
cap.expected.emplace(found_counter.handle, info.instance_ids_count);
auto& info_vector =
cap.expected_data_dims.emplace(found_counter.handle, validate_dim_presence{})
.first->second;
ROCPROFILER_CALL(rocprofiler_iterate_counter_dimensions(
found_counter,
[](rocprofiler_counter_id_t,
const rocprofiler_record_dimension_info_t* dim_info,
size_t num_dims,
void* user_data) {
validate_dim_presence* dim_presence =
static_cast<validate_dim_presence*>(user_data);
for(size_t i = 0; i < num_dims; i++)
{
dim_presence->maybe_forward(dim_info[i]);
}
return ROCPROFILER_STATUS_SUCCESS;
},
static_cast<void*>(&info_vector)),
"Could not fetch dimension info");
for(uint64_t i = 0; i < info.dimensions_count; i++)
{
info_vector.maybe_forward(info.dimensions[i]);
}
}
if(cap.expected.empty())
{
@@ -326,10 +310,10 @@ dispatch_callback(rocprofiler_dispatch_counting_service_data_t dispatch_data,
}
if(cap.remaining.empty()) return;
rocprofiler_profile_config_id_t profile = {.handle = 0};
rocprofiler_counter_config_id_t profile = {.handle = 0};
// Select the next counter to collect.
if(rocprofiler_create_profile_config(
if(rocprofiler_create_counter_config(
dispatch_data.dispatch_info.agent_id, &(cap.remaining.back()), 1, &profile) ==
ROCPROFILER_STATUS_SUCCESS)
{
@@ -362,7 +346,7 @@ tool_init(rocprofiler_client_finalize_t, void*)
ROCPROFILER_CALL(rocprofiler_assign_callback_thread(get_buffer(), client_thread),
"failed to assign thread for buffer");
ROCPROFILER_CALL(rocprofiler_configure_buffered_dispatch_counting_service(
ROCPROFILER_CALL(rocprofiler_configure_buffer_dispatch_counting_service(
get_client_ctx(), get_buffer(), dispatch_callback, nullptr),
"Could not setup buffered service");
rocprofiler_start_context(get_client_ctx());
@@ -33,14 +33,6 @@
#include "client.hpp"
#include <rocprofiler-sdk/buffer.h>
#include <rocprofiler-sdk/buffer_tracing.h>
#include <rocprofiler-sdk/callback_tracing.h>
#include <rocprofiler-sdk/context.h>
#include <rocprofiler-sdk/external_correlation.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/hip/runtime_api_id.h>
#include <rocprofiler-sdk/internal_threading.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
-5
Ver fichero
@@ -33,11 +33,6 @@
#include "client.hpp"
#include <rocprofiler-sdk/callback_tracing.h>
#include <rocprofiler-sdk/context.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/marker/api_id.h>
#include <rocprofiler-sdk/ompt.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
-3
Ver fichero
@@ -34,9 +34,6 @@
#include "pcs.hpp"
#include "utils.hpp"
#include <rocprofiler-sdk/buffer.h>
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/internal_threading.h>
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>