rocprofiler-sdk/experimental/registration.h Source File

rocprofiler-sdk/experimental/registration.h Source File#

ROCprofiler-SDK developer API: rocprofiler-sdk/experimental/registration.h Source File
ROCprofiler-SDK developer API 1.3.5
ROCm Profiling API and tools
registration.h
1// MIT License
2//
3// Copyright (c) 2023-2025 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
25#include <rocprofiler-sdk/defines.h>
26#include <rocprofiler-sdk/fwd.h>
27#include <rocprofiler-sdk/registration.h>
28
29ROCPROFILER_EXTERN_C_INIT
30
31/**
32 * @defgroup EXPERIMENTAL_REGISTRATION_GROUP Experimental tool registration
33 *
34 * @brief Data types and functions for tool registration with rocprofiler
35 * @{
36 */
37
38/// @brief Struct containing the information about the libraries which have registered
39/// with rocprofiler-register. @see rocprofiler_iterate_runtime_registration_info
40typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_runtime_registration_info_t
41{
42 size_t size; ///< in case of future extensions
43 const char* common_name; ///< name of the library
44 uint32_t lib_version; ///< version
45 uint64_t api_table_length; ///< number of API tables
47
48/**
49 * @brief (experimental)
50 *
51 */
52ROCPROFILER_SDK_EXPERIMENTAL
54
55/**
56 * @brief Prototype for the start of the attach function that will be called after the
57 * configuration.
58 * @param [in] tool_data `tool_data` field returned from ::rocprofiler_configure_attach in
59 * ::rocprofiler_tool_configure_result_t.
60 */
61ROCPROFILER_SDK_EXPERIMENTAL
63 rocprofiler_context_id_t* context_ids,
64 uint64_t context_ids_length,
65 void* tool_data);
66
67/**
68 * @brief Prototype for the detach function where a tool can temporarily suspend operations.
69 * @param [in] tool_data `tool_data` field returned from ::rocprofiler_configure in
70 * ::rocprofiler_tool_configure_attach_result_t.
71 */
72ROCPROFILER_SDK_EXPERIMENTAL
73typedef void (*rocprofiler_tool_detach_t)(void* tool_data);
74
75/**
76 * @brief Callback function for iterating over the libraries which have registered
77 * with rocprofiler-register. @see rocprofiler_iterate_runtime_registration_info
78 *
79 * @param [in] info Pointer to library registration instance. Caller should make a copy
80 * for reference outside of callback.
81 * @param [in] data User data passed to ::rocprofiler_iterate_runtime_registration_info
82 * @return int
83 * @retval 0 If zero is returned from callback, rocprofiler-register will continue to next
84 * registration info, if one exists
85 * @retval -1 If -1 (or any value != 0) is returned from callback, rocprofiler-register
86 * will cease to iterate over the remaining registration info, if any exists
87 */
88ROCPROFILER_SDK_EXPERIMENTAL
91 void* data);
92
93/**
94 * @brief (EXPERIMENTAL) Extended data structure containing initialization, finalization,
95 * attach/detach, and data.
96 *
97 * This is an experimental extension of ::rocprofiler_tool_configure_result_t that adds support for
98 * runtime attachment and detachment of tools. The `tool_attach` and `tool_detach` function
99 * pointers allow tools to handle dynamic attachment scenarios where they may need to suspend and
100 * resume profiling operations.
101 *
102 * The `size` field is used for ABI reasons and should be set to
103 * `sizeof(rocprofiler_tool_configure_result_t)`
104 */
105typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_tool_configure_attach_result_t
106{
107 size_t size; ///< size of this struct (in case of future extensions)
108 rocprofiler_tool_attach_t tool_attach; ///< after configuration
109 rocprofiler_tool_detach_t tool_detach; ///< end of attach session
110 void* tool_data; ///< data to provide to init and fini callbacks
112
113/**
114 * @brief (experimental) This is the special function that tools define to enable rocprofiler
115 * attachment support.
116 *
117 * @param version
118 * @param runtime_version
119 * @param priority
120 * @param client_id
121 * @return rocprofiler_tool_configure_attach_result_t*
122 */
123ROCPROFILER_SDK_EXPERIMENTAL
126 const char* runtime_version,
127 uint32_t priority,
128 rocprofiler_client_id_t* client_id) ROCPROFILER_PUBLIC_API;
129
130/**
131 * @brief Function pointer typedef for ::rocprofiler_configure_attach function
132 * @param [in] version The version of rocprofiler: `(10000 * major) + (100 * minor) + patch`
133 * @param [in] runtime_version String descriptor of the rocprofiler version and other relevant info.
134 * @param [in] priority How many client tools were initialized before this client tool
135 * @param [in, out] client_id tool identifier value.
136 */
137ROCPROFILER_SDK_EXPERIMENTAL
138typedef rocprofiler_tool_configure_attach_result_t* (*rocprofiler_configure_attach_func_t)(
139 uint32_t version,
140 const char* runtime_version,
141 uint32_t priority,
142 rocprofiler_client_id_t* client_id);
143
144/**
145 * @brief Iterates over all the (valid) libraries which registered their API tables with
146 * rocprofiler-register. Any libraries which do not have an accepted common name, have an
147 * invalid import function address (in secure mode), or have registered too many instances
148 * are not reported by this function.
149 *
150 * @param [in] callback Callback function to invoke for each valid registered library
151 * @param [in] data User data to pass to the callback function
152 * @return ::rocprofiler_status_t
153 * @retval ::ROCPROFILER_STATUS_SUCCESS if iteration completes successfully
154 * @retval other ::rocprofiler_status_t values if an error occurs
155 */
156ROCPROFILER_SDK_EXPERIMENTAL
159 void* data)
160 ROCPROFILER_ATTRIBUTE(nonnull(1)) ROCPROFILER_API;
161
162/** @} */
163
164ROCPROFILER_EXTERN_C_FINI
rocprofiler_status_t
Status codes.
Definition fwd.h:49
Context ID.
Definition fwd.h:648
unsigned long size
in case of future extensions
void * tool_data
data to provide to init and fini callbacks
rocprofiler_tool_attach_t tool_attach
after configuration
uint64_t api_table_length
number of API tables
rocprofiler_tool_detach_t tool_detach
end of attach session
const char * common_name
name of the library
unsigned long size
size of this struct (in case of future extensions)
rocprofiler_tool_configure_attach_result_t * rocprofiler_configure_attach(uint32_t version, const char *runtime_version, uint32_t priority, rocprofiler_client_id_t *client_id)
(experimental) This is the special function that tools define to enable rocprofiler attachment suppor...
int(* rocprofiler_runtime_registration_info_cb_t)(rocprofiler_runtime_registration_info_t *info, void *data)
Callback function for iterating over the libraries which have registered with rocprofiler-register.
rocprofiler_status_t rocprofiler_iterate_runtime_registration_info(rocprofiler_runtime_registration_info_cb_t callback, void *data) ROCPROFILER_ATTRIBUTE(nonnull(1))
Iterates over all the (valid) libraries which registered their API tables with rocprofiler-register....
void(* rocprofiler_tool_detach_t)(void *tool_data)
Prototype for the detach function where a tool can temporarily suspend operations.
int(* rocprofiler_tool_attach_t)(rocprofiler_client_detach_t detach_func, rocprofiler_context_id_t *context_ids, uint64_t context_ids_length, void *tool_data)
Prototype for the start of the attach function that will be called after the configuration.
void(* rocprofiler_client_detach_t)(rocprofiler_client_id_t)
(experimental)
Struct containing the information about the libraries which have registered with rocprofiler-register...
(EXPERIMENTAL) Extended data structure containing initialization, finalization, attach/detach,...
(experimental) A client refers to an individual or entity engaged in the configuration of ROCprofiler...