rocprofiler-sdk/agent_profile.h Source File

rocprofiler-sdk/agent_profile.h Source File#

Rocprofiler SDK Developer API: rocprofiler-sdk/agent_profile.h Source File
Rocprofiler SDK Developer API 0.4.0
ROCm Profiling API and tools
agent_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
26#include <rocprofiler-sdk/fwd.h>
27
28/**
29 * @defgroup AGENT_PROFILE_COUNTING_SERVICE Agent Profile Counting Service
30 * @brief needs brief description
31 *
32 * @{
33 */
34ROCPROFILER_EXTERN_C_INIT
35
36/**
37 * @brief Callback to set the profile config for the agent.
38 *
39 * @param [in] context_id context id
40 * @param [in] config_id Profile config detailing the counters to collect for this kernel
41 * @return ::rocprofiler_status_t
42 * @retval ::ROCPROFILER_STATUS_ERROR_PROFILE_NOT_FOUND Returned if the config_id is not found
43 * @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID Returned if the ctx is not valid
44 * @retval ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED Returned if attempting to make this
45 * call outside of context startup.
46 * @retval ::ROCPROFILER_STATUS_ERROR_AGENT_MISMATCH Agent of profile does not match agent of the
47 * context.
48 * @retval ::ROCPROFILER_STATUS_SUCCESS Returned if succesfully configured
49 */
51 rocprofiler_context_id_t context_id,
53
54/**
55 * @brief Configure Profile Counting Service for agent. Called when the context is started.
56 * Selects the counters to be used for agent profiling.
57 *
58 * @param [in] context_id context id
59 * @param [in] agent_id agent id
60 * @param [in] set_config Function to call to set the profile config (see
61 * rocprofiler_agent_set_profile_callback_t)
62 * @param [in] user_data Data supplied to rocprofiler_configure_agent_profile_counting_service
63 */
65 rocprofiler_context_id_t context_id,
68 void* user_data);
69
70/**
71 * @brief Configure Profile Counting Service for agent. There may only be one agent profile
72 * configured per context and can be only one active context that is profiling a single agent
73 * at a time. Multiple agent contexts can be started at the same time if they are profiling
74 * different agents.
75 *
76 * @param [in] context_id context id
77 * @param [in] buffer_id id of the buffer to use for the counting service. When
78 * rocprofiler_sample_agent_profile_counting_service is called, counter data will be written
79 * to this buffer.
80 * @param [in] agent_id agent to configure profiling on.
81 * @param [in] cb Callback called when the context is started for the tool to specify what
82 * counters to collect (rocprofiler_profile_config_id_t).
83 * @param [in] user_data User supplied data to be passed to the callback cb when triggered
84 * @return ::rocprofiler_status_t
85 * @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID Returned if the context does not exist.
86 * @retval ::ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND Returned if the buffer is not found.
87 * @retval ::ROCPROFILER_STATUS_SUCCESS Returned if succesfully configured
88 */
94 void* user_data)
95 ROCPROFILER_NONNULL(4) ROCPROFILER_API;
96
97/**
98 * @brief Trigger a read of the counter data for the agent profile. The counter data will be
99 * written to the buffer specified in rocprofiler_configure_agent_profile_counting_service.
100 * The data in rocprofiler_user_data_t will be written to the buffer along with the counter data.
101 * flags can be used to specify if this call should be performed asynchronously (default is
102 * synchronous).
103 *
104 * @param [in] context_id context id
105 * @param [in] user_data User supplied data, included in records outputted to buffer.
106 * @param [in] flags Flags to specify how the counter data should be collected (defaults to sync).
107 * @return ::rocprofiler_status_t
108 * @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_INVALID Returned if the context does not exist or
109 * the context is not configured for agent profiling.
110 * @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_ERROR Returned if another operation is in progress (
111 * start/stop ctx or another read).
112 * @retval ::ROCPROFILER_STATUS_ERROR Returned if HSA has not been initialized yet.
113 * @retval ::ROCPROFILER_STATUS_SUCCESS Returned if read request was successful.
114 */
117 rocprofiler_user_data_t user_data,
118 rocprofiler_counter_flag_t flags) ROCPROFILER_API;
119
120/** @} */
121
122ROCPROFILER_EXTERN_C_FINI
rocprofiler_status_t rocprofiler_sample_agent_profile_counting_service(rocprofiler_context_id_t context_id, rocprofiler_user_data_t user_data, rocprofiler_counter_flag_t flags)
Trigger a read of the counter data for the agent profile. The counter data will be written to the buf...
void(* rocprofiler_agent_profile_callback_t)(rocprofiler_context_id_t context_id, rocprofiler_agent_id_t agent_id, rocprofiler_agent_set_profile_callback_t set_config, void *user_data)
Configure Profile Counting Service for agent. Called when the context is started. Selects the counter...
rocprofiler_status_t rocprofiler_configure_agent_profile_counting_service(rocprofiler_context_id_t context_id, rocprofiler_buffer_id_t buffer_id, rocprofiler_agent_id_t agent_id, rocprofiler_agent_profile_callback_t cb, void *user_data)
Configure Profile Counting Service for agent. There may only be one agent profile configured per cont...
rocprofiler_status_t(* rocprofiler_agent_set_profile_callback_t)(rocprofiler_context_id_t context_id, rocprofiler_profile_config_id_t config_id)
Callback to set the profile config for the agent.
rocprofiler_status_t
Status codes.
Definition fwd.h:55
rocprofiler_counter_flag_t
Enumeration of flags that can be used with some counter api calls.
Definition fwd.h:401
Agent Identifier.
Definition fwd.h:541
Context ID.
Definition fwd.h:502
Profile Configurations.
Definition fwd.h:558
User-assignable data type.
Definition fwd.h:487