From a8250fb31dca4d39a932cc4a5501f1b2cade3133 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 12:40:13 +0200 Subject: [PATCH] fix bug where CK datatypes would be registered as unknown in the output files --- cmake/argparse.cmake | 42 +++++++++++--------- profiler/include/profiler/io_profiler.hpp | 47 ++++++++++++++++++----- profiler/src/profile_gemm.cpp | 1 + 3 files changed, 62 insertions(+), 28 deletions(-) diff --git a/cmake/argparse.cmake b/cmake/argparse.cmake index f3c9d86c80..f3a4b2e9fb 100644 --- a/cmake/argparse.cmake +++ b/cmake/argparse.cmake @@ -1,26 +1,32 @@ include(FetchContent) - set(ARGPARSE_DIR "" CACHE STRING "Location of local argparse repo to build against") +set(ARGPARSE_DIR "" CACHE STRING "Location of local argparse repo to build against") - if(ARGPARSE_DIR) set(FETCHCONTENT_SOURCE_DIR_ARGPARSE ${ARGPARSE_DIR} CACHE STRING - "argparse source directory override") endif() +if(ARGPARSE_DIR) + set(FETCHCONTENT_SOURCE_DIR_ARGPARSE ${ARGPARSE_DIR} CACHE STRING "argparse source directory override") +endif() - FetchContent_Declare(argparse GIT_REPOSITORY https - : // github.com/p-ranav/argparse.git - GIT_TAG v2 .9 #Using a stable version) +FetchContent_Declare( + argparse + GIT_REPOSITORY https://github.com/p-ranav/argparse.git + GIT_TAG v2.9 # Using a stable version +) - FetchContent_MakeAvailable(argparse) +FetchContent_MakeAvailable(argparse) -#Create a proper modern CMake INTERFACE target - if(NOT TARGET argparse::argparse) add_library(argparse::argparse INTERFACE) - target_include_directories(argparse::argparse INTERFACE - $ $) +# Create a proper modern CMake INTERFACE target +if(NOT TARGET argparse::argparse) + add_library(argparse::argparse INTERFACE) + target_include_directories(argparse::argparse + INTERFACE + $ + $ + ) -#Disable the specific warning for code that includes argparse - target_compile_options( - argparse::argparse INTERFACE - $<$ : -Wno - missing - - noreturn>) endif() + # Disable the specific warning for code that includes argparse + target_compile_options(argparse::argparse INTERFACE + $<$:-Wno-missing-noreturn> + ) +endif() - message(STATUS "Argparse source dir: ${argparse_SOURCE_DIR}") +message(STATUS "Argparse source dir: ${argparse_SOURCE_DIR}") diff --git a/profiler/include/profiler/io_profiler.hpp b/profiler/include/profiler/io_profiler.hpp index b421e1840d..1e3f75ee4f 100644 --- a/profiler/include/profiler/io_profiler.hpp +++ b/profiler/include/profiler/io_profiler.hpp @@ -6,15 +6,18 @@ #include #include #include -#include #include #include #include #include #include #include + +#include "ck/utility/data_type.hpp" +#include "ck/utility/amd_ck_fp8.hpp" + +#include "data_type_enum.hpp" #include "profiler/argparse_wrapper.hpp" -#include "profiler/data_type_enum.hpp" namespace ck { namespace profiler { @@ -345,20 +348,44 @@ DataTypeEnum GetDataTypeEnum() { return DataTypeEnum::Int32; } - else - { - // Use typeid to try to identify CK-specific types + + // Add explicit checks for CK-specific types + else if constexpr(std::is_same_v) { + return DataTypeEnum::Half; + } else if constexpr(std::is_same_v) { + return DataTypeEnum::BFloat16; + } else if constexpr(std::is_same_v) { + return DataTypeEnum::Float8; + } + // Handle potential alternative type names that might be used + else if constexpr(std::is_same_v) { + return DataTypeEnum::Half; + } + // Fallback for any 1-byte floating point types that aren't int8_t + else if constexpr(sizeof(DataType) == 1 && std::is_floating_point_v) { + return DataTypeEnum::Float8; + } + // Fallback for 2-byte types that might be half precision + else if constexpr(sizeof(DataType) == 2 && std::is_floating_point_v) { + // Try to distinguish between fp16 and bf16 using typeid as last resort std::string type_name = typeid(DataType).name(); - if(type_name.find("half") != std::string::npos) - { + if (type_name.find("bhalf") != std::string::npos || type_name.find("bf16") != std::string::npos) { + return DataTypeEnum::BFloat16; + } else { + return DataTypeEnum::Half; + } + } + // Additional fallback using typeid for types we might have missed + else { + std::string type_name = typeid(DataType).name(); + if (type_name.find("half") != std::string::npos && type_name.find("bhalf") == std::string::npos) { return DataTypeEnum::Half; } else if(type_name.find("bhalf") != std::string::npos) { return DataTypeEnum::BFloat16; - } - else if(sizeof(DataType) == 1 && !std::is_same_v) - { + + } else if (type_name.find("f8") != std::string::npos || type_name.find("fp8") != std::string::npos) { return DataTypeEnum::Float8; } return DataTypeEnum::Unknown; diff --git a/profiler/src/profile_gemm.cpp b/profiler/src/profile_gemm.cpp index c322c7054b..84f9bea5f3 100644 --- a/profiler/src/profile_gemm.cpp +++ b/profiler/src/profile_gemm.cpp @@ -57,6 +57,7 @@ int profile_gemm(int argc, char* argv[]) } const auto data_type = static_cast(std::stoi(argv[2])); + std::cout << "Data Type: " << static_cast(data_type) << std::endl; const auto layout = static_cast(std::stoi(argv[3])); const bool do_verification = std::stoi(argv[4]); const int init_method = std::stoi(argv[5]);