[SDK] Expose counter dims in rocprofiler_counter_info_v1_t and only show counters being profiled in metadata. (#325)

* expose dimensional info in rocprofiler_counter_info_v1_t.

* add counter_id in dim info.

* address review comments

* format.

* address comments.

* use array of pointers for dimensions_instaces.

* format and comments.

* address comments.

* new line.

* Update counter_defs.yaml

* Update counter_defs.yaml

* Update counter_defs.yaml

* counter_defs.

* format counter defs.

* format counter defs.

* format counter defs.

* show only counters being profiled in metadata.

* Format.

* use config for counters and fix warnings.

* add version for rocprofiler_counter_dimension_info_v1_t struct.

* rename rocprofiler_counter_record_dimension_instance_v1_info_t.

* account device id from pmc for counters metadata.

* move dim structs to counters.h.

* address comments to compare value.

* fix tests.

* Address comments. use pointer of arrays for ABI.

* rebase.

* fix build error.

* use separate metadata::init() for rocprofv3.

* also print not found counters.

* precompute all the perf counters needed to be in metadata.

* Misc.

* format

* Format.

* rocprofiler::sdk::container::c_array

* Address comments.

* source/lib/output/metadata.cpp

* lint.

* add unit test for c_array.

* add unit test and serialization support for c_array container.

* Misc.

* Clean files.

* Format.

* clang-tidy.

* add more checks to c_array.

* misc. typo

* Addr comments.

---------

Co-authored-by: Venkateshwar Reddy Kandula <vkandula@amd.com>
Co-authored-by: Jonathan R. Madsen <Jonathan.Madsen@amd.com>
This commit is contained in:
Kandula, Venkateshwar reddy
2025-07-22 16:24:25 -05:00
gecommit door GitHub
bovenliggende e948034c83
commit bf0fad1d54
19 gewijzigde bestanden met toevoegingen van 796 en 103 verwijderingen
@@ -50,24 +50,83 @@ typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_info_v0_t
uint8_t is_derived : 1; ///< If this counter is a derived counter
} rocprofiler_counter_info_v0_t;
/**
* @brief (experimental) Represents metadata about a single dimension of a counter instance.
*
* This structure provides the name of the dimension (e.g., "XCC", "SE", etc.)
* and the index indicating the position of a specific counter instance within that dimension.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_dimension_info_t
{
uint64_t size; ///< Size of this structure. Used for versioning and validation.
const char* dimension_name;
size_t index;
/**
* @var dimension_name
* @brief Name of the dimension this instance belongs to.
* @var index
* @brief Position (zero-based) of the instance within the specified dimension.
*/
} rocprofiler_counter_dimension_info_t;
/**
* @brief (experimental) Describes a specific counter instance and its position across multiple
* dimensions.
*
* This structure provides the unique instance ID, associated counter ID, number of dimensions for
* the instance, and a pointer to an array of metadata describing each dimension's name and index.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_record_dimension_instance_info_t
{
uint64_t size; ///< Size of this structure. Used for versioning and validation.
rocprofiler_counter_instance_id_t instance_id;
uint64_t counter_id;
uint64_t dimensions_count;
const rocprofiler_counter_dimension_info_t** dimensions;
/**
* @var instance_id
* @brief Encoded identifier for the instance, which includes the counter ID and all dimension
positions.
* @var counter_id
* @brief Identifier of the counter associated with this instance.
* @var dimensions_count
* @brief Number of dimensions associated with this instance.
* @var dimensions
* @brief Array of pointers to dimension info structures, each representing one dimension
* and the position of this instance within that dimension.
*
* The array has `dimensions_count` elements, and each element is a pointer to a
* `rocprofiler_counter_dimension_info_t` structure.
*/
} rocprofiler_counter_record_dimension_instance_info_t;
/**
* @brief (experimental) Counter info struct version 1. Combines information from
* ::rocprofiler_counter_info_v0_t with the dimension information.
*/
typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_info_v1_t
{
rocprofiler_counter_id_t id; ///< Id of this counter
const char* name; ///< Name of the counter
uint64_t size; ///< Size of this structure. Used for versioning and validation.
rocprofiler_counter_id_t id; ///< Id of this counter
const char* name; ///< Name of the counter
const char* description; ///< Description of the counter
const char* block; ///< Block of the counter (non-derived only)
const char* expression; ///< Counter expression (derived counters only)
uint8_t is_constant : 1; ///< If this counter is HW constant
uint8_t is_derived : 1; ///< If this counter is a derived counter
uint64_t dimensions_count;
const rocprofiler_counter_record_dimension_info_t* dimensions;
uint64_t instance_ids_count;
const rocprofiler_counter_instance_id_t* instance_ids;
uint64_t dimensions_count;
const rocprofiler_counter_record_dimension_info_t** dimensions;
uint64_t dimensions_instances_count;
const rocprofiler_counter_record_dimension_instance_info_t** dimensions_instances;
/// @var dimensions_count
/// @brief Number of dimensions for the counter
@@ -75,11 +134,12 @@ typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_counter_info_v1_t
/// @var dimensions
/// @brief Dimension information of the counter
///
/// @var instance_ids_count
/// @brief Number of instance ids for the counter
/// @var dimensions_instances_count
/// @brief Number of unique instances for this counter, across all dimension combinations.
///
/// @var instance_ids
/// @brief Instance ids that can be generated by the counter
/// @var dimensions_instances
/// @brief Array of pointers to instance info structs, each describing a unique instance
/// and its specific dimension mapping.
} rocprofiler_counter_info_v1_t;
/**