rocprofiler_kernel_dispatch_info_t + header record for buffered counter collection (#758)

* Update include/rocprofiler-sdk

- defines.h
  - ROCPROFILER_VERSION_10_0 -> ROCPROFILER_SDK_VERSION_0_0
- fwd.h
  - rocprofiler_counter_record_kind_t
  - rocprofiler_kernel_dispatch_info_t
  - rocprofiler_record_counter_t
    - has dispatch id instead of correlation id
  - rocprofiler_counter_info_v0_t
    - added rocprofiler_counter_id_t field
    - added is_constant field
    - reordered better packing
- dispatch_profile.h
  - added rocprofiler_profile_counting_dispatch_record_t for use as a header record for rocprofiler_profile_counting_dispatch_data_t
- callback_tracing.h
  - rocprofiler_callback_tracing_kernel_dispatch_data_t uses rocprofiler_kernel_dispatch_info_t
- buffer_tracing.h
  - rocprofiler_buffer_tracing_kernel_dispatch_record_t uses rocprofiler_kernel_dispatch_info_t

* Update lib/rocprofiler-sdk/*

- transition to rocprofiler_kernel_dispatch_info_t
- set id and is_constant values for rocprofiler_counter_info_v0_t in rocprofiler_query_counter_info

* Update lib/rocprofiler-sdk-tool

- transition to rocprofiler_kernel_dispatch_info_t

* Update lib/rocprofiler-sdk/counters/tests/core.cpp

- transition to rocprofiler_kernel_dispatch_info_t

* Update samples

- transition to rocprofiler_kernel_dispatch_info_t
- transition to rocprofiler_counter_record_kind_t

* Update tests

- transition to rocprofiler_kernel_dispatch_info_t
- transition to rocprofiler_counter_record_kind_t
- improve integration test validation for counter-collection
- update serialization for new/additional types

* Fix tests/counter-collection/validate.py

- loosen restrictions on the length of counter description

* Update include/rocprofiler-sdk/buffer_tracing.h

- remove accidental packed attribute

* Update lib/rocprofiler-sdk/counters/xml/derived_counters.xml

- Add description for TCC_TAG_STALL_sum (reference: https://rocm.docs.amd.com/en/develop/conceptual/gpu-arch/mi300-mi200-performance-counters.html)

* Update tests/page-migration/validate.py
This commit is contained in:
Jonathan R. Madsen
2024-04-12 17:30:34 -05:00
کامیت شده توسط GitHub
والد fd3d97287c
کامیت 07537b6231
23فایلهای تغییر یافته به همراه489 افزوده شده و 273 حذف شده
@@ -99,8 +99,9 @@ typedef struct
/// ::ROCPROFILER_CALLBACK_TRACING_HSA_IMAGE_EXT_API, or
/// ::ROCPROFILER_CALLBACK_TRACING_HSA_FINALIZE_EXT_API
/// @var operation
/// @brief ::rocprofiler_hsa_core_api_id_t, ::rocprofiler_hsa_amd_ext_api_id_t,
/// ::rocprofiler_hsa_image_ext_api_id_t, or ::rocprofiler_hsa_finalize_ext_api_id_t
/// @brief Specification of the API function, e.g., ::rocprofiler_hsa_core_api_id_t,
/// ::rocprofiler_hsa_amd_ext_api_id_t, ::rocprofiler_hsa_image_ext_api_id_t, or
/// ::rocprofiler_hsa_finalize_ext_api_id_t
} rocprofiler_buffer_tracing_hsa_api_record_t;
/**
@@ -120,7 +121,8 @@ typedef struct
/// @brief ::ROCPROFILER_CALLBACK_TRACING_HIP_RUNTIME_API or
/// ::ROCPROFILER_CALLBACK_TRACING_HIP_COMPILER_API
/// @var operation
/// @brief ::rocprofiler_hip_runtime_api_id_t or ::rocprofiler_hip_compiler_api_id_t
/// @brief Specification of the API function, e.g., ::rocprofiler_hip_runtime_api_id_t or
/// ::rocprofiler_hip_compiler_api_id_t
} rocprofiler_buffer_tracing_hip_api_record_t;
/**
@@ -140,7 +142,8 @@ typedef struct
/// @brief ::ROCPROFILER_CALLBACK_TRACING_MARKER_CORE_API,
/// ::ROCPROFILER_CALLBACK_TRACING_MARKER_CONTROL_API, or
/// ::ROCPROFILER_CALLBACK_TRACING_MARKER_NAME_API
/// @brief ::rocprofiler_marker_core_api_id_t, ::rocprofiler_marker_control_api_id_t, or
/// @brief Specification of the API function, e.g., ::rocprofiler_marker_core_api_id_t,
/// ::rocprofiler_marker_control_api_id_t, or
/// ::rocprofiler_marker_name_api_id_t
} rocprofiler_buffer_tracing_marker_api_record_t;
@@ -161,7 +164,8 @@ typedef struct
/// @var kind
/// @brief ::ROCPROFILER_BUFFER_TRACING_MEMORY_COPY
/// @var operation
/// @brief memory copy direction (::rocprofiler_memory_copy_operation_t)
/// @brief Specification of the memory copy direction (@see
/// ::rocprofiler_memory_copy_operation_t)
} rocprofiler_buffer_tracing_memory_copy_record_t;
/**
@@ -171,28 +175,17 @@ typedef struct rocprofiler_buffer_tracing_kernel_dispatch_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ::ROCPROFILER_BUFFER_TRACING_KERNEL_DISPATCH
rocprofiler_kernel_dispatch_operation_t operation; ///<
rocprofiler_kernel_dispatch_operation_t operation;
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_thread_id_t thread_id; ///< id for thread that launched kernel
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_agent_id_t agent_id; ///< agent kernel was dispatched on
rocprofiler_queue_id_t queue_id; ///< queue kernel was dispatched on
rocprofiler_kernel_id_t kernel_id; ///< identifier for kernel
rocprofiler_dispatch_id_t dispatch_id; ///< unique id for each dispatch
uint32_t private_segment_size;
uint32_t group_segment_size;
rocprofiler_dim3_t workgroup_size;
rocprofiler_dim3_t grid_size;
rocprofiler_kernel_dispatch_info_t dispatch_info; ///< Dispatch info
/// @var private_segment_size
/// @brief runtime private memory segment size
/// @var group_segment_size
/// @brief runtime group memory segment size
/// @var workgroup_size
/// @brief runtime workgroup size (grid * threads)
/// @var grid_size
/// @brief runtime grid size
/// @var operation
/// @brief Kernel dispatch buffer records only report the ::ROCPROFILER_KERNEL_DISPATCH_COMPLETE
/// operation because there are no "real" wrapper around the enqueuing of an individual kernel
/// dispatch
} rocprofiler_buffer_tracing_kernel_dispatch_record_t;
typedef struct
@@ -232,7 +225,7 @@ typedef struct
/**
* @brief ROCProfiler Buffer Page Migration Tracer Record
*/
typedef struct
typedef struct rocprofiler_buffer_tracing_page_migration_record_t
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ROCPROFILER_BUFFER_TRACING_PAGE_MIGRATION
@@ -259,17 +252,16 @@ typedef struct
*/
typedef struct
{
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ::ROCPROFILER_BUFFER_TRACING_SCRATCH_MEMORY
rocprofiler_scratch_memory_operation_t
operation; ///< @see rocprofiler_scratch_memory_operation_t
rocprofiler_agent_id_t agent_id; ///< agent kernel was dispatched on
rocprofiler_queue_id_t queue_id; ///< queue kernel was dispatched on
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_scratch_alloc_flag_t flags;
uint64_t size; ///< size of this struct
rocprofiler_buffer_tracing_kind_t kind; ///< ::ROCPROFILER_BUFFER_TRACING_SCRATCH_MEMORY
rocprofiler_scratch_memory_operation_t operation; ///< specification of the kind
rocprofiler_agent_id_t agent_id; ///< agent kernel was dispatched on
rocprofiler_queue_id_t queue_id; ///< queue kernel was dispatched on
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
rocprofiler_scratch_alloc_flag_t flags;
} rocprofiler_buffer_tracing_scratch_memory_record_t;
/**
@@ -286,7 +278,9 @@ typedef struct
/// @brief ::ROCPROFILER_BUFFER_TRACING_CORRELATION_ID_RETIREMENT
/// @var timestamp
/// @brief Timestamp (in nanosec) of when rocprofiler detected the correlation ID could be
/// retired
/// retired. Due to clock skew between the CPU and GPU, this may at times, *appear* to be before
/// the kernel or memory copy completed but the reality is that if this ever occurred, the API
/// would report a FATAL error
/// @var internal_correlation_id
/// @brief Only internal correlation ID is provided
} rocprofiler_buffer_tracing_correlation_id_retirement_record_t;
@@ -162,26 +162,10 @@ typedef struct
*/
typedef struct rocprofiler_callback_tracing_kernel_dispatch_data_t
{
uint64_t size; ///< size of this struct
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_agent_id_t agent_id; ///< agent kernel was dispatched on
rocprofiler_queue_id_t queue_id; ///< queue kernel was dispatched on
rocprofiler_kernel_id_t kernel_id; ///< identifier for kernel
rocprofiler_dispatch_id_t dispatch_id; ///< unique id for each dispatch
uint32_t private_segment_size;
uint32_t group_segment_size;
rocprofiler_dim3_t workgroup_size;
rocprofiler_dim3_t grid_size;
/// @var private_segment_size
/// @brief runtime private memory segment size
/// @var group_segment_size
/// @brief runtime group memory segment size
/// @var workgroup_size
/// @brief runtime workgroup size (grid * threads)
/// @var grid_size
/// @brief runtime grid size
uint64_t size; ///< size of this struct
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
rocprofiler_kernel_dispatch_info_t dispatch_info; ///< Dispatch info
} rocprofiler_callback_tracing_kernel_dispatch_data_t;
/**
@@ -39,10 +39,10 @@
*/
/**
* @brief The function was introduced in version 10.0 of the interface and has the
* symbol version string of ``"ROCPROFILER_10.0"``.
* @brief The function was introduced in version 0.0 of the interface and has the
* symbol version string of ``"ROCPROFILER_SDK_0.0"``.
*/
#define ROCPROFILER_VERSION_10_0
#define ROCPROFILER_SDK_VERSION_0_0
/** @} */
@@ -123,7 +123,9 @@
#ifdef __cplusplus
# define ROCPROFILER_EXTERN_C_INIT extern "C" {
# define ROCPROFILER_EXTERN_C_FINI }
# define ROCPROFILER_CXX_CODE(...) __VA_ARGS__
#else
# define ROCPROFILER_EXTERN_C_INIT
# define ROCPROFILER_EXTERN_C_FINI
# define ROCPROFILER_CXX_CODE(...)
#endif
@@ -38,23 +38,29 @@ ROCPROFILER_EXTERN_C_INIT
*/
/**
* @brief Kernel dispatch data for profile counting callbacks
* @brief Kernel dispatch data for profile counting callbacks.
*
*/
typedef struct rocprofiler_profile_counting_dispatch_data_t
{
uint64_t size; ///< Size of this struct
rocprofiler_agent_id_t agent_id; ///< Agent ID where kernel is launched
rocprofiler_queue_id_t queue_id; ///< Queue ID where kernel packet is enqueued
rocprofiler_kernel_id_t kernel_id; ///< Kernel identifier
rocprofiler_dispatch_id_t dispatch_id; ///< unique id for each dispatch
rocprofiler_correlation_id_t correlation_id; ///< Correlation ID for this dispatch
uint32_t private_segment_size; ///< runtime private memory segment size
uint32_t group_segment_size; ///< runtime group memory segment size
rocprofiler_dim3_t workgroup_size; ///< runtime workgroup size (grid * threads)
rocprofiler_dim3_t grid_size; ///< runtime grid size
uint64_t size; ///< Size of this struct
rocprofiler_correlation_id_t correlation_id; ///< Correlation ID for this dispatch
rocprofiler_kernel_dispatch_info_t dispatch_info; ///< Dispatch info
} rocprofiler_profile_counting_dispatch_data_t;
/**
* @brief ROCProfiler Profile Counting Counter Record Header Information
*
* This is buffer equivalent of ::rocprofiler_profile_counting_dispatch_data_t
*/
typedef struct rocprofiler_profile_counting_dispatch_record_t
{
uint64_t size; ///< Size of this struct
uint64_t num_records; ///< number of ::rocprofiler_record_counter_t records
rocprofiler_correlation_id_t correlation_id; ///< Correlation ID for this dispatch
rocprofiler_kernel_dispatch_info_t dispatch_info; ///< Contains the `dispatch_id`
} rocprofiler_profile_counting_dispatch_record_t;
/**
* @brief Kernel Dispatch Callback. This is a callback that is invoked before the kernel
* is enqueued into the HSA queue. What counters to collect for a kernel are set
@@ -364,6 +364,22 @@ typedef enum
ROCPROFILER_COUNTER_INFO_VERSION_LAST,
} rocprofiler_counter_info_version_id_t;
/**
* @brief Enumeration for distinguishing different buffer record kinds within the
* ::ROCPROFILER_BUFFER_CATEGORY_COUNTERS category
*/
typedef enum
{
ROCPROFILER_COUNTER_RECORD_NONE = 0,
ROCPROFILER_COUNTER_RECORD_PROFILE_COUNTING_DISPATCH_HEADER, ///< ::rocprofiler_profile_counting_dispatch_record_t
ROCPROFILER_COUNTER_RECORD_VALUE,
ROCPROFILER_COUNTER_RECORD_LAST,
/// @var ROCPROFILER_COUNTER_RECORD_KIND_DISPATCH_PROFILE_HEADER
/// @brief Indicates the payload type is of type
/// ::rocprofiler_profile_counting_dispatch_record_t
} rocprofiler_counter_record_kind_t;
//--------------------------------------------------------------------------------------//
//
// ALIASES
@@ -591,6 +607,24 @@ rocprofiler_record_header_compute_hash(uint32_t category, uint32_t kind)
return value;
}
/**
* @brief ROCProfiler kernel dispatch information
*
*/
typedef struct rocprofiler_kernel_dispatch_info_t
{
uint64_t size; ///< Size of this struct
rocprofiler_agent_id_t agent_id; ///< Agent ID where kernel is launched
rocprofiler_queue_id_t queue_id; ///< Queue ID where kernel packet is enqueued
rocprofiler_kernel_id_t kernel_id; ///< Kernel identifier
rocprofiler_dispatch_id_t dispatch_id; ///< unique id for each dispatch
uint32_t private_segment_size; ///< runtime private memory segment size
uint32_t group_segment_size; ///< runtime group memory segment size
rocprofiler_dim3_t workgroup_size; ///< runtime workgroup size (grid * threads)
rocprofiler_dim3_t grid_size; ///< runtime grid size
uint8_t reserved_padding[56]; // reserved for extensions w/o ABI break
} rocprofiler_kernel_dispatch_info_t;
/**
* @brief Details for the dimension, including its size, for a counter record.
*/
@@ -611,10 +645,17 @@ typedef struct
{
rocprofiler_counter_instance_id_t id; ///< counter identifier
double counter_value; ///< counter value
rocprofiler_correlation_id_t correlation_id;
rocprofiler_dispatch_id_t dispatch_id;
/// @var correlation_id
/// @brief Used to correlate the kernel data to an API call
/// @var dispatch_id
/// @brief A value greater than zero indicates that this counter record is associated with a
/// specific dispatch.
///
/// This value can be mapped to a dispatch via the `dispatch_info` field (@see
/// ::rocprofiler_kernel_dispatch_info_t) of a ::rocprofiler_profile_counting_dispatch_data_t
/// instance (provided during callback for profile config) or a
/// ::rocprofiler_profile_counting_dispatch_record_t records (which will be insert into the
/// buffer prior to the associated ::rocprofiler_record_counter_t records).
} rocprofiler_record_counter_t;
/**
@@ -622,11 +663,13 @@ typedef struct
*/
typedef struct
{
int is_derived; ///< If this counter is a derived counter
const char* name; ///< Name of the counter
const char* description; ///< Description of the counter
const char* block; ///< Block of the counter (non-derived only)
const char* expression; ///< Counter expression (derived counters only)
rocprofiler_counter_id_t id; ///< Id of this counter
const char* name; ///< Name of the counter
const char* description; ///< Description of the counter
const char* block; ///< Block of the counter (non-derived only)
const char* expression; ///< Counter expression (derived counters only)
uint8_t is_constant : 1; ///< If this counter is HW constant
uint8_t is_derived : 1; ///< If this counter is a derived counter
} rocprofiler_counter_info_v0_t;
/**
@@ -646,3 +689,7 @@ typedef struct
/** @} */
ROCPROFILER_EXTERN_C_FINI
ROCPROFILER_CXX_CODE(
static_assert(sizeof(rocprofiler_kernel_dispatch_info_t) == 128,
"Increasing the size of the kernel dispatch info is not permitted");)