Host trap PC sampling uses new record type (#1207)
* Host trap PC sampling uses new record type * removing redundant field * formatting * simplifying templates in the parser - no need for HostTrap boolean * reviving some parser tests * hw_id decoding on GFX9 * HW id parser test * parser CID test * Parser multigpu test * removing rocprofiler_pc_sampling_record_t and some fields from hw_id * simplifying parser context * keep bench test internally * initializing gfx9_hw_id_t differently * anonymous struct first * avoiding inlining initialization of struct
This commit is contained in:
@@ -439,7 +439,8 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
ROCPROFILER_PC_SAMPLING_RECORD_NONE = 0,
|
||||
ROCPROFILER_PC_SAMPLING_RECORD_SAMPLE, ///< ::rocprofiler_pc_sampling_record_t
|
||||
ROCPROFILER_PC_SAMPLING_RECORD_HOST_TRAP_V0_SAMPLE, ///< ::rocprofiler_pc_sampling_record_host_trap_v0_t
|
||||
ROCPROFILER_PC_SAMPLING_RECORD_STOCHASTIC_V0_SAMPLE, ///< for the future use
|
||||
ROCPROFILER_PC_SAMPLING_RECORD_LAST,
|
||||
} rocprofiler_pc_sampling_record_kind_t;
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ ROCPROFILER_EXTERN_C_INIT
|
||||
* @param [in] unit - The unit appropriate to the PC sampling type/method.
|
||||
* @param [in] interval - frequency at which PC samples are generated
|
||||
* @param [in] buffer_id - id of the buffer used for delivering PC samples
|
||||
* @param [in] flags - for future use
|
||||
* @return ::rocprofiler_status_t
|
||||
* @retval ::ROCPROFILER_STATUS_SUCCESS PC sampling service configured successfully
|
||||
* @retval ::ROCPROFILER_STATUS_ERROR_NOT_AVAILABLE One of the scenarios is present:
|
||||
@@ -117,7 +118,8 @@ rocprofiler_configure_pc_sampling_service(rocprofiler_context_id_t conte
|
||||
rocprofiler_pc_sampling_method_t method,
|
||||
rocprofiler_pc_sampling_unit_t unit,
|
||||
uint64_t interval,
|
||||
rocprofiler_buffer_id_t buffer_id) ROCPROFILER_API;
|
||||
rocprofiler_buffer_id_t buffer_id,
|
||||
int flags) ROCPROFILER_API;
|
||||
|
||||
/**
|
||||
* @brief PC sampling configuration supported by a GPU agent.
|
||||
@@ -195,122 +197,69 @@ rocprofiler_query_pc_sampling_agent_configurations(
|
||||
void* user_data) ROCPROFILER_API ROCPROFILER_NONNULL(2, 3);
|
||||
|
||||
/**
|
||||
* @brief The header of the @ref rocprofiler_pc_sampling_record_t, indicating
|
||||
* what fields of the @ref rocprofiler_pc_sampling_record_t instance are meaningful
|
||||
* for the sample.
|
||||
* @brief Information about the GPU part where wave was executing
|
||||
* at the moment of sampling.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct rocprofiler_pc_sampling_hw_id_v0_t
|
||||
{
|
||||
uint8_t valid : 1; /// ::rocprofiler_pc_sampling_snapshot_v1_t field is valid
|
||||
uint8_t type : 4;
|
||||
uint8_t has_stall_reason : 1;
|
||||
uint8_t has_wave_cnt : 1;
|
||||
uint8_t reserved : 1; /// for future use
|
||||
|
||||
/// @var type
|
||||
/// @brief The following values are possible:
|
||||
/// - 0 - reserved
|
||||
/// - 1 - host trap pc sample
|
||||
/// - 2 - stochastic pc sample
|
||||
/// - 3 - perfcounter (unsupported at the moment)
|
||||
/// - other values does not mean anything at the moment
|
||||
/// @var has_stall_reason
|
||||
/// @brief whether the sample contains information about the stall reason.
|
||||
/// If so, please @see rocprofiler_pc_sampling_snapshot_v1_t.
|
||||
/// @var has_wave_cnt
|
||||
/// @brief whether the @ref rocprofiler_pc_sampling_record_t::wave_count
|
||||
/// contains meaningful value
|
||||
} rocprofiler_pc_sampling_header_v1_t;
|
||||
|
||||
/**
|
||||
* @brief For future use.
|
||||
*
|
||||
* @todo: Provide the description
|
||||
* @todo: Should we use bitfields because of C ABI portability?
|
||||
* @todo: Should we abstract this to be architecture agnostic?
|
||||
* @todo: Consider having a query to determine organization of this information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t dual_issue_valu : 1;
|
||||
uint32_t inst_type : 4;
|
||||
uint32_t reason_not_issued : 7;
|
||||
uint32_t arb_state_issue : 10;
|
||||
uint32_t arb_state_stall : 10;
|
||||
} rocprofiler_pc_sampling_snapshot_v1_t;
|
||||
uint64_t chiplet : 6; ///< chiplet index (3 bits allocated by the ROCr runtime)
|
||||
uint64_t wave_id : 7; ///< wave slot index
|
||||
uint64_t simd_id : 2; ///< SIMD index
|
||||
uint64_t pipe_id : 4; ///< pipe index
|
||||
uint64_t cu_or_wgp_id : 4; ///< Index of compute unit on GFX9 or workgroup processer on other
|
||||
///< architectures
|
||||
uint64_t shader_array_id : 1; ///< Shared array index
|
||||
uint64_t shader_engine_id : 5; ///< shared engine index
|
||||
uint64_t workgroup_id : 7; ///< thread_group index on GFX9, and workgroup index on GFX10+
|
||||
uint64_t vm_id : 6; ///< virtual memory ID
|
||||
uint64_t queue_id : 4; ///< queue id
|
||||
uint64_t microengine_id : 2; ///< ACE (microengine) index
|
||||
uint64_t reserved0 : 16; ///< Reserved for the future use
|
||||
} rocprofiler_pc_sampling_hw_id_v0_t;
|
||||
|
||||
/**
|
||||
* @brief Sampled program counter.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t loaded_code_object_id;
|
||||
uint64_t loaded_code_object_offset;
|
||||
uint64_t code_object_id;
|
||||
uint64_t code_object_offset;
|
||||
|
||||
/// @var loaded_code_object_id
|
||||
/// @var code_object_id
|
||||
/// @brief id of the loaded code object instance that contains sampled PC.
|
||||
/// This fields holds the value ::ROCPROFILER_CODE_OBJECT_ID_NONE
|
||||
/// if the code object cannot be determined
|
||||
/// (e.g., sampled PC belongs to code generated by self modifying code).
|
||||
/// @var loaded_code_object_offset
|
||||
/// @brief If @ref loaded_code_object_id is different than ::ROCPROFILER_CODE_OBJECT_ID_NONE,
|
||||
/// @var code_object_offset
|
||||
/// @brief If @ref code_object_id is different than ::ROCPROFILER_CODE_OBJECT_ID_NONE,
|
||||
/// then this field contains the offset of the sampled PC relative to the
|
||||
/// ::rocprofiler_callback_tracing_code_object_load_data_t::load_base
|
||||
/// of the code object instance with @ref loaded_code_object_id.
|
||||
/// of the code object instance with @ref code_object_id.
|
||||
/// To calculate the original virtual address of the sampled PC, one can add the value
|
||||
/// of this field to the ::rocprofiler_callback_tracing_code_object_load_data_t::load_base.
|
||||
/// The value of @ref loaded_code_object_offset matches
|
||||
/// The value of @ref code_object_offset matches
|
||||
/// the virtual address of the sampled instruction (PC), only if the
|
||||
/// @ref loaded_code_object_id is equal to the ::ROCPROFILER_CODE_OBJECT_ID_NONE.
|
||||
/// @ref code_object_id is equal to the ::ROCPROFILER_CODE_OBJECT_ID_NONE.
|
||||
} rocprofiler_pc_t;
|
||||
|
||||
// TODO: The definition of this structure might change over time
|
||||
// to reduce the space needed to represent a single sample.
|
||||
// TODO: The definition of this struct might change over time.
|
||||
/**
|
||||
* @brief ROCProfiler PC Sampling Record corresponding to the interrupted wave.
|
||||
* @brief ROCProfiler Host-Trap PC Sampling Record.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct rocprofiler_pc_sampling_record_host_trap_v0_t
|
||||
{
|
||||
uint64_t size; ///< Size of this struct
|
||||
rocprofiler_pc_sampling_header_v1_t flags;
|
||||
uint8_t chiplet; ///< chiplet index
|
||||
uint8_t wave_id; ///< wave identifier within the workgroup
|
||||
uint8_t wave_issued : 1;
|
||||
uint8_t reserved : 7; ///< reserved 7 bits, must be zero
|
||||
uint32_t hw_id; ///< compute unit identifier
|
||||
rocprofiler_pc_t pc; ///< information about sampled program counter
|
||||
uint64_t exec_mask;
|
||||
rocprofiler_dim3_t workgroup_id; ///< wave coordinates within the workgroup
|
||||
uint32_t wave_count;
|
||||
uint64_t timestamp; ///< timestamp when sample is generated
|
||||
rocprofiler_correlation_id_t correlation_id;
|
||||
rocprofiler_pc_sampling_snapshot_v1_t
|
||||
snapshot; ///< @see ::rocprofiler_pc_sampling_snapshot_v1_t
|
||||
uint32_t reserved2; ///< for future use
|
||||
|
||||
/// @var flags
|
||||
/// @brief indicates what fields of this struct are meaningful for the represented sample.
|
||||
/// The values depend on what the underlying GPU agent architecture supports.
|
||||
/// @var wave_issued
|
||||
/// @brief indicates whether the wave is issueing the instruction represented by the @ref pc
|
||||
/// @var exec_mask
|
||||
/// @brief shows how many SIMD lanes of the wave were executing the instruction
|
||||
/// represented by the @ref pc. Useful to understand thread-divergance within the wave
|
||||
/// @var wave_count
|
||||
/// @brief number of active waves on the CU at the moment of sample generation
|
||||
/// @var correlation_id
|
||||
/// @brief correlation id of the API call that initiated a dispatch of the kernel
|
||||
/// during whose execution the wave was interrupted at @ref pc.
|
||||
} rocprofiler_pc_sampling_record_t;
|
||||
uint64_t size; ///< Size of this struct
|
||||
rocprofiler_pc_sampling_hw_id_v0_t hw_id; ///< @see ::rocprofiler_pc_sampling_hw_id_0_t
|
||||
rocprofiler_pc_t pc; ///< information about sampled program counter
|
||||
uint64_t exec_mask; ///< active SIMD lanes when sampled
|
||||
uint64_t timestamp; ///< timestamp when sample is generated
|
||||
uint64_t dispatch_id; ///< originating kernel dispatch ID
|
||||
rocprofiler_correlation_id_t correlation_id; ///< API launch call id that matches dispatch ID
|
||||
rocprofiler_dim3_t workgroup_id; ///< wave coordinates within the workgroup
|
||||
uint32_t wave_in_group : 8; ///< wave position within the workgroup (0-31)
|
||||
uint32_t reserved0 : 24; ///< wave position within the workgroup (0-31)
|
||||
} rocprofiler_pc_sampling_record_host_trap_v0_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
ROCPROFILER_EXTERN_C_FINI
|
||||
|
||||
ROCPROFILER_CXX_CODE(
|
||||
static_assert(sizeof(rocprofiler_pc_sampling_record_t) == 88,
|
||||
"Increasing the size of the pc sampling record is not permitted."));
|
||||
|
||||
ROCPROFILER_CXX_CODE(static_assert(offsetof(rocprofiler_pc_sampling_record_t, chiplet) == 9 &&
|
||||
offsetof(rocprofiler_pc_sampling_record_t, reserved2) == 84,
|
||||
"PC sampling record layout changed."));
|
||||
|
||||
Viittaa uudesa ongelmassa
Block a user