rocprofiler-sdk/experimental/thread-trace/dispatch.h Source File

rocprofiler-sdk/experimental/thread-trace/dispatch.h Source File#

ROCprofiler-SDK developer API: rocprofiler-sdk/experimental/thread-trace/dispatch.h Source File
ROCprofiler-SDK developer API 1.0.0
ROCm Profiling API and tools
dispatch.h
1// MIT License
2//
3// Copyright (c) 2024-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/agent.h>
26#include <rocprofiler-sdk/defines.h>
27#include <rocprofiler-sdk/experimental/thread-trace/core.h>
28#include <rocprofiler-sdk/fwd.h>
29#include <rocprofiler-sdk/hsa.h>
30
31ROCPROFILER_EXTERN_C_INIT
32
33/**
34 * @defgroup THREAD_TRACE Thread Trace Service
35 * @brief Provides API calls to enable and handle thread trace data
36 *
37 * @{
38 */
39
40typedef enum rocprofiler_thread_trace_control_flags_t
41{
42 ROCPROFILER_THREAD_TRACE_CONTROL_NONE = 0,
43 ROCPROFILER_THREAD_TRACE_CONTROL_START_AND_STOP = 3
44} rocprofiler_thread_trace_control_flags_t;
45
46/**
47 * @brief Callback to be triggered every kernel dispatch, indicating to start and/or stop ATT
48 * @param [in] agent_id agent_id.
49 * @param [in] queue_id queue_id.
50 * @param [in] correlation_id internal correlation id.
51 * @param [in] kernel_id kernel_id.
52 * @param [in] dispatch_id dispatch_id.
53 * @param [in] userdata_config Userdata passed back from
54 * rocprofiler_configure_dispatch_thread_trace_service.
55 * @param [out] userdata_shader Userdata to be passed in shader_callback
56 */
57typedef rocprofiler_thread_trace_control_flags_t (*rocprofiler_thread_trace_dispatch_callback_t)(
62 rocprofiler_dispatch_id_t dispatch_id,
63 void* userdata_config,
64 rocprofiler_user_data_t* userdata_shader);
65
66/**
67 * @brief Enables the thread trace service for dispatch-based tracing.
68 * The tool has an option to enable/disable thread trace on every dispatch callback.
69 * This service serializes all traced kernels, and optionally all non-traced kernels.
70 * @param [in] context_id id of the context used for start/stop thread_trace.
71 * @param [in] agent_id rocprofiler_agent_id_t to configure thread trace.
72 * @param [in] parameters List of ATT-specific parameters.
73 * @param [in] num_parameters Number of parameters. Zero is allowed.
74 * @param [in] dispatch_callback Control fn which decides when TT starts/stop collecting.
75 * @param [in] shader_callback Callback fn where the collected data will be sent to.
76 * @param [in] callback_userdata Passed back to user in dispatch_callback.
77 * @return ::rocprofiler_status_t
78 * @retval ROCPROFILER_STATUS_SUCCESS on success
79 * @retval ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED for configuration locked
80 * @retval ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID for conflicting configurations in the same ctx
81 * @retval ROCPROFILER_STATUS_ERROR_CONTEXT_NOT_FOUND for invalid context id
82 * @retval ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT for invalid
83 * rocprofiler_thread_trace_parameter_t
84 * @retval ROCPROFILER_STATUS_ERROR_SERVICE_ALREADY_CONFIGURED if already configured
85 */
88 rocprofiler_context_id_t context_id,
91 size_t num_parameters,
94 void* callback_userdata) ROCPROFILER_API;
95
96/** @} */
97
98ROCPROFILER_EXTERN_C_FINI
rocprofiler_status_t
Status codes.
Definition fwd.h:49
uint64_t rocprofiler_kernel_id_t
Kernel identifier type.
Definition fwd.h:522
Agent Identifier.
Definition fwd.h:677
ROCProfiler Correlation ID record for async activity.
Definition fwd.h:643
Context ID.
Definition fwd.h:600
User-assignable data type.
Definition fwd.h:555
void(* rocprofiler_thread_trace_shader_data_callback_t)(rocprofiler_agent_id_t agent, int64_t shader_engine_id, void *data, unsigned long data_size, rocprofiler_user_data_t userdata)
Callback to be triggered every time some ATT data is generated by the device.
Definition core.h:87
rocprofiler_status_t rocprofiler_configure_dispatch_thread_trace_service(rocprofiler_context_id_t context_id, rocprofiler_agent_id_t agent_id, rocprofiler_thread_trace_parameter_t *parameters, unsigned long num_parameters, rocprofiler_thread_trace_dispatch_callback_t dispatch_callback, rocprofiler_thread_trace_shader_data_callback_t shader_callback, void *callback_userdata)
Enables the thread trace service for dispatch-based tracing. The tool has an option to enable/disable...
rocprofiler_thread_trace_control_flags_t(* rocprofiler_thread_trace_dispatch_callback_t)(rocprofiler_agent_id_t agent_id, rocprofiler_queue_id_t queue_id, rocprofiler_async_correlation_id_t correlation_id, rocprofiler_kernel_id_t kernel_id, rocprofiler_dispatch_id_t dispatch_id, void *userdata_config, rocprofiler_user_data_t *userdata_shader)
Callback to be triggered every kernel dispatch, indicating to start and/or stop ATT.
Definition dispatch.h:57
Thread Trace parameter specification.
Definition core.h:66