SWDEV-545950 - Add hipStreamCopyAttributes API Implementation (#914)

* SWDEV-545950 - Add hipStreamCopyAttributes API Implementation

* Add unit test for hipStreamCopyAttributes API

* Add ChangeLog and nvidia mapping for the API

* Update rocprofiler-sdk with new HIP API details

* [rocprofiler-sdk] handle hipStreamCopyAttributes in stream tracing service

- this new HIP function has multiple stream arguments and needs to be skipped because it does not have an explicit create/destroy/set functionality

* Update HIP_RUNTIME_API_TABLE_STEP_VERSION in clr and rocprofiler-sdk

* Resolve merge conflicts

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
Tento commit je obsažen v:
Satyanvesh Dittakavi
2025-10-12 19:57:05 +05:30
odevzdal GitHub
rodič 7f79d0febc
revize 46e683d41a
18 změnil soubory, kde provedl 237 přidání a 12 odebrání
@@ -987,6 +987,9 @@ ROCPROFILER_ENUM_LABEL(ROCPROFILER_HIP_RUNTIME_API_ID_hipLibraryUnload)
ROCPROFILER_ENUM_LABEL(ROCPROFILER_HIP_RUNTIME_API_ID_hipLibraryGetKernel)
ROCPROFILER_ENUM_LABEL(ROCPROFILER_HIP_RUNTIME_API_ID_hipLibraryGetKernelCount)
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 16
ROCPROFILER_ENUM_LABEL(ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamCopyAttributes)
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION == 0
static_assert(ROCPROFILER_HIP_RUNTIME_API_ID_LAST == 442);
#elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 1
@@ -1019,6 +1022,8 @@ static_assert(ROCPROFILER_HIP_RUNTIME_API_ID_LAST == 477);
static_assert(ROCPROFILER_HIP_RUNTIME_API_ID_LAST == 496);
#elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 15
static_assert(ROCPROFILER_HIP_RUNTIME_API_ID_LAST == 501);
#elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 16
static_assert(ROCPROFILER_HIP_RUNTIME_API_ID_LAST == 502);
#else
# if !defined(ROCPROFILER_UNSAFE_NO_VERSION_CHECK) && \
(defined(ROCPROFILER_CI) && ROCPROFILER_CI > 0)
@@ -3324,6 +3324,13 @@ typedef union rocprofiler_hip_api_args_t
hipLibrary_t library;
} hipLibraryGetKernelCount;
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 16
struct
{
hipStream_t dst;
hipStream_t src;
} hipStreamCopyAttributes;
#endif
} rocprofiler_hip_api_args_t;
ROCPROFILER_EXTERN_C_FINI
@@ -558,6 +558,9 @@ typedef enum rocprofiler_hip_runtime_api_id_t // NOLINT(performance-enum-size)
ROCPROFILER_HIP_RUNTIME_API_ID_hipLibraryUnload,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLibraryGetKernel,
ROCPROFILER_HIP_RUNTIME_API_ID_hipLibraryGetKernelCount,
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 16
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamCopyAttributes,
#endif
ROCPROFILER_HIP_RUNTIME_API_ID_LAST,
} rocprofiler_hip_runtime_api_id_t;
+6
Zobrazit soubor
@@ -601,6 +601,10 @@ ROCP_SDK_ENFORCE_ABI(::HipDispatchTable, hipLibraryGetKernel_fn, 499);
ROCP_SDK_ENFORCE_ABI(::HipDispatchTable, hipLibraryGetKernelCount_fn, 500);
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 16
ROCP_SDK_ENFORCE_ABI(::HipDispatchTable, hipStreamCopyAttributes_fn, 501);
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION == 0
ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 442)
#elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 1
@@ -633,6 +637,8 @@ ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 477)
ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 496)
#elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 15
ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 501)
#elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 16
ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 502)
#else
INTERNAL_CI_ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 0)
#endif
@@ -627,6 +627,10 @@ HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNT
HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipLibraryGetKernel, hipLibraryGetKernel, hipLibraryGetKernel_fn, pKernel, library, name);
HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipLibraryGetKernelCount, hipLibraryGetKernelCount, hipLibraryGetKernelCount_fn, count, library);
#endif
#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 16
HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamCopyAttributes, hipStreamCopyAttributes, hipStreamCopyAttributes_fn, dst, src);
#endif
// clang-format on
#else
+37 -4
Zobrazit soubor
@@ -416,13 +416,38 @@ enable_stream_stack()
return false;
}
#define HIP_RUNTIME_API_TABLE_VERSION \
ROCPROFILER_SDK_COMPUTE_VERSION( \
HIP_RUNTIME_API_TABLE_MAJOR_VERSION, 0, HIP_RUNTIME_API_TABLE_STEP_VERSION)
#define HIP_STREAM_EXPLICIT_DISABLE(TABLE, OPERATION, REASON) \
template <> \
struct explicit_disable_update<TABLE, OPERATION> : std::true_type \
{ \
static constexpr auto reason = REASON; \
};
template <size_t TableIdx, size_t OpIdx>
struct explicit_disable_update : std::false_type
{};
#if HIP_RUNTIME_API_TABLE_VERSION >= ROCPROFILER_SDK_COMPUTE_VERSION(0, 0, 16)
HIP_STREAM_EXPLICIT_DISABLE(ROCPROFILER_HIP_TABLE_ID_Runtime,
ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamCopyAttributes,
"has multiple HIP stream arguments")
#endif
#undef HIP_RUNTIME_API_TABLE_VERSION
#undef HIP_STREAM_EXPLICIT_DISABLE
template <size_t TableIdx, typename Tp, size_t OpIdx>
void
update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
{
using table_type = typename hip_table_lookup<TableIdx>::type;
using info_type = hip_api_info<TableIdx, OpIdx>;
using function_args_type = decltype(info_type::get_args_type());
using table_type = typename hip_table_lookup<TableIdx>::type;
using info_type = hip_api_info<TableIdx, OpIdx>;
using explicit_disable_type = explicit_disable_update<TableIdx, OpIdx>;
using function_args_type = decltype(info_type::get_args_type());
static_assert(info_type::table_idx == ROCPROFILER_HIP_TABLE_ID_Runtime,
"This function should only be instantiated for HIP runtime API");
@@ -440,7 +465,15 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
constexpr auto num_args = function_args_type::size();
if constexpr(common::mpl::is_one_of<hipStream_t, function_args_type>::value)
if constexpr(explicit_disable_type::value)
{
ROCP_INFO << fmt::format(
"[hip stream] {} is explicitly disabled from stream tracing: {}",
info_type::name,
explicit_disable_type::reason);
return;
}
else if constexpr(common::mpl::is_one_of<hipStream_t, function_args_type>::value)
{
constexpr auto stream_idx =
common::mpl::index_of<hipStream_t, function_args_type>::value;