rocprofiler-sdk/callback_tracing.h Source File

rocprofiler-sdk/callback_tracing.h Source File#

ROCprofiler-SDK developer API: rocprofiler-sdk/callback_tracing.h Source File
ROCprofiler-SDK developer API 1.3.5
ROCm Profiling API and tools
callback_tracing.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/hip.h>
28#include <rocprofiler-sdk/hipfile.h>
29#include <rocprofiler-sdk/hsa.h>
30#include <rocprofiler-sdk/marker.h>
31#include <rocprofiler-sdk/ompt.h>
32#include <rocprofiler-sdk/rccl.h>
33#include <rocprofiler-sdk/rocdecode.h>
34#include <rocprofiler-sdk/rocjpeg.h>
35#include <rocprofiler-sdk/rocshmem.h>
36
37#include <hsa/hsa.h>
38#include <hsa/hsa_amd_tool.h>
39#include <hsa/hsa_ext_amd.h>
40#include <hsa/hsa_ven_amd_loader.h>
41
42#include <stdint.h>
43
44ROCPROFILER_EXTERN_C_INIT
45
46/**
47 * @defgroup CALLBACK_TRACING_SERVICE Synchronous Tracing Services
48 * @brief Receive immediate callbacks on the calling thread
49 *
50 * @{
51 */
52
53/**
54 * @brief ROCProfiler Enumeration for code object storage types (identical values to
55 * `hsa_ven_amd_loader_code_object_storage_type_t` enumeration)
56 */
58{
59 ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_NONE = HSA_VEN_AMD_LOADER_CODE_OBJECT_STORAGE_TYPE_NONE,
60 ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_FILE = HSA_VEN_AMD_LOADER_CODE_OBJECT_STORAGE_TYPE_FILE,
61 ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_MEMORY =
62 HSA_VEN_AMD_LOADER_CODE_OBJECT_STORAGE_TYPE_MEMORY,
63 ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_LAST,
65
66/**
67 * @brief ROCProfiler HSA API Callback Data.
68 */
70{
71 uint64_t size; ///< size of this struct
72 rocprofiler_hsa_api_args_t args;
73 rocprofiler_hsa_api_retval_t retval;
75
76/**
77 * @brief ROCProfiler HIP runtime and compiler API Tracer Callback Data.
78 */
80{
81 uint64_t size; ///< size of this struct
82 rocprofiler_hip_api_args_t args;
83 rocprofiler_hip_api_retval_t retval; ///< return value of function call
84
85 /// @var args
86 /// @brief Arguments of the function call. @see
87 /// ::rocprofiler_iterate_callback_tracing_kind_operation_args for generic
88 /// access/stringification of the arguments.
90
91/**
92 * @brief ROCProfiler OMPT Callback Data
93 */
95{
96 uint64_t size; ///< size of this struct
97 rocprofiler_ompt_args_t args;
99
100/**
101 * @brief ROCProfiler Marker Tracer Callback Data.
102 */
104{
105 uint64_t size; ///< size of this struct
106 rocprofiler_marker_api_args_t args;
107 rocprofiler_marker_api_retval_t retval;
109
110/**
111 * @brief ROCProfiler RCCL API Callback Data.
112 */
114{
115 uint64_t size; ///< size of this struct
116 rocprofiler_rccl_api_args_t args;
117 rocprofiler_rccl_api_retval_t retval;
119
120/**
121 * @brief ROCProfiler rocDecode API Callback Data.
122 */
124{
125 uint64_t size; ///< size of this struct
126 rocprofiler_rocdecode_api_args_t args;
127 rocprofiler_rocdecode_api_retval_t retval;
129
130/**
131 * @brief ROCProfiler rocJPEG API Callback Data.
132 */
134{
135 uint64_t size; ///< size of this struct
136 rocprofiler_rocjpeg_api_args_t args;
137 rocprofiler_rocjpeg_api_retval_t retval;
139
140/**
141 * @brief ROCProfiler rocSHMEM API Callback Data.
142 */
144{
145 uint64_t size; ///< size of this struct
146 rocprofiler_rocshmem_api_args_t args;
147 rocprofiler_rocshmem_api_retval_t retval;
149
150/**
151 * @brief ROCProfiler hipFILE API Callback Data.
152 */
154{
155 uint64_t size; ///< size of this struct
156 rocprofiler_hipfile_api_args_t args;
157 rocprofiler_hipfile_api_retval_t retval;
159
160/**
161 * @brief ROCProfiler Code Object Load Tracer Callback Record.
162 */
164{
165 uint64_t size; ///< size of this struct
166 uint64_t code_object_id; ///< unique code object identifier
167 union
168 {
169 rocprofiler_agent_id_t rocp_agent; ///< Deprecated. Renamed to agent_id
170 rocprofiler_agent_id_t agent_id; ///< The agent on which this loaded code object is loaded
171 };
172 hsa_agent_t hsa_agent; ///< Deprecated. The agent on which this loaded code object is loaded
173 const char* uri; ///< The URI name from which the code object was loaded
174 uint64_t load_base;
175 uint64_t load_size;
176 int64_t load_delta;
178
179 /// @var load_base
180 /// @brief The base memory address at which the code object is loaded. This is the base address
181 /// of the allocation for the lowest addressed segment of the code object that is loaded. Note
182 /// that any non-loaded segments before the first loaded segment are ignored.
183 ///
184 /// @var load_size
185 /// @brief The byte size of the loaded code objects contiguous memory allocation.
186 ///
187 /// @var load_delta
188 /// @brief The signed byte address difference of the memory address at which the code object is
189 /// loaded minus the virtual address specified in the code object that is loaded.
190 ///
191 /// @var storage_type
192 /// @brief storage type of the code object reader used to load the loaded code object
193 ///
194
195 union
196 {
197 struct
198 {
199 int storage_file; ///< file descriptor of the code object that was loaded. Access this
200 ///< field if ::rocprofiler_code_object_storage_type_t is
201 ///< ::ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_FILE
202 };
203 struct
204 {
205 uint64_t memory_base; ///< The memory address of the first byte of the code object that
206 ///< was loaded. Access this
207 ///< field if ::rocprofiler_code_object_storage_type_t is
208 ///< ::ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_MEMORY
209 uint64_t
210 memory_size; ///< The memory size in bytes of the code object that was loaded.
211 ///< Access this field if ::rocprofiler_code_object_storage_type_t is
212 ///< ::ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_MEMORY
213 };
214 };
216
217/**
218 * @brief The NULL value of a code object id. Used when code object is unknown.
219 */
220#define ROCPROFILER_CODE_OBJECT_ID_NONE ROCPROFILER_UINT64_C(0)
221
222/**
223 * @brief ROCProfiler Code Object Kernel Symbol Tracer Callback Record.
224 *
225 */
227{
228 uint64_t size; ///< size of this struct
229 uint64_t kernel_id; ///< unique symbol identifier value
230 uint64_t code_object_id; ///< parent unique code object identifier
231 const char* kernel_name; ///< name of the kernel
237 uint32_t sgpr_count; ///< Scalar general purpose register count
238 uint32_t arch_vgpr_count; ///< Architecture vector general purpose register count
239 uint32_t accum_vgpr_count; ///< Accum vector general purpose register count
242
243 /// @var kernel_object
244 /// @brief kernel object handle, used in the kernel dispatch packet
245 ///
246 /// @var kernarg_segment_size
247 /// @brief size of memory (in bytes) allocated for kernel arguments. Will be multiple of 16
248 ///
249 /// @var kernarg_segment_alignment
250 /// @brief Alignment (in bytes) of the buffer used to pass arguments to the kernel
251 ///
252 /// @var group_segment_size
253 /// @brief Size of static group segment memory required by the kernel (per work-group), in
254 /// bytes. AKA: LDS size
255 ///
256 /// @var private_segment_size
257 /// @brief Size of static private, spill, and arg segment memory required by this kernel (per
258 /// work-item), in bytes. AKA: scratch size
259 ///
260 /// @var kernel_code_entry_byte_offset
261 /// @brief Relative offset from kernel_object address to calculate the first address of a
262 /// kernel.
263 ///
264 /// @var kernel_address
265 /// @brief The first address of a kernel. Useful for PC sampling.
266 ///
268// rename struct
269
270typedef struct rocprofiler_callback_tracing_code_object_host_kernel_symbol_register_data_t
271{
272 uint64_t size; ///< size of this struct
273 uint64_t host_function_id; ///< unique host function identifier value
274 uint64_t kernel_id; ///< unique symbol identifier value
275 uint64_t code_object_id; ///< parent unique code object identifier
276 rocprofiler_address_t host_function; ///< kernel host function pointer
277 rocprofiler_address_t modules; ///< reference address where modules will be loaded
278 const char* device_function;
279 uint32_t thread_limit; ///< thread limit
280 rocprofiler_dim3_t thread_ids; ///< thread ids address
281 rocprofiler_dim3_t block_ids; ///< block ids address
282 rocprofiler_dim3_t block_dims; ///< block dimensions address
283 rocprofiler_dim3_t grid_dims; ///< grid dimensions address
284 uint64_t workgroup_size; ///< workgroup size address
285
286 /// @var device_function
287 /// @brief device function name used to map the metadata during kernel launch
288} rocprofiler_callback_tracing_code_object_host_kernel_symbol_register_data_t;
289
290/**
291 * @brief ROCProfiler Kernel Dispatch Callback Tracer Record.
292 *
293 */
301
302/**
303 * @brief ROCProfiler Memory Copy Callback Tracer Record.
304 *
305 * The timestamps in this record will only be non-zero in the ::ROCPROFILER_CALLBACK_PHASE_EXIT
306 * callback
307 */
309{
310 uint64_t size; ///< size of this struct
311 rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
312 rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
313 rocprofiler_agent_id_t dst_agent_id; ///< destination agent of copy
314 rocprofiler_agent_id_t src_agent_id; ///< source agent of copy
315 uint64_t bytes; ///< bytes copied
316 rocprofiler_address_t dst_address; ///< destination address
319
320/**
321 * @brief ROCProfiler Memory Allocation Tracer Record.
322 */
324{
325 uint64_t size; ///< size of this struct
326 rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
327 rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
328 rocprofiler_agent_id_t agent_id; ///< agent id for memory allocation
329 rocprofiler_address_t address; ///< starting address for memory allocation
330 uint64_t allocation_size; ///< size of memory allocation
332
333/**
334 * @brief ROCProfiler Scratch Memory Callback Data.
335 */
337{
338 uint64_t size; ///< size of this struct
339 rocprofiler_agent_id_t agent_id;
340 rocprofiler_queue_id_t queue_id;
341 rocprofiler_scratch_alloc_flag_t flags;
342 hsa_amd_tool_event_kind_t args_kind;
343 rocprofiler_scratch_memory_args_t args;
345
346/**
347 * @brief ROCProfiler Runtime Initialization Data.
348 */
350{
351 uint64_t size; ///< size of this struct
352 uint64_t version;
353 uint64_t instance; ///< Number of times this runtime had been loaded previously
354
355 /// @var version
356 /// @brief The version number of the library
357 ///
358 /// Version number is encoded as: (10000 * MAJOR) + (100 * MINOR) + PATCH
360
361/**
362 * @brief ROCProfiler Stream Handle Callback Data.
363 */
370
371/**
372 * @brief ROCProfiler HIP Graph Callback Data.
373 *
374 * Delivered with callbacks fired for hipGraphInstantiate*, hipGraphExecDestroy,
375 * and hipGraphLaunch{,_spt} via the ::ROCPROFILER_CALLBACK_TRACING_HIP_GRAPH
376 * domain.
377 *
378 * Sub-operations (::rocprofiler_hip_graph_operation_t):
379 * - EXEC_CREATE fires after a successful hipGraphInstantiate*
380 * - EXEC_DESTROY fires after a successful hipGraphExecDestroy
381 * - EXEC_LAUNCH fires at ENTER and EXIT phases of
382 * hipGraphLaunch / hipGraphLaunch_spt
383 *
384 * Tools that want to associate kernel dispatches with their producing graph
385 * node should:
386 * 1. Subscribe to ::ROCPROFILER_CALLBACK_TRACING_HIP_GRAPH and maintain a
387 * per-thread stack of (graph_exec_id, node_counter) by handling
388 * EXEC_LAUNCH ENTER (push) and EXIT (pop).
389 * 2. Register an external correlation id request callback that, when invoked
390 * for KERNEL_DISPATCH / MEMORY_COPY, captures the current top-of-stack
391 * graph attribution into the external correlation id and increments the
392 * node_counter.
393 * 3. At record consumption time, extract the captured attribution from
394 * ::rocprofiler_correlation_id_t::external on the dispatch/copy record.
395 *
396 * This mirrors the ::ROCPROFILER_CALLBACK_TRACING_HIP_STREAM design.
397 */
399{
400 uint64_t size; ///< size of this struct
401 rocprofiler_graph_exec_id_t graph_exec_id; ///< process-monotonic ID of the hipGraphExec_t
402 rocprofiler_address_t graph_exec_value; ///< raw hipGraphExec_t pointer value
404
405/**
406 * @brief API Tracing callback function. This function is invoked twice per API function: once
407 * before the function is invoked and once after the function is invoked. The external correlation
408 * id value within the record is assigned the value at the top of the external correlation id stack.
409 * It is permissible to invoke ::rocprofiler_push_external_correlation_id within the enter phase;
410 * when a new external correlation id is pushed during the enter phase, rocprofiler will use that
411 * external correlation id for any async events and provide the new external correlation id during
412 * the exit callback... In other words, pushing a new external correlation id within the enter
413 * callback will result in that external correlation id value in the exit callback (which may or may
414 * not be different from the external correlation id value in the enter callback). If a tool pushes
415 * new external correlation ids in the enter phase, it is recommended to pop the external
416 * correlation id in the exit callback.
417 *
418 * @param [in] record Callback record data
419 * @param [in,out] user_data This parameter can be used to retain information in between the enter
420 * and exit phases.
421 * @param [in] callback_data User data provided when configuring the callback tracing service
422 */
424 rocprofiler_user_data_t* user_data,
425 void* callback_data) ROCPROFILER_NONNULL(2);
426
427/**
428 * @brief Callback function for mapping ::rocprofiler_callback_tracing_kind_t ids to
429 * string names. @see rocprofiler_iterate_callback_tracing_kind_names.
430 */
432 void* data);
433
434/**
435 * @brief Callback function for mapping the operations of a given
436 * ::rocprofiler_callback_tracing_kind_t to string names. @see
437 * rocprofiler_iterate_callback_tracing_kind_operation_names.
438 */
442 void* data);
443
444/**
445 * @brief Callback function for iterating over the function arguments to a traced function.
446 * This function will be invoked for each argument.
447 * @see rocprofiler_iterate_callback_tracing_operation_args
448 *
449 * @param [in] kind domain
450 * @param [in] operation associated domain operation
451 * @param [in] arg_number the argument number, starting at zero
452 * @param [in] arg_value_addr the address of the argument stored by rocprofiler.
453 * @param [in] arg_indirection_count the total number of indirection levels for the argument, e.g.
454 * int == 0, int* == 1, int** == 2
455 * @param [in] arg_type the typeid name of the argument
456 * @param [in] arg_name the name of the argument in the prototype (or rocprofiler union)
457 * @param [in] arg_value_str conversion of the argument to a string, e.g. operator<< overload
458 * @param [in] arg_dereference_count the number of times the argument was dereferenced when it was
459 * converted to a string
460 * @param [in] data user data
461 */
465 uint32_t arg_number,
466 const void* const arg_value_addr,
467 int32_t arg_indirection_count,
468 const char* arg_type,
469 const char* arg_name,
470 const char* arg_value_str,
471 int32_t arg_dereference_count,
472 void* data);
473
474/**
475 * @brief Configure Callback Tracing Service. The callback tracing service provides two synchronous
476 * callbacks around an API function on the same thread as the application which is invoking the API
477 * function. This function can only be invoked once per ::rocprofiler_callback_tracing_kind_t value,
478 * i.e. it can be invoked once for the HSA API, once for the HIP API, and so on but it will fail if
479 * it is invoked for the HSA API twice. Please note, the callback API does have the potentially
480 * non-trivial overhead of copying the function arguments into the record. If you are willing to let
481 * rocprofiler record the timestamps, do not require synchronous notifications of the API calls, and
482 * want to lowest possible overhead, use the
483 * @see BUFFER_TRACING_SERVICE.
484 *
485 * @param [in] context_id Context to associate the service with
486 * @param [in] kind The domain of the callback tracing service
487 * @param [in] operations Array of operations in the domain (i.e. enum values which identify
488 * specific API functions). If this is null, all API functions in the domain will be traced
489 * @param [in] operations_count If the operations array is non-null, set this to the size of the
490 * array.
491 * @param [in] callback The function to invoke before and after an API function
492 * @param [in] callback_args Data provided to every invocation of the callback function
493 * @return ::rocprofiler_status_t
494 * @retval ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED Invoked outside of the initialization
495 * function in ::rocprofiler_tool_configure_result_t provided to rocprofiler via
496 * ::rocprofiler_configure function
497 * @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND The provided context is not valid/registered
498 * @retval ::ROCPROFILER_STATUS_ERROR_SERVICE_ALREADY_CONFIGURED if the same
499 * ::rocprofiler_callback_tracing_kind_t value is provided more than once (per context) -- in other
500 * words, we do not support overriding or combining the operations in separate function calls.
501 *
502 */
506 const rocprofiler_tracing_operation_t* operations,
507 size_t operations_count,
509 void* callback_args) ROCPROFILER_API;
510
511/**
512 * @brief Query the name of the callback tracing kind. The name retrieved from this function is a
513 * string literal that is encoded in the read-only section of the binary (i.e. it is always
514 * "allocated" and never "deallocated").
515 *
516 * @param [in] kind Callback tracing domain
517 * @param [out] name If non-null and the name is a constant string that does not require dynamic
518 * allocation, this parameter will be set to the address of the string literal, otherwise it will
519 * be set to nullptr
520 * @param [out] name_len If non-null, this will be assigned the length of the name (regardless of
521 * the name is a constant string or requires dynamic allocation)
522 * @return ::rocprofiler_status_t
523 */
526 const char** name,
527 uint64_t* name_len) ROCPROFILER_API;
528
529/**
530 * @brief Query the name of the callback tracing kind. The name retrieved from this function is a
531 * string literal that is encoded in the read-only section of the binary (i.e. it is always
532 * "allocated" and never "deallocated").
533 *
534 * @param [in] kind Callback tracing domain
535 * @param [in] operation Enumeration id value which maps to a specific API function or event type
536 * @param [out] name If non-null and the name is a constant string that does not require dynamic
537 * allocation, this parameter will be set to the address of the string literal, otherwise it will
538 * be set to nullptr
539 * @param [out] name_len If non-null, this will be assigned the length of the name (regardless of
540 * the name is a constant string or requires dynamic allocation)
541 * @return ::rocprofiler_status_t
542 * @retval ::ROCPROFILER_STATUS_ERROR_KIND_NOT_FOUND Domain id is not valid
543 * @retval ::ROCPROFILER_STATUS_SUCCESS Valid domain provided, regardless if there is a constant
544 * string or not.
545 */
549 const char** name,
550 uint64_t* name_len) ROCPROFILER_API;
551
552/**
553 * @brief Iterate over all the mappings of the callback tracing kinds and get a callback for each
554 * kind.
555 *
556 * @param [in] callback Callback function invoked for each enumeration value in
557 * ::rocprofiler_callback_tracing_kind_t with the exception of the `NONE` and `LAST` values.
558 * @param [in] data User data passed back into the callback
559 * @return ::rocprofiler_status_t
560 */
563 void* data) ROCPROFILER_API ROCPROFILER_NONNULL(1);
564
565/**
566 * @brief Iterates over all the mappings of the operations for a given
567 * ::rocprofiler_callback_tracing_kind_t and invokes the callback with the kind id, operation id,
568 * and user-provided data.
569 *
570 * @param [in] kind which tracing callback kind operations to iterate over
571 * @param [in] callback Callback function invoked for each operation associated with
572 * ::rocprofiler_callback_tracing_kind_t with the exception of the `NONE` and `LAST` values.
573 * @param [in] data User data passed back into the callback
574 * @return ::rocprofiler_status_t
575 * @retval ::ROCPROFILER_STATUS_ERROR_KIND_NOT_FOUND Invalid domain id
576 * @retval ::ROCPROFILER_STATUS_SUCCESS Valid domain
577 */
582 void* data) ROCPROFILER_API ROCPROFILER_NONNULL(2);
583
584/**
585 * @brief Iterates over all the arguments for the traced function (when available). This is
586 * particularly useful when tools want to annotate traces with the function arguments. See
587 * @example samples/api_callback_tracing/client.cpp for a usage example.
588 *
589 * It is recommended to use this function when the record phase is ::ROCPROFILER_CALLBACK_PHASE_EXIT
590 * or ::ROCPROFILER_CALLBACK_PHASE_NONE. When the phase is ::ROCPROFILER_CALLBACK_PHASE_ENTER, the
591 * function may have output parameters which have not set. In the case of an output parameter with
592 * one level of indirection, e.g. `int* output_len`, this is considered safe since the output
593 * parameter is either null or, in the worst case scenario, pointing to an uninitialized value which
594 * will result in garbage values to be stringified. However, if the output parameter has more than
595 * one level of indirection, e.g. `const char** output_name`, this can result in a segmentation
596 * fault because the dereferenced output parameter may be uninitialized and point to an invalid
597 address. E.g.:
598 *
599 * @code{.cpp}
600 * struct dim3
601 * {
602 * int x;
603 * int y;
604 * int z;
605 * };
606 *
607 * static dim3 default_dims = {.x = 1, .y = 1, .z = 1};
608 *
609 * void set_dim_x(int val, dim3* output_dims) { output_dims->x = val; }
610 *
611 * void get_default_dims(dim3** output_dims) { *output_dims = default_dims; }
612 *
613 * int main()
614 * {
615 * dim3 my_dims; // uninitialized value. x, y, and z may be set to random values
616 * dim3* current_dims; // uninitialized pointer. May be set to invalid address
617 *
618 * set_dim_x(3, &my_dims); // if rocprofiler-sdk wrapped this function and tried to stringify
619 * // in the enter phase, dereferencing my_dims is not problematic
620 * // since there is an actual dim3 allocation
621 *
622 * get_default_dims(&current_dims); // if rocprofiler-sdk wrapped this function,
623 * // and tried to stringify in the enter phase,
624 * // current_dims may point to an address outside
625 * // of the address space of this process and
626 * // cause a segfault
627 * }
628 * @endcode
629 *
630 *
631 * @param[in] record Record provided by service callback
632 * @param[in] callback The callback function which will be invoked for each argument
633 * @param[in] max_dereference_count In the callback enter phase, certain arguments may be output
634 * parameters which have not been set. When the output parameter has multiple levels of indirection,
635 * it may be invalid to dereference the output parameter more than once and doing so may result in a
636 * segmentation fault. Thus, it is recommended to set this parameter to a maximum value of 1 when
637 * the phase is ::ROCPROFILER_CALLBACK_PHASE_ENTER to ensure that output parameters which point to
638 * uninitialized pointers do not cause segmentation faults.
639 * @param[in] user_data Data to be passed to each invocation of the callback
640 */
642rocprofiler_iterate_callback_tracing_kind_operation_args(
645 int32_t max_dereference_count,
646 void* user_data) ROCPROFILER_API ROCPROFILER_NONNULL(2);
647
648/** @} */
649
650ROCPROFILER_EXTERN_C_FINI
int32_t rocprofiler_tracing_operation_t
Tracing Operation ID. Depending on the kind, operations can be determined. If the value is equal to z...
Definition fwd.h:564
rocprofiler_status_t
Status codes.
Definition fwd.h:49
uint64_t rocprofiler_timestamp_t
ROCProfiler Timestamp.
Definition fwd.h:550
rocprofiler_callback_tracing_kind_t
Service Callback Tracing Kind.
Definition fwd.h:158
Agent Identifier.
Definition fwd.h:743
Context ID.
Definition fwd.h:648
Multi-dimensional struct of data used to describe GPU workgroup and grid sizes.
Definition fwd.h:768
HIP graph executable instance ID. Process-monotonic identifier assigned by rocprofiler-sdk for each s...
Definition fwd.h:673
ROCProfiler kernel dispatch information.
Definition fwd.h:859
Stores memory address for profiling.
Definition fwd.h:613
User-assignable data type.
Definition fwd.h:603
uint64_t version
The version number of the library.
uint32_t group_segment_size
Size of static group segment memory required by the kernel (per work-group), in bytes....
rocprofiler_hip_api_retval_t retval
return value of function call
rocprofiler_timestamp_t start_timestamp
start time in nanoseconds
uint32_t kernarg_segment_alignment
Alignment (in bytes) of the buffer used to pass arguments to the kernel.
uint64_t code_object_id
unique code object identifier
rocprofiler_code_object_storage_type_t storage_type
storage type of the code object reader used to load the loaded code object
uint32_t arch_vgpr_count
Architecture vector general purpose register count.
rocprofiler_timestamp_t end_timestamp
end time in nanoseconds
rocprofiler_kernel_dispatch_info_t dispatch_info
Dispatch info.
rocprofiler_timestamp_t start_timestamp
start time in nanoseconds
uint32_t accum_vgpr_count
Accum vector general purpose register count.
rocprofiler_agent_id_t agent_id
agent id for memory allocation
uint64_t kernel_object
kernel object handle, used in the kernel dispatch packet
uint32_t private_segment_size
Size of static private, spill, and arg segment memory required by this kernel (per work-item),...
uint64_t instance
Number of times this runtime had been loaded previously.
rocprofiler_timestamp_t start_timestamp
start time in nanoseconds
hsa_agent_t hsa_agent
Deprecated. The agent on which this loaded code object is loaded.
rocprofiler_address_t kernel_address
The first address of a kernel. Useful for PC sampling.
rocprofiler_stream_id_t stream_id
HIP stream ID.
uint64_t load_base
The base memory address at which the code object is loaded. This is the base address of the allocatio...
uint64_t load_size
The byte size of the loaded code objects contiguous memory allocation.
rocprofiler_hip_api_args_t args
Arguments of the function call.
int64_t load_delta
The signed byte address difference of the memory address at which the code object is loaded minus the...
rocprofiler_address_t graph_exec_value
raw hipGraphExec_t pointer value
rocprofiler_address_t dst_address
destination address
uint32_t kernarg_segment_size
size of memory (in bytes) allocated for kernel arguments. Will be multiple of 16
int64_t kernel_code_entry_byte_offset
Relative offset from kernel_object address to calculate the first address of a kernel.
rocprofiler_address_t address
starting address for memory allocation
const char * uri
The URI name from which the code object was loaded.
rocprofiler_timestamp_t end_timestamp
end time in nanoseconds
rocprofiler_address_t stream_value
HIP stream value.
rocprofiler_graph_exec_id_t graph_exec_id
process-monotonic ID of the hipGraphExec_t
rocprofiler_timestamp_t end_timestamp
end time in nanoseconds
rocprofiler_address_t src_address
source address
rocprofiler_agent_id_t dst_agent_id
destination agent of copy
rocprofiler_agent_id_t src_agent_id
source agent of copy
rocprofiler_status_t rocprofiler_query_callback_tracing_kind_operation_name(rocprofiler_callback_tracing_kind_t kind, rocprofiler_tracing_operation_t operation, const char **name, uint64_t *name_len)
Query the name of the callback tracing kind. The name retrieved from this function is a string litera...
int(* rocprofiler_callback_tracing_kind_cb_t)(rocprofiler_callback_tracing_kind_t kind, void *data)
Callback function for mapping rocprofiler_callback_tracing_kind_t ids to string names.
int(* rocprofiler_callback_tracing_kind_operation_cb_t)(rocprofiler_callback_tracing_kind_t kind, rocprofiler_tracing_operation_t operation, void *data)
Callback function for mapping the operations of a given rocprofiler_callback_tracing_kind_t to string...
int(* rocprofiler_callback_tracing_operation_args_cb_t)(rocprofiler_callback_tracing_kind_t kind, rocprofiler_tracing_operation_t operation, uint32_t arg_number, const void *const arg_value_addr, int32_t arg_indirection_count, const char *arg_type, const char *arg_name, const char *arg_value_str, int32_t arg_dereference_count, void *data)
Callback function for iterating over the function arguments to a traced function. This function will ...
rocprofiler_status_t rocprofiler_configure_callback_tracing_service(rocprofiler_context_id_t context_id, rocprofiler_callback_tracing_kind_t kind, const rocprofiler_tracing_operation_t *operations, unsigned long operations_count, rocprofiler_callback_tracing_cb_t callback, void *callback_args)
Configure Callback Tracing Service. The callback tracing service provides two synchronous callbacks a...
rocprofiler_status_t rocprofiler_query_callback_tracing_kind_name(rocprofiler_callback_tracing_kind_t kind, const char **name, uint64_t *name_len)
Query the name of the callback tracing kind. The name retrieved from this function is a string litera...
rocprofiler_code_object_storage_type_t
ROCProfiler Enumeration for code object storage types (identical values to hsa_ven_amd_loader_code_ob...
rocprofiler_status_t rocprofiler_iterate_callback_tracing_kind_operations(rocprofiler_callback_tracing_kind_t kind, rocprofiler_callback_tracing_kind_operation_cb_t callback, void *data)
Iterates over all the mappings of the operations for a given rocprofiler_callback_tracing_kind_t and ...
rocprofiler_status_t rocprofiler_iterate_callback_tracing_kinds(rocprofiler_callback_tracing_kind_cb_t callback, void *data)
Iterate over all the mappings of the callback tracing kinds and get a callback for each kind.
void(* rocprofiler_callback_tracing_cb_t)(rocprofiler_callback_tracing_record_t record, rocprofiler_user_data_t *user_data, void *callback_data)
API Tracing callback function. This function is invoked twice per API function: once before the funct...
ROCProfiler Code Object Kernel Symbol Tracer Callback Record.
ROCProfiler Code Object Load Tracer Callback Record.
ROCProfiler HIP runtime and compiler API Tracer Callback Data.
ROCProfiler HIP Graph Callback Data.
ROCProfiler Stream Handle Callback Data.
ROCProfiler hipFILE API Callback Data.
ROCProfiler HSA API Callback Data.
ROCProfiler Kernel Dispatch Callback Tracer Record.
ROCProfiler Marker Tracer Callback Data.
ROCProfiler Memory Allocation Tracer Record.
ROCProfiler Memory Copy Callback Tracer Record.
ROCProfiler OMPT Callback Data.
ROCProfiler RCCL API Callback Data.
ROCProfiler rocDecode API Callback Data.
ROCProfiler rocJPEG API Callback Data.
ROCProfiler rocSHMEM API Callback Data.
ROCProfiler Scratch Memory Callback Data.