From f3752faa0a958dfab824c78800de5699b3adced7 Mon Sep 17 00:00:00 2001 From: "Madsen, Jonathan" Date: Thu, 30 Jan 2025 20:51:52 -0600 Subject: [PATCH] Update HIP string formatting for ROCm 6.4.0 (#144) Fix HIP data type stringify - when ROCPROFILER_CI is not defined, provide default for case statements - Add support for hipGraphNodeTypeBatchMemOp when HIP version is >= 6.4.0 Co-authored-by: Jonathan R. Madsen --- .../rocprofiler-sdk/hip/details/format.hpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/lib/rocprofiler-sdk/hip/details/format.hpp b/source/lib/rocprofiler-sdk/hip/details/format.hpp index 8abe860b30..7509fecf1a 100644 --- a/source/lib/rocprofiler-sdk/hip/details/format.hpp +++ b/source/lib/rocprofiler-sdk/hip/details/format.hpp @@ -30,6 +30,7 @@ #include // must be included after runtime api #include +#include #include "fmt/core.h" #include "fmt/ranges.h" @@ -61,6 +62,15 @@ #define ROCP_SDK_HIP_FORMAT_CASE_STMT(PREFIX, SUFFIX) \ case PREFIX##SUFFIX: return fmt::format_to(ctx.out(), #SUFFIX) +// provide a default case when not building in CI +#if defined(ROCPROFILER_CI) +# define ROCP_SDK_HIP_FORMAT_DFLT_CASE(PREFIX) +#else +# define ROCP_SDK_HIP_FORMAT_DFLT_CASE(PREFIX) \ + default: \ + return fmt::format_to(ctx.out(), "{}_UNKNOWN={}", #PREFIX, static_cast(v)) +#endif + namespace rocprofiler { namespace hip @@ -177,6 +187,10 @@ struct formatter : rocprofiler::hip::details::base_formatter ROCP_SDK_HIP_FORMAT_CASE_STMT(hipGraphNodeType, MemcpyToSymbol); ROCP_SDK_HIP_FORMAT_CASE_STMT(hipGraphNodeType, Empty); ROCP_SDK_HIP_FORMAT_CASE_STMT(hipGraphNodeType, Count); +#if HIP_VERSION >= 60400000 + ROCP_SDK_HIP_FORMAT_CASE_STMT(hipGraphNodeType, BatchMemOp); +#endif + ROCP_SDK_HIP_FORMAT_DFLT_CASE(hipGraphNodeType); } return fmt::format_to(ctx.out(), "Unknown"); } @@ -195,6 +209,7 @@ struct formatter : rocprofiler::hip::details::base_fo ROCP_SDK_HIP_FORMAT_CASE_STMT(hipGraphInstantiate, InvalidStructure); ROCP_SDK_HIP_FORMAT_CASE_STMT(hipGraphInstantiate, NodeOperationNotSupported); ROCP_SDK_HIP_FORMAT_CASE_STMT(hipGraphInstantiate, MultipleDevicesNotSupported); + ROCP_SDK_HIP_FORMAT_DFLT_CASE(hipGraphInstantiate); } return fmt::format_to(ctx.out(), "Unknown"); } @@ -211,6 +226,7 @@ struct formatter : rocprofiler::hip::details::base_formatt ROCP_SDK_HIP_FORMAT_CASE_STMT(hipMemAllocationType, Invalid); ROCP_SDK_HIP_FORMAT_CASE_STMT(hipMemAllocationType, Pinned); ROCP_SDK_HIP_FORMAT_CASE_STMT(hipMemAllocationType, Max); + ROCP_SDK_HIP_FORMAT_DFLT_CASE(hipMemAllocationType); } return fmt::format_to(ctx.out(), "Unknown"); } @@ -226,6 +242,7 @@ struct formatter : rocprofiler::hip::details::base_formatter { ROCP_SDK_HIP_FORMAT_CASE_STMT(hipMemLocationType, Invalid); ROCP_SDK_HIP_FORMAT_CASE_STMT(hipMemLocationType, Device); + ROCP_SDK_HIP_FORMAT_DFLT_CASE(hipMemLocationType); } return fmt::format_to(ctx.out(), "Unknown"); } @@ -243,6 +260,7 @@ struct formatter : rocprofiler::hip::details::base_f ROCP_SDK_HIP_FORMAT_CASE_STMT(hipMemHandleType, PosixFileDescriptor); ROCP_SDK_HIP_FORMAT_CASE_STMT(hipMemHandleType, Win32); ROCP_SDK_HIP_FORMAT_CASE_STMT(hipMemHandleType, Win32Kmt); + ROCP_SDK_HIP_FORMAT_DFLT_CASE(hipMemHandleType); } return fmt::format_to(ctx.out(), "Unknown"); } @@ -262,6 +280,7 @@ struct formatter : rocprofiler::hip::details::base_formatter ROCP_SDK_HIP_FORMAT_CASE_STMT(hipMemcpy, DeviceToDevice); ROCP_SDK_HIP_FORMAT_CASE_STMT(hipMemcpy, Default); ROCP_SDK_HIP_FORMAT_CASE_STMT(hipMemcpy, DeviceToDeviceNoCU); + ROCP_SDK_HIP_FORMAT_DFLT_CASE(hipMemcpy); } return fmt::format_to(ctx.out(), "Unknown"); } @@ -322,3 +341,4 @@ struct formatter : rocprofiler::hip::details::base_formatter #undef ROCP_SDK_HIP_FORMATTER #undef ROCP_SDK_HIP_OSTREAM_FORMATTER #undef ROCP_SDK_HIP_FORMAT_CASE_STMT +#undef ROCP_SDK_HIP_FORMAT_DFLT_CASE