From dd5c0ea25798feb47ffad8275442e9433293fc9c Mon Sep 17 00:00:00 2001 From: "Elwazir, Ammar" Date: Tue, 4 Feb 2025 15:50:18 -0600 Subject: [PATCH] Support new HIP APIs (#179) * Adding New HIP APIs * Format Fix * Format Fix * Removing changes from ostream and moving it to format * Addressing Code Review Comments * Versioning the new hip calls formatting --------- Co-authored-by: Ammar ELWazir --- source/include/rocprofiler-sdk/hip/api_args.h | 35 +++++++++++ .../rocprofiler-sdk/hip/runtime_api_id.h | 9 +++ source/lib/rocprofiler-sdk/hip/abi.cpp | 15 +++++ .../rocprofiler-sdk/hip/details/format.hpp | 61 +++++++++++++++++++ source/lib/rocprofiler-sdk/hip/hip.def.cpp | 11 ++++ 5 files changed, 131 insertions(+) diff --git a/source/include/rocprofiler-sdk/hip/api_args.h b/source/include/rocprofiler-sdk/hip/api_args.h index 5bbb7f9a97..ea0af4ec08 100644 --- a/source/include/rocprofiler-sdk/hip/api_args.h +++ b/source/include/rocprofiler-sdk/hip/api_args.h @@ -3016,6 +3016,41 @@ typedef union rocprofiler_hip_api_args_t int device; } hipDeviceGetTexture1DLinearMaxWidth; #endif +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 7 + struct + { + hipStream_t stream; + unsigned int count; + hipStreamBatchMemOpParams* paramArray; + unsigned int flags; + } hipStreamBatchMemOp; +#endif +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 8 + struct + { + hipGraphNode_t* phGraphNode; + hipGraph_t hGraph; + const hipGraphNode_t* dependencies; + size_t numDependencies; + const hipBatchMemOpNodeParams* nodeParams; + } hipGraphAddBatchMemOpNode; + struct + { + hipGraphNode_t hNode; + hipBatchMemOpNodeParams* nodeParams_out; + } hipGraphBatchMemOpNodeGetParams; + struct + { + hipGraphNode_t hNode; + hipBatchMemOpNodeParams* nodeParams; + } hipGraphBatchMemOpNodeSetParams; + struct + { + hipGraphExec_t hGraphExec; + hipGraphNode_t hNode; + const hipBatchMemOpNodeParams* nodeParams; + } hipGraphExecBatchMemOpNodeSetParams; +#endif } rocprofiler_hip_api_args_t; ROCPROFILER_EXTERN_C_FINI diff --git a/source/include/rocprofiler-sdk/hip/runtime_api_id.h b/source/include/rocprofiler-sdk/hip/runtime_api_id.h index ad20b3a311..c7f6d262ab 100644 --- a/source/include/rocprofiler-sdk/hip/runtime_api_id.h +++ b/source/include/rocprofiler-sdk/hip/runtime_api_id.h @@ -506,6 +506,15 @@ typedef enum // NOLINT(performance-enum-size) #endif #if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 6 ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetTexture1DLinearMaxWidth, +#endif +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 7 + ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamBatchMemOp, +#endif +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 8 + ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddBatchMemOpNode, + ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphBatchMemOpNodeGetParams, + ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphBatchMemOpNodeSetParams, + ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecBatchMemOpNodeSetParams, #endif ROCPROFILER_HIP_RUNTIME_API_ID_LAST, } rocprofiler_hip_runtime_api_id_t; diff --git a/source/lib/rocprofiler-sdk/hip/abi.cpp b/source/lib/rocprofiler-sdk/hip/abi.cpp index 9df166832d..84ec610e26 100644 --- a/source/lib/rocprofiler-sdk/hip/abi.cpp +++ b/source/lib/rocprofiler-sdk/hip/abi.cpp @@ -539,6 +539,17 @@ ROCP_SDK_ENFORCE_ABI(::HipDispatchTable, hipExtHostAlloc_fn, 461) ROCP_SDK_ENFORCE_ABI(::HipDispatchTable, hipDeviceGetTexture1DLinearMaxWidth_fn, 462) #endif +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 7 +ROCP_SDK_ENFORCE_ABI(::HipDispatchTable, hipStreamBatchMemOp_fn, 463) +#endif + +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 8 +ROCP_SDK_ENFORCE_ABI(::HipDispatchTable, hipGraphAddBatchMemOpNode_fn, 464) +ROCP_SDK_ENFORCE_ABI(::HipDispatchTable, hipGraphBatchMemOpNodeGetParams_fn, 465) +ROCP_SDK_ENFORCE_ABI(::HipDispatchTable, hipGraphBatchMemOpNodeSetParams_fn, 466) +ROCP_SDK_ENFORCE_ABI(::HipDispatchTable, hipGraphExecBatchMemOpNodeSetParams_fn, 467) +#endif + #if HIP_RUNTIME_API_TABLE_STEP_VERSION == 0 ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 442) #elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 1 @@ -553,6 +564,10 @@ ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 461) ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 462) #elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 6 ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 463) +#elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 7 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 464) +#elif HIP_RUNTIME_API_TABLE_STEP_VERSION == 8 +ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 468) #else INTERNAL_CI_ROCP_SDK_ENFORCE_ABI_VERSIONING(::HipDispatchTable, 0) #endif diff --git a/source/lib/rocprofiler-sdk/hip/details/format.hpp b/source/lib/rocprofiler-sdk/hip/details/format.hpp index 9fb7635d13..10602305a7 100644 --- a/source/lib/rocprofiler-sdk/hip/details/format.hpp +++ b/source/lib/rocprofiler-sdk/hip/details/format.hpp @@ -113,6 +113,7 @@ ROCP_SDK_HIP_OSTREAM_FORMATTER(hipHostNodeParams) ROCP_SDK_HIP_OSTREAM_FORMATTER(hipExternalSemaphoreSignalNodeParams) ROCP_SDK_HIP_OSTREAM_FORMATTER(hipExternalSemaphoreWaitNodeParams) ROCP_SDK_HIP_OSTREAM_FORMATTER(hipMemPoolProps) +ROCP_SDK_HIP_OSTREAM_FORMATTER(hipCtx_t) ROCP_SDK_HIP_FORMATTER(hipMemcpyNodeParams, "{}flags={}, copyParams={}{}", @@ -163,6 +164,41 @@ ROCP_SDK_HIP_FORMATTER(HIP_MEMSET_NODE_PARAMS, v.height, '}') ROCP_SDK_HIP_FORMATTER(hipMemLocation, "{}type={}, id={}{}", '{', v.type, v.id, '}') +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 7 +ROCP_SDK_HIP_FORMATTER( + hipStreamBatchMemOpParams, + "{}operation={}, waitValueOperation={}, waitValueAddress={}, waitValueValue={}, " + "waitValueValue64={}, waitValueFlags={}, writeValueOperation={}, writeValueAddress={}, " + "writeValueValue={}, writeValueValue64={}, writeValueFlags={}, flushRemoteWritesOperation={}, " + "flushRemoteWritesFlags={}, memoryBarrierOperation={}, memoryBarrierFlags={}{}", + '{', + v.operation, + v.waitValue.operation, + v.waitValue.address, + v.waitValue.value, + v.waitValue.value64, + v.waitValue.flags, + v.writeValue.operation, + v.writeValue.address, + v.writeValue.value, + v.writeValue.value64, + v.writeValue.flags, + v.flushRemoteWrites.operation, + v.flushRemoteWrites.flags, + v.memoryBarrier.operation, + v.memoryBarrier.flags, + '}') +#endif +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 8 +ROCP_SDK_HIP_FORMATTER(hipBatchMemOpNodeParams, + "{}ctx={}, count={}, paramArray=[{}], flags={}{}", + '{', + static_cast(v.ctx), + v.count, + fmt::join(v.paramArray, v.paramArray + v.count, ", "), + v.flags, + '}') +#endif template <> struct formatter : rocprofiler::hip::details::base_formatter @@ -325,6 +361,9 @@ struct formatter : rocprofiler::hip::details::base_formatter case hipGraphNodeTypeMemcpyFromSymbol: case hipGraphNodeTypeMemcpyToSymbol: case hipGraphNodeTypeEmpty: +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 8 + case hipGraphNodeTypeBatchMemOp: +#endif case hipGraphNodeTypeCount: { break; @@ -333,6 +372,28 @@ struct formatter : rocprofiler::hip::details::base_formatter return fmt::format_to(ctx.out(), "{}type={}{}", '{', v.type, '}'); } }; + +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 7 +template <> +struct formatter : rocprofiler::hip::details::base_formatter +{ + template + auto format(hipStreamBatchMemOpType v, Ctx& ctx) const + { + switch(v) + { + ROCP_SDK_HIP_FORMAT_CASE_STMT(hipStreamMemOp, WaitValue32); + ROCP_SDK_HIP_FORMAT_CASE_STMT(hipStreamMemOp, WriteValue32); + ROCP_SDK_HIP_FORMAT_CASE_STMT(hipStreamMemOp, WaitValue64); + ROCP_SDK_HIP_FORMAT_CASE_STMT(hipStreamMemOp, WriteValue64); + ROCP_SDK_HIP_FORMAT_CASE_STMT(hipStreamMemOp, Barrier); + ROCP_SDK_HIP_FORMAT_CASE_STMT(hipStreamMemOp, FlushRemoteWrites); + ROCP_SDK_HIP_FORMAT_DFLT_CASE(hipStreamMemOp); + } + return fmt::format_to(ctx.out(), "Unknown"); + } +}; +#endif } // namespace fmt #undef ROCP_SDK_HIP_FORMATTER diff --git a/source/lib/rocprofiler-sdk/hip/hip.def.cpp b/source/lib/rocprofiler-sdk/hip/hip.def.cpp index f52b2b8fb8..cd836ac768 100644 --- a/source/lib/rocprofiler-sdk/hip/hip.def.cpp +++ b/source/lib/rocprofiler-sdk/hip/hip.def.cpp @@ -562,6 +562,17 @@ HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNT #if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 6 HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipDeviceGetTexture1DLinearMaxWidth, hipDeviceGetTexture1DLinearMaxWidth, hipDeviceGetTexture1DLinearMaxWidth_fn, maxWidthInElements, fmtDesc, device) #endif + +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 7 +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipStreamBatchMemOp, hipStreamBatchMemOp, hipStreamBatchMemOp_fn, stream, count, paramArray, flags); +#endif + +#if HIP_RUNTIME_API_TABLE_STEP_VERSION >= 8 +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphAddBatchMemOpNode, hipGraphAddBatchMemOpNode, hipGraphAddBatchMemOpNode_fn, phGraphNode, hGraph, dependencies, numDependencies, nodeParams); +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphBatchMemOpNodeGetParams, hipGraphBatchMemOpNodeGetParams, hipGraphBatchMemOpNodeGetParams_fn, hNode, nodeParams_out); +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphBatchMemOpNodeSetParams, hipGraphBatchMemOpNodeSetParams, hipGraphBatchMemOpNodeSetParams_fn, hNode, nodeParams); +HIP_API_INFO_DEFINITION_V(ROCPROFILER_HIP_TABLE_ID_Runtime, ROCPROFILER_HIP_RUNTIME_API_ID_hipGraphExecBatchMemOpNodeSetParams, hipGraphExecBatchMemOpNodeSetParams, hipGraphExecBatchMemOpNodeSetParams_fn, hGraphExec, hNode, nodeParams); +#endif // clang-format on #else