rocprofiler-sdk/dispatch_profile.h Source File

rocprofiler-sdk/dispatch_profile.h Source File#

Rocprofiler SDK Developer API: rocprofiler-sdk/dispatch_profile.h Source File
Rocprofiler SDK Developer API 0.4.0
ROCm Profiling API and tools
dispatch_profile.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#include <rocprofiler-sdk/hsa.h>
30
31ROCPROFILER_EXTERN_C_INIT
32
33/**
34 * @defgroup DISPATCH_PROFILE_COUNTING_SERVICE Dispatch Profile Counting Service
35 * @brief Per-dispatch hardware counter collection service
36 *
37 * @{
38 */
39
40/**
41 * @brief Kernel dispatch data for profile counting callbacks.
42 *
43 */
50
51/**
52 * @brief ROCProfiler Profile Counting Counter Record Header Information
53 *
54 * This is buffer equivalent of ::rocprofiler_profile_counting_dispatch_data_t
55 */
57{
58 uint64_t size; ///< Size of this struct
59 uint64_t num_records; ///< number of ::rocprofiler_record_counter_t records
60 rocprofiler_correlation_id_t correlation_id; ///< Correlation ID for this dispatch
61 rocprofiler_kernel_dispatch_info_t dispatch_info; ///< Contains the `dispatch_id`
63
64/**
65 * @brief Kernel Dispatch Callback. This is a callback that is invoked before the kernel
66 * is enqueued into the HSA queue. What counters to collect for a kernel are set
67 * via passing back a profile config (config) in this callback. These counters
68 * will be collected and emplaced in the buffer with @ref rocprofiler_buffer_id_t used when
69 * setting up this callback.
70 *
71 * @param [in] dispatch_data @see ::rocprofiler_profile_counting_dispatch_data_t
72 * @param [out] config Profile config detailing the counters to collect for this kernel
73 * @param [out] user_data User data unique to this dispatch. Returned in record callback
74 * @param [in] callback_data_args Callback supplied via buffered_dispatch_profile_counting_service
75 */
79 rocprofiler_user_data_t* user_data,
80 void* callback_data_args);
81
82/**
83 * @brief Counting record callback. This is a callback is invoked when the kernel
84 * execution is complete and contains the counter profile data requested in
85 * @ref rocprofiler_profile_counting_dispatch_callback_t. Only used with
86 * @ref rocprofiler_configure_callback_dispatch_profile_counting_service.
87 *
88 * @param [in] dispatch_data @see ::rocprofiler_profile_counting_dispatch_data_t
89 * @param [in] record_data Counter record data.
90 * @param [in] record_count Number of counter records.
91 * @param [in] user_data User data instance from dispatch callback
92 * @param [in] callback_data_args Callback supplied via buffered_dispatch_profile_counting_service
93 */
97 size_t record_count,
99 void* callback_data_args);
100
101/**
102 * @brief Configure buffered dispatch profile Counting Service.
103 * Collects the counters in dispatch packets and stores them
104 * in a buffer with @p buffer_id. The buffer may contain packets from more than
105 * one dispatch (denoted by correlation id). Will trigger the
106 * callback based on the parameters setup in buffer_id_t.
107 *
108 * NOTE: Interface is up for comment as to whether restrictions
109 * on agent should be made here (limiting the CB based on agent)
110 * or if the restriction should be performed by the tool in
111 * @ref rocprofiler_profile_counting_dispatch_callback_t (i.e.
112 * tool code checking the agent param to see if they want to profile
113 * it).
114 *
115 * Interface is up for comment as to whether restrictions
116 * on agent should be made here (limiting the CB based on agent)
117 * or if the restriction should be performed by the tool in
118 * @ref rocprofiler_profile_counting_dispatch_callback_t (i.e.
119 * tool code checking the agent param to see if they want to profile
120 * it).
121 *
122 * @param [in] context_id context id
123 * @param [in] buffer_id id of the buffer to use for the counting service
124 * @param [in] callback callback to perform when dispatch is enqueued
125 * @param [in] callback_data_args callback data
126 * @return ::rocprofiler_status_t
127 */
128rocprofiler_status_t ROCPROFILER_API
130 rocprofiler_context_id_t context_id,
131 rocprofiler_buffer_id_t buffer_id,
133 void* callback_data_args);
134
135/**
136 * @brief Configure buffered dispatch profile Counting Service.
137 * Collects the counters in dispatch packets and calls a callback
138 * with the counters collected during that dispatch.
139 *
140 * @param [in] context_id context id
141 * @param [in] dispatch_callback callback to perform when dispatch is enqueued
142 * @param [in] dispatch_callback_args callback data for dispatch callback
143 * @param [in] record_callback Record callback for completed profile data
144 * @param [in] record_callback_args Callback args for record callback
145 * @return ::rocprofiler_status_t
146 */
147rocprofiler_status_t ROCPROFILER_API
149 rocprofiler_context_id_t context_id,
151 void* dispatch_callback_args,
153 void* record_callback_args);
154/** @} */
155
156ROCPROFILER_EXTERN_C_FINI
rocprofiler_status_t
Status codes.
Definition fwd.h:55
Context ID.
Definition fwd.h:502
ROCProfiler Record Correlation ID.
Definition fwd.h:518
ROCProfiler kernel dispatch information.
Definition fwd.h:653
Profile Configurations.
Definition fwd.h:558
ROCProfiler Profile Counting Counter Record per instance.
Definition fwd.h:683
User-assignable data type.
Definition fwd.h:487
rocprofiler_kernel_dispatch_info_t dispatch_info
Contains the dispatch_id
rocprofiler_kernel_dispatch_info_t dispatch_info
Dispatch info.
rocprofiler_correlation_id_t correlation_id
Correlation ID for this dispatch.
uint64_t num_records
number of rocprofiler_record_counter_t records
rocprofiler_correlation_id_t correlation_id
Correlation ID for this dispatch.
rocprofiler_status_t rocprofiler_configure_buffered_dispatch_profile_counting_service(rocprofiler_context_id_t context_id, rocprofiler_buffer_id_t buffer_id, rocprofiler_profile_counting_dispatch_callback_t callback, void *callback_data_args)
Configure buffered dispatch profile Counting Service. Collects the counters in dispatch packets and s...
rocprofiler_status_t rocprofiler_configure_callback_dispatch_profile_counting_service(rocprofiler_context_id_t context_id, rocprofiler_profile_counting_dispatch_callback_t dispatch_callback, void *dispatch_callback_args, rocprofiler_profile_counting_record_callback_t record_callback, void *record_callback_args)
Configure buffered dispatch profile Counting Service. Collects the counters in dispatch packets and c...
void(* rocprofiler_profile_counting_dispatch_callback_t)(rocprofiler_profile_counting_dispatch_data_t dispatch_data, rocprofiler_profile_config_id_t *config, rocprofiler_user_data_t *user_data, void *callback_data_args)
Kernel Dispatch Callback. This is a callback that is invoked before the kernel is enqueued into the H...
void(* rocprofiler_profile_counting_record_callback_t)(rocprofiler_profile_counting_dispatch_data_t dispatch_data, rocprofiler_record_counter_t *record_data, unsigned long record_count, rocprofiler_user_data_t user_data, void *callback_data_args)
Counting record callback. This is a callback is invoked when the kernel execution is complete and con...
Kernel dispatch data for profile counting callbacks.
ROCProfiler Profile Counting Counter Record Header Information.