HIP Streams to Queues Translation (#235)

* rocprofiler_stream_id_t: opaque handle for a stream

- e.g. HIP stream
- the same HIP stream may map to different HSA queues at different points in the application
- added to:
  - rocprofiler_buffer_tracing_hip_api_record_t
  - rocprofiler_buffer_tracing_memory_copy_record_t
  - rocprofiler_callback_tracing_hip_api_data_t
  - rocprofiler_callback_tracing_memory_copy_data_t
---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
Co-authored-by: Mark Meserve <mark.meserve@amd.com>
Co-authored-by: Elwazir, Ammar <Ammar.Elwazir@amd.com>
Co-authored-by: Ammar ELWazir <aelwazir@amd.com>
Co-authored-by: Jakaraddi, Manjunath <Manjunath.Jakaraddi@amd.com>
Co-authored-by: Bhardwaj, Gopesh <Gopesh.Bhardwaj@amd.com>
Co-authored-by: Nagaraj, Sriraksha <Sriraksha.Nagaraj@amd.com>
Co-authored-by: U, Srihari <Srihari.U@amd.com>
Co-authored-by: Madsen, Jonathan <Jonathan.Madsen@amd.com>
Co-authored-by: Welton, Benjamin <Benjamin.Welton@amd.com>
Co-authored-by: Benjamin Welton <ben@amd.com>
Co-authored-by: Indic, Vladimir <Vladimir.Indic@amd.com>
Co-authored-by: Benjamin Welton <bewelton@amd.com>

[ROCm/rocprofiler-sdk commit: ccd1e54293]
This commit is contained in:
Trowbridge, Ian
2025-03-14 04:45:13 -05:00
committed by GitHub
parent c08db2daa1
commit 7aeaffd871
50 changed files with 1812 additions and 220 deletions
@@ -78,7 +78,12 @@ typedef struct
{
uint64_t size; ///< size of this struct
rocprofiler_hip_api_args_t args;
rocprofiler_hip_api_retval_t retval;
rocprofiler_hip_api_retval_t retval; ///< return value of function call
/// @var args
/// @brief Arguments of the function call. @see
/// ::rocprofiler_iterate_callback_tracing_kind_operation_args for generic
/// access/stringification of the arguments.
} rocprofiler_callback_tracing_hip_api_data_t;
/**
@@ -329,6 +334,15 @@ typedef struct rocprofiler_callback_tracing_runtime_initialization_data_t
/// Version number is encoded as: (10000 * MAJOR) + (100 * MINOR) + PATCH
} rocprofiler_callback_tracing_runtime_initialization_data_t;
/**
* @brief ROCProfiler Stream Handle Callback Data.
*/
typedef struct
{
uint64_t size; ///< size of this struct
rocprofiler_stream_id_t stream_id; ///< HIP stream ID
} rocprofiler_callback_tracing_stream_handle_data_t;
/**
* @brief API Tracing callback function. This function is invoked twice per API function: once
* before the function is invoked and once after the function is invoked. The external correlation
@@ -60,6 +60,7 @@ ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_context_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_agent_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_address_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_queue_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_stream_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_counter_id_t)
ROCPROFILER_CXX_SPECIALIZE_HANDLE_HASHER(rocprofiler_profile_config_id_t)
@@ -97,6 +97,7 @@ ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_context_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_address_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_agent_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_queue_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_stream_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_counter_id_t)
ROCPROFILER_CXX_DECLARE_OPERATORS(rocprofiler_profile_config_id_t)
@@ -114,6 +115,7 @@ ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_context_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_address_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_agent_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_queue_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_stream_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_counter_id_t)
ROCPROFILER_CXX_DEFINE_EQ_HANDLE_OPERATOR(rocprofiler_profile_config_id_t)
@@ -141,6 +143,7 @@ ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_context_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_address_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_agent_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_queue_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_stream_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_counter_id_t)
ROCPROFILER_CXX_DEFINE_NE_OPERATOR(rocprofiler_profile_config_id_t)
@@ -158,6 +161,7 @@ ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_context_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_address_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_agent_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_queue_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_stream_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_counter_id_t)
ROCPROFILER_CXX_DEFINE_LT_HANDLE_OPERATOR(rocprofiler_profile_config_id_t)
@@ -190,6 +194,7 @@ ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_context_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_address_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_agent_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_queue_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_stream_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_buffer_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_counter_id_t)
ROCPROFILER_CXX_DEFINE_COMPARE_OPERATORS(rocprofiler_profile_config_id_t)
@@ -114,6 +114,13 @@ save(ArchiveT& ar, rocprofiler_queue_id_t data)
ROCP_SDK_SAVE_DATA_FIELD(handle);
}
template <typename ArchiveT>
void
save(ArchiveT& ar, rocprofiler_stream_id_t data)
{
ROCP_SDK_SAVE_DATA_FIELD(handle);
}
template <typename ArchiveT>
void
save(ArchiveT& ar, rocprofiler_counter_id_t data)
@@ -178,6 +178,8 @@ typedef enum // NOLINT(performance-enum-size)
///< library has been initialized
ROCPROFILER_CALLBACK_TRACING_ROCDECODE_API, ///< rocDecode API Tracing
ROCPROFILER_CALLBACK_TRACING_ROCJPEG_API, ///< rocJPEG API Tracing
ROCPROFILER_CALLBACK_TRACING_HIP_STREAM_API, ///< @see
///< ::rocprofiler_hip_stream_operation_t
ROCPROFILER_CALLBACK_TRACING_LAST,
} rocprofiler_callback_tracing_kind_t;
@@ -209,8 +211,9 @@ typedef enum // NOLINT(performance-enum-size)
ROCPROFILER_BUFFER_TRACING_RUNTIME_INITIALIZATION, ///< Record indicating a runtime library has
///< been initialized. @see
///< ::rocprofiler_runtime_initialization_operation_t
ROCPROFILER_BUFFER_TRACING_ROCDECODE_API, ///< rocDecode tracing
ROCPROFILER_BUFFER_TRACING_ROCJPEG_API, ///< rocJPEG tracing
ROCPROFILER_BUFFER_TRACING_ROCDECODE_API, ///< rocDecode tracing
ROCPROFILER_BUFFER_TRACING_ROCJPEG_API, ///< rocJPEG tracing
ROCPROFILER_BUFFER_TRACING_HIP_STREAM_API, ///< Display HIP Stream
ROCPROFILER_BUFFER_TRACING_LAST,
} rocprofiler_buffer_tracing_kind_t;
@@ -226,6 +229,23 @@ typedef enum // NOLINT(performance-enum-size)
ROCPROFILER_CODE_OBJECT_LAST,
} rocprofiler_code_object_operation_t;
/**
* @brief ROCProfiler Stream Handle Operations.
*/
typedef enum // NOLINT(performance-enum-size)
{
ROCPROFILER_HIP_STREAM_NONE = 0, ///< Unknown stream handle operation
ROCPROFILER_HIP_STREAM_CREATE, ///< A stream handle is created
ROCPROFILER_HIP_STREAM_DESTROY, ///< A stream handle is destroyed
ROCPROFILER_HIP_STREAM_SET,
ROCPROFILER_HIP_STREAM_LAST,
/// @var ROCPROFILER_HIP_STREAM_SET
/// @brief Invokes callbacks before and after a HIP API, kernel dispatch, or memory copy
/// operation that has a stream handle associated with it. HIP API calls will always have a
/// stream, but kernel dispatches and memory copy operations may or may not.
} rocprofiler_hip_stream_operation_t;
/**
* @brief Memory Copy Operations.
*/
@@ -556,7 +576,7 @@ typedef union rocprofiler_uuid_t
/**
* @brief Context ID.
*/
typedef struct
typedef struct rocprofiler_context_id_t
{
uint64_t handle;
} rocprofiler_context_id_t;
@@ -564,15 +584,23 @@ typedef struct
/**
* @brief Queue ID.
*/
typedef struct
typedef struct rocprofiler_queue_id_t
{
uint64_t handle;
} rocprofiler_queue_id_t;
/**
* @brief Stream ID.
*/
typedef struct rocprofiler_stream_id_t
{
uint64_t handle;
} rocprofiler_stream_id_t;
/**
* @brief ROCProfiler Record Correlation ID.
*/
typedef struct
typedef struct rocprofiler_correlation_id_t
{
uint64_t internal;
rocprofiler_user_data_t external;
@@ -587,7 +615,7 @@ typedef struct
* @struct rocprofiler_buffer_id_t
* @brief Buffer ID.
*/
typedef struct
typedef struct rocprofiler_buffer_id_t
{
uint64_t handle;
} rocprofiler_buffer_id_t;
@@ -595,7 +623,7 @@ typedef struct
/**
* @brief Agent Identifier
*/
typedef struct
typedef struct rocprofiler_agent_id_t
{
uint64_t handle;
} rocprofiler_agent_id_t;
@@ -603,7 +631,7 @@ typedef struct
/**
* @brief Counter ID.
*/
typedef struct
typedef struct rocprofiler_counter_id_t
{
uint64_t handle;
} rocprofiler_counter_id_t;
@@ -612,7 +640,7 @@ typedef struct
* @brief Profile Configurations
* @see rocprofiler_create_profile_config for how to create.
*/
typedef struct
typedef struct rocprofiler_profile_config_id_t
{
uint64_t handle; // Opaque handle
} rocprofiler_profile_config_id_t;