rocprofiler-sdk/pc_sampling.h Source File

rocprofiler-sdk/pc_sampling.h Source File#

ROCprofiler-SDK developer API: rocprofiler-sdk/pc_sampling.h Source File
ROCprofiler-SDK developer API 1.3.5
ROCm Profiling API and tools
pc_sampling.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/agent.h>
26#include <rocprofiler-sdk/defines.h>
27#include <rocprofiler-sdk/fwd.h>
28
29ROCPROFILER_EXTERN_C_INIT
30
31/**
32 * @defgroup PC_SAMPLING_SERVICE PC Sampling
33 * @brief Enabling PC (Program Counter) Sampling for GPU Activity
34 * @{
35 */
36
37/**
38 * @brief (experimental) Function used to configure the PC sampling service on the GPU agent with @p
39 * agent_id.
40 *
41 * Prerequisites are the following:
42 * - The client must create a context and supply its @p context_id. By using this context,
43 * the client can start/stop PC sampling on the agent. For more information,
44 * please @see rocprofiler_start_context/rocprofiler_stop_context.
45 * - The user must create a buffer and supply its @p buffer_id. Rocprofiler-SDK uses the buffer
46 * to deliver the PC samples to the client. For more information about the data delivery,
47 * please @see rocprofiler_create_buffer and @see rocprofiler_buffer_tracing_cb_t.
48 *
49 * Before calling this function, we recommend querying PC sampling configurations
50 * supported by the GPU agent via the @see rocprofiler_query_pc_sampling_agent_configurations.
51 * The client chooses the @p method, @p unit, and @p interval to match one of the
52 * available configurations. Note that the @p interval must belong to the range of values
53 * [available_config.min_interval, available_config.max_interval],
54 * where available_config is the instance of the @see rocprofiler_pc_sampling_configuration_s
55 * supported/available at the moment.
56 *
57 * Rocprofiler-SDK checks whether the requested configuration is actually supported
58 * at the moment of calling this function. If the answer is yes, it returns
59 * the @see ROCPROFILER_STATUS_SUCCESS. Otherwise, it notifies the client about the
60 * rejection reason via the returned status code. For more information
61 * about the status codes, please @see rocprofiler_status_t.
62 *
63 * There are a few constraints a client's code needs to be aware of.
64 *
65 * Constraint1: A GPU agent can be configured to support at most one running PC sampling
66 * configuration at any time, which implies some of the consequences described below.
67 * After the tool configures the PC sampling with one of the available configurations,
68 * rocprofiler-SDK guarantees that this configuration will be valid for the tool's
69 * lifetime. The tool can start and stop the configured PC sampling service whenever convenient.
70 *
71 * Constraint2: Since the same GPU agent can be used by multiple processes concurrently,
72 * Rocprofiler-SDK cannot guarantee the exclusive access to the PC sampling capability.
73 * The consequence is the following scenario. The tool TA that belongs to the process PA,
74 * calls the @see rocprofiler_query_pc_sampling_agent_configurations that returns the
75 * two supported configurations CA and CB by the agent. Then the tool TB of the process PB,
76 * configures the PC sampling on the same agent by using the configuration CB.
77 * Subsequently, the TA tries configuring the CA on the agent, and it fails.
78 * To point out that this case happened, we introduce a special status code
79 * @see ROCPROFILER_STATUS_ERROR_NOT_AVAILABLE.
80 * When this status code is observed by the tool TA, it queries all available configurations again
81 * by calling @see rocprofiler_query_pc_sampling_agent_configurations,
82 * that returns only CB this time. The tool TA can choose CB, so that both
83 * TA and TB use the PC sampling capability in the separate processes.
84 * Both TA and TB receives samples generated by the kernels launched by the
85 * corresponding processes PA and PB, respectively.
86 *
87 * Constraint3: Rocprofiler-SDK allows multiple contexts to configure PC sampling service
88 * within the process, but at most one context can configure PC sampling for any given GPU
89 * agent. This enables multiple tools to use PC sampling concurrently, as long as each tool
90 * targets different GPU agents. Each context can contain multiple PC sampling services
91 * configured for different GPU agents.
92 *
93 * Constraint4: PC sampling feature is not available within the ROCgdb.
94 *
95 * Constraint5: PC sampling service cannot be used simultaneously with
96 * counter collection service.
97 *
98 * @param [in] context_id - id of the context used for starting/stopping PC sampling service
99 * @param [in] agent_id - id of the agent on which caller tries using PC sampling capability
100 * @param [in] method - the type of PC sampling the caller tries to use on the agent.
101 * @param [in] unit - The unit appropriate to the PC sampling type/method.
102 * @param [in] interval - frequency at which PC samples are generated
103 * @param [in] buffer_id - id of the buffer used for delivering PC samples
104 * @param [in] flags - for future use
105 * @return ::rocprofiler_status_t
106 * @retval ::ROCPROFILER_STATUS_SUCCESS PC sampling service configured successfully
107 * @retval ::ROCPROFILER_STATUS_ERROR_NOT_AVAILABLE One of the scenarios is present:
108 * 1. PC sampling is already configured with configuration different than requested,
109 * 2. PC sampling is requested from a process that runs within the ROCgdb.
110 * 3. HSA runtime does not support PC sampling.
111 * 4. GPU device does not support requested PC sampling method.
112 * @retval ::ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_KERNEL the amdgpu driver installed on the system
113 * does not support the PC sampling feature
114 * @retval ::ROCPROFILER_STATUS_ERROR a general error caused by the amdgpu driver
115 * @retval ::ROCPROFILER_STATUS_ERROR_CONTEXT_CONFLICT counter collection service already
116 * setup in the context
117 * @retval ::ROCPROFILER_STATUS_ERROR_SERVICE_ALREADY_CONFIGURED PC sampling for this agent is
118 * already configured by a different context
119 * @retval ::ROCPROFILER_STATUS_ERROR_INVALID_ARGUMENT function invoked with an invalid argument
120 */
121ROCPROFILER_SDK_EXPERIMENTAL
124 rocprofiler_agent_id_t agent_id,
127 uint64_t interval,
128 rocprofiler_buffer_id_t buffer_id,
129 int flags) ROCPROFILER_API;
130
131/**
132 * @brief (experimental) Enumeration describing values of flags of
133 * ::rocprofiler_pc_sampling_configuration_t.
134 */
135typedef enum ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_configuration_flags_t
136{
137 ROCPROFILER_PC_SAMPLING_CONFIGURATION_FLAGS_NONE = 0,
138 ROCPROFILER_PC_SAMPLING_CONFIGURATION_FLAGS_INTERVAL_POW2,
139 ROCPROFILER_PC_SAMPLING_CONFIGURATION_FLAGS_LAST
140
141 /// @var ROCPROFILER_PC_SAMPLING_CONFIGURATION_FLAGS_INTERVAL_POW2
142 /// @brief The interval value must be a power of 2.
144
145/**
146 * @brief (experimental) PC sampling configuration supported by a GPU agent.
147 */
148typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_configuration_t
149{
150 uint64_t size; ///< Size of this struct
155 uint64_t flags; ///< take values from ::rocprofiler_pc_sampling_configuration_flags_t
156
157 /// @var method
158 /// @brief Sampling method supported by the GPU agent.
159 /// Currently, it can take one of the following two values:
160 /// - ::ROCPROFILER_PC_SAMPLING_METHOD_HOST_TRAP: a background host kernel thread
161 /// periodically interrupts waves execution on the GPU to generate PC samples
162 /// - ::ROCPROFILER_PC_SAMPLING_METHOD_STOCHASTIC: performance monitoring hardware
163 /// on the GPU periodically interrupts waves to generate PC samples.
164 /// @var unit
165 /// @brief A unit used to specify the interval of the @ref method for samples generation.
166 /// @var min_interval
167 /// @brief the highest possible frequency for generating samples using @ref method.
168 /// @var max_interval
169 /// @brief the lowest possible frequency for generating samples using @ref method
170
172
173/**
174 * @brief (experimental) Rocprofiler SDK's callback function to deliver the list of available PC
175 * sampling configurations upon the call to the
176 * ::rocprofiler_query_pc_sampling_agent_configurations.
177 *
178 * @param[out] configs - The array of PC sampling configurations supported by the agent
179 * at the moment of invoking ::rocprofiler_query_pc_sampling_agent_configurations.
180 * @param[out] num_config - The number of configurations contained in the underlying array
181 * @p configs.
182 * In case the GPU agent does not support PC sampling, the value is 0.
183 * @param[in] user_data - client's private data passed via
184 * ::rocprofiler_query_pc_sampling_agent_configurations
185 * @return ::rocprofiler_status_t
186 */
187ROCPROFILER_SDK_EXPERIMENTAL
190 size_t num_config,
191 void* user_data);
192
193/**
194 * @brief (experimental) Query PC Sampling Configuration.
195 *
196 * Lists PC sampling configurations a GPU agent with @p agent_id supports at the moment
197 * of invoking the function. Delivers configurations via @p cb.
198 * In case the PC sampling is configured on the GPU agent, the @p cb delivers information
199 * about the active PC sampling configuration.
200 * In case the GPU agent does not support PC sampling capability,
201 * the @p cb delivers none PC sampling configurations.
202 *
203 * @param [in] agent_id - id of the agent for which available configurations will be listed
204 * @param [in] cb - User callback that delivers the available PC sampling configurations
205 * @param [in] user_data - passed to the @p cb
206 * @return ::rocprofiler_status_t
207 * @retval ::ROCPROFILER_STATUS_ERROR_NOT_AVAILABLE One of the scenarios is present:
208 * 1. PC sampling is requested from a process that runs within the ROCgdb.
209 * 2. HSA runtime does not support PC sampling.
210 * @retval ::ROCPROFILER_STATUS_ERROR_INCOMPATIBLE_KERNEL the amdgpu driver installed on the system
211 * does not support the PC sampling feature.
212 * @retval ::ROCPROFILER_STATUS_ERROR a general error caused by the amdgpu driver
213 * @retval ::ROCPROFILER_STATUS_SUCCESS @p cb successfully finished
214 */
215ROCPROFILER_SDK_EXPERIMENTAL
218 rocprofiler_agent_id_t agent_id,
220 void* user_data) ROCPROFILER_API ROCPROFILER_NONNULL(2, 3);
221
222/**
223 * @brief (experimental) Information about the GPU part where wave was executing
224 * at the moment of sampling.
225 */
226typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_hw_id_v0_t
227{
228 uint64_t chiplet : 6; ///< chiplet index (3 bits allocated by the ROCr runtime)
229 uint64_t wave_id : 7; ///< wave slot index
230 uint64_t simd_id : 2; ///< SIMD index
231 uint64_t pipe_id : 4; ///< pipe index
232 uint64_t cu_or_wgp_id : 4;
233 uint64_t shader_array_id : 1; ///< Shared array index
234 uint64_t shader_engine_id : 5; ///< shared engine index
235 uint64_t workgroup_id : 7; ///< thread_group index on GFX9, and workgroup index on GFX10+
236 uint64_t vm_id : 6; ///< virtual memory ID
237 uint64_t queue_id : 4; ///< queue id
238 uint64_t microengine_id : 2; ///< ACE (microengine) index
239 uint64_t reserved0 : 16; ///< Reserved for the future use
240
241 /// @var cu_or_wgp_id
242 /// @brief Compute unit index on GFX9 or workgroup processor index on GFX10+.
244
245/**
246 * @brief (experimental) Sampled program counter.
247 */
248typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_t
249{
252
253 /// @var code_object_id
254 /// @brief id of the loaded code object instance that contains sampled PC.
255 /// This fields holds the value ::ROCPROFILER_CODE_OBJECT_ID_NONE
256 /// if the code object cannot be determined
257 /// (e.g., sampled PC belongs to code generated by self modifying code).
258 /// @var code_object_offset
259 /// @brief If @ref code_object_id is different than ::ROCPROFILER_CODE_OBJECT_ID_NONE,
260 /// then this field contains the offset of the sampled PC relative to the
261 /// ::rocprofiler_callback_tracing_code_object_load_data_t.load_base
262 /// of the code object instance with @ref code_object_id.
263 /// To calculate the original virtual address of the sampled PC, one can add the value
264 /// of this field to the ::rocprofiler_callback_tracing_code_object_load_data_t.load_base.
265 /// The value of @ref code_object_offset matches
266 /// the virtual address of the sampled instruction (PC), only if the
267 /// @ref code_object_id is equal to the ::ROCPROFILER_CODE_OBJECT_ID_NONE.
269
270/**
271 * @brief (experimental) ROCProfiler Host-Trap PC Sampling Record.
272 */
273typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_record_host_trap_v0_t
274{
275 uint64_t size; ///< Size of this struct
276 rocprofiler_pc_sampling_hw_id_v0_t hw_id; ///< @see ::rocprofiler_pc_sampling_hw_id_v0_t
277 rocprofiler_pc_t pc; ///< information about sampled program counter
278 uint64_t exec_mask; ///< active SIMD lanes when sampled
279 uint64_t timestamp; ///< timestamp when sample is generated
280 uint64_t dispatch_id; ///< originating kernel dispatch ID
282 rocprofiler_dim3_t workgroup_id; ///< wave coordinates within the workgroup
283 uint32_t wave_in_group : 8; ///< wave position within the workgroup (0-31)
284 uint32_t reserved0 : 24; ///< wave position within the workgroup (0-31)
285
286 /// @var correlation_id
287 /// @brief API launch call id that matches dispatch ID
289
290/**
291 * @brief (experimental) The header of the ::rocprofiler_pc_sampling_record_stochastic_v0_t,
292 * indicating what fields of the ::rocprofiler_pc_sampling_record_stochastic_v0_t instance are
293 * meaningful for the sample.
294 */
295typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_record_stochastic_header_t
296{
297 uint8_t has_memory_counter : 1; ///< pc sample provides memory counters information
298 ///< via ::rocprofiler_pc_sampling_memory_counters_t
299 uint8_t reserved_type : 7;
301
302/**
303 * @brief (experimental) Enumeration describing type of sampled issued instruction.
304 */
305typedef enum ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_instruction_type_t
306{
307 ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_NONE = 0,
310 ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_SCALAR, ///< scalar (memory) instruction
311 ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_TEX, ///< texture memory instruction
313 ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_LDS_DIRECT, ///< LDS direct memory instruction
318 ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_BRANCH_NOT_TAKEN,
319 ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_BRANCH_TAKEN,
321 ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_OTHER, ///< other types of instruction
323 ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_DUAL_VALU, /// dual VALU instruction
324 ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_LAST
325
326 /// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_BRANCH_NOT_TAKEN
327 /// @brief Instruction representing a branch not being taken.
328 /// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_BRANCH_TAKEN
329 /// @brief Instruction representing a taken branch.
331
332/**
333 * @brief (experimental) Enumeration describing reason for not issuing an instruction.
334 */
335typedef enum ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_instruction_not_issued_reason_t
336{
337 ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_NONE = 0,
338 ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_NO_INSTRUCTION_AVAILABLE,
339 ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ALU_DEPENDENCY,
341 ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_INTERNAL_INSTRUCTION,
343 ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ARBITER_NOT_WIN,
344 ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ARBITER_WIN_EX_STALL,
345 ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_OTHER_WAIT,
347 ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_LAST
348
349 /// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_NO_INSTRUCTION_AVAILABLE
350 /// @brief No instruction available in the instruction cache.
351 /// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ALU_DEPENDENCY
352 /// @brief ALU dependency not resolved.
353 /// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_INTERNAL_INSTRUCTION
354 /// @brief Wave executes an internal instruction.
355 /// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ARBITER_NOT_WIN
356 /// @brief The instruction did not win the arbiter.
357 /// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_ARBITER_WIN_EX_STALL
358 /// @brief Arbiter issued an instruction, but the execution pipe pushed it back from execution.
359 /// @var ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_OTHER_WAIT
360 /// @brief Other types of wait (e.g., wait for XNACK acknowledgment).
362
363/**
364 * @brief (experimental) Data provided by stochastic sampling hardware.
365 *
366 */
367typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_snapshot_v0_t
368{
369 uint32_t reason_not_issued : 4;
370 uint32_t reserved0 : 1; ///< reserved for future use
371 uint32_t arb_state_issue_valu : 1; ///< arbiter issued a VALU instruction
372 uint32_t arb_state_issue_matrix : 1; ///< arbiter issued a matrix instruction
373 uint32_t arb_state_issue_lds : 1; ///< arbiter issued a LDS instruction
374 uint32_t arb_state_issue_lds_direct : 1; ///< arbiter issued a LDS direct instruction
375 uint32_t arb_state_issue_scalar : 1; ///< arbiter issued a scalar (SALU/SMEM) instruction
376 uint32_t arb_state_issue_vmem_tex : 1; ///< arbiter issued a texture instruction
377 uint32_t arb_state_issue_flat : 1; ///< arbiter issued a FLAT instruction
378 uint32_t arb_state_issue_exp : 1; ///< arbiter issued a export instruction
379 uint32_t arb_state_issue_misc : 1; ///< arbiter issued a miscellaneous instruction
380 uint32_t arb_state_issue_brmsg : 1; ///< arbiter issued a branch/message instruction
381 uint32_t arb_state_issue_reserved : 1; ///< reserved for the future use
383 uint32_t arb_state_stall_matrix : 1; ///< matrix instruction was stalled
384 uint32_t arb_state_stall_lds : 1; ///< LDS instruction was stalled
385 uint32_t arb_state_stall_lds_direct : 1; ///< LDS direct instruction was stalled
386 uint32_t arb_state_stall_scalar : 1; ///< Scalar (SALU/SMEM) instruction was stalled
387 uint32_t arb_state_stall_vmem_tex : 1; ///< texture instruction was stalled
388 uint32_t arb_state_stall_flat : 1; ///< flat instruction was stalled
389 uint32_t arb_state_stall_exp : 1; ///< export instruction was stalled
390 uint32_t arb_state_stall_misc : 1; ///< miscellaneous instruction was stalled
391 uint32_t arb_state_stall_brmsg : 1; ///< branch/message instruction was stalled
392 uint32_t arb_state_state_reserved : 1; ///< reserved for the future use
393 // We have two reserved bits
394 uint32_t dual_issue_valu : 1;
396 uint32_t reserved2 : 3; ///< reserved for the future use
397
398 /// @var reason_not_issued
399 /// @brief The reason for not issuing an instruction. The field takes one of the value defined
400 /// in ::rocprofiler_pc_sampling_instruction_not_issued_reason_t
401 /// @var arb_state_stall_valu
402 /// @brief VALU instruction was stalled when a sample was generated
403 /// @var dual_issue_valu
404 /// @brief Two VALU instructions were issued for coexecution (MI3xx specific)
405 /// @var sampling_lock_error
406 /// @brief At least one wave was locked out from taking a sample,
407 /// due to the latency introduced by current sample read.
408 /// Too many samples with this bit on indicates that the sampling frequency is too high
410
411/**
412 * @brief (experimental) Counters of issued but not yet completed instructions.
413 */
414typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_memory_counters_t
415{
416 uint64_t load_cnt : 6;
417 uint64_t store_cnt : 6;
418 uint64_t bvh_cnt : 3;
419 uint64_t sample_cnt : 6;
420 uint64_t ds_cnt : 6;
421 uint64_t km_cnt : 5;
422 // The following counters are relevant for gfx1250 only.
423 uint64_t async_cnt : 6;
424 uint64_t tensor_cnt : 6;
425 uint64_t xnack_cnt : 6;
426 uint64_t reserved : 14; ///< reserved for the future use
427
428 /// @var load_cnt
429 /// @brief Counts the number of VMEM load instructions issued but not yet completed.
430 /// @var store_cnt
431 /// @brief Counts the number of VMEM store instructions issued but not yet completed.
432 /// @var bvh_cnt
433 /// @brief Counts the number of VMEM BVH instructions issued but not yet completed.
434 /// @var sample_cnt
435 /// @brief Counts the number of VMEM sample instructions issued but not yet completed.
436 /// @var ds_cnt
437 /// @brief Counts the number of LDS instructions issued but not yet completed.
438 /// @var km_cnt
439 /// @brief Counts the number of scalar memory reads and memory instructions issued but not yet
440 /// completed.
441 /// @var async_cnt
442 /// @brief Counts the number of async instructions issued but not yet completed.
443 /// @var tensor_cnt
444 /// @brief Counts the number of tensor instructions issued but not yet completed.
445 /// @var xnack_cnt
446 /// @brief Counts the number of outstanding memory instructions not yet reported
447 /// XNACK acknowledgment.
449
450/**
451 * @brief (experimental) ROCProfiler Stochastic PC Sampling Record.
452 */
453typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_record_stochastic_v0_t
454{
455 uint64_t size; ///< Size of this struct
458 uint8_t wave_issued : 1;
459 uint8_t inst_type : 5;
460 uint8_t reserved : 2;
463 uint64_t exec_mask;
465 uint32_t wave_count;
466 uint64_t timestamp;
467 uint64_t dispatch_id;
471
472 /// @var flags
473 /// @brief Defines what fields are meaningful for the sample.
474 /// @var wave_in_group
475 /// @brief wave position within the workgroup (0-15)
476 /// @var wave_issued
477 /// @brief wave issued the instruction represented with the PC
478 /// @var inst_type
479 /// @brief instruction type, takes a value defined in @ref
480 /// ::rocprofiler_pc_sampling_instruction_type_t
481 /// @var reserved
482 /// @brief reserved 2 bits must be zero
483 /// @var hw_id
484 /// @brief @see ::rocprofiler_pc_sampling_hw_id_v0_t
485 /// @var pc
486 /// @brief information about sampled program counter
487 /// @var exec_mask
488 /// @brief active SIMD lanes at the moment of sampling
489 /// @var workgroup_id
490 /// @brief wave coordinates within the workgroup
491 /// @var wave_count
492 /// @brief active waves on the CU at the moment of sampling
493 /// @var timestamp
494 /// @brief timestamp when sample is generated
495 /// @var dispatch_id
496 /// @brief originating kernel dispatch ID
497 /// @var correlation_id
498 /// @brief API launch call id that matches dispatch ID
499 /// @var snapshot
500 /// @brief Data provided by stochastic sampling hardware. @see
501 /// ::rocprofiler_pc_sampling_snapshot_v0_t
502 /// @var memory_counters
503 /// @brief Counters of issued but not yet completed instructions. @see
504 /// ::rocprofiler_pc_sampling_memory_counters_t
506
507/**
508 * @brief (experimental) Record representing an invalid PC Sampling Record.
509 */
510typedef struct ROCPROFILER_SDK_EXPERIMENTAL rocprofiler_pc_sampling_record_invalid_t
511{
512 uint64_t size; ///< Size of the struct
514
515/**
516 * @brief (experimental) Return the string encoding of ::rocprofiler_pc_sampling_instruction_type_t
517 * value
518 * @param [in] instruction_type instruction type enum value
519 * @return Will return a nullptr if invalid/unsupported ::rocprofiler_pc_sampling_instruction_type_t
520 * value is provided.
521 */
522ROCPROFILER_SDK_EXPERIMENTAL
523const char*
525 rocprofiler_pc_sampling_instruction_type_t instruction_type) ROCPROFILER_API;
526
527/**
528 * @brief (experimental) Return the string encoding of
529 * ::rocprofiler_pc_sampling_instruction_not_issued_reason_t value
530 * @param [in] not_issued_reason no issue reason enum value
531 * @return Will return a nullptr if invalid/unsupported
532 * ::rocprofiler_pc_sampling_instruction_not_issued_reason_t value is provided.
533 */
534ROCPROFILER_SDK_EXPERIMENTAL const char*
536 rocprofiler_pc_sampling_instruction_not_issued_reason_t not_issued_reason) ROCPROFILER_API;
537
538/** @} */
539
540ROCPROFILER_EXTERN_C_FINI
rocprofiler_pc_sampling_method_t
PC Sampling Method.
Definition fwd.h:390
rocprofiler_pc_sampling_unit_t
PC Sampling Unit.
Definition fwd.h:401
rocprofiler_status_t
Status codes.
Definition fwd.h:49
Agent Identifier.
Definition fwd.h:743
ROCProfiler Correlation ID record for async activity.
Definition fwd.h:709
Context ID.
Definition fwd.h:648
Multi-dimensional struct of data used to describe GPU workgroup and grid sizes.
Definition fwd.h:768
uint32_t arb_state_stall_exp
export instruction was stalled
uint32_t arb_state_stall_valu
VALU instruction was stalled when a sample was generated.
rocprofiler_pc_sampling_snapshot_v0_t snapshot
Data provided by stochastic sampling hardware.
uint64_t timestamp
timestamp when sample is generated
uint32_t arb_state_stall_misc
miscellaneous instruction was stalled
uint32_t arb_state_issue_lds_direct
arbiter issued a LDS direct instruction
uint32_t arb_state_issue_exp
arbiter issued a export instruction
uint8_t wave_in_group
wave position within the workgroup (0-15)
uint64_t reserved0
Reserved for the future use.
uint64_t shader_array_id
Shared array index.
rocprofiler_async_correlation_id_t correlation_id
API launch call id that matches dispatch ID.
rocprofiler_pc_sampling_memory_counters_t memory_counters
Counters of issued but not yet completed instructions.
uint32_t arb_state_stall_flat
flat instruction was stalled
uint64_t sample_cnt
Counts the number of VMEM sample instructions issued but not yet completed.
uint64_t tensor_cnt
Counts the number of tensor instructions issued but not yet completed.
uint64_t size
Size of this struct.
uint64_t bvh_cnt
Counts the number of VMEM BVH instructions issued but not yet completed.
uint32_t arb_state_issue_lds
arbiter issued a LDS instruction
uint64_t size
Size of the struct.
uint64_t timestamp
timestamp when sample is generated
uint32_t sampling_lock_error
At least one wave was locked out from taking a sample, due to the latency introduced by current sampl...
uint64_t code_object_id
id of the loaded code object instance that contains sampled PC. This fields holds the value ROCPROFIL...
uint32_t arb_state_issue_valu
arbiter issued a VALU instruction
uint64_t workgroup_id
thread_group index on GFX9, and workgroup index on GFX10+
uint64_t xnack_cnt
Counts the number of outstanding memory instructions not yet reported XNACK acknowledgment.
uint8_t reserved
reserved 2 bits must be zero
uint64_t dispatch_id
originating kernel dispatch ID
uint32_t wave_count
active waves on the CU at the moment of sampling
uint32_t arb_state_issue_matrix
arbiter issued a matrix instruction
uint32_t arb_state_issue_brmsg
arbiter issued a branch/message instruction
rocprofiler_pc_t pc
information about sampled program counter
uint32_t arb_state_stall_scalar
Scalar (SALU/SMEM) instruction was stalled.
uint64_t reserved
reserved for the future use
uint32_t arb_state_stall_matrix
matrix instruction was stalled
uint32_t reserved0
wave position within the workgroup (0-31)
uint64_t dispatch_id
originating kernel dispatch ID
uint64_t microengine_id
ACE (microengine) index.
uint64_t shader_engine_id
shared engine index
uint64_t exec_mask
active SIMD lanes when sampled
rocprofiler_pc_sampling_hw_id_v0_t hw_id
uint32_t dual_issue_valu
Two VALU instructions were issued for coexecution (MI3xx specific)
uint32_t arb_state_issue_scalar
arbiter issued a scalar (SALU/SMEM) instruction
uint64_t flags
take values from rocprofiler_pc_sampling_configuration_flags_t
uint32_t reserved2
reserved for the future use
rocprofiler_pc_sampling_record_stochastic_header_t flags
Defines what fields are meaningful for the sample.
rocprofiler_pc_t pc
information about sampled program counter
uint32_t wave_in_group
wave position within the workgroup (0-31)
rocprofiler_pc_sampling_method_t method
Sampling method supported by the GPU agent. Currently, it can take one of the following two values:
unsigned long max_interval
the lowest possible frequency for generating samples using method
uint64_t ds_cnt
Counts the number of LDS instructions issued but not yet completed.
uint64_t chiplet
chiplet index (3 bits allocated by the ROCr runtime)
uint64_t cu_or_wgp_id
Compute unit index on GFX9 or workgroup processor index on GFX10+.
rocprofiler_dim3_t workgroup_id
wave coordinates within the workgroup
uint32_t arb_state_state_reserved
reserved for the future use
uint8_t wave_issued
wave issued the instruction represented with the PC
unsigned long min_interval
the highest possible frequency for generating samples using method.
uint32_t arb_state_stall_lds
LDS instruction was stalled.
rocprofiler_async_correlation_id_t correlation_id
API launch call id that matches dispatch ID.
uint32_t arb_state_issue_flat
arbiter issued a FLAT instruction
uint32_t arb_state_stall_brmsg
branch/message instruction was stalled
uint32_t reason_not_issued
The reason for not issuing an instruction. The field takes one of the value defined in rocprofiler_pc...
uint64_t exec_mask
active SIMD lanes at the moment of sampling
rocprofiler_dim3_t workgroup_id
wave coordinates within the workgroup
uint64_t wave_id
wave slot index
uint8_t has_memory_counter
pc sample provides memory counters information via rocprofiler_pc_sampling_memory_counters_t
uint32_t arb_state_stall_vmem_tex
texture instruction was stalled
uint64_t km_cnt
Counts the number of scalar memory reads and memory instructions issued but not yet completed.
uint32_t arb_state_issue_vmem_tex
arbiter issued a texture instruction
uint64_t async_cnt
Counts the number of async instructions issued but not yet completed.
uint64_t vm_id
virtual memory ID
uint32_t arb_state_stall_lds_direct
LDS direct instruction was stalled.
uint32_t arb_state_issue_reserved
reserved for the future use
uint32_t arb_state_issue_misc
arbiter issued a miscellaneous instruction
rocprofiler_pc_sampling_hw_id_v0_t hw_id
uint64_t load_cnt
Counts the number of VMEM load instructions issued but not yet completed.
uint64_t store_cnt
Counts the number of VMEM store instructions issued but not yet completed.
uint32_t reserved0
reserved for future use
uint64_t code_object_offset
If code_object_id is different than ROCPROFILER_CODE_OBJECT_ID_NONE, then this field contains the off...
rocprofiler_pc_sampling_unit_t unit
A unit used to specify the interval of the method for samples generation.
uint8_t inst_type
instruction type, takes a value defined in rocprofiler_pc_sampling_instruction_type_t
rocprofiler_pc_sampling_configuration_flags_t
(experimental) Enumeration describing values of flags of rocprofiler_pc_sampling_configuration_t.
rocprofiler_status_t(* rocprofiler_available_pc_sampling_configurations_cb_t)(const rocprofiler_pc_sampling_configuration_t *configs, unsigned long num_config, void *user_data)
(experimental) Rocprofiler SDK's callback function to deliver the list of available PC sampling confi...
rocprofiler_pc_sampling_instruction_not_issued_reason_t
(experimental) Enumeration describing reason for not issuing an instruction.
const char * rocprofiler_get_pc_sampling_instruction_type_name(rocprofiler_pc_sampling_instruction_type_t instruction_type)
(experimental) Return the string encoding of rocprofiler_pc_sampling_instruction_type_t value
rocprofiler_status_t rocprofiler_configure_pc_sampling_service(rocprofiler_context_id_t context_id, rocprofiler_agent_id_t agent_id, rocprofiler_pc_sampling_method_t method, rocprofiler_pc_sampling_unit_t unit, uint64_t interval, rocprofiler_buffer_id_t buffer_id, int flags)
(experimental) Function used to configure the PC sampling service on the GPU agent with agent_id.
rocprofiler_status_t rocprofiler_query_pc_sampling_agent_configurations(rocprofiler_agent_id_t agent_id, rocprofiler_available_pc_sampling_configurations_cb_t cb, void *user_data)
(experimental) Query PC Sampling Configuration.
rocprofiler_pc_sampling_instruction_type_t
(experimental) Enumeration describing type of sampled issued instruction.
const char * rocprofiler_get_pc_sampling_instruction_not_issued_reason_name(rocprofiler_pc_sampling_instruction_not_issued_reason_t not_issued_reason)
(experimental) Return the string encoding of rocprofiler_pc_sampling_instruction_not_issued_reason_t ...
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_SLEEP_WAIT
wave was sleeping
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_BARRIER_WAIT
waiting on a barrier
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_NOT_ISSUED_REASON_WAITCNT
waitcnt dependency
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_LDS
LDS memory instruction.
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_BARRIER
barrier instruction
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_OTHER
other types of instruction
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_MATRIX
matrix instruction
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_TEX
texture memory instruction
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_NO_INST
no instruction issued
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_MESSAGE
message instruction
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_EXPORT
export instruction
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_SCALAR
scalar (memory) instruction
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_VALU
vector ALU instruction
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_LDS_DIRECT
LDS direct memory instruction.
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_JUMP
jump instruction
@ ROCPROFILER_PC_SAMPLING_INSTRUCTION_TYPE_FLAT
flat memory instruction
(experimental) PC sampling configuration supported by a GPU agent.
(experimental) Information about the GPU part where wave was executing at the moment of sampling.
(experimental) Counters of issued but not yet completed instructions.
(experimental) ROCProfiler Host-Trap PC Sampling Record.
(experimental) Record representing an invalid PC Sampling Record.
(experimental) The header of the rocprofiler_pc_sampling_record_stochastic_v0_t, indicating what fiel...
(experimental) ROCProfiler Stochastic PC Sampling Record.
(experimental) Data provided by stochastic sampling hardware.
(experimental) Sampled program counter.