diff --git a/CMakeLists.txt b/CMakeLists.txt index 90c733403c..aae8ff9dac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # ######################################################################## -# Copyright (C) 2022 Advanced Micro Devices, Inc. +# Copyright (C) 2022-2023 Advanced Micro Devices, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -163,7 +163,7 @@ else() message(STATUS "AMDGPU_TARGETS: ${AMDGPU_TARGETS}") if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) - find_package( hip REQUIRED CONFIG PATHS ${HIP_DIR} ${ROCM_PATH} /opt/rocm ) + find_package( hip 5.5 REQUIRED CONFIG PATHS ${HIP_DIR} ${ROCM_PATH} /opt/rocm ) endif( ) option( BUILD_WITH_TENSILE "Build full functionality which requires tensile?" ON ) @@ -225,7 +225,6 @@ else() endif() endif() -find_package( hipblas 0.50.0 REQUIRED CONFIG PATHS ${HIP_DIR} ${ROCM_PATH} /opt/rocm) # Setup version set(VERSION_STRING "0.1.0") @@ -292,10 +291,6 @@ if( BUILD_CLIENTS_SAMPLES OR BUILD_CLIENTS_TESTS OR BUILD_CLIENTS_BENCHMARKS ) add_subdirectory( clients ) endif( ) -if( NOT BUILD_CUDA ) - rocm_package_add_dependencies(DEPENDS "hipblas >= 0.50.0") -endif( ) - # Package specific CPACK vars set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md" ) set( CPACK_RPM_PACKAGE_LICENSE "MIT") diff --git a/clients/benchmarks/CMakeLists.txt b/clients/benchmarks/CMakeLists.txt index 684ff29ba8..b49eca07b9 100644 --- a/clients/benchmarks/CMakeLists.txt +++ b/clients/benchmarks/CMakeLists.txt @@ -1,5 +1,5 @@ # ######################################################################## -# Copyright (C) 2022 Advanced Micro Devices, Inc. +# Copyright (C) 2022-2023 Advanced Micro Devices, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -43,7 +43,7 @@ target_include_directories( hipblaslt-bench $ # may be blank if not used ) -target_link_libraries( hipblaslt-bench PRIVATE ${BLAS_LIBRARY} roc::hipblas roc::hipblaslt) +target_link_libraries( hipblaslt-bench PRIVATE ${BLAS_LIBRARY} roc::hipblaslt) if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") # GCC or hip-clang needs specific flags to turn on f16c intrinsics diff --git a/clients/benchmarks/client.cpp b/clients/benchmarks/client.cpp index 94ae990a90..ecdfae7001 100644 --- a/clients/benchmarks/client.cpp +++ b/clients/benchmarks/client.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -68,7 +68,7 @@ void run_function(const func_map& map, const Arguments& arg, const std::string& auto match = map.find(arg.function); if(match == map.end()) throw std::invalid_argument("Invalid combination --function "s + arg.function - + " --a_type "s + hipblas_datatype_to_string(arg.a_type) + msg); + + " --a_type "s + hip_datatype_to_string(arg.a_type) + msg); match->second(arg); } @@ -462,33 +462,33 @@ try std::transform(precision.begin(), precision.end(), precision.begin(), ::tolower); auto prec = string_to_hipblas_datatype(precision); - if(prec == static_cast(-1)) + if(prec == static_cast(-1)) throw std::invalid_argument("Invalid value for --precision " + precision); arg.a_type = a_type == "" ? prec : string_to_hipblas_datatype(a_type); - if(arg.a_type == static_cast(-1)) + if(arg.a_type == static_cast(-1)) throw std::invalid_argument("Invalid value for --a_type " + a_type); arg.b_type = b_type == "" ? prec : string_to_hipblas_datatype(b_type); - if(arg.b_type == static_cast(-1)) + if(arg.b_type == static_cast(-1)) throw std::invalid_argument("Invalid value for --b_type " + b_type); arg.c_type = c_type == "" ? prec : string_to_hipblas_datatype(c_type); - if(arg.c_type == static_cast(-1)) + if(arg.c_type == static_cast(-1)) throw std::invalid_argument("Invalid value for --c_type " + c_type); arg.d_type = d_type == "" ? prec : string_to_hipblas_datatype(d_type); - if(arg.d_type == static_cast(-1)) + if(arg.d_type == static_cast(-1)) throw std::invalid_argument("Invalid value for --d_type " + d_type); - bool is_f16 = arg.a_type == HIPBLAS_R_16F || arg.a_type == HIPBLAS_R_16B; - bool is_f32 = arg.a_type == HIPBLAS_R_32F; + bool is_f16 = arg.a_type == HIP_R_16F || arg.a_type == HIP_R_16BF; + bool is_f32 = arg.a_type == HIP_R_32F; arg.compute_type = compute_type == "" ? (HIPBLASLT_COMPUTE_F32) : string_to_hipblaslt_computetype(compute_type); if(arg.compute_type == static_cast(-1)) throw std::invalid_argument("Invalid value for --compute_type " + compute_type); - if(string_to_hipblas_datatype(bias_type) == static_cast(-1) + if(string_to_hipblas_datatype(bias_type) == static_cast(-1) && bias_type != "" && bias_type != "default") throw std::invalid_argument("Invalid value for --bias_type " + bias_type); else diff --git a/clients/common/cblas_interface.cpp b/clients/common/cblas_interface.cpp index 38dc9b5e6a..870d9bc066 100644 --- a/clients/common/cblas_interface.cpp +++ b/clients/common/cblas_interface.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,23 +30,23 @@ #include #include -CBLAS_TRANSPOSE HIPOperationToCBLASTanspose(hipblasOperation_t trans) +CBLAS_TRANSPOSE HIPOperationToCBLASTanspose(hipblasltOperation_t trans) { switch(trans) { - case HIPBLAS_OP_N: + case HIPBLASLT_OP_N: return CblasNoTrans; - case HIPBLAS_OP_T: + case HIPBLASLT_OP_T: return CblasTrans; - case HIPBLAS_OP_C: + case HIPBLASLT_OP_C: return CblasConjTrans; } } // gemm template <> -void cblas_gemm(hipblasOperation_t transA, - hipblasOperation_t transB, +void cblas_gemm(hipblasltOperation_t transA, + hipblasltOperation_t transB, int64_t m, int64_t n, int64_t k, @@ -63,8 +63,8 @@ void cblas_gemm(hipblasOperation_t transA, // cblas does not support hip_bfloat16, so convert to higher precision float // This will give more precise result which is acceptable for testing - size_t sizeA = (transA == HIPBLAS_OP_N ? k : m) * size_t(lda); - size_t sizeB = (transB == HIPBLAS_OP_N ? n : k) * size_t(ldb); + size_t sizeA = (transA == HIPBLASLT_OP_N ? k : m) * size_t(lda); + size_t sizeB = (transB == HIPBLASLT_OP_N ? n : k) * size_t(ldb); size_t sizeC = n * size_t(ldc); host_vector A_float(sizeA), B_float(sizeB), C_float(sizeC); @@ -98,8 +98,8 @@ void cblas_gemm(hipblasOperation_t transA, } template <> -void cblas_gemm(hipblasOperation_t transA, - hipblasOperation_t transB, +void cblas_gemm(hipblasltOperation_t transA, + hipblasltOperation_t transB, int64_t m, int64_t n, int64_t k, @@ -116,8 +116,8 @@ void cblas_gemm(hipblasOperation_t transA, // cblas does not support hip_bfloat16, so convert to higher precision float // This will give more precise result which is acceptable for testing - size_t sizeA = (transA == HIPBLAS_OP_N ? k : m) * size_t(lda); - size_t sizeB = (transB == HIPBLAS_OP_N ? n : k) * size_t(ldb); + size_t sizeA = (transA == HIPBLASLT_OP_N ? k : m) * size_t(lda); + size_t sizeB = (transB == HIPBLASLT_OP_N ? n : k) * size_t(ldb); size_t sizeC = n * size_t(ldc); host_vector A_float(sizeA), B_float(sizeB), C_float(sizeC); @@ -146,8 +146,8 @@ void cblas_gemm(hipblasOperation_t transA, } template <> -void cblas_gemm(hipblasOperation_t transA, - hipblasOperation_t transB, +void cblas_gemm(hipblasltOperation_t transA, + hipblasltOperation_t transB, int64_t m, int64_t n, int64_t k, @@ -164,8 +164,8 @@ void cblas_gemm(hipblasOperation_t transA // cblas does not support hipblasLtHalf, so convert to higher precision float // This will give more precise result which is acceptable for testing - size_t sizeA = (transA == HIPBLAS_OP_N ? k : m) * size_t(lda); - size_t sizeB = (transB == HIPBLAS_OP_N ? n : k) * size_t(ldb); + size_t sizeA = (transA == HIPBLASLT_OP_N ? k : m) * size_t(lda); + size_t sizeB = (transB == HIPBLASLT_OP_N ? n : k) * size_t(ldb); size_t sizeC = n * size_t(ldc); host_vector A_float(sizeA), B_float(sizeB), C_float(sizeC); @@ -211,8 +211,8 @@ void cblas_gemm(hipblasOperation_t transA } template <> -void cblas_gemm(hipblasOperation_t transA, - hipblasOperation_t transB, +void cblas_gemm(hipblasltOperation_t transA, + hipblasltOperation_t transB, int64_t m, int64_t n, int64_t k, @@ -229,8 +229,8 @@ void cblas_gemm(hipblasOperation_t transA, // cblas does not support hipblasLtHalf, so convert to higher precision float // This will give more precise result which is acceptable for testing - size_t sizeA = (transA == HIPBLAS_OP_N ? k : m) * size_t(lda); - size_t sizeB = (transB == HIPBLAS_OP_N ? n : k) * size_t(ldb); + size_t sizeA = (transA == HIPBLASLT_OP_N ? k : m) * size_t(lda); + size_t sizeB = (transB == HIPBLASLT_OP_N ? n : k) * size_t(ldb); host_vector A_float(sizeA), B_float(sizeB); @@ -268,8 +268,8 @@ void cblas_gemm(hipblasOperation_t transA, } template <> -void cblas_gemm(hipblasOperation_t transA, - hipblasOperation_t transB, +void cblas_gemm(hipblasltOperation_t transA, + hipblasltOperation_t transB, int64_t m, int64_t n, int64_t k, diff --git a/clients/common/hipblaslt_arguments.cpp b/clients/common/hipblaslt_arguments.cpp index 0b96338c5e..ae2881020f 100644 --- a/clients/common/hipblaslt_arguments.cpp +++ b/clients/common/hipblaslt_arguments.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -68,12 +68,12 @@ void Arguments::init() algo = 0; solution_index = 0; - a_type = HIPBLAS_R_16F; - b_type = HIPBLAS_R_16F; - c_type = HIPBLAS_R_16F; - d_type = HIPBLAS_R_16F; + a_type = HIP_R_16F; + b_type = HIP_R_16F; + c_type = HIP_R_16F; + d_type = HIP_R_16F; compute_type = HIPBLASLT_COMPUTE_F32; - scale_type = HIPBLAS_R_32F; + scale_type = HIP_R_32F; initialization = hipblaslt_initialization::hpl; @@ -97,7 +97,7 @@ void Arguments::init() activation_type = hipblaslt_activation_type::none; activation_arg1 = 0.0f; activation_arg2 = std::numeric_limits::infinity(); - bias_type = static_cast(-1); + bias_type = static_cast(-1); bias_vector = false; c_noalias_d = false; HMM = false; diff --git a/clients/common/utility.cpp b/clients/common/utility.cpp index 5ce1495c93..4c3dc0957e 100644 --- a/clients/common/utility.cpp +++ b/clients/common/utility.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -146,8 +146,8 @@ double get_time_us_no_sync(void) int64_t query_device_property() { int device_count; - hipblasStatus_t status = (hipblasStatus_t)hipGetDeviceCount(&device_count); - if(status != HIPBLAS_STATUS_SUCCESS) + hipblasltStatus_t status = (hipblasltStatus_t)hipGetDeviceCount(&device_count); + if(status != HIPBLASLT_STATUS_SUCCESS) { hipblaslt_cerr << "Query device error: cannot get device count" << std::endl; return -1; @@ -168,8 +168,8 @@ int64_t query_device_property() break; hipDeviceProp_t props; - hipblasStatus_t status = (hipblasStatus_t)hipGetDeviceProperties(&props, i); - if(status != HIPBLAS_STATUS_SUCCESS) + hipblasltStatus_t status = (hipblasltStatus_t)hipGetDeviceProperties(&props, i); + if(status != HIPBLASLT_STATUS_SUCCESS) { hipblaslt_cerr << "Query device error: cannot get device ID " << i << "'s property" << std::endl; @@ -206,8 +206,8 @@ int64_t query_device_property() /* set current device to device_id */ void set_device(int64_t device_id) { - hipblasStatus_t status = (hipblasStatus_t)hipSetDevice(device_id); - if(status != HIPBLAS_STATUS_SUCCESS) + hipblasltStatus_t status = (hipblasltStatus_t)hipSetDevice(device_id); + if(status != HIPBLASLT_STATUS_SUCCESS) { hipblaslt_cerr << "Set device error: cannot set device ID " << device_id << ", there may not be such device ID" << std::endl; @@ -221,8 +221,8 @@ void set_device(int64_t device_id) hipblaslt_local_handle::hipblaslt_local_handle() { auto status = hipblasLtCreate(&m_handle); - if(status != HIPBLAS_STATUS_SUCCESS) - throw std::runtime_error(hipblas_status_to_string(status)); + if(status != HIPBLASLT_STATUS_SUCCESS) + throw std::runtime_error(hipblaslt_status_to_string(status)); #ifdef GOOGLE_TEST if(t_set_stream_callback) diff --git a/clients/gtest/CMakeLists.txt b/clients/gtest/CMakeLists.txt index 59938da5de..647530b85b 100644 --- a/clients/gtest/CMakeLists.txt +++ b/clients/gtest/CMakeLists.txt @@ -1,5 +1,5 @@ # ######################################################################## -# Copyright (C) 2022 Advanced Micro Devices, Inc. +# Copyright (C) 2022-2023 Advanced Micro Devices, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -53,7 +53,7 @@ target_include_directories( hipblaslt-test $ ) message("BLIS_INCLUDE_DIR=" ${BLIS_INCLUDE_DIR}) -target_link_libraries( hipblaslt-test PRIVATE ${BLAS_LIBRARY} ${GTEST_BOTH_LIBRARIES} roc::hipblas roc::hipblaslt ) +target_link_libraries( hipblaslt-test PRIVATE ${BLAS_LIBRARY} ${GTEST_BOTH_LIBRARIES} roc::hipblaslt ) if( NOT BUILD_CUDA ) target_link_libraries( hipblaslt-test PRIVATE hip::host hip::device ) diff --git a/clients/gtest/auxiliary_gtest.cpp b/clients/gtest/auxiliary_gtest.cpp index c1c5ef778b..03a9211b5f 100644 --- a/clients/gtest/auxiliary_gtest.cpp +++ b/clients/gtest/auxiliary_gtest.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -142,7 +142,7 @@ namespace { RocBlasLt_TestName name(arg.name); - name << hipblas_datatype_to_string(arg.a_type); + name << hip_datatype_to_string(arg.a_type); return std::move(name); } diff --git a/clients/gtest/hipblaslt_test.cpp b/clients/gtest/hipblaslt_test.cpp index 91f36b7aa3..72ceec64d9 100644 --- a/clients/gtest/hipblaslt_test.cpp +++ b/clients/gtest/hipblaslt_test.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -376,7 +376,7 @@ bool match_test_category(const Arguments& arg, const char* category) // The name of the current GPU platform char* archName; - if(hipblasLtGetArchName(&archName) != HIPBLAS_STATUS_SUCCESS) + if(hipblasLtGetArchName(&archName) != HIPBLASLT_STATUS_SUCCESS) return false; static const std::string platform(archName); diff --git a/clients/gtest/matmul_gtest.cpp b/clients/gtest/matmul_gtest.cpp index 923e37e134..6a262032c3 100644 --- a/clients/gtest/matmul_gtest.cpp +++ b/clients/gtest/matmul_gtest.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -96,10 +96,10 @@ namespace } else { - name << hipblas_datatype_to_string(arg.a_type) - << hipblas_datatype_to_string(arg.b_type) - << hipblas_datatype_to_string(arg.c_type) - << hipblas_datatype_to_string(arg.d_type) + name << hip_datatype_to_string(arg.a_type) + << hip_datatype_to_string(arg.b_type) + << hip_datatype_to_string(arg.c_type) + << hip_datatype_to_string(arg.d_type) << hipblaslt_computetype_to_string(arg.compute_type); if(arg.activation_type != hipblaslt_activation_type::none) @@ -111,7 +111,7 @@ namespace { name << "_BIAS"; if(arg.d_type != arg.scale_type && arg.bias_type == arg.scale_type) - name << hipblas_datatype_to_string(arg.bias_type); + name << hip_datatype_to_string(arg.bias_type); } name << '_' << (char)std::toupper(arg.transA) << (char)std::toupper(arg.transB); diff --git a/clients/include/cblas_interface.hpp b/clients/include/cblas_interface.hpp index d357d0ae72..a4854fd990 100644 --- a/clients/include/cblas_interface.hpp +++ b/clients/include/cblas_interface.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -37,8 +37,8 @@ // gemm template -void cblas_gemm(hipblasOperation_t transA, - hipblasOperation_t transB, +void cblas_gemm(hipblasltOperation_t transA, + hipblasltOperation_t transB, int64_t m, int64_t n, int64_t k, diff --git a/clients/include/hipblaslt_arguments.hpp b/clients/include/hipblaslt_arguments.hpp index cb0e798369..2eb8f0b82b 100644 --- a/clients/include/hipblaslt_arguments.hpp +++ b/clients/include/hipblaslt_arguments.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -83,12 +83,12 @@ struct Arguments uint32_t algo; int32_t solution_index; - hipblasDatatype_t a_type; - hipblasDatatype_t b_type; - hipblasDatatype_t c_type; - hipblasDatatype_t d_type; + hipDataType a_type; + hipDataType b_type; + hipDataType c_type; + hipDataType d_type; hipblasLtComputeType_t compute_type; - hipblasDatatype_t scale_type; + hipDataType scale_type; hipblaslt_initialization initialization; @@ -113,7 +113,7 @@ struct Arguments float activation_arg1; // threshold when activation type is relu float activation_arg2; // upperbound when activation type is relu - hipblasDatatype_t bias_type; + hipDataType bias_type; bool bias_vector; bool c_noalias_d; bool HMM; @@ -198,7 +198,7 @@ struct Arguments std::pair p); friend hipblaslt_internal_ostream& operator<<(hipblaslt_internal_ostream& os, - std::pair p); + std::pair p); friend hipblaslt_internal_ostream& operator<<(hipblaslt_internal_ostream& os, diff --git a/clients/include/hipblaslt_common.yaml b/clients/include/hipblaslt_common.yaml index e31d114a3a..dcdee1682b 100644 --- a/clients/include/hipblaslt_common.yaml +++ b/clients/include/hipblaslt_common.yaml @@ -1,7 +1,7 @@ # Data types are defined as either aliases to Python-recognized ctypes, # or enums defined with c_int base clases and attributes. Datatypes: - - hipblasDatatype_t: + - hipDataType: bases: [ c_int ] attr: default: -1 @@ -76,12 +76,12 @@ Arguments: - cold_iters: c_int32 - algo: c_uint32 - solution_index: c_int32 - - a_type: hipblasDatatype_t - - b_type: hipblasDatatype_t - - c_type: hipblasDatatype_t - - d_type: hipblasDatatype_t + - a_type: hipDataType + - b_type: hipDataType + - c_type: hipDataType + - d_type: hipDataType - compute_type: hipblasLtComputeType_t - - scale_type: hipblasDatatype_t + - scale_type: hipDataType - initialization: hipblaslt_initialization - pad: c_uint32 - threads: c_uint16 @@ -95,7 +95,7 @@ Arguments: - activation_type: hipblaslt_activation_type - activation_arg1: c_float - activation_arg2: c_float - - bias_type: hipblasDatatype_t + - bias_type: hipDataType - bias_vector: c_bool - c_noalias_d: c_bool - HMM: c_bool diff --git a/clients/include/hipblaslt_test.hpp b/clients/include/hipblaslt_test.hpp index d8d7d4f344..e67ec2795e 100644 --- a/clients/include/hipblaslt_test.hpp +++ b/clients/include/hipblaslt_test.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -75,12 +75,12 @@ // This wraps the hipBLASLt call with catch_signals_and_exceptions_as_failures(). // By placing it at the hipBLASLt call site, memory resources are less likely to // be leaked in the event of a caught signal. -#define EXPECT_HIPBLAS_STATUS(STATUS, EXPECT) \ +#define EXPECT_HIPBLASLT_STATUS(STATUS, EXPECT) \ do \ { \ volatile bool signal_or_exception = true; \ /* Use status__ in case STATUS contains "status" */ \ - hipblasStatus_t status__; \ + hipblasltStatus_t status__; \ catch_signals_and_exceptions_as_failures([&] { \ status__ = (STATUS); \ signal_or_exception = false; \ @@ -88,20 +88,20 @@ if(signal_or_exception) \ return; \ { /* localize status for ASSERT_EQ message */ \ - hipblasStatus_t status_ = status__; \ + hipblasltStatus_t status_ = status__; \ ASSERT_EQ(status_, EXPECT); /* prints "status" */ \ } \ } while(0) #else // GOOGLE_TEST -inline void hipblaslt_expect_status(hipblasStatus_t status, hipblasStatus_t expect) +inline void hipblaslt_expect_status(hipblasltStatus_t status, hipblasltStatus_t expect) { if(status != expect) { - hipblaslt_cerr << "hipBLASLt status error: Expected " << hipblas_status_to_string(expect) - << ", received " << hipblas_status_to_string(status) << std::endl; - if(expect == HIPBLAS_STATUS_SUCCESS) + hipblaslt_cerr << "hipBLASLt status error: Expected " << hipblaslt_status_to_string(expect) + << ", received " << hipblaslt_status_to_string(status) << std::endl; + if(expect == HIPBLASLT_STATUS_SUCCESS) exit(EXIT_FAILURE); } } @@ -121,7 +121,7 @@ inline void hipblaslt_expect_status(hipblasStatus_t status, hipblasStatus_t expe #define CHECK_DEVICE_ALLOCATION CHECK_HIP_ERROR -#define EXPECT_HIPBLAS_STATUS hipblaslt_expect_status +#define EXPECT_HIPBLASLT_STATUS hipblaslt_expect_status #define CHECK_SUCCESS(ERROR) \ if(!(ERROR)) \ @@ -129,7 +129,7 @@ inline void hipblaslt_expect_status(hipblasStatus_t status, hipblasStatus_t expe #endif // GOOGLE_TEST -#define CHECK_HIPBLASLT_ERROR2(STATUS) EXPECT_HIPBLAS_STATUS(STATUS, HIPBLAS_STATUS_SUCCESS) +#define CHECK_HIPBLASLT_ERROR2(STATUS) EXPECT_HIPBLASLT_STATUS(STATUS, HIPBLASLT_STATUS_SUCCESS) #define CHECK_HIPBLASLT_ERROR(STATUS) CHECK_HIPBLASLT_ERROR2(STATUS) #ifdef GOOGLE_TEST @@ -404,10 +404,10 @@ struct hipblaslt_test_invalid #else hipblaslt_cerr << msg << std::endl; hipblaslt_cerr << "function: " << arg.function << " types: " - << " a: " << hipblas_datatype_to_string(arg.a_type) - << " b: " << hipblas_datatype_to_string(arg.b_type) - << " c: " << hipblas_datatype_to_string(arg.c_type) - << " d: " << hipblas_datatype_to_string(arg.d_type) + << " a: " << hip_datatype_to_string(arg.a_type) + << " b: " << hip_datatype_to_string(arg.b_type) + << " c: " << hip_datatype_to_string(arg.c_type) + << " d: " << hip_datatype_to_string(arg.d_type) << " compute:" << hipblaslt_computetype_to_string(arg.compute_type) << std::endl; hipblaslt_abort(); diff --git a/clients/include/testing_auxiliary.hpp b/clients/include/testing_auxiliary.hpp index 6de05a2b8c..a54e86973e 100644 --- a/clients/include/testing_auxiliary.hpp +++ b/clients/include/testing_auxiliary.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -39,19 +39,19 @@ void testing_aux_handle_init_bad_arg(const Arguments& arg) { - EXPECT_HIPBLAS_STATUS(hipblasLtCreate(nullptr), HIPBLAS_STATUS_INVALID_VALUE); + EXPECT_HIPBLASLT_STATUS(hipblasLtCreate(nullptr), HIPBLASLT_STATUS_INVALID_VALUE); } void testing_aux_handle_destroy_bad_arg(const Arguments& arg) { - EXPECT_HIPBLAS_STATUS(hipblasLtDestroy(nullptr), HIPBLAS_STATUS_INVALID_VALUE); + EXPECT_HIPBLASLT_STATUS(hipblasLtDestroy(nullptr), HIPBLASLT_STATUS_INVALID_VALUE); } void testing_aux_handle(const Arguments& arg) { hipblasLtHandle_t handle; - EXPECT_HIPBLAS_STATUS(hipblasLtCreate(&handle), HIPBLAS_STATUS_SUCCESS); - EXPECT_HIPBLAS_STATUS(hipblasLtDestroy(handle), HIPBLAS_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS(hipblasLtCreate(&handle), HIPBLASLT_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS(hipblasLtDestroy(handle), HIPBLASLT_STATUS_SUCCESS); } void testing_aux_mat_init_bad_arg(const Arguments& arg) @@ -62,8 +62,8 @@ void testing_aux_mat_init_bad_arg(const Arguments& arg) hipblasLtMatrixLayout_t m_descr; - EXPECT_HIPBLAS_STATUS(hipblasLtMatrixLayoutCreate(nullptr, arg.a_type, row, col, ld), - HIPBLAS_STATUS_INVALID_VALUE); + EXPECT_HIPBLASLT_STATUS(hipblasLtMatrixLayoutCreate(nullptr, arg.a_type, row, col, ld), + HIPBLASLT_STATUS_INVALID_VALUE); } void testing_aux_mat_init(const Arguments& arg) @@ -74,12 +74,12 @@ void testing_aux_mat_init(const Arguments& arg) hipblaslt_local_handle handle{arg}; hipblaslt_local_matrix_layout mat(row, col, ld, arg.a_type); - EXPECT_HIPBLAS_STATUS(mat.status(), HIPBLAS_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS(mat.status(), HIPBLASLT_STATUS_SUCCESS); } void testing_aux_mat_destroy_bad_arg(const Arguments& arg) { - EXPECT_HIPBLAS_STATUS(hipblasLtMatrixLayoutDestroy(nullptr), HIPBLAS_STATUS_INVALID_VALUE); + EXPECT_HIPBLASLT_STATUS(hipblasLtMatrixLayoutDestroy(nullptr), HIPBLASLT_STATUS_INVALID_VALUE); } void testing_aux_mat_set_attr_bad_arg(const Arguments& arg) @@ -92,26 +92,26 @@ void testing_aux_mat_set_attr_bad_arg(const Arguments& arg) int64_t data64; hipblaslt_local_matrix_layout mat(row, col, ld, arg.a_type); - EXPECT_HIPBLAS_STATUS(mat.status(), HIPBLAS_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS(mat.status(), HIPBLASLT_STATUS_SUCCESS); - EXPECT_HIPBLAS_STATUS(hipblasLtMatrixLayoutSetAttribute( + EXPECT_HIPBLASLT_STATUS(hipblasLtMatrixLayoutSetAttribute( mat, HIPBLASLT_MATRIX_LAYOUT_BATCH_COUNT, nullptr, sizeof(int)), - HIPBLAS_STATUS_INVALID_VALUE); + HIPBLASLT_STATUS_INVALID_VALUE); data = 1; - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutSetAttribute(mat, HIPBLASLT_MATRIX_LAYOUT_BATCH_COUNT, &data, 1), - HIPBLAS_STATUS_INVALID_VALUE); + HIPBLASLT_STATUS_INVALID_VALUE); - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutSetAttribute( mat, HIPBLASLT_MATRIX_LAYOUT_STRIDED_BATCH_OFFSET, nullptr, sizeof(int64_t)), - HIPBLAS_STATUS_INVALID_VALUE); + HIPBLASLT_STATUS_INVALID_VALUE); data64 = ld * col; - EXPECT_HIPBLAS_STATUS(hipblasLtMatrixLayoutSetAttribute( + EXPECT_HIPBLASLT_STATUS(hipblasLtMatrixLayoutSetAttribute( mat, HIPBLASLT_MATRIX_LAYOUT_STRIDED_BATCH_OFFSET, &data64, 1), - HIPBLAS_STATUS_INVALID_VALUE); + HIPBLASLT_STATUS_INVALID_VALUE); } void testing_aux_mat_get_attr_bad_arg(const Arguments& arg) @@ -121,35 +121,35 @@ void testing_aux_mat_get_attr_bad_arg(const Arguments& arg) const int64_t ld = 128; hipblaslt_local_matrix_layout mat(row, col, ld, arg.a_type); - EXPECT_HIPBLAS_STATUS(mat.status(), HIPBLAS_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS(mat.status(), HIPBLASLT_STATUS_SUCCESS); int data; int64_t data64; size_t sizeWritten; - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutGetAttribute( nullptr, HIPBLASLT_MATRIX_LAYOUT_BATCH_COUNT, &data, sizeof(int), &sizeWritten), - HIPBLAS_STATUS_NOT_INITIALIZED); + HIPBLASLT_STATUS_NOT_INITIALIZED); - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutGetAttribute( mat, HIPBLASLT_MATRIX_LAYOUT_BATCH_COUNT, nullptr, sizeof(int), &sizeWritten), - HIPBLAS_STATUS_INVALID_VALUE); - EXPECT_HIPBLAS_STATUS(hipblasLtMatrixLayoutGetAttribute( + HIPBLASLT_STATUS_INVALID_VALUE); + EXPECT_HIPBLASLT_STATUS(hipblasLtMatrixLayoutGetAttribute( mat, HIPBLASLT_MATRIX_LAYOUT_BATCH_COUNT, &data, 1, &sizeWritten), - HIPBLAS_STATUS_INVALID_VALUE); - EXPECT_HIPBLAS_STATUS( + HIPBLASLT_STATUS_INVALID_VALUE); + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutGetAttribute(mat, HIPBLASLT_MATRIX_LAYOUT_STRIDED_BATCH_OFFSET, nullptr, sizeof(int64_t), &sizeWritten), - HIPBLAS_STATUS_INVALID_VALUE); - EXPECT_HIPBLAS_STATUS( + HIPBLASLT_STATUS_INVALID_VALUE); + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutGetAttribute( mat, HIPBLASLT_MATRIX_LAYOUT_STRIDED_BATCH_OFFSET, &data64, sizeof(int), &sizeWritten), - HIPBLAS_STATUS_INVALID_VALUE); + HIPBLASLT_STATUS_INVALID_VALUE); } void testing_aux_mat_set_get_attr(const Arguments& arg) @@ -159,125 +159,125 @@ void testing_aux_mat_set_get_attr(const Arguments& arg) const int64_t ld = 128; hipblaslt_local_matrix_layout mat(row, col, ld, arg.a_type); - EXPECT_HIPBLAS_STATUS(mat.status(), HIPBLAS_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS(mat.status(), HIPBLASLT_STATUS_SUCCESS); int32_t data, data_r; size_t sizeWritten; data = 2; - EXPECT_HIPBLAS_STATUS(hipblasLtMatrixLayoutSetAttribute( + EXPECT_HIPBLASLT_STATUS(hipblasLtMatrixLayoutSetAttribute( mat, HIPBLASLT_MATRIX_LAYOUT_BATCH_COUNT, &data, sizeof(data)), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutGetAttribute( mat, HIPBLASLT_MATRIX_LAYOUT_BATCH_COUNT, &data_r, sizeof(data), &sizeWritten), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); ASSERT_TRUE(data_r == data); std::vector data64_v = {0, ld * col}; int64_t data64_r = 0; for(int64_t data64 : data64_v) { - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutSetAttribute( mat, HIPBLASLT_MATRIX_LAYOUT_STRIDED_BATCH_OFFSET, &data64, sizeof(int64_t)), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutGetAttribute(mat, HIPBLASLT_MATRIX_LAYOUT_STRIDED_BATCH_OFFSET, &data64_r, sizeof(int64_t), &sizeWritten), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); ASSERT_TRUE(data64_r == data64); } } void testing_aux_matmul_init_bad_arg(const Arguments& arg) { - EXPECT_HIPBLAS_STATUS(hipblasLtMatmulDescCreate(nullptr, arg.compute_type, arg.scale_type), - HIPBLAS_STATUS_INVALID_VALUE); + EXPECT_HIPBLASLT_STATUS(hipblasLtMatmulDescCreate(nullptr, arg.compute_type, arg.scale_type), + HIPBLASLT_STATUS_INVALID_VALUE); } void testing_aux_matmul_init(const Arguments& arg) { - const hipblasOperation_t opA = HIPBLAS_OP_T; - const hipblasOperation_t opB = HIPBLAS_OP_N; + const hipblasltOperation_t opA = HIPBLASLT_OP_T; + const hipblasltOperation_t opB = HIPBLASLT_OP_N; hipblaslt_local_matmul_descr matmul(opA, opB, arg.compute_type, arg.scale_type); - EXPECT_HIPBLAS_STATUS(matmul.status(), HIPBLAS_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS(matmul.status(), HIPBLASLT_STATUS_SUCCESS); } void testing_aux_matmul_set_attr_bad_arg(const Arguments& arg) { - const hipblasOperation_t opA = HIPBLAS_OP_T; - const hipblasOperation_t opB = HIPBLAS_OP_N; + const hipblasltOperation_t opA = HIPBLASLT_OP_T; + const hipblasltOperation_t opB = HIPBLASLT_OP_N; hipblaslt_local_matmul_descr matmul(opA, opB, arg.compute_type, arg.scale_type); - EXPECT_HIPBLAS_STATUS(matmul.status(), HIPBLAS_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS(matmul.status(), HIPBLASLT_STATUS_SUCCESS); hipblasLtEpilogue_t data = HIPBLASLT_EPILOGUE_RELU; - EXPECT_HIPBLAS_STATUS(hipblasLtMatmulDescSetAttribute( + EXPECT_HIPBLASLT_STATUS(hipblasLtMatmulDescSetAttribute( nullptr, HIPBLASLT_MATMUL_DESC_EPILOGUE, &data, sizeof(data)), - HIPBLAS_STATUS_NOT_INITIALIZED); + HIPBLASLT_STATUS_NOT_INITIALIZED); - EXPECT_HIPBLAS_STATUS(hipblasLtMatmulDescSetAttribute( + EXPECT_HIPBLASLT_STATUS(hipblasLtMatmulDescSetAttribute( matmul, HIPBLASLT_MATMUL_DESC_EPILOGUE, nullptr, sizeof(data)), - HIPBLAS_STATUS_INVALID_VALUE); - EXPECT_HIPBLAS_STATUS( + HIPBLASLT_STATUS_INVALID_VALUE); + EXPECT_HIPBLASLT_STATUS( hipblasLtMatmulDescSetAttribute(matmul, HIPBLASLT_MATMUL_DESC_EPILOGUE, &data, 1), - HIPBLAS_STATUS_INVALID_VALUE); + HIPBLASLT_STATUS_INVALID_VALUE); } void testing_aux_matmul_get_attr_bad_arg(const Arguments& arg) { - const hipblasOperation_t opA = HIPBLAS_OP_T; - const hipblasOperation_t opB = HIPBLAS_OP_N; + const hipblasltOperation_t opA = HIPBLASLT_OP_T; + const hipblasltOperation_t opB = HIPBLASLT_OP_N; hipblaslt_local_matmul_descr matmul(opA, opB, arg.compute_type, arg.scale_type); - EXPECT_HIPBLAS_STATUS(matmul.status(), HIPBLAS_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS(matmul.status(), HIPBLASLT_STATUS_SUCCESS); hipblasLtEpilogue_t data = HIPBLASLT_EPILOGUE_RELU; size_t sizeWritten; - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatmulDescGetAttribute( nullptr, HIPBLASLT_MATMUL_DESC_EPILOGUE, &data, sizeof(data), &sizeWritten), - HIPBLAS_STATUS_NOT_INITIALIZED); + HIPBLASLT_STATUS_NOT_INITIALIZED); - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatmulDescGetAttribute( matmul, HIPBLASLT_MATMUL_DESC_EPILOGUE, nullptr, sizeof(data), &sizeWritten), - HIPBLAS_STATUS_INVALID_VALUE); - EXPECT_HIPBLAS_STATUS(hipblasLtMatmulDescGetAttribute( + HIPBLASLT_STATUS_INVALID_VALUE); + EXPECT_HIPBLASLT_STATUS(hipblasLtMatmulDescGetAttribute( matmul, HIPBLASLT_MATMUL_DESC_EPILOGUE, &data, 1, &sizeWritten), - HIPBLAS_STATUS_INVALID_VALUE); + HIPBLASLT_STATUS_INVALID_VALUE); void* dBias = nullptr; - EXPECT_HIPBLAS_STATUS(hipblasLtMatmulDescGetAttribute( + EXPECT_HIPBLASLT_STATUS(hipblasLtMatmulDescGetAttribute( matmul, HIPBLASLT_MATMUL_DESC_BIAS_POINTER, &dBias, 4, &sizeWritten), - HIPBLAS_STATUS_INVALID_VALUE); + HIPBLASLT_STATUS_INVALID_VALUE); } void testing_aux_matmul_set_get_attr(const Arguments& arg) { - const hipblasOperation_t opA = HIPBLAS_OP_T; - const hipblasOperation_t opB = HIPBLAS_OP_N; + const hipblasltOperation_t opA = HIPBLASLT_OP_T; + const hipblasltOperation_t opB = HIPBLASLT_OP_N; hipblaslt_local_matmul_descr matmul(opA, opB, arg.compute_type, arg.scale_type); - EXPECT_HIPBLAS_STATUS(matmul.status(), HIPBLAS_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS(matmul.status(), HIPBLASLT_STATUS_SUCCESS); hipblasLtEpilogue_t data = HIPBLASLT_EPILOGUE_DEFAULT; hipblasLtEpilogue_t data_r = HIPBLASLT_EPILOGUE_RELU; size_t sizeWritten; - EXPECT_HIPBLAS_STATUS(hipblasLtMatmulDescSetAttribute( + EXPECT_HIPBLASLT_STATUS(hipblasLtMatmulDescSetAttribute( matmul, HIPBLASLT_MATMUL_DESC_EPILOGUE, &data, sizeof(data)), - HIPBLAS_STATUS_SUCCESS); - EXPECT_HIPBLAS_STATUS( + HIPBLASLT_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS( hipblasLtMatmulDescGetAttribute( matmul, HIPBLASLT_MATMUL_DESC_EPILOGUE, &data_r, sizeof(data_r), &sizeWritten), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); ASSERT_TRUE(data == data_r); } @@ -294,11 +294,11 @@ void testing_aux_matmul_pref_init_bad_arg(const Arguments& arg) hipblasLtMatmulPreference_t pref; size_t workspace_size = 0; - EXPECT_HIPBLAS_STATUS(hipblasLtMatmulPreferenceCreate(nullptr), HIPBLAS_STATUS_INVALID_VALUE); + EXPECT_HIPBLASLT_STATUS(hipblasLtMatmulPreferenceCreate(nullptr), HIPBLASLT_STATUS_INVALID_VALUE); } void testing_aux_matmul_pref_init(const Arguments& arg) { hipblaslt_local_preference pref; - EXPECT_HIPBLAS_STATUS(pref.status(), HIPBLAS_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS(pref.status(), HIPBLASLT_STATUS_SUCCESS); } diff --git a/clients/include/testing_matmul.hpp b/clients/include/testing_matmul.hpp index 9ddae914cb..42824f394d 100644 --- a/clients/include/testing_matmul.hpp +++ b/clients/include/testing_matmul.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -114,8 +114,8 @@ void testing_matmul_bad_arg(const Arguments& arg) const size_t safe_size = N * lda; - const hipblasOperation_t transA = HIPBLAS_OP_T; - const hipblasOperation_t transB = HIPBLAS_OP_N; + const hipblasltOperation_t transA = HIPBLASLT_OP_T; + const hipblasltOperation_t transB = HIPBLASLT_OP_N; // allocate memory on device device_vector dA(safe_size / 2); @@ -149,8 +149,8 @@ template void testing_matmul(const Arguments& arg) { - hipblasOperation_t transA = char_to_hipblas_operation(arg.transA); - hipblasOperation_t transB = char_to_hipblas_operation(arg.transB); + hipblasltOperation_t transA = char_to_hipblaslt_operation(arg.transA); + hipblasltOperation_t transB = char_to_hipblaslt_operation(arg.transB); using Talpha = float; @@ -172,13 +172,13 @@ void testing_matmul(const Arguments& arg) hipStream_t stream; CHECK_HIP_ERROR(hipStreamCreate(&stream)); - int64_t A_row = transA == HIPBLAS_OP_N ? M : K; - int64_t A_col = transA == HIPBLAS_OP_N ? K : M; - int64_t B_row = transB == HIPBLAS_OP_N ? K : N; - int64_t B_col = transB == HIPBLAS_OP_N ? N : K; + int64_t A_row = transA == HIPBLASLT_OP_N ? M : K; + int64_t A_col = transA == HIPBLASLT_OP_N ? K : M; + int64_t B_row = transB == HIPBLASLT_OP_N ? K : N; + int64_t B_col = transB == HIPBLASLT_OP_N ? N : K; - int64_t stride_1_a = transA == HIPBLAS_OP_N ? 1 : lda; - int64_t stride_2_a = transA == HIPBLAS_OP_N ? lda : 1; + int64_t stride_1_a = transA == HIPBLASLT_OP_N ? 1 : lda; + int64_t stride_2_a = transA == HIPBLASLT_OP_N ? lda : 1; constexpr bool do_batched = (btype == hipblaslt_batch_type::batched); int num_batches = (do_batched ? arg.batch_count : 1); @@ -194,22 +194,22 @@ void testing_matmul(const Arguments& arg) if(do_batched) { - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutSetAttribute( matA, HIPBLASLT_MATRIX_LAYOUT_BATCH_COUNT, &num_batches, sizeof(int)), - HIPBLAS_STATUS_SUCCESS); - EXPECT_HIPBLAS_STATUS( + HIPBLASLT_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutSetAttribute( matB, HIPBLASLT_MATRIX_LAYOUT_BATCH_COUNT, &num_batches, sizeof(int)), - HIPBLAS_STATUS_SUCCESS); - EXPECT_HIPBLAS_STATUS( + HIPBLASLT_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutSetAttribute( matC, HIPBLASLT_MATRIX_LAYOUT_BATCH_COUNT, &num_batches, sizeof(int)), - HIPBLAS_STATUS_SUCCESS); - EXPECT_HIPBLAS_STATUS( + HIPBLASLT_STATUS_SUCCESS); + EXPECT_HIPBLASLT_STATUS( hipblasLtMatrixLayoutSetAttribute( matD, HIPBLASLT_MATRIX_LAYOUT_BATCH_COUNT, &num_batches, sizeof(int)), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); } hipblaslt_local_matmul_descr matmul(transA, transB, arg.compute_type, arg.scale_type); @@ -251,12 +251,12 @@ void testing_matmul(const Arguments& arg) size_t workspace_size = 1024; hipblaslt_local_preference pref; - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatmulPreferenceSetAttribute(pref, HIPBLASLT_MATMUL_PREF_MAX_WORKSPACE_BYTES, &workspace_size, sizeof(workspace_size)), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); const size_t size_A = stride_a == 0 ? lda * A_col * num_batches : stride_a * num_batches; @@ -369,10 +369,10 @@ void testing_matmul(const Arguments& arg) } if(epilogue_on) - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatmulDescSetAttribute( matmul, HIPBLASLT_MATMUL_DESC_EPILOGUE, &epilogue, sizeof(epilogue)), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); bool change_bias_type = false; if(arg.bias_vector) @@ -382,35 +382,35 @@ void testing_matmul(const Arguments& arg) { bias_addr = dBias_C; change_bias_type = true; - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatmulDescSetAttribute(matmul, HIPBLASLT_MATMUL_DESC_BIAS_DATA_TYPE, &arg.bias_type, - sizeof(hipblasDatatype_t)), - HIPBLAS_STATUS_SUCCESS); + sizeof(hipDataType)), + HIPBLASLT_STATUS_SUCCESS); } else { bias_addr = dBias; } - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( hipblasLtMatmulDescSetAttribute( matmul, HIPBLASLT_MATMUL_DESC_BIAS_POINTER, &bias_addr, sizeof(void*)), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); } // Get Heuristic results hipblasLtMatmulHeuristicResult_t heuristicResult[3] = {0}; int returnedAlgoCount = 0; - EXPECT_HIPBLAS_STATUS( + EXPECT_HIPBLASLT_STATUS( (hipblasLtMatmulAlgoGetHeuristic( handle, matmul, matA, matB, matC, matD, pref, 3, heuristicResult, &returnedAlgoCount)), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); if(arg.unit_check || arg.norm_check) { CHECK_HIP_ERROR(hipStreamSynchronize(stream)); - EXPECT_HIPBLAS_STATUS(hipblasLtMatmul(handle, + EXPECT_HIPBLASLT_STATUS(hipblasLtMatmul(handle, matmul, &h_alpha, dA, @@ -426,7 +426,7 @@ void testing_matmul(const Arguments& arg) dWorkspace, workspace_size, stream), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); // now we can recycle gold matrix for reference purposes if(arg.timing) { @@ -544,7 +544,7 @@ void testing_matmul(const Arguments& arg) int number_hot_calls = arg.iters; for(int i = 0; i < number_cold_calls; i++) { - EXPECT_HIPBLAS_STATUS(hipblasLtMatmul(handle, + EXPECT_HIPBLASLT_STATUS(hipblasLtMatmul(handle, matmul, &h_alpha, dA, @@ -560,14 +560,14 @@ void testing_matmul(const Arguments& arg) dWorkspace, workspace_size, stream), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); } CHECK_HIP_ERROR(hipStreamSynchronize(stream)); gpu_time_used = get_time_us_sync(stream); // in microseconds for(int i = 0; i < number_hot_calls; i++) { - EXPECT_HIPBLAS_STATUS(hipblasLtMatmul(handle, + EXPECT_HIPBLASLT_STATUS(hipblasLtMatmul(handle, matmul, &h_alpha, dA, @@ -583,7 +583,7 @@ void testing_matmul(const Arguments& arg) dWorkspace, workspace_size, stream), - HIPBLAS_STATUS_SUCCESS); + HIPBLASLT_STATUS_SUCCESS); } CHECK_HIP_ERROR(hipStreamSynchronize(stream)); gpu_time_used = get_time_us_sync(stream) - gpu_time_used; diff --git a/clients/include/type_dispatch.hpp b/clients/include/type_dispatch.hpp index 1a5601ddc9..0e5039b55c 100644 --- a/clients/include/type_dispatch.hpp +++ b/clients/include/type_dispatch.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -33,13 +33,13 @@ template constexpr auto hipblaslt_type2datatype() { if(std::is_same{}) - return HIPBLAS_R_16F; + return HIP_R_16F; if(std::is_same{}) - return HIPBLAS_R_16B; + return HIP_R_16BF; if(std::is_same{}) - return HIPBLAS_R_32F; + return HIP_R_32F; - return HIPBLAS_R_16F; // testing purposes we default to f32 ex + return HIP_R_16F; // testing purposes we default to f32 ex } // ---------------------------------------------------------------------------- @@ -59,11 +59,11 @@ auto hipblaslt_simple_dispatch(const Arguments& arg) { switch(arg.a_type) { - case HIPBLAS_R_16F: + case HIP_R_16F: return TEST{}(arg); - case HIPBLAS_R_16B: + case HIP_R_16BF: return TEST{}(arg); - case HIPBLAS_R_32F: + case HIP_R_32F: return TEST{}(arg); default: return TEST{}(arg); @@ -79,15 +79,15 @@ auto hipblaslt_matmul_dispatch(const Arguments& arg) if(arg.b_type == Ti && arg.d_type == To) { - if(Ti == To && To == HIPBLAS_R_16F && Tc == HIPBLASLT_COMPUTE_F32) + if(Ti == To && To == HIP_R_16F && Tc == HIPBLASLT_COMPUTE_F32) { return TEST{}(arg); } - else if(Ti == To && To == HIPBLAS_R_16B && Tc == HIPBLASLT_COMPUTE_F32) + else if(Ti == To && To == HIP_R_16BF && Tc == HIPBLASLT_COMPUTE_F32) { return TEST{}(arg); } - else if(Ti == To && To == HIPBLAS_R_32F && Tc == HIPBLASLT_COMPUTE_F32) + else if(Ti == To && To == HIP_R_32F && Tc == HIPBLASLT_COMPUTE_F32) { return TEST{}(arg); } diff --git a/clients/include/utility.hpp b/clients/include/utility.hpp index a6e160a5c5..3a4ee76c9c 100644 --- a/clients/include/utility.hpp +++ b/clients/include/utility.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -139,18 +139,18 @@ class hipblaslt_local_handle class hipblaslt_local_matrix_layout { hipblasLtMatrixLayout_t m_descr; - hipblasStatus_t m_status = HIPBLAS_STATUS_NOT_INITIALIZED; + hipblasltStatus_t m_status = HIPBLASLT_STATUS_NOT_INITIALIZED; static constexpr int alignment = 16; public: - hipblaslt_local_matrix_layout(int64_t row, int64_t col, int64_t ld, hipblasDatatype_t type) + hipblaslt_local_matrix_layout(int64_t row, int64_t col, int64_t ld, hipDataType type) { this->m_status = hipblasLtMatrixLayoutCreate(&this->m_descr, type, row, col, ld); } ~hipblaslt_local_matrix_layout() { - if(this->m_status == HIPBLAS_STATUS_SUCCESS) + if(this->m_status == HIPBLASLT_STATUS_SUCCESS) hipblasLtMatrixLayoutDestroy(this->m_descr); } @@ -159,7 +159,7 @@ class hipblaslt_local_matrix_layout hipblaslt_local_matrix_layout& operator=(const hipblaslt_local_matrix_layout&) = delete; hipblaslt_local_matrix_layout& operator=(hipblaslt_local_matrix_layout&&) = delete; - hipblasStatus_t status() + hipblasltStatus_t status() { return m_status; } @@ -188,13 +188,13 @@ class hipblaslt_local_matrix_layout class hipblaslt_local_matmul_descr { hipblasLtMatmulDesc_t m_descr; - hipblasStatus_t m_status = HIPBLAS_STATUS_NOT_INITIALIZED; + hipblasltStatus_t m_status = HIPBLASLT_STATUS_NOT_INITIALIZED; public: - hipblaslt_local_matmul_descr(hipblasOperation_t opA, - hipblasOperation_t opB, + hipblaslt_local_matmul_descr(hipblasltOperation_t opA, + hipblasltOperation_t opB, hipblasLtComputeType_t compute_type, - hipblasDatatype_t scale_type) + hipDataType scale_type) { this->m_status = hipblasLtMatmulDescCreate(&this->m_descr, compute_type, scale_type); @@ -211,7 +211,7 @@ class hipblaslt_local_matmul_descr hipblaslt_local_matmul_descr& operator=(const hipblaslt_local_matmul_descr&) = delete; hipblaslt_local_matmul_descr& operator=(hipblaslt_local_matmul_descr&&) = delete; - hipblasStatus_t status() + hipblasltStatus_t status() { return m_status; } @@ -240,7 +240,7 @@ class hipblaslt_local_matmul_descr class hipblaslt_local_preference { hipblasLtMatmulPreference_t m_pref; - hipblasStatus_t m_status = HIPBLAS_STATUS_NOT_INITIALIZED; + hipblasltStatus_t m_status = HIPBLASLT_STATUS_NOT_INITIALIZED; public: hipblaslt_local_preference() @@ -251,7 +251,7 @@ class hipblaslt_local_preference ~hipblaslt_local_preference() { - if(this->m_status == HIPBLAS_STATUS_SUCCESS) + if(this->m_status == HIPBLASLT_STATUS_SUCCESS) hipblasLtMatmulPreferenceDestroy(this->m_pref); } @@ -260,7 +260,7 @@ class hipblaslt_local_preference hipblaslt_local_preference& operator=(const hipblaslt_local_preference&) = delete; hipblaslt_local_preference& operator=(hipblaslt_local_preference&&) = delete; - hipblasStatus_t status() + hipblasltStatus_t status() { return this->m_status; } diff --git a/clients/samples/example_hipblaslt_preference.cpp b/clients/samples/example_hipblaslt_preference.cpp index 052b4a3584..a1c667f57d 100644 --- a/clients/samples/example_hipblaslt_preference.cpp +++ b/clients/samples/example_hipblaslt_preference.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -51,7 +51,7 @@ #ifndef CHECK_HIPBLASLT_ERROR #define CHECK_HIPBLASLT_ERROR(error) \ - if(error != HIPBLAS_STATUS_SUCCESS) \ + if(error != HIPBLASLT_STATUS_SUCCESS) \ { \ fprintf(stderr, "hipBLASLt error(Err=%d) at %s:%d\n", error, __FILE__, __LINE__); \ fprintf(stderr, "\n"); \ @@ -249,31 +249,31 @@ static void show_usage(char* argv[]) << std::endl; } -static int parse_arguments(int argc, - char* argv[], - hipblasDatatype_t& in_out_datatype, - int64_t& m, - int64_t& n, - int64_t& k, - int64_t& lda, - int64_t& ldb, - int64_t& ldc, - int64_t& ldd, - int64_t& stride_a, - int64_t& stride_b, - int64_t& stride_c, - int64_t& stride_d, - int32_t& batch_count, - float& alpha, - float& beta, - hipblasOperation_t& trans_a, - hipblasOperation_t& trans_b, - bool& enable_bias, - ActivationType& actType, - bool& header, - bool& verbose, - bool& validate, - bool& timing) +static int parse_arguments(int argc, + char* argv[], + hipDataType& in_out_datatype, + int64_t& m, + int64_t& n, + int64_t& k, + int64_t& lda, + int64_t& ldb, + int64_t& ldc, + int64_t& ldd, + int64_t& stride_a, + int64_t& stride_b, + int64_t& stride_c, + int64_t& stride_d, + int32_t& batch_count, + float& alpha, + float& beta, + hipblasltOperation_t& trans_a, + hipblasltOperation_t& trans_b, + bool& enable_bias, + ActivationType& actType, + bool& header, + bool& verbose, + bool& validate, + bool& timing) { if(argc >= 2) { @@ -382,11 +382,11 @@ static int parse_arguments(int argc, ++i; if(strncmp(argv[i], "N", 1) == 0 || strncmp(argv[i], "n", 1) == 0) { - trans_a = HIPBLAS_OP_N; + trans_a = HIPBLASLT_OP_N; } else if(strncmp(argv[i], "T", 1) == 0 || strncmp(argv[i], "t", 1) == 0) { - trans_a = HIPBLAS_OP_T; + trans_a = HIPBLASLT_OP_T; } else { @@ -400,11 +400,11 @@ static int parse_arguments(int argc, ++i; if(strncmp(argv[i], "N", 1) == 0 || strncmp(argv[i], "n", 1) == 0) { - trans_b = HIPBLAS_OP_N; + trans_b = HIPBLASLT_OP_N; } else if(strncmp(argv[i], "T", 1) == 0 || strncmp(argv[i], "t", 1) == 0) { - trans_b = HIPBLAS_OP_T; + trans_b = HIPBLASLT_OP_T; } else { @@ -418,15 +418,15 @@ static int parse_arguments(int argc, ++i; if(strncmp(argv[i], "fp32", 4) == 0) { - in_out_datatype = HIPBLAS_R_32F; + in_out_datatype = HIP_R_32F; } else if(strncmp(argv[i], "fp16", 4) == 0) { - in_out_datatype = HIPBLAS_R_16F; + in_out_datatype = HIP_R_16F; } else if(strncmp(argv[i], "bf16", 4) == 0) { - in_out_datatype = HIPBLAS_R_16B; + in_out_datatype = HIP_R_16BF; } else { @@ -453,8 +453,8 @@ static int parse_arguments(int argc, return EXIT_SUCCESS; } -bool bad_argument(hipblasOperation_t trans_a, - hipblasOperation_t trans_b, +bool bad_argument(hipblasltOperation_t trans_a, + hipblasltOperation_t trans_b, int64_t m, int64_t n, int64_t k, @@ -469,22 +469,22 @@ bool bad_argument(hipblasOperation_t trans_a, int32_t batch_count) { bool argument_error = false; - if((trans_a == HIPBLAS_OP_N) && (lda < m)) + if((trans_a == HIPBLASLT_OP_N) && (lda < m)) { argument_error = true; std::cerr << "ERROR: bad argument lda = " << lda << " < " << m << std::endl; } - if((trans_a == HIPBLAS_OP_T) && (lda < k)) + if((trans_a == HIPBLASLT_OP_T) && (lda < k)) { argument_error = true; std::cerr << "ERROR: bad argument lda = " << lda << " < " << k << std::endl; } - if((trans_b == HIPBLAS_OP_N) && (ldb < k)) + if((trans_b == HIPBLASLT_OP_N) && (ldb < k)) { argument_error = true; std::cerr << "ERROR: bad argument ldb = " << ldb << " < " << k << std::endl; } - if((trans_b == HIPBLAS_OP_T) && (ldb < n)) + if((trans_b == HIPBLASLT_OP_T) && (ldb < n)) { argument_error = true; std::cerr << "ERROR: bad argument ldb = " << ldb << " < " << n << std::endl; @@ -558,9 +558,9 @@ void initialize_a_b_c_bias(std::vector& ha, } template -void test_hipblaslt(hipblasDatatype_t in_out_datatype, - hipblasOperation_t trans_a, - hipblasOperation_t trans_b, +void test_hipblaslt(hipDataType in_out_datatype, + hipblasltOperation_t trans_a, + hipblasltOperation_t trans_b, int64_t m, int64_t n, int64_t k, @@ -585,7 +585,7 @@ void test_hipblaslt(hipblasDatatype_t in_out_datatype, int64_t row_a, col_a, row_b, col_b, row_c, col_c; int size_a1, size_b1, size_c1 = ldc * n, size_d1 = ldd * n; std::string trans_string; - if(trans_a == HIPBLAS_OP_N) + if(trans_a == HIPBLASLT_OP_N) { trans_string += "N"; row_a = m; @@ -603,7 +603,7 @@ void test_hipblaslt(hipblasDatatype_t in_out_datatype, a_stride_2 = 1; size_a1 = lda * m; } - if(trans_b == HIPBLAS_OP_N) + if(trans_b == HIPBLASLT_OP_N) { trans_string += "N, "; row_b = k; @@ -694,7 +694,7 @@ void test_hipblaslt(hipblasDatatype_t in_out_datatype, matD, HIPBLASLT_MATRIX_LAYOUT_STRIDED_BATCH_OFFSET, &stride_d, sizeof(stride_d))); } - CHECK_HIPBLASLT_ERROR(hipblasLtMatmulDescCreate(&matmul, HIPBLASLT_COMPUTE_F32, HIPBLAS_R_32F)); + CHECK_HIPBLASLT_ERROR(hipblasLtMatmulDescCreate(&matmul, HIPBLASLT_COMPUTE_F32, HIP_R_32F)); CHECK_HIPBLASLT_ERROR(hipblasLtMatmulDescSetAttribute( matmul, HIPBLASLT_MATMUL_DESC_TRANSA, &trans_a, sizeof(int32_t))); @@ -858,7 +858,7 @@ void test_hipblaslt(hipblasDatatype_t in_out_datatype, if(verbose) { printf("\n"); - if(trans_a == HIPBLAS_OP_N) + if(trans_a == HIPBLASLT_OP_N) { print_strided_batched("ha initial", &ha[0], m, k, batch_count, 1, lda, stride_a); } @@ -866,7 +866,7 @@ void test_hipblaslt(hipblasDatatype_t in_out_datatype, { print_strided_batched("ha initial", &ha[0], m, k, batch_count, lda, 1, stride_a); } - if(trans_b == HIPBLAS_OP_N) + if(trans_b == HIPBLASLT_OP_N) { print_strided_batched("hb initial", &hb[0], k, n, batch_count, 1, ldb, stride_b); } @@ -902,9 +902,9 @@ void test_hipblaslt(hipblasDatatype_t in_out_datatype, int main(int argc, char* argv[]) { // initialize parameters with default values - hipblasOperation_t trans_a = HIPBLAS_OP_N; - hipblasOperation_t trans_b = HIPBLAS_OP_N; - hipblasDatatype_t in_out_datatype = HIPBLAS_R_32F; + hipblasltOperation_t trans_a = HIPBLASLT_OP_N; + hipblasltOperation_t trans_b = HIPBLASLT_OP_N; + hipDataType in_out_datatype = HIP_R_32F; int64_t invalid_int = std::numeric_limits::min() + 1; float invalid_float = std::numeric_limits::quiet_NaN(); @@ -966,17 +966,17 @@ int main(int argc, char* argv[]) if(k == invalid_int) k = DIM3; if(lda == invalid_int) - lda = trans_a == HIPBLAS_OP_N ? m : k; + lda = trans_a == HIPBLASLT_OP_N ? m : k; if(ldb == invalid_int) - ldb = trans_b == HIPBLAS_OP_N ? k : n; + ldb = trans_b == HIPBLASLT_OP_N ? k : n; if(ldc == invalid_int) ldc = m; if(ldd == invalid_int) ldd = m; if(stride_a == invalid_int) - stride_a = trans_a == HIPBLAS_OP_N ? lda * k : lda * m; + stride_a = trans_a == HIPBLASLT_OP_N ? lda * k : lda * m; if(stride_b == invalid_int) - stride_b = trans_b == HIPBLAS_OP_N ? ldb * n : ldb * k; + stride_b = trans_b == HIPBLASLT_OP_N ? ldb * n : ldb * k; if(stride_c == invalid_int) stride_c = ldc * n; if(stride_d == invalid_int) @@ -1016,7 +1016,7 @@ int main(int argc, char* argv[]) std::cout << std::endl; } - if(in_out_datatype == HIPBLAS_R_32F) + if(in_out_datatype == HIP_R_32F) test_hipblaslt(in_out_datatype, trans_a, trans_b, @@ -1039,7 +1039,7 @@ int main(int argc, char* argv[]) validate, verbose, timing); - else if(in_out_datatype == HIPBLAS_R_16F) + else if(in_out_datatype == HIP_R_16F) test_hipblaslt(in_out_datatype, trans_a, trans_b, @@ -1062,7 +1062,7 @@ int main(int argc, char* argv[]) validate, verbose, timing); - else if(in_out_datatype == HIPBLAS_R_16B) + else if(in_out_datatype == HIP_R_16BF) test_hipblaslt(in_out_datatype, trans_a, trans_b, diff --git a/docs/source/functions.rst b/docs/source/functions.rst index 211f6c853e..c207064d8f 100644 --- a/docs/source/functions.rst +++ b/docs/source/functions.rst @@ -121,7 +121,7 @@ hipblasLtMatmul supports the following computeType, scaleType, Atype/Btype, Ctyp ======================= =================== ============= ============== computeType scaleType/Bias Type Atype/Btype Ctype/Dtype ======================= =================== ============= ============== -HIPBLASLT_COMPUTE_F32 HIPBLAS_R_32F HIPBLAS_R_32F HIPBLAS_R_32F -HIPBLASLT_COMPUTE_F32 HIPBLAS_R_32F HIPBLAS_R_16F HIPBLAS_R_16F -HIPBLASLT_COMPUTE_F32 HIPBLAS_R_32F HIPBLAS_R_16B HIPBLAS_R_16B +HIPBLASLT_COMPUTE_F32 HIP_R_32F HIP_R_32F HIP_R_32F +HIPBLASLT_COMPUTE_F32 HIP_R_32F HIP_R_16F HIP_R_16F +HIPBLASLT_COMPUTE_F32 HIP_R_32F HIP_R_16BF HIP_R_16BF ======================= =================== ============= ============== diff --git a/library/include/hipblaslt.h b/library/include/hipblaslt.h index 131e825452..62be5057c4 100644 --- a/library/include/hipblaslt.h +++ b/library/include/hipblaslt.h @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -46,7 +46,6 @@ #include "hipblaslt-export.h" #include "hipblaslt-version.h" -#include #include #include @@ -91,11 +90,11 @@ typedef enum { * \brief Specify the attributes that define the specifics of the matrix multiply operation. */ typedef enum { - HIPBLASLT_MATMUL_DESC_TRANSA = 0, /**= m (number of * rows). * - * \retval HIPBLAS_STATUS_SUCCESS If the descriptor was created successfully. - * \retval HIPBLAS_STATUS_ALLOC_FAILED If the memory could not be allocated. + * \retval HIPBLASLT_STATUS_SUCCESS If the descriptor was created successfully. + * \retval HIPBLASLT_STATUS_ALLOC_FAILED If the memory could not be allocated. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatrixLayoutCreate(hipblasLtMatrixLayout_t* matLayout, - hipblasDatatype_t type, +hipblasltStatus_t hipblasLtMatrixLayoutCreate(hipblasLtMatrixLayout_t* matLayout, + hipDataType type, uint64_t rows, uint64_t cols, int64_t ld); @@ -288,10 +313,10 @@ hipblasStatus_t hipblasLtMatrixLayoutCreate(hipblasLtMatrixLayout_t* matLayout, * matLayout Pointer to the structure holding the matrix layout descriptor that * should be destroyed by this function. see \ref hipblasLtMatrixLayout_t . * - * \retval HIPBLAS_STATUS_SUCCESS If the operation was successful. + * \retval HIPBLASLT_STATUS_SUCCESS If the operation was successful. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatrixLayoutDestroy(const hipblasLtMatrixLayout_t matLayout); +hipblasltStatus_t hipblasLtMatrixLayoutDestroy(const hipblasLtMatrixLayout_t matLayout); /*! \ingroup library_module * \brief Set attribute to a matrix descriptor @@ -312,12 +337,12 @@ hipblasStatus_t hipblasLtMatrixLayoutDestroy(const hipblasLtMatrixLayout_t matLa * @param[in] * sizeInBytes Size of buf buffer (in bytes) for verification. * - * \retval HIPBLAS_STATUS_SUCCESS If the attribute was set successfully.. - * \retval HIPBLAS_STATUS_INVALID_VALUE If \p buf is NULL or \p sizeInBytes + * \retval HIPBLASLT_STATUS_SUCCESS If the attribute was set successfully.. + * \retval HIPBLASLT_STATUS_INVALID_VALUE If \p buf is NULL or \p sizeInBytes * doesn't match the size of the internal storage for the selected attribute. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatrixLayoutSetAttribute(hipblasLtMatrixLayout_t matLayout, +hipblasltStatus_t hipblasLtMatrixLayoutSetAttribute(hipblasLtMatrixLayout_t matLayout, hipblasLtMatrixLayoutAttribute_t attr, const void* buf, size_t sizeInBytes); @@ -342,19 +367,19 @@ hipblasStatus_t hipblasLtMatrixLayoutSetAttribute(hipblasLtMatrixLayout_t * @param[in] * sizeInBytes Size of \p buf buffer (in bytes) for verification. * @param[out] - * sizeWritten Valid only when the return value is HIPBLAS_STATUS_SUCCESS. If + * sizeWritten Valid only when the return value is HIPBLASLT_STATUS_SUCCESS. If * sizeInBytes is non-zero: then sizeWritten is the number of bytes actually * written; if sizeInBytes is 0: then sizeWritten is the number of bytes needed * to write full contents. * - * \retval HIPBLAS_STATUS_SUCCESS If attribute's value was successfully - * written to user memory. \retval HIPBLAS_STATUS_INVALID_VALUE If \p + * \retval HIPBLASLT_STATUS_SUCCESS If attribute's value was successfully + * written to user memory. \retval HIPBLASLT_STATUS_INVALID_VALUE If \p * sizeInBytes is 0 and \p sizeWritten is NULL, or if \p sizeInBytes is non-zero * and \p buf is NULL, or \p sizeInBytes doesn't match size of internal storage * for the selected attribute. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatrixLayoutGetAttribute(hipblasLtMatrixLayout_t matLayout, +hipblasltStatus_t hipblasLtMatrixLayoutGetAttribute(hipblasLtMatrixLayout_t matLayout, hipblasLtMatrixLayoutAttribute_t attr, void* buf, size_t sizeInBytes, @@ -375,15 +400,15 @@ hipblasStatus_t hipblasLtMatrixLayoutGetAttribute(hipblasLtMatrixLayout_t * multiply descriptor this function creates. See \ref hipblasLtComputeType_t . * @param[in] * scaleType Enumerant that specifies the data precision for the matrix - * transform descriptor this function creates. See hipblasDataType_t. + * transform descriptor this function creates. See hipDataType. * - * \retval HIPBLAS_STATUS_SUCCESS If the descriptor was created successfully. - * \retval HIPBLAS_STATUS_ALLOC_FAILED If the memory could not be allocated. + * \retval HIPBLASLT_STATUS_SUCCESS If the descriptor was created successfully. + * \retval HIPBLASLT_STATUS_ALLOC_FAILED If the memory could not be allocated. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatmulDescCreate(hipblasLtMatmulDesc_t* matmulDesc, +hipblasltStatus_t hipblasLtMatmulDescCreate(hipblasLtMatmulDesc_t* matmulDesc, hipblasLtComputeType_t computeType, - hipblasDatatype_t scaleType); + hipDataType scaleType); /*! \ingroup library_module * \brief Destory a matrix multiply descriptor @@ -396,10 +421,10 @@ hipblasStatus_t hipblasLtMatmulDescCreate(hipblasLtMatmulDesc_t* matmulDesc, * matmulDesc Pointer to the structure holding the matrix multiply descriptor * that should be destroyed by this function. See \ref hipblasLtMatmulDesc_t . * - * \retval HIPBLAS_STATUS_SUCCESS If operation was successful. + * \retval HIPBLASLT_STATUS_SUCCESS If operation was successful. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatmulDescDestroy(const hipblasLtMatmulDesc_t matmulDesc); +hipblasltStatus_t hipblasLtMatmulDescDestroy(const hipblasLtMatmulDesc_t matmulDesc); /*! \ingroup library_module * \brief Set attribute to a matrix multiply descriptor @@ -420,12 +445,12 @@ hipblasStatus_t hipblasLtMatmulDescDestroy(const hipblasLtMatmulDesc_t matmulDes * @param[in] * sizeInBytes Size of buf buffer (in bytes) for verification. * - * \retval HIPBLAS_STATUS_SUCCESS If the attribute was set successfully.. - * \retval HIPBLAS_STATUS_INVALID_VALUE If \p buf is NULL or \p sizeInBytes + * \retval HIPBLASLT_STATUS_SUCCESS If the attribute was set successfully.. + * \retval HIPBLASLT_STATUS_INVALID_VALUE If \p buf is NULL or \p sizeInBytes * doesn't match the size of the internal storage for the selected attribute. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatmulDescSetAttribute(hipblasLtMatmulDesc_t matmulDesc, +hipblasltStatus_t hipblasLtMatmulDescSetAttribute(hipblasLtMatmulDesc_t matmulDesc, hipblasLtMatmulDescAttributes_t attr, const void* buf, size_t sizeInBytes); @@ -450,19 +475,19 @@ hipblasStatus_t hipblasLtMatmulDescSetAttribute(hipblasLtMatmulDesc_t * @param[in] * sizeInBytes Size of \p buf buffer (in bytes) for verification. * @param[out] - * sizeWritten Valid only when the return value is HIPBLAS_STATUS_SUCCESS. If + * sizeWritten Valid only when the return value is HIPBLASLT_STATUS_SUCCESS. If * sizeInBytes is non-zero: then sizeWritten is the number of bytes actually * written; if sizeInBytes is 0: then sizeWritten is the number of bytes needed * to write full contents. * - * \retval HIPBLAS_STATUS_SUCCESS If attribute's value was successfully - * written to user memory. \retval HIPBLAS_STATUS_INVALID_VALUE If \p + * \retval HIPBLASLT_STATUS_SUCCESS If attribute's value was successfully + * written to user memory. \retval HIPBLASLT_STATUS_INVALID_VALUE If \p * sizeInBytes is 0 and \p sizeWritten is NULL, or if \p sizeInBytes is non-zero * and \p buf is NULL, or \p sizeInBytes doesn't match size of internal storage * for the selected attribute. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatmulDescGetAttribute(hipblasLtMatmulDesc_t matmulDesc, +hipblasltStatus_t hipblasLtMatmulDescGetAttribute(hipblasLtMatmulDesc_t matmulDesc, hipblasLtMatmulDescAttributes_t attr, void* buf, size_t sizeInBytes, @@ -479,12 +504,12 @@ hipblasStatus_t hipblasLtMatmulDescGetAttribute(hipblasLtMatmulDesc_t * pref Pointer to the structure holding the matrix multiply preferences * descriptor created by this function. see \ref hipblasLtMatmulPreference_t . * - * \retval HIPBLAS_STATUS_SUCCESS If the descriptor was created - * successfully. \retval HIPBLAS_STATUS_ALLOC_FAILED If memory could not be + * \retval HIPBLASLT_STATUS_SUCCESS If the descriptor was created + * successfully. \retval HIPBLASLT_STATUS_ALLOC_FAILED If memory could not be * allocated. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatmulPreferenceCreate(hipblasLtMatmulPreference_t* pref); +hipblasltStatus_t hipblasLtMatmulPreferenceCreate(hipblasLtMatmulPreference_t* pref); /*! \ingroup library_module * \brief Destory a preferences descriptor @@ -498,10 +523,10 @@ hipblasStatus_t hipblasLtMatmulPreferenceCreate(hipblasLtMatmulPreference_t* pre * descriptor that should be destroyed by this function. See \ref * hipblasLtMatmulPreference_t . * - * \retval HIPBLAS_STATUS_SUCCESS If operation was successful. + * \retval HIPBLASLT_STATUS_SUCCESS If operation was successful. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatmulPreferenceDestroy(const hipblasLtMatmulPreference_t pref); +hipblasltStatus_t hipblasLtMatmulPreferenceDestroy(const hipblasLtMatmulPreference_t pref); /*! \ingroup library_module * \brief Set attribute to a preference descriptor @@ -522,12 +547,12 @@ hipblasStatus_t hipblasLtMatmulPreferenceDestroy(const hipblasLtMatmulPreference * @param[in] * sizeInBytes Size of \p buf buffer (in bytes) for verification. * - * \retval HIPBLAS_STATUS_SUCCESS If the attribute was set successfully.. - * \retval HIPBLAS_STATUS_INVALID_VALUE If \p buf is NULL or \p sizeInBytes + * \retval HIPBLASLT_STATUS_SUCCESS If the attribute was set successfully.. + * \retval HIPBLASLT_STATUS_INVALID_VALUE If \p buf is NULL or \p sizeInBytes * doesn't match the size of the internal storage for the selected attribute. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatmulPreferenceSetAttribute(hipblasLtMatmulPreference_t pref, +hipblasltStatus_t hipblasLtMatmulPreferenceSetAttribute(hipblasLtMatmulPreference_t pref, hipblasLtMatmulPreferenceAttributes_t attr, const void* buf, size_t sizeInBytes); @@ -552,19 +577,19 @@ hipblasStatus_t hipblasLtMatmulPreferenceSetAttribute(hipblasLtMatmulPreference_ * @param[in] * sizeInBytes Size of \p buf buffer (in bytes) for verification. * @param[out] - * sizeWritten Valid only when the return value is HIPBLAS_STATUS_SUCCESS. If + * sizeWritten Valid only when the return value is HIPBLASLT_STATUS_SUCCESS. If * sizeInBytes is non-zero: then sizeWritten is the number of bytes actually * written; if sizeInBytes is 0: then sizeWritten is the number of bytes needed * to write full contents. * - * \retval HIPBLAS_STATUS_SUCCESS If attribute's value was successfully - * written to user memory. \retval HIPBLAS_STATUS_INVALID_VALUE If \p + * \retval HIPBLASLT_STATUS_SUCCESS If attribute's value was successfully + * written to user memory. \retval HIPBLASLT_STATUS_INVALID_VALUE If \p * sizeInBytes is 0 and \p sizeWritten is NULL, or if \p sizeInBytes is non-zero * and \p buf is NULL, or \p sizeInBytes doesn't match size of internal storage * for the selected attribute. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatmulPreferenceGetAttribute(hipblasLtMatmulPreference_t pref, +hipblasltStatus_t hipblasLtMatmulPreferenceGetAttribute(hipblasLtMatmulPreference_t pref, hipblasLtMatmulPreferenceAttributes_t attr, void* buf, size_t sizeInBytes, @@ -602,14 +627,14 @@ hipblasStatus_t hipblasLtMatmulPreferenceGetAttribute(hipblasLtMatmulPreference_ * returnAlgoCount Number of algorithms returned by this function. This * is the number of \p heuristicResultsArray elements written. * - * \retval HIPBLAS_STATUS_SUCCESS If query was successful. Inspect + * \retval HIPBLASLT_STATUS_SUCCESS If query was successful. Inspect * heuristicResultsArray[0 to (returnAlgoCount -1)].state for the status of the - * results. \retval HIPBLAS_STATUS_NOT_SUPPORTED If no heuristic function - * available for current configuration. \retval HIPBLAS_STATUS_INVALID_VALUE If + * results. \retval HIPBLASLT_STATUS_NOT_SUPPORTED If no heuristic function + * available for current configuration. \retval HIPBLASLT_STATUS_INVALID_VALUE If * \p requestedAlgoCount is less or equal to zero. */ HIPBLASLT_EXPORT -hipblasStatus_t +hipblasltStatus_t hipblasLtMatmulAlgoGetHeuristic(hipblasLtHandle_t handle, hipblasLtMatmulDesc_t matmulDesc, hipblasLtMatrixLayout_t Adesc, @@ -669,20 +694,20 @@ hipblasStatus_t * stream The HIP stream where all the GPU work will be * submitted. * - * \retval HIPBLAS_STATUS_SUCCESS If the operation completed - * successfully. \retval HIPBLAS_STATUS_EXECUTION_FAILED If HIP reported an - * execution error from the device. \retval HIPBLAS_STATUS_ARCH_MISMATCH If + * \retval HIPBLASLT_STATUS_SUCCESS If the operation completed + * successfully. \retval HIPBLASLT_STATUS_EXECUTION_FAILED If HIP reported an + * execution error from the device. \retval HIPBLASLT_STATUS_ARCH_MISMATCH If * the configured operation cannot be run using the selected device. \retval - * HIPBLAS_STATUS_NOT_SUPPORTED If the current implementation on the + * HIPBLASLT_STATUS_NOT_SUPPORTED If the current implementation on the * selected device doesn't support the configured operation. \retval - * HIPBLAS_STATUS_INVALID_VALUE If the parameters are unexpectedly NULL, in + * HIPBLASLT_STATUS_INVALID_VALUE If the parameters are unexpectedly NULL, in * conflict or in an impossible configuration. For example, when * workspaceSizeInBytes is less than workspace required by the configured algo. * \retval HIBLAS_STATUS_NOT_INITIALIZED If hipBLASLt handle has not been * initialized. */ HIPBLASLT_EXPORT -hipblasStatus_t hipblasLtMatmul(hipblasLtHandle_t handle, +hipblasltStatus_t hipblasLtMatmul(hipblasLtHandle_t handle, hipblasLtMatmulDesc_t matmulDesc, const void* alpha, const void* A, diff --git a/library/src/amd_detail/hipblaslt.cpp b/library/src/amd_detail/hipblaslt.cpp index 1bf9c10397..64a32616a3 100644 --- a/library/src/amd_detail/hipblaslt.cpp +++ b/library/src/amd_detail/hipblaslt.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,8 +41,8 @@ extern "C" { #define RETURN_IF_HIPBLASLT_ERROR(INPUT_STATUS_FOR_CHECK) \ { \ - hipblasStatus_t TMP_STATUS_FOR_CHECK = INPUT_STATUS_FOR_CHECK; \ - if(TMP_STATUS_FOR_CHECK != HIPBLAS_STATUS_SUCCESS) \ + hipblasltStatus_t TMP_STATUS_FOR_CHECK = INPUT_STATUS_FOR_CHECK; \ + if(TMP_STATUS_FOR_CHECK != HIPBLASLT_STATUS_SUCCESS) \ { \ return TMP_STATUS_FOR_CHECK; \ } \ @@ -57,69 +57,69 @@ extern "C" { } \ } -hipblasStatus_t hipErrorToHIPBLASStatus(hipError_t status) +hipblasltStatus_t hipErrorToHIPBLASStatus(hipError_t status) { switch(status) { case hipSuccess: - return HIPBLAS_STATUS_SUCCESS; + return HIPBLASLT_STATUS_SUCCESS; case hipErrorMemoryAllocation: case hipErrorLaunchOutOfResources: - return HIPBLAS_STATUS_ALLOC_FAILED; + return HIPBLASLT_STATUS_ALLOC_FAILED; case hipErrorInvalidDevicePointer: - return HIPBLAS_STATUS_INVALID_VALUE; + return HIPBLASLT_STATUS_INVALID_VALUE; case hipErrorInvalidDevice: case hipErrorInvalidResourceHandle: - return HIPBLAS_STATUS_NOT_INITIALIZED; + return HIPBLASLT_STATUS_NOT_INITIALIZED; case hipErrorInvalidValue: - return HIPBLAS_STATUS_INVALID_VALUE; + return HIPBLASLT_STATUS_INVALID_VALUE; case hipErrorNoDevice: case hipErrorUnknown: - return HIPBLAS_STATUS_INTERNAL_ERROR; + return HIPBLASLT_STATUS_INTERNAL_ERROR; default: - return HIPBLAS_STATUS_INTERNAL_ERROR; + return HIPBLASLT_STATUS_INTERNAL_ERROR; } } -hipblasStatus_t RocBlasLtStatusToHIPStatus(rocblaslt_status_ status) +hipblasltStatus_t RocBlasLtStatusToHIPStatus(rocblaslt_status_ status) { switch(status) { case rocblaslt_status_success: - return HIPBLAS_STATUS_SUCCESS; + return HIPBLASLT_STATUS_SUCCESS; case rocblaslt_status_invalid_handle: - return HIPBLAS_STATUS_NOT_INITIALIZED; + return HIPBLASLT_STATUS_NOT_INITIALIZED; case rocblaslt_status_not_implemented: - return HIPBLAS_STATUS_INTERNAL_ERROR; + return HIPBLASLT_STATUS_INTERNAL_ERROR; case rocblaslt_status_invalid_pointer: - return HIPBLAS_STATUS_INVALID_VALUE; + return HIPBLASLT_STATUS_INVALID_VALUE; case rocblaslt_status_invalid_size: - return HIPBLAS_STATUS_INVALID_VALUE; + return HIPBLASLT_STATUS_INVALID_VALUE; case rocblaslt_status_memory_error: - return HIPBLAS_STATUS_ALLOC_FAILED; + return HIPBLASLT_STATUS_ALLOC_FAILED; case rocblaslt_status_internal_error: - return HIPBLAS_STATUS_INTERNAL_ERROR; + return HIPBLASLT_STATUS_INTERNAL_ERROR; case rocblaslt_status_invalid_value: - return HIPBLAS_STATUS_INVALID_VALUE; + return HIPBLASLT_STATUS_INVALID_VALUE; case rocblaslt_status_arch_mismatch: - return HIPBLAS_STATUS_ARCH_MISMATCH; + return HIPBLASLT_STATUS_ARCH_MISMATCH; default: - throw HIPBLAS_STATUS_INVALID_ENUM; + throw HIPBLASLT_STATUS_INVALID_ENUM; } } -hipblasStatus_t hipblasLtCreate(hipblasLtHandle_t* handle) +hipblasltStatus_t hipblasLtCreate(hipblasLtHandle_t* handle) try { // Check if handle is valid if(handle == nullptr) { - return HIPBLAS_STATUS_INVALID_VALUE; + return HIPBLASLT_STATUS_INVALID_VALUE; } int deviceId; hipError_t err; - hipblasStatus_t retval = HIPBLAS_STATUS_SUCCESS; + hipblasltStatus_t retval = HIPBLASLT_STATUS_SUCCESS; err = hipGetDevice(&deviceId); if(err == hipSuccess) @@ -130,21 +130,21 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtDestroy(const hipblasLtHandle_t handle) +hipblasltStatus_t hipblasLtDestroy(const hipblasLtHandle_t handle) try { return RocBlasLtStatusToHIPStatus(rocblaslt_destroy((const rocblaslt_handle)handle)); } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtMatrixLayoutCreate(hipblasLtMatrixLayout_t* matDescr, - hipblasDatatype_t valueType, +hipblasltStatus_t hipblasLtMatrixLayoutCreate(hipblasLtMatrixLayout_t* matDescr, + hipDataType valueType, uint64_t rows, uint64_t cols, int64_t ld) @@ -155,10 +155,10 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtMatrixLayoutDestroy(const hipblasLtMatrixLayout_t descr) +hipblasltStatus_t hipblasLtMatrixLayoutDestroy(const hipblasLtMatrixLayout_t descr) try { return RocBlasLtStatusToHIPStatus( @@ -166,12 +166,12 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtMatmulDescCreate(hipblasLtMatmulDesc_t* matmulDesc, +hipblasltStatus_t hipblasLtMatmulDescCreate(hipblasLtMatmulDesc_t* matmulDesc, hipblasLtComputeType_t computeType, - hipblasDatatype_t scaleType) + hipDataType scaleType) try { return RocBlasLtStatusToHIPStatus(rocblaslt_matmul_desc_create( @@ -179,10 +179,10 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtMatrixLayoutSetAttribute(hipblasLtMatrixLayout_t matLayout, +hipblasltStatus_t hipblasLtMatrixLayoutSetAttribute(hipblasLtMatrixLayout_t matLayout, hipblasLtMatrixLayoutAttribute_t attr, const void* buf, size_t sizeInBytes) @@ -196,10 +196,10 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtMatrixLayoutGetAttribute(hipblasLtMatrixLayout_t matLayout, +hipblasltStatus_t hipblasLtMatrixLayoutGetAttribute(hipblasLtMatrixLayout_t matLayout, hipblasLtMatrixLayoutAttribute_t attr, void* buf, size_t sizeInBytes, @@ -215,10 +215,10 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtMatmulDescDestroy(const hipblasLtMatmulDesc_t descr) +hipblasltStatus_t hipblasLtMatmulDescDestroy(const hipblasLtMatmulDesc_t descr) try { return RocBlasLtStatusToHIPStatus( @@ -226,10 +226,10 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtMatmulDescSetAttribute(hipblasLtMatmulDesc_t matmulDesc, +hipblasltStatus_t hipblasLtMatmulDescSetAttribute(hipblasLtMatmulDesc_t matmulDesc, hipblasLtMatmulDescAttributes_t matmulAttr, const void* buf, size_t sizeInBytes) @@ -243,9 +243,9 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtMatmulDescGetAttribute(hipblasLtMatmulDesc_t matmulDesc, +hipblasltStatus_t hipblasLtMatmulDescGetAttribute(hipblasLtMatmulDesc_t matmulDesc, hipblasLtMatmulDescAttributes_t matmulAttr, void* buf, size_t sizeInBytes, @@ -261,10 +261,10 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtMatmulPreferenceCreate(hipblasLtMatmulPreference_t* pref) +hipblasltStatus_t hipblasLtMatmulPreferenceCreate(hipblasLtMatmulPreference_t* pref) try { return RocBlasLtStatusToHIPStatus( @@ -272,9 +272,9 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtMatmulPreferenceDestroy(const hipblasLtMatmulPreference_t pref) +hipblasltStatus_t hipblasLtMatmulPreferenceDestroy(const hipblasLtMatmulPreference_t pref) try { return RocBlasLtStatusToHIPStatus( @@ -282,10 +282,10 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t +hipblasltStatus_t hipblasLtMatmulPreferenceSetAttribute(hipblasLtMatmulPreference_t pref, hipblasLtMatmulPreferenceAttributes_t attribute, const void* data, @@ -300,10 +300,10 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t +hipblasltStatus_t hipblasLtMatmulPreferenceGetAttribute(hipblasLtMatmulPreference_t pref, hipblasLtMatmulPreferenceAttributes_t attribute, void* data, @@ -320,10 +320,10 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t +hipblasltStatus_t hipblasLtMatmulAlgoGetHeuristic(hipblasLtHandle_t handle, hipblasLtMatmulDesc_t matmulDesc, hipblasLtMatrixLayout_t Adesc, @@ -350,10 +350,10 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtMatmul(hipblasLtHandle_t handle, +hipblasltStatus_t hipblasLtMatmul(hipblasLtHandle_t handle, hipblasLtMatmulDesc_t matmul_descr, const void* alpha, const void* A, @@ -390,60 +390,60 @@ try } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } // Other Utilities -hipblasStatus_t hipblasLtGetVersion(hipblasLtHandle_t handle, int* version) +hipblasltStatus_t hipblasLtGetVersion(hipblasLtHandle_t handle, int* version) try { if(handle == nullptr) { - return HIPBLAS_STATUS_NOT_INITIALIZED; + return HIPBLASLT_STATUS_NOT_INITIALIZED; } *version = HIPBLASLT_VERSION_MAJOR * 100000 + HIPBLASLT_VERSION_MINOR * 100 + HIPBLASLT_VERSION_PATCH; - return HIPBLAS_STATUS_SUCCESS; + return HIPBLASLT_STATUS_SUCCESS; } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtGetGitRevision(hipblasLtHandle_t handle, char* rev) +hipblasltStatus_t hipblasLtGetGitRevision(hipblasLtHandle_t handle, char* rev) try { // Get hipBLASLt revision if(handle == nullptr) { - return HIPBLAS_STATUS_NOT_INITIALIZED; + return HIPBLASLT_STATUS_NOT_INITIALIZED; } if(rev == nullptr) { - return HIPBLAS_STATUS_INVALID_VALUE; + return HIPBLASLT_STATUS_INVALID_VALUE; } static constexpr char v[] = TO_STR(HIPBLASLT_VERSION_TWEAK); memcpy(rev, v, sizeof(v)); - return HIPBLAS_STATUS_SUCCESS; + return HIPBLASLT_STATUS_SUCCESS; } catch(...) { - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } -hipblasStatus_t hipblasLtGetArchName(char** archName) +hipblasltStatus_t hipblasLtGetArchName(char** archName) try { *archName = nullptr; std::string arch = rocblaslt_internal_get_arch_name(); *archName = (char*)malloc(arch.size() * sizeof(char)); strncpy(*archName, arch.c_str(), arch.size()); - return HIPBLAS_STATUS_SUCCESS; + return HIPBLASLT_STATUS_SUCCESS; } catch(...) { @@ -452,7 +452,7 @@ catch(...) free(*archName); *archName = nullptr; } - return exception_to_hipblas_status(); + return exception_to_hipblaslt_status(); } #ifdef __cplusplus diff --git a/library/src/amd_detail/rocblaslt/include/rocblaslt-auxiliary.h b/library/src/amd_detail/rocblaslt/include/rocblaslt-auxiliary.h index 5e8a08e144..694a8277eb 100644 --- a/library/src/amd_detail/rocblaslt/include/rocblaslt-auxiliary.h +++ b/library/src/amd_detail/rocblaslt/include/rocblaslt-auxiliary.h @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -90,7 +90,7 @@ rocblaslt_status rocblaslt_destroy(const rocblaslt_handle handle); * \retval rocblaslt_status_invalid_value */ rocblaslt_status rocblaslt_matrix_layout_create(rocblaslt_matrix_layout* matDescr, - hipblasDatatype_t valueType, + hipDataType valueType, uint64_t rows, uint64_t cols, int64_t ld); @@ -144,7 +144,7 @@ rocblaslt_status rocblaslt_matrix_layout_get_attribute(rocblaslt_matrix_layout */ rocblaslt_status rocblaslt_matmul_desc_create(rocblaslt_matmul_desc* matmulDesc, rocblaslt_compute_type computeType, - hipblasDatatype_t scaleType); + hipDataType scaleType); /*! \ingroup aux_module * \brief Destroy a matrix multiplication descriptor diff --git a/library/src/amd_detail/rocblaslt/include/rocblaslt-types.h b/library/src/amd_detail/rocblaslt/include/rocblaslt-types.h index 4cf00183b6..4ee09b961b 100644 --- a/library/src/amd_detail/rocblaslt/include/rocblaslt-types.h +++ b/library/src/amd_detail/rocblaslt/include/rocblaslt-types.h @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -32,8 +32,9 @@ #ifndef _ROCBLASLT_TYPES_H_ #define _ROCBLASLT_TYPES_H_ +#include + #include -#include #include #include #include diff --git a/library/src/amd_detail/rocblaslt/src/include/handle.h b/library/src/amd_detail/rocblaslt/src/include/handle.h index 9e118028ea..a755f3111e 100644 --- a/library/src/amd_detail/rocblaslt/src/include/handle.h +++ b/library/src/amd_detail/rocblaslt/src/include/handle.h @@ -3,7 +3,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -117,7 +117,7 @@ struct _rocblaslt_matrix_layout // leading dimension int64_t ld = 0; // data type of the matrix - hipblasDatatype_t type; + hipDataType type; int32_t batch_count = 1; int64_t batch_stride = 0; }; @@ -136,17 +136,17 @@ struct _rocblaslt_matmul_desc ~_rocblaslt_matmul_desc(){}; // operation applied to the matrix A - hipblasOperation_t op_A = HIPBLAS_OP_N; + hipblasltOperation_t op_A = HIPBLASLT_OP_N; // operation applied to the matrix B - hipblasOperation_t op_B = HIPBLAS_OP_N; + hipblasltOperation_t op_B = HIPBLASLT_OP_N; // epilogue operation rocblaslt_epilogue epilogue = ROCBLASLT_EPILOGUE_DEFAULT; // bias vector pointer void* bias = nullptr; - hipblasDatatype_t bias_type = static_cast(-1); + hipDataType bias_type = static_cast(-1); // rocblaslt_compute_type compute_type; - hipblasDatatype_t scale_type; + hipDataType scale_type; }; /******************************************************************************** diff --git a/library/src/amd_detail/rocblaslt/src/include/rocblaslt_mat_utils.hpp b/library/src/amd_detail/rocblaslt/src/include/rocblaslt_mat_utils.hpp index dfcc4bf6dd..cb5e65dea4 100644 --- a/library/src/amd_detail/rocblaslt/src/include/rocblaslt_mat_utils.hpp +++ b/library/src/amd_detail/rocblaslt/src/include/rocblaslt_mat_utils.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,25 +29,25 @@ #define ROCBLASLT_UTILS_HPP #include "handle.h" -inline rocblaslt_status getOriginalSizes(hipblasOperation_t opA, - hipblasOperation_t opB, - int64_t num_rows_a, - int64_t num_cols_a, - int64_t num_rows_b, - int64_t num_cols_b, - int64_t& m, - int64_t& n, - int64_t& k) +inline rocblaslt_status getOriginalSizes(hipblasltOperation_t opA, + hipblasltOperation_t opB, + int64_t num_rows_a, + int64_t num_cols_a, + int64_t num_rows_b, + int64_t num_cols_b, + int64_t& m, + int64_t& n, + int64_t& k) { // values of num_* are values after been transposed, redirect to before which // been transposed. initialized m,n,k by NN. m = num_rows_a, n = num_cols_b, k = num_cols_a; - if(opA == HIPBLAS_OP_T) + if(opA == HIPBLASLT_OP_T) { m = num_cols_a; k = num_rows_a; } - if(opB == HIPBLAS_OP_T) + if(opB == HIPBLASLT_OP_T) { n = num_rows_b; if(k != num_cols_b) @@ -69,8 +69,8 @@ inline rocblaslt_status getOriginalSizes(hipblasOperation_t opA, * Validate Matmul Descr. init Arguments - matrix init. ******************************************************************************/ inline rocblaslt_status validateMatmulDescrArgs(rocblaslt_handle handle, - hipblasOperation_t opA, - hipblasOperation_t opB, + hipblasltOperation_t opA, + hipblasltOperation_t opB, int64_t num_rows_a, int64_t num_cols_a, int64_t lda, @@ -83,10 +83,10 @@ inline rocblaslt_status validateMatmulDescrArgs(rocblaslt_handle handle, int64_t num_rows_d, int64_t num_cols_d, int64_t ldd, - hipblasDatatype_t type_a, - hipblasDatatype_t type_b, - hipblasDatatype_t type_c, - hipblasDatatype_t type_d, + hipDataType type_a, + hipDataType type_b, + hipDataType type_c, + hipDataType type_d, rocblaslt_compute_type compute_type) { // handle must be valid @@ -115,7 +115,7 @@ inline rocblaslt_status validateMatmulDescrArgs(rocblaslt_handle handle, switch(type_a) { - case HIPBLAS_R_32F: + case HIP_R_32F: if(compute_type != rocblaslt_compute_f32) return rocblaslt_status_invalid_value; break; @@ -186,7 +186,7 @@ inline rocblaslt_status validateMatmulArgs(rocblaslt_handle handle, } template -inline int rocblaslt_get_matmul_alg_config_max_id(hipblasOperation_t opA, hipblasOperation_t opB) +inline int rocblaslt_get_matmul_alg_config_max_id(hipblasltOperation_t opA, hipblasltOperation_t opB) { // TODO return true; diff --git a/library/src/amd_detail/rocblaslt/src/include/tensile_host.hpp b/library/src/amd_detail/rocblaslt/src/include/tensile_host.hpp index b57891f1c8..c7316178fc 100644 --- a/library/src/amd_detail/rocblaslt/src/include/tensile_host.hpp +++ b/library/src/amd_detail/rocblaslt/src/include/tensile_host.hpp @@ -3,7 +3,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -52,8 +52,8 @@ template struct RocblasltContractionProblem { rocblaslt_handle handle; - hipblasOperation_t trans_a; - hipblasOperation_t trans_b; + hipblasltOperation_t trans_a; + hipblasltOperation_t trans_b; // The RocblasltContractionProblem data members should exactly match // Tensile's parameter types, even if rocBLAS uses differently @@ -99,7 +99,7 @@ struct RocblasltContractionProblem bool strided_batch; const void* bias; - hipblasDatatype_t bias_type; + hipDataType bias_type; rocblaslt_epilogue epilogue; void* workspace; size_t workspaceSize; @@ -108,42 +108,42 @@ struct RocblasltContractionProblem // gemm_ex // gemm_strided_batched_ex - RocblasltContractionProblem(rocblaslt_handle handle, - hipblasOperation_t trans_a, - hipblasOperation_t trans_b, - int64_t m, - int64_t n, - int64_t k, - const Tc* alpha, - const Ti* A, - const Ti* const* batch_A, - int64_t ld_a, - int64_t batch_stride_a, - int64_t offset_a, - const Ti* B, - const Ti* const* batch_B, - int64_t ld_b, - int64_t batch_stride_b, - int64_t offset_b, - const Tc* beta, - const To* C, - const To* const* batch_C, - int64_t ld_c, - int64_t batch_stride_c, - int64_t offset_c, - To* D, - To* const* batch_D, - int64_t ld_d, - int64_t batch_stride_d, - int64_t offset_d, - int64_t batch_count, - bool strided_batch, - const void* bias, - hipblasDatatype_t bias_type, - rocblaslt_epilogue epilogue, - void* workspace, - size_t workspaceSize, - hipStream_t stream) + RocblasltContractionProblem(rocblaslt_handle handle, + hipblasltOperation_t trans_a, + hipblasltOperation_t trans_b, + int64_t m, + int64_t n, + int64_t k, + const Tc* alpha, + const Ti* A, + const Ti* const* batch_A, + int64_t ld_a, + int64_t batch_stride_a, + int64_t offset_a, + const Ti* B, + const Ti* const* batch_B, + int64_t ld_b, + int64_t batch_stride_b, + int64_t offset_b, + const Tc* beta, + const To* C, + const To* const* batch_C, + int64_t ld_c, + int64_t batch_stride_c, + int64_t offset_c, + To* D, + To* const* batch_D, + int64_t ld_d, + int64_t batch_stride_d, + int64_t offset_d, + int64_t batch_count, + bool strided_batch, + const void* bias, + hipDataType bias_type, + rocblaslt_epilogue epilogue, + void* workspace, + size_t workspaceSize, + hipStream_t stream) : handle(handle) , trans_a(trans_a) , trans_b(trans_b) diff --git a/library/src/amd_detail/rocblaslt/src/include/utility.hpp b/library/src/amd_detail/rocblaslt/src/include/utility.hpp index 50923d872a..be5ecf66ee 100644 --- a/library/src/amd_detail/rocblaslt/src/include/utility.hpp +++ b/library/src/amd_detail/rocblaslt/src/include/utility.hpp @@ -3,7 +3,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -42,15 +42,15 @@ inline bool isAligned(const void* pointer, size_t byte_count) } // return precision string for rocblaslt_datatype -constexpr const char* rocblaslt_datatype_string(hipblasDatatype_t type) +constexpr const char* rocblaslt_datatype_string(hipDataType type) { switch(type) { - case HIPBLAS_R_16F: + case HIP_R_16F: return "f16_r"; - case HIPBLAS_R_32F: + case HIP_R_32F: return "f32_r"; - case HIPBLAS_R_16B: + case HIP_R_16BF: return "b16_r"; default: return "invalidType"; @@ -69,13 +69,13 @@ constexpr const char* rocblaslt_compute_type_string(rocblaslt_compute_type type) } } -constexpr const char* rocblaslt_transpose_letter(hipblasOperation_t op) +constexpr const char* rocblaslt_transpose_letter(hipblasltOperation_t op) { switch(op) { - case HIPBLAS_OP_N: + case HIPBLASLT_OP_N: return "N"; - case HIPBLAS_OP_T: + case HIPBLASLT_OP_T: return "T"; default: return "invalidTranspose"; @@ -131,7 +131,7 @@ static constexpr char rocblaslt_precision_string[] = "u32_r"; std::string prefix(const char* layer, const char* caller); -const char* hipblasDatatype_to_string(hipblasDatatype_t type); +const char* hipDataType_to_string(hipDataType type); const char* rocblaslt_compute_type_to_string(rocblaslt_compute_type type); @@ -139,7 +139,7 @@ const char* rocblaslt_matrix_layout_attributes_to_string(rocblaslt_matrix_layout const char* rocblaslt_matmul_desc_attributes_to_string(rocblaslt_matmul_desc_attributes type); -const char* hipblasOperation_to_string(hipblasOperation_t op); +const char* hipblasltOperation_to_string(hipblasltOperation_t op); const char* rocblaslt_layer_mode2string(rocblaslt_layer_mode layer_mode); diff --git a/library/src/amd_detail/rocblaslt/src/rocblaslt_auxiliary.cpp b/library/src/amd_detail/rocblaslt/src/rocblaslt_auxiliary.cpp index 8a869e771f..065c45c533 100644 --- a/library/src/amd_detail/rocblaslt/src/rocblaslt_auxiliary.cpp +++ b/library/src/amd_detail/rocblaslt/src/rocblaslt_auxiliary.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -102,7 +102,7 @@ rocblaslt_status rocblaslt_destroy(const rocblaslt_handle handle) * It should be destroyed at the end using rocblaslt_matrix_layout_destory(). *******************************************************************************/ rocblaslt_status rocblaslt_matrix_layout_create(rocblaslt_matrix_layout* matDescr, - hipblasDatatype_t valueType, + hipDataType valueType, uint64_t rows, uint64_t cols, int64_t ld) @@ -128,7 +128,7 @@ rocblaslt_status rocblaslt_matrix_layout_create(rocblaslt_matrix_layout* matDesc "matLayout[out]", matDescr, "type", - hipblasDatatype_to_string(valueType), + hipDataType_to_string(valueType), "rows", rows, "cols", @@ -315,7 +315,7 @@ rocblaslt_status rocblaslt_matrix_layout_get_attribute(rocblaslt_matrix_layout *******************************************************************************/ rocblaslt_status rocblaslt_matmul_desc_create(rocblaslt_matmul_desc* matmulDesc, rocblaslt_compute_type computeType, - hipblasDatatype_t scaleType) + hipDataType scaleType) { // Check if matmulDesc is valid if(matmulDesc == nullptr) @@ -335,7 +335,7 @@ rocblaslt_status rocblaslt_matmul_desc_create(rocblaslt_matmul_desc* matmulDesc, throw rocblaslt_status_invalid_value; } - if(scaleType != HIPBLAS_R_32F) + if(scaleType != HIP_R_32F) { log_error(__func__, "invalid scale type", scaleType); throw rocblaslt_status_invalid_value; @@ -350,7 +350,7 @@ rocblaslt_status rocblaslt_matmul_desc_create(rocblaslt_matmul_desc* matmulDesc, "computeType", rocblaslt_compute_type_to_string(computeType), "scaleType", - hipblasDatatype_to_string(scaleType)); + hipDataType_to_string(scaleType)); } catch(const rocblaslt_status& status) { @@ -787,14 +787,14 @@ rocblaslt_status rocblaslt_status status = rocblaslt_status_success; try { - hipblasDatatype_t a_type = matA->type; - hipblasDatatype_t b_type = matB->type; - hipblasDatatype_t c_type = matC->type; - hipblasDatatype_t d_type = matD->type; + hipDataType a_type = matA->type; + hipDataType b_type = matB->type; + hipDataType c_type = matC->type; + hipDataType d_type = matD->type; rocblaslt_compute_type compute_type = matmul_desc->compute_type; - if(a_type == HIPBLAS_R_32F && b_type == HIPBLAS_R_32F) + if(a_type == HIP_R_32F && b_type == HIP_R_32F) { - if(c_type == HIPBLAS_R_32F && d_type == HIPBLAS_R_32F) + if(c_type == HIP_R_32F && d_type == HIP_R_32F) { if(compute_type == rocblaslt_compute_f32) { @@ -818,9 +818,9 @@ rocblaslt_status } } } - else if(a_type == HIPBLAS_R_16F && b_type == HIPBLAS_R_16F) + else if(a_type == HIP_R_16F && b_type == HIP_R_16F) { - if(c_type == HIPBLAS_R_16F && d_type == HIPBLAS_R_16F) + if(c_type == HIP_R_16F && d_type == HIP_R_16F) { if(compute_type == rocblaslt_compute_f32) { @@ -845,9 +845,9 @@ rocblaslt_status } } } - else if(a_type == HIPBLAS_R_16B && b_type == HIPBLAS_R_16B) + else if(a_type == HIP_R_16BF && b_type == HIP_R_16BF) { - if(c_type == HIPBLAS_R_16B && d_type == HIPBLAS_R_16B) + if(c_type == HIP_R_16BF && d_type == HIP_R_16BF) { if(compute_type == rocblaslt_compute_f32) { diff --git a/library/src/amd_detail/rocblaslt/src/rocblaslt_mat.cpp b/library/src/amd_detail/rocblaslt/src/rocblaslt_mat.cpp index 0508390879..5e7ab9d9cf 100644 --- a/library/src/amd_detail/rocblaslt/src/rocblaslt_mat.cpp +++ b/library/src/amd_detail/rocblaslt/src/rocblaslt_mat.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -56,11 +56,11 @@ rocblaslt_status rocblaslt_matmul_impl(const rocblaslt_handle handle, size_t workspaceSizeInBytes, hipStream_t stream) { - hipblasOperation_t opA = matmul_descr->op_A; - hipblasOperation_t opB = matmul_descr->op_B; + hipblasltOperation_t opA = matmul_descr->op_A; + hipblasltOperation_t opB = matmul_descr->op_B; rocblaslt_compute_type compute_type = matmul_descr->compute_type; const void* bias = nullptr; - hipblasDatatype_t bias_type + hipDataType bias_type = matmul_descr->bias_type == -1 ? matD->type : matmul_descr->bias_type; rocblaslt_epilogue epilogue = matmul_descr->epilogue; if(is_bias_enabled(epilogue)) @@ -72,7 +72,7 @@ rocblaslt_status rocblaslt_matmul_impl(const rocblaslt_handle handle, int64_t lda = matA->ld; int64_t batch_stride_a = matA->batch_stride; int num_batches_a = matA->batch_count; - hipblasDatatype_t type_a = matA->type; + hipDataType type_a = matA->type; // matrix B // int64_t num_rows_b = matB->m; @@ -80,7 +80,7 @@ rocblaslt_status rocblaslt_matmul_impl(const rocblaslt_handle handle, int64_t ldb = matB->ld; int64_t batch_stride_b = matB->batch_stride; int num_batches_b = matB->batch_count; - hipblasDatatype_t type_b = matB->type; + hipDataType type_b = matB->type; // matrix C // int64_t num_rows_c = matC->m; @@ -88,7 +88,7 @@ rocblaslt_status rocblaslt_matmul_impl(const rocblaslt_handle handle, int64_t ldc = matC->ld; int64_t batch_stride_c = matC->batch_stride; int num_batches_c = matC->batch_count; - hipblasDatatype_t type_c = matC->type; + hipDataType type_c = matC->type; // matrix D int64_t num_rows_d = matD->m; @@ -96,11 +96,11 @@ rocblaslt_status rocblaslt_matmul_impl(const rocblaslt_handle handle, int64_t ldd = matD->ld; int64_t batch_stride_d = matD->batch_stride; int num_batches_d = matD->batch_count; - hipblasDatatype_t type_d = matD->type; + hipDataType type_d = matD->type; int64_t m = num_rows_d; int64_t n = num_cols_d; - int64_t k = (opA == HIPBLAS_OP_N) ? num_cols_a : num_rows_a; + int64_t k = (opA == HIPBLASLT_OP_N) ? num_cols_a : num_rows_a; auto validArgs = validateMatmulArgs(handle, m, diff --git a/library/src/amd_detail/rocblaslt/src/rocblaslt_mat.hpp b/library/src/amd_detail/rocblaslt/src/rocblaslt_mat.hpp index 859dd6dd24..b751e7ca05 100644 --- a/library/src/amd_detail/rocblaslt/src/rocblaslt_mat.hpp +++ b/library/src/amd_detail/rocblaslt/src/rocblaslt_mat.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -35,8 +35,8 @@ template rocblaslt_status rocblaslt_batched_template(rocblaslt_handle handle, - hipblasOperation_t trans_a, - hipblasOperation_t trans_b, + hipblasltOperation_t trans_a, + hipblasltOperation_t trans_b, int64_t m, int64_t n, int64_t k, @@ -64,7 +64,7 @@ rocblaslt_status rocblaslt_batched_template(rocblaslt_handle handle, void* workspace, size_t workspaceSizeInBytes, const void* bias, - hipblasDatatype_t bias_type, + hipDataType bias_type, rocblaslt_epilogue epilogue, hipStream_t stream) { @@ -110,8 +110,8 @@ rocblaslt_status rocblaslt_batched_template(rocblaslt_handle handle, template rocblaslt_status rocblaslt_matmul_typecasting(rocblaslt_handle handle, - hipblasOperation_t trans_a, - hipblasOperation_t trans_b, + hipblasltOperation_t trans_a, + hipblasltOperation_t trans_b, int64_t m, int64_t n, int64_t k, @@ -139,7 +139,7 @@ rocblaslt_status rocblaslt_matmul_typecasting(rocblaslt_handle handl void* workspace, size_t workspaceSizeInBytes, const void* bias, - hipblasDatatype_t bias_type, + hipDataType bias_type, rocblaslt_epilogue epilogue, hipStream_t stream) { @@ -186,30 +186,30 @@ rocblaslt_status rocblaslt_matmul_typecasting(rocblaslt_handle handl } inline rocblaslt_status rocblaslt_matmul_template(rocblaslt_handle handle, - hipblasOperation_t trans_a, - hipblasOperation_t trans_b, + hipblasltOperation_t trans_a, + hipblasltOperation_t trans_b, int64_t m, int64_t n, int64_t k, const void* alpha, const void* a, - hipblasDatatype_t a_type, + hipDataType a_type, int64_t ld_a, int64_t batch_stride_a, int64_t offset_a, const void* b, - hipblasDatatype_t b_type, + hipDataType b_type, int64_t ld_b, int64_t batch_stride_b, int64_t offset_b, const void* beta, const void* c, - hipblasDatatype_t c_type, + hipDataType c_type, int64_t ld_c, int64_t batch_stride_c, int64_t offset_c, void* d, - hipblasDatatype_t d_type, + hipDataType d_type, int64_t ld_d, int64_t batch_stride_d, int64_t offset_d, @@ -220,7 +220,7 @@ inline rocblaslt_status rocblaslt_matmul_template(rocblaslt_handle h void* workspace, size_t workspaceSizeInBytes, const void* bias, - hipblasDatatype_t bias_type, + hipDataType bias_type, rocblaslt_epilogue epilogue, hipStream_t stream) { @@ -232,9 +232,9 @@ inline rocblaslt_status rocblaslt_matmul_template(rocblaslt_handle h batch_stride_d, offset_d, batch_count, strided_batch, algo, workspace, \ workspaceSizeInBytes, bias, bias_type, epilogue, stream - if(a_type == HIPBLAS_R_32F && b_type == HIPBLAS_R_32F) + if(a_type == HIP_R_32F && b_type == HIP_R_32F) { - if(c_type == HIPBLAS_R_32F && d_type == HIPBLAS_R_32F) + if(c_type == HIP_R_32F && d_type == HIP_R_32F) { if(compute_type == rocblaslt_compute_f32) { @@ -242,9 +242,9 @@ inline rocblaslt_status rocblaslt_matmul_template(rocblaslt_handle h } } } - else if(a_type == HIPBLAS_R_16F && b_type == HIPBLAS_R_16F) + else if(a_type == HIP_R_16F && b_type == HIP_R_16F) { - if(c_type == HIPBLAS_R_16F && d_type == HIPBLAS_R_16F) + if(c_type == HIP_R_16F && d_type == HIP_R_16F) { if(compute_type == rocblaslt_compute_f32) { @@ -253,9 +253,9 @@ inline rocblaslt_status rocblaslt_matmul_template(rocblaslt_handle h } } } - else if(a_type == HIPBLAS_R_16B && b_type == HIPBLAS_R_16B) + else if(a_type == HIP_R_16BF && b_type == HIP_R_16BF) { - if(c_type == HIPBLAS_R_16B && d_type == HIPBLAS_R_16B) + if(c_type == HIP_R_16BF && d_type == HIP_R_16BF) { if(compute_type == rocblaslt_compute_f32) { diff --git a/library/src/amd_detail/rocblaslt/src/tensile_host.cpp b/library/src/amd_detail/rocblaslt/src/tensile_host.cpp index c2f9e0bc53..b48476cb50 100644 --- a/library/src/amd_detail/rocblaslt/src/tensile_host.cpp +++ b/library/src/amd_detail/rocblaslt/src/tensile_host.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -84,18 +84,18 @@ namespace /****************************************************** * Map a hipblas data type to a corresponding Tensile type * ******************************************************/ - inline Tensile::DataType hipblasDatatype_to_tensile_type(hipblasDatatype_t type) + inline Tensile::DataType hipDataType_to_tensile_type(hipDataType type) { switch(type) { - case HIPBLAS_R_16F: + case HIP_R_16F: return Tensile::DataType::Half; - case HIPBLAS_R_32F: + case HIP_R_32F: return Tensile::DataType::Float; - case HIPBLAS_R_16B: + case HIP_R_16BF: return Tensile::DataType::BFloat16; default: - assert(!"hipblasDatatype_to_tensile_type: non-supported type"); + assert(!"hipDataType_to_tensile_type: non-supported type"); return Tensile::DataType::None; } } @@ -191,7 +191,7 @@ namespace // clang-format off // If A is transposed, swap the free and bound dimensions and their ranks - if(prob.trans_a != HIPBLAS_OP_N) + if(prob.trans_a != HIPBLASLT_OP_N) { a = { Tensile_Ti, @@ -215,7 +215,7 @@ namespace } // If B is transposed, swap the free and bound dimensions and their ranks - if(prob.trans_b != HIPBLAS_OP_N) + if(prob.trans_b != HIPBLASLT_OP_N) { b = { Tensile_Ti, @@ -300,7 +300,7 @@ namespace // set bias mode tensileProblem.setUseBias(true); - tensileProblem.setBiasType(hipblasDatatype_to_tensile_type(prob.bias_type)); + tensileProblem.setBiasType(hipDataType_to_tensile_type(prob.bias_type)); // set Actvation tensileProblem.setActivationType(Tensile::ActivationType::All); @@ -777,10 +777,10 @@ RocblasltContractionProblem const Tc* beta, size_t maxWorkSpaceBytes) { - hipblasOperation_t opA = matmul_descr->op_A; - hipblasOperation_t opB = matmul_descr->op_B; + hipblasltOperation_t opA = matmul_descr->op_A; + hipblasltOperation_t opB = matmul_descr->op_B; const void* bias = nullptr; - hipblasDatatype_t bias_type = matmul_descr->bias_type == static_cast(-1) + hipDataType bias_type = matmul_descr->bias_type == static_cast(-1) ? matD->type : matmul_descr->bias_type; rocblaslt_epilogue epilogue = matmul_descr->epilogue; @@ -813,7 +813,7 @@ RocblasltContractionProblem int64_t m = num_rows_d; int64_t n = num_cols_d; - int64_t k = (opA == HIPBLAS_OP_N) ? num_cols_a : num_rows_a; + int64_t k = (opA == HIPBLASLT_OP_N) ? num_cols_a : num_rows_a; int8_t dummy; const void* dummy_ptr = &dummy; diff --git a/library/src/amd_detail/rocblaslt/src/utility.cpp b/library/src/amd_detail/rocblaslt/src/utility.cpp index 54ba155d2d..a81a38d432 100644 --- a/library/src/amd_detail/rocblaslt/src/utility.cpp +++ b/library/src/amd_detail/rocblaslt/src/utility.cpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -60,15 +60,15 @@ std::string prefix(const char* layer, const char* caller) return std::string(buf.get()); } -const char* hipblasDatatype_to_string(hipblasDatatype_t type) +const char* hipDataType_to_string(hipDataType type) { switch(type) { - case HIPBLAS_R_16F: + case HIP_R_16F: return "R_16F"; - case HIPBLAS_R_16B: + case HIP_R_16BF: return "R_16BF"; - case HIPBLAS_R_32F: + case HIP_R_32F: return "R_32F"; default: return "Invalid"; @@ -117,15 +117,15 @@ const char* rocblaslt_matmul_desc_attributes_to_string(rocblaslt_matmul_desc_att return "Invalid"; } } -const char* hipblasOperation_to_string(hipblasOperation_t op) +const char* hipblasltOperation_to_string(hipblasltOperation_t op) { switch(op) { - case HIPBLAS_OP_N: + case HIPBLASLT_OP_N: return "OP_N"; - case HIPBLAS_OP_T: + case HIPBLASLT_OP_T: return "OP_T"; - case HIPBLAS_OP_C: + case HIPBLASLT_OP_C: return "OP_C"; default: return "Invalid"; @@ -183,14 +183,14 @@ std::string rocblaslt_matrix_layout_to_string(rocblaslt_matrix_layout mat) if(mat->batch_count <= 1) std::sprintf(buf.get(), format.c_str(), - hipblasDatatype_to_string(mat->type), + hipDataType_to_string(mat->type), mat->m, mat->n, mat->ld); else std::sprintf(buf.get(), format.c_str(), - hipblasDatatype_to_string(mat->type), + hipDataType_to_string(mat->type), mat->m, mat->n, mat->ld, @@ -200,7 +200,7 @@ std::string rocblaslt_matrix_layout_to_string(rocblaslt_matrix_layout mat) } std::string rocblaslt_matmul_desc_to_string(rocblaslt_matmul_desc matmul_desc) { - std::string format = matmul_desc->bias_type == static_cast(-1) + std::string format = matmul_desc->bias_type == static_cast(-1) ? "[computeType=%s scaleType=%s transA=%s transB=%s " "epilogue=%s biasPointer=0x%x]\0" : "[computeType=%s scaleType=%s transA=%s transB=%s " @@ -208,24 +208,24 @@ std::string rocblaslt_matmul_desc_to_string(rocblaslt_matmul_desc matmul_desc) std::unique_ptr buf(new char[255]); - if(matmul_desc->bias_type == static_cast(-1)) + if(matmul_desc->bias_type == static_cast(-1)) std::sprintf(buf.get(), format.c_str(), rocblaslt_compute_type_to_string(matmul_desc->compute_type), - hipblasDatatype_to_string(matmul_desc->scale_type), - hipblasOperation_to_string(matmul_desc->op_A), - hipblasOperation_to_string(matmul_desc->op_B), + hipDataType_to_string(matmul_desc->scale_type), + hipblasltOperation_to_string(matmul_desc->op_A), + hipblasltOperation_to_string(matmul_desc->op_B), rocblaslt_epilogue_to_string(matmul_desc->epilogue), matmul_desc->bias); else std::sprintf(buf.get(), format.c_str(), rocblaslt_compute_type_to_string(matmul_desc->compute_type), - hipblasDatatype_to_string(matmul_desc->scale_type), - hipblasOperation_to_string(matmul_desc->op_A), - hipblasOperation_to_string(matmul_desc->op_B), + hipDataType_to_string(matmul_desc->scale_type), + hipblasltOperation_to_string(matmul_desc->op_A), + hipblasltOperation_to_string(matmul_desc->op_B), rocblaslt_epilogue_to_string(matmul_desc->epilogue), matmul_desc->bias, - hipblasDatatype_to_string(matmul_desc->bias_type)); + hipDataType_to_string(matmul_desc->bias_type)); return std::string(buf.get()); } diff --git a/library/src/include/auxiliary.hpp b/library/src/include/auxiliary.hpp index 30ba1359ea..460099ef2c 100644 --- a/library/src/include/auxiliary.hpp +++ b/library/src/include/auxiliary.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,80 +29,80 @@ #include HIPBLASLT_EXPORT -constexpr const char* hipblas_status_to_string(hipblasStatus_t status) +constexpr const char* hipblaslt_status_to_string(hipblasltStatus_t status) { #define CASE(x) \ case x: \ return #x switch(status) { - CASE(HIPBLAS_STATUS_SUCCESS); - CASE(HIPBLAS_STATUS_NOT_INITIALIZED); - CASE(HIPBLAS_STATUS_ALLOC_FAILED); - CASE(HIPBLAS_STATUS_INVALID_VALUE); - CASE(HIPBLAS_STATUS_MAPPING_ERROR); - CASE(HIPBLAS_STATUS_EXECUTION_FAILED); - CASE(HIPBLAS_STATUS_INTERNAL_ERROR); - CASE(HIPBLAS_STATUS_NOT_SUPPORTED); - CASE(HIPBLAS_STATUS_ARCH_MISMATCH); - CASE(HIPBLAS_STATUS_INVALID_ENUM); - CASE(HIPBLAS_STATUS_UNKNOWN); - CASE(HIPBLAS_STATUS_HANDLE_IS_NULLPTR); + CASE(HIPBLASLT_STATUS_SUCCESS); + CASE(HIPBLASLT_STATUS_NOT_INITIALIZED); + CASE(HIPBLASLT_STATUS_ALLOC_FAILED); + CASE(HIPBLASLT_STATUS_INVALID_VALUE); + CASE(HIPBLASLT_STATUS_MAPPING_ERROR); + CASE(HIPBLASLT_STATUS_EXECUTION_FAILED); + CASE(HIPBLASLT_STATUS_INTERNAL_ERROR); + CASE(HIPBLASLT_STATUS_NOT_SUPPORTED); + CASE(HIPBLASLT_STATUS_ARCH_MISMATCH); + CASE(HIPBLASLT_STATUS_INVALID_ENUM); + CASE(HIPBLASLT_STATUS_UNKNOWN); + CASE(HIPBLASLT_STATUS_HANDLE_IS_NULLPTR); } #undef CASE // We don't use default: so that the compiler warns us if any valid enums are - // missing from our switch. If the value is not a valid hipblasStatus_t, we + // missing from our switch. If the value is not a valid hipblasltStatus_t, we // return this string. - return ""; + return ""; } HIPBLASLT_EXPORT -constexpr const char* hipblas_operation_to_string(hipblasOperation_t value) +constexpr const char* hipblaslt_operation_to_string(hipblasltOperation_t value) { switch(value) { - case HIPBLAS_OP_N: + case HIPBLASLT_OP_N: return "N"; - case HIPBLAS_OP_T: + case HIPBLASLT_OP_T: return "T"; - case HIPBLAS_OP_C: + case HIPBLASLT_OP_C: return "C"; } return "invalid"; } HIPBLASLT_EXPORT -constexpr hipblasOperation_t char_to_hipblas_operation(char value) +constexpr hipblasltOperation_t char_to_hipblaslt_operation(char value) { switch(value) { case 'N': case 'n': - return HIPBLAS_OP_N; + return HIPBLASLT_OP_N; case 'T': case 't': - return HIPBLAS_OP_T; + return HIPBLASLT_OP_T; case 'C': case 'c': - return HIPBLAS_OP_C; + return HIPBLASLT_OP_C; default: - return static_cast(-1); + return static_cast(-1); } } -// return precision string for hipblasDatatype_t +// return precision string for hipDataType HIPBLASLT_EXPORT -constexpr const char* hipblas_datatype_to_string(hipblasDatatype_t type) +constexpr const char* hip_datatype_to_string(hipDataType type) { switch(type) { - case HIPBLAS_R_32F: + case HIP_R_32F: return "f32_r"; - case HIPBLAS_R_16F: + case HIP_R_16F: return "f16_r"; - case HIPBLAS_R_16B: + case HIP_R_16BF: return "bf16_r"; - case HIPBLAS_R_8I: + case HIP_R_8I: return "i8_r"; default: return "non-supported type"; @@ -110,7 +110,7 @@ constexpr const char* hipblas_datatype_to_string(hipblasDatatype_t type) return "invalid"; } -// return precision string for hipblasDatatype_t +// return precision string for hipDataType HIPBLASLT_EXPORT constexpr const char* hipblaslt_computetype_to_string(hipblasLtComputeType_t type) { @@ -124,13 +124,13 @@ constexpr const char* hipblaslt_computetype_to_string(hipblasLtComputeType_t typ // clang-format off HIPBLASLT_EXPORT -constexpr hipblasDatatype_t string_to_hipblas_datatype(const std::string& value) +constexpr hipDataType string_to_hipblas_datatype(const std::string& value) { return - value == "f32_r" || value == "s" ? HIPBLAS_R_32F : - value == "f16_r" || value == "h" ? HIPBLAS_R_16F : - value == "bf16_r" ? HIPBLAS_R_16B : - static_cast(-1); + value == "f32_r" || value == "s" ? HIP_R_32F : + value == "f16_r" || value == "h" ? HIP_R_16F : + value == "bf16_r" ? HIP_R_16BF : + static_cast(-1); } HIPBLASLT_EXPORT diff --git a/library/src/include/exceptions.hpp b/library/src/include/exceptions.hpp index 245ccf8371..982a0fa527 100644 --- a/library/src/include/exceptions.hpp +++ b/library/src/include/exceptions.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,24 +30,24 @@ // Convert the current C++ exception to hiblasStatus_t // This allows extern "C" functions to return this function in a catch(...) -// block while converting all C++ exceptions to an equivalent hipblasStatus_t +// block while converting all C++ exceptions to an equivalent hipblasltStatus_t // here -inline hipblasStatus_t exception_to_hipblas_status(std::exception_ptr e = std::current_exception()) +inline hipblasltStatus_t exception_to_hipblaslt_status(std::exception_ptr e = std::current_exception()) try { if(e) std::rethrow_exception(e); - return HIPBLAS_STATUS_SUCCESS; + return HIPBLASLT_STATUS_SUCCESS; } -catch(const hipblasStatus_t& status) +catch(const hipblasltStatus_t& status) { return status; } catch(const std::bad_alloc&) { - return HIPBLAS_STATUS_ALLOC_FAILED; + return HIPBLASLT_STATUS_ALLOC_FAILED; } catch(...) { - return HIPBLAS_STATUS_INTERNAL_ERROR; + return HIPBLASLT_STATUS_INTERNAL_ERROR; } diff --git a/library/src/include/hipblaslt_ostream.hpp b/library/src/include/hipblaslt_ostream.hpp index 62afda64f4..d3c6d62a96 100644 --- a/library/src/include/hipblaslt_ostream.hpp +++ b/library/src/include/hipblaslt_ostream.hpp @@ -2,7 +2,7 @@ * * MIT License * - * Copyright (C) 2022 Advanced Micro Devices, Inc. + * Copyright (C) 2022-2023 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -415,11 +415,11 @@ class HIPBLASLT_EXPORT hipblaslt_internal_ostream return os << s.c_str(); } - // hipblasDatatype_t output + // hipDataType output friend hipblaslt_internal_ostream& operator<<(hipblaslt_internal_ostream& os, - hipblasDatatype_t d) + hipDataType d) { - os.m_os << hipblas_datatype_to_string(d); + os.m_os << hip_datatype_to_string(d); return os; } @@ -431,19 +431,19 @@ class HIPBLASLT_EXPORT hipblaslt_internal_ostream return os; } - // hipblasOperation_t output + // hipblasltOperation_t output friend hipblaslt_internal_ostream& operator<<(hipblaslt_internal_ostream& os, - hipblasOperation_t trans) + hipblasltOperation_t trans) { - return os << hipblas_operation_to_string(trans); + return os << hipblaslt_operation_to_string(trans); } - // hipblasStatus_t output + // hipblasltStatus_t output friend hipblaslt_internal_ostream& operator<<(hipblaslt_internal_ostream& os, - hipblasStatus_t status) + hipblasltStatus_t status) { - os.m_os << hipblas_status_to_string(status); + os.m_os << hipblaslt_status_to_string(status); return os; }