rocprofiler-sdk/counters.h Source File

rocprofiler-sdk/counters.h Source File#

Rocprofiler SDK Developer API: rocprofiler-sdk/counters.h Source File
Rocprofiler SDK Developer API 0.4.0
ROCm Profiling API and tools
counters.h
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in all
13// copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23#pragma once
24
27#include <rocprofiler-sdk/fwd.h>
28
29ROCPROFILER_EXTERN_C_INIT
30
31/**
32 * @defgroup COUNTERS Hardware counters Information
33 * @brief Query functions related to hardware counters
34 * @{
35 */
36
37/**
38 * @brief Query counter id information from record_id.
39 *
40 * @param [in] id record id from rocprofiler_record_counter_t
41 * @param [out] counter_id counter id associated with the record
42 * @return ::rocprofiler_status_t
43 * @retval ROCPROFILER_STATUS_SUCCESS if id decoded
44 */
45rocprofiler_status_t ROCPROFILER_API
47 rocprofiler_counter_id_t* counter_id) ROCPROFILER_NONNULL(2);
48
49/**
50 * @brief Query dimension position from record_id. If the dimension does not exist
51 * in the counter, the return will be 0.
52 *
53 * @param [in] id record id from @ref rocprofiler_record_counter_t
54 * @param [in] dim dimension for which positional info is requested (currently only
55 * 0 is allowed, i.e. flat array without dimension).
56 * @param [out] pos value of the dimension in id
57 * @return ::rocprofiler_status_t
58 * @retval ROCPROFILER_STATUS_SUCCESS if dimension decoded
59 */
60rocprofiler_status_t ROCPROFILER_API
63 size_t* pos) ROCPROFILER_NONNULL(3);
64
65/**
66 * @brief Callback that gives a list of available dimensions for a counter
67 *
68 * @param [in] id Counter id the dimension data is for
69 * @param [in] dim_info An array of dimensions for the counter
70 * @ref rocprofiler_iterate_counter_dimensions was called on.
71 * @param [in] num_dims Number of dimensions
72 * @param [in] user_data User data supplied by
73 * @ref rocprofiler_iterate_agent_supported_counters
74 */
78 size_t num_dims,
79 void* user_data);
80
81/**
82 * @brief Return information about the dimensions that exists for a specific counter
83 * and the extent of each dimension.
84 *
85 * @param [in] id counter id to query dimension info for.
86 * @param [in] info_cb Callback to return dimension information for counter
87 * @param [in] user_data data to pass into the callback
88 * @return ::rocprofiler_status_t
89 * @retval ROCPROFILER_STATUS_SUCCESS if dimension exists
90 * @retval ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND if counter is not found
91 * @retval ROCPROFILER_STATUS_ERROR_DIM_NOT_FOUND if counter does not have this dimension
92 */
93rocprofiler_status_t ROCPROFILER_API
96 void* user_data);
97
98/**
99 * @brief Query Counter info such as name or description.
100 *
101 * @param [in] counter_id counter to get info for
102 * @param [in] version Version of struct in info, see @ref rocprofiler_counter_info_version_id_t for
103 * available types
104 * @param [out] info rocprofiler_counter_info_{version}_t struct to write info to.
105 * @return ::rocprofiler_status_t
106 * @retval ROCPROFILER_STATUS_SUCCESS if counter found
107 * @retval ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND if counter not found
108 * @retval ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_ABI Version is not supported
109 */
110rocprofiler_status_t ROCPROFILER_API
113 void* info) ROCPROFILER_NONNULL(3);
114
115/**
116 * @brief This call returns the number of instances specific counter contains.
117 *
118 * @param [in] agent_id rocprofiler agent identifier
119 * @param [in] counter_id counter id (obtained from iterate_agent_supported_counters)
120 * @param [out] instance_count number of instances the counter has
121 * @return ::rocprofiler_status_t
122 * @retval ROCPROFILER_STATUS_SUCCESS if counter found
123 * @retval ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND if counter not found
124 */
125rocprofiler_status_t ROCPROFILER_API
127 rocprofiler_counter_id_t counter_id,
128 size_t* instance_count) ROCPROFILER_NONNULL(3);
129
130/**
131 * @brief Callback that gives a list of counters available on an agent. The
132 * counters variable is owned by rocprofiler and should not be free'd.
133 *
134 * @param [in] agent_id Agent ID of the current callback
135 * @param [in] counters An array of counters that are avialable on the agent
136 * @ref rocprofiler_iterate_agent_supported_counters was called on.
137 * @param [in] num_counters Number of counters contained in counters
138 * @param [in] user_data User data supplied by
139 * @ref rocprofiler_iterate_agent_supported_counters
140 */
142 rocprofiler_agent_id_t agent_id,
143 rocprofiler_counter_id_t* counters,
144 size_t num_counters,
145 void* user_data);
146
147/**
148 * @brief Query Agent Counters Availability.
149 *
150 * @param [in] agent_id GPU agent identifier
151 * @param [in] cb callback to caller to get counters
152 * @param [in] user_data data to pass into the callback
153 * @return ::rocprofiler_status_t
154 * @retval ROCPROFILER_STATUS_SUCCESS if counters found for agent
155 * @retval ROCPROFILER_STATUS_ERROR if no counters found for agent
156 */
157rocprofiler_status_t ROCPROFILER_API
160 void* user_data) ROCPROFILER_NONNULL(2);
161
162/** @} */
163
164ROCPROFILER_EXTERN_C_FINI
uint64_t rocprofiler_counter_dimension_id_t
A dimension for counter instances. Some example dimensions include XCC, SM (Shader),...
Definition fwd.h:474
uint64_t rocprofiler_counter_instance_id_t
Unique record id encoding both the counter and dimensional values (positions) for the record.
Definition fwd.h:466
rocprofiler_status_t
Status codes.
Definition fwd.h:55
rocprofiler_counter_info_version_id_t
Enumeration for specifying the counter info struct version you want.
Definition fwd.h:375
Agent Identifier.
Definition fwd.h:541
Counter ID.
Definition fwd.h:549
Details for the dimension, including its size, for a counter record.
Definition fwd.h:670
rocprofiler_status_t rocprofiler_iterate_counter_dimensions(rocprofiler_counter_id_t id, rocprofiler_available_dimensions_cb_t info_cb, void *user_data)
Return information about the dimensions that exists for a specific counter and the extent of each dim...
rocprofiler_status_t rocprofiler_iterate_agent_supported_counters(rocprofiler_agent_id_t agent_id, rocprofiler_available_counters_cb_t cb, void *user_data)
Query Agent Counters Availability.
rocprofiler_status_t(* rocprofiler_available_counters_cb_t)(rocprofiler_agent_id_t agent_id, rocprofiler_counter_id_t *counters, unsigned long num_counters, void *user_data)
Callback that gives a list of counters available on an agent. The counters variable is owned by rocpr...
Definition counters.h:141
rocprofiler_status_t rocprofiler_query_record_counter_id(rocprofiler_counter_instance_id_t id, rocprofiler_counter_id_t *counter_id)
Query counter id information from record_id.
rocprofiler_status_t rocprofiler_query_record_dimension_position(rocprofiler_counter_instance_id_t id, rocprofiler_counter_dimension_id_t dim, unsigned long *pos)
Query dimension position from record_id. If the dimension does not exist in the counter,...
rocprofiler_status_t(* rocprofiler_available_dimensions_cb_t)(rocprofiler_counter_id_t id, const rocprofiler_record_dimension_info_t *dim_info, unsigned long num_dims, void *user_data)
Callback that gives a list of available dimensions for a counter.
Definition counters.h:75
rocprofiler_status_t rocprofiler_query_counter_instance_count(rocprofiler_agent_id_t agent_id, rocprofiler_counter_id_t counter_id, unsigned long *instance_count)
This call returns the number of instances specific counter contains.
rocprofiler_status_t rocprofiler_query_counter_info(rocprofiler_counter_id_t counter_id, rocprofiler_counter_info_version_id_t version, void *info)
Query Counter info such as name or description.