Adding new trace decoder record types and new ATT parameters (#195)

* Adding new trace decoder record types and new ATT parameters

* Add compatiblity with decoder 0.1.2

* Added RT

* Format

* Add logging to sdata values

* Review comment

* Review comments

* Update projects/rocprofiler-sdk/source/include/rocprofiler-sdk/experimental/thread-trace/trace_decoder_types.h
This commit is contained in:
Giovanni Lenzi Baraldi
2025-08-12 14:31:12 +02:00
committed by GitHub
parent 83971da05e
commit cb77f5af5c
13 changed files with 213 additions and 86 deletions
@@ -1663,7 +1663,9 @@ ROCPROFILER_ENUM_LABEL(ROCPROFILER_THREAD_TRACE_PARAMETER_SIMD_SELECT);
ROCPROFILER_ENUM_LABEL(ROCPROFILER_THREAD_TRACE_PARAMETER_PERFCOUNTERS_CTRL);
ROCPROFILER_ENUM_LABEL(ROCPROFILER_THREAD_TRACE_PARAMETER_PERFCOUNTER);
ROCPROFILER_ENUM_LABEL(ROCPROFILER_THREAD_TRACE_PARAMETER_SERIALIZE_ALL);
static_assert(ROCPROFILER_THREAD_TRACE_PARAMETER_LAST == 7);
ROCPROFILER_ENUM_LABEL(ROCPROFILER_THREAD_TRACE_PARAMETER_PERFCOUNTER_EXCLUDE_MASK);
ROCPROFILER_ENUM_LABEL(ROCPROFILER_THREAD_TRACE_PARAMETER_NO_DETAIL);
static_assert(ROCPROFILER_THREAD_TRACE_PARAMETER_LAST == 9);
ROCPROFILER_ENUM_LABEL(ROCPROFILER_THREAD_TRACE_CONTROL_NONE);
ROCPROFILER_ENUM_LABEL(ROCPROFILER_THREAD_TRACE_CONTROL_START_AND_STOP);
@@ -47,9 +47,14 @@ typedef enum rocprofiler_thread_trace_parameter_type_t
ROCPROFILER_THREAD_TRACE_PARAMETER_BUFFER_SIZE, ///< Size of combined GPU buffer for ATT
ROCPROFILER_THREAD_TRACE_PARAMETER_SIMD_SELECT, ///< Bitmask (GFX9) or ID (Navi) of SIMDs
ROCPROFILER_THREAD_TRACE_PARAMETER_PERFCOUNTERS_CTRL, ///< Period [1,32] or disable (0) perfmon
ROCPROFILER_THREAD_TRACE_PARAMETER_PERFCOUNTER, ///< Perfmon ID and SIMD mask
ROCPROFILER_THREAD_TRACE_PARAMETER_SERIALIZE_ALL, ///< Serializes kernels not under thread
///< trace
ROCPROFILER_THREAD_TRACE_PARAMETER_PERFCOUNTER, ///< Perfmon ID and SIMD mask. gfx9 only
ROCPROFILER_THREAD_TRACE_PARAMETER_SERIALIZE_ALL, ///< Serializes also kernels not under
///< thread trace
ROCPROFILER_THREAD_TRACE_PARAMETER_PERFCOUNTER_EXCLUDE_MASK, ///< Bitmask of which compute
///< units to exclude from
///< perfcounters. gfx9 only
ROCPROFILER_THREAD_TRACE_PARAMETER_NO_DETAIL, ///< Dont collect instruction timing,
///< only shader-wide information
ROCPROFILER_THREAD_TRACE_PARAMETER_LAST
} rocprofiler_thread_trace_parameter_type_t;
@@ -40,6 +40,7 @@ typedef enum rocprofiler_thread_trace_decoder_info_t
ROCPROFILER_THREAD_TRACE_DECODER_INFO_NONE = 0,
ROCPROFILER_THREAD_TRACE_DECODER_INFO_DATA_LOST,
ROCPROFILER_THREAD_TRACE_DECODER_INFO_STITCH_INCOMPLETE,
ROCPROFILER_THREAD_TRACE_DECODER_INFO_WAVE_INCOMPLETE,
ROCPROFILER_THREAD_TRACE_DECODER_INFO_LAST
} rocprofiler_thread_trace_decoder_info_t;
@@ -76,7 +77,7 @@ typedef struct rocprofiler_thread_trace_decoder_occupancy_t
uint8_t reserved; ///< Reserved
uint8_t cu; ///< Compute unit ID (gfx9) or WGP ID (gfx10+).
uint8_t simd; ///< SIMD ID [0,3] within compute unit
uint8_t slot; ///< Wave slot ID within SIMD
uint8_t wave_id; ///< Wave slot ID within SIMD
uint32_t start : 1; ///< 1 if wave_start, 0 if a wave_end
uint32_t _rsvd : 31;
} rocprofiler_thread_trace_decoder_occupancy_t;
@@ -168,6 +169,49 @@ typedef struct rocprofiler_thread_trace_decoder_wave_t
rocprofiler_thread_trace_decoder_inst_t* instructions_array; ///< Instructions executed
} rocprofiler_thread_trace_decoder_wave_t;
/**
* @brief Matches the reference (realtime) clock with the shader clock
* Added in rocprof-trace-decoder 0.1.3. Requires aqlprofile for rocm 7.1+.
* clock_in_seconds = realtime_clock / ROCPROFILER_THREAD_TRACE_DECODER_RECORD_RT_FREQUENCY
* gfx_frequency = delta(shader_clock) / delta(clock_in_seconds)
* For best average, use
* gfx_frequency[n] = (shader_clock[n]-shader_clock[0]) / (clock_in_seconds[n]-clock_in_seconds[0])
*/
typedef struct rocprofiler_thread_trace_decoder_realtime_t
{
int64_t shader_clock; ///< Clock timestamp in gfx clock units
uint64_t realtime_clock; ///< Clock timestamp in realtime units
uint64_t reserved;
} rocprofiler_thread_trace_decoder_realtime_t;
/**
* @brief Bitmask of additional information for shaderdata_t
* Added in rocprof-trace-decoder 0.1.3
*/
typedef enum rocprofiler_thread_trace_decoder_shaderdata_flags_t
{
ROCPROFILER_THREAD_TRACE_DECODER_SHADERDATA_FLAGS_IMM = 0,
ROCPROFILER_THREAD_TRACE_DECODER_SHADERDATA_FLAGS_PRIV ///< Generated by the trap handler
/// @var ROCPROFILER_THREAD_TRACE_DECODER_SHADERDATA_FLAGS_IMM
/// @brief Value comes from s_ttracedata_imm.
} rocprofiler_thread_trace_decoder_shaderdata_flags_t;
/**
* @brief Record created by s_ttracedata and s_ttracedata_imm
* Added in rocprof-trace-decoder 0.1.3
*/
typedef struct rocprofiler_thread_trace_decoder_shaderdata_t
{
int64_t time;
uint64_t value; ///< Value written from M0/IMM
uint8_t cu; ///< CU id (gfx9) or wgp id (gfx10+). This is always the target_cu.
uint8_t simd; ///< SIMD ID [0,3].
uint8_t wave_id; ///< Wave slot ID within SIMD.
uint8_t flags; ///< bitmask of rocprofiler_thread_trace_decoder_shaderdata_flags_t
uint32_t reserved;
} rocprofiler_thread_trace_decoder_shaderdata_t;
/**
* @brief Defines the type of payload received by rocprofiler_thread_trace_decoder_callback_t
*/
@@ -179,7 +223,13 @@ typedef enum rocprofiler_thread_trace_decoder_record_type_t
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_WAVE, ///< rocprofiler_thread_trace_decoder_wave_t*
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_INFO, ///< rocprofiler_thread_trace_decoder_info_t*
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_DEBUG, ///< Debug
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_SHADERDATA, ///< rocprofiler_thread_trace_decoder_shaderdata_t*
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_REALTIME, ///< rocprofiler_thread_trace_decoder_realtime_t*
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_RT_FREQUENCY,
ROCPROFILER_THREAD_TRACE_DECODER_RECORD_LAST
/// @var ROCPROFILER_THREAD_TRACE_DECODER_RECORD_RT_FREQUENCY
/// @brief uint64_t*. Realtime clock frequency in Hz.
} rocprofiler_thread_trace_decoder_record_type_t;
/** @} */