From d9fb3b1382845ec00dc37b2fe16c5d917f55dc04 Mon Sep 17 00:00:00 2001 From: Loris Lucido <loris.lucido@atos.net> Date: Mon, 31 Oct 2022 11:20:14 +0100 Subject: [PATCH] hipblas: Add the basis for the hipblas library by copy of the cudablas one for all level-3 BLAS subroutines --- hipblas/CMakeLists.txt | 36 +++ hipblas/compute/CMakeLists.txt | 91 ++++++ hipblas/compute/hip_zgemm.c | 46 +++ hipblas/compute/hip_zhemm.c | 45 +++ hipblas/compute/hip_zher2k.c | 45 +++ hipblas/compute/hip_zherk.c | 43 +++ hipblas/compute/hip_zsymm.c | 45 +++ hipblas/compute/hip_zsyr2k.c | 45 +++ hipblas/compute/hip_zsyrk.c | 43 +++ hipblas/compute/hip_ztrmm.c | 45 +++ hipblas/compute/hip_ztrsm.c | 45 +++ hipblas/compute/hipglobal.c | 128 +++++++++ hipblas/eztrace_module/CMakeLists.txt | 79 ++++++ hipblas/eztrace_module/hipblas_eztrace_module | 266 ++++++++++++++++++ hipblas/include/CMakeLists.txt | 66 +++++ hipblas/include/hipblas.h | 82 ++++++ hipblas/include/hipblas/hipblas_z.h | 38 +++ 17 files changed, 1188 insertions(+) create mode 100644 hipblas/CMakeLists.txt create mode 100644 hipblas/compute/CMakeLists.txt create mode 100644 hipblas/compute/hip_zgemm.c create mode 100644 hipblas/compute/hip_zhemm.c create mode 100644 hipblas/compute/hip_zher2k.c create mode 100644 hipblas/compute/hip_zherk.c create mode 100644 hipblas/compute/hip_zsymm.c create mode 100644 hipblas/compute/hip_zsyr2k.c create mode 100644 hipblas/compute/hip_zsyrk.c create mode 100644 hipblas/compute/hip_ztrmm.c create mode 100644 hipblas/compute/hip_ztrsm.c create mode 100644 hipblas/compute/hipglobal.c create mode 100644 hipblas/eztrace_module/CMakeLists.txt create mode 100644 hipblas/eztrace_module/hipblas_eztrace_module create mode 100644 hipblas/include/CMakeLists.txt create mode 100644 hipblas/include/hipblas.h create mode 100644 hipblas/include/hipblas/hipblas_z.h diff --git a/hipblas/CMakeLists.txt b/hipblas/CMakeLists.txt new file mode 100644 index 000000000..87a384f7b --- /dev/null +++ b/hipblas/CMakeLists.txt @@ -0,0 +1,36 @@ +### +# +# @file CMakeLists.txt +# +# @copyright 2009-2014 The University of Tennessee and The University of +# Tennessee Research Foundation. All rights reserved. +# @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +# Univ. Bordeaux. All rights reserved. +# +### +# +# @project CHAMELEON +# CHAMELEON is a software package provided by: +# Inria Bordeaux - Sud-Ouest, +# Univ. of Tennessee, +# King Abdullah Univesity of Science and Technology +# Univ. of California Berkeley, +# Univ. of Colorado Denver. +# +# @version 1.2.0 +# @author Cedric Castagnede +# @author Emmanuel Agullo +# @author Mathieu Faverge +# @author Florent Pruvost +# @author Loris Lucido +# @date 2023-01-30 +# +### + +add_subdirectory(include) +add_subdirectory(compute) +add_subdirectory(eztrace_module) + +### +### END CMakeLists.txt +### diff --git a/hipblas/compute/CMakeLists.txt b/hipblas/compute/CMakeLists.txt new file mode 100644 index 000000000..632049557 --- /dev/null +++ b/hipblas/compute/CMakeLists.txt @@ -0,0 +1,91 @@ +### +# +# @file CMakeLists.txt +# +# @copyright 2009-2014 The University of Tennessee and The University of +# Tennessee Research Foundation. All rights reserved. +# @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +# Univ. Bordeaux. All rights reserved. +# +### +# +# @project CHAMELEON +# CHAMELEON is a software package provided by: +# Inria Bordeaux - Sud-Ouest, +# Univ. of Tennessee, +# King Abdullah Univesity of Science and Technology +# Univ. of California Berkeley, +# Univ. of Colorado Denver. +# +# @version 1.2.0 +# @author Florent Pruvost +# @author Guillaume Sylvand +# @author Mathieu Faverge +# @author Loris Lucido +# @date 2023-01-30 +# +### + +# Generate the chameleon sources for all possible precisions +# ------------------------------------------------------ +set(HIPBLAS_SRCS_GENERATED "") +set(ZSRC + hip_zgemm.c + hip_zhemm.c + hip_zher2k.c + hip_zherk.c + hip_zsymm.c + hip_zsyr2k.c + hip_zsyrk.c + hip_ztrmm.c + hip_ztrsm.c + ) + +precisions_rules_py( + HIPBLAS_SRCS_GENERATED "${ZSRC}" + PRECISIONS "${CHAMELEON_PRECISION}") + +set(HIPBLAS_SRCS + ${HIPBLAS_SRCS_GENERATED} + hipglobal.c + ) + +# Force generation of sources +# --------------------------- +add_custom_target(hipblas_sources ALL SOURCES ${HIPBLAS_SRCS}) +set(CHAMELEON_SOURCES_TARGETS "${CHAMELEON_SOURCES_TARGETS};hipblas_sources" CACHE INTERNAL "List of targets of sources") + +# Compile step +# ------------ +add_library(hipblas ${HIPBLAS_SRCS}) +set_target_properties(hipblas PROPERTIES VERSION ${CHAMELEON_VERSION}) +set_target_properties(hipblas PROPERTIES SOVERSION ${CHAMELEON_VERSION_MAJOR}) +add_dependencies(hipblas hipblas_include hipblas_sources) +target_include_directories(hipblas PUBLIC + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/hipblas/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/hipblas/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/include> + $<INSTALL_INTERFACE:include>) +set_property(TARGET hipblas PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +target_link_libraries(hipblas PRIVATE coreblas HIP::HIPBLAS) +target_link_libraries(hipblas PUBLIC MORSE::M) + +# export target coreblas +install(EXPORT hipblasTargets + NAMESPACE CHAMELEON:: + DESTINATION lib/cmake/chameleon + ) + +# installation +# ------------ +install(TARGETS hipblas + EXPORT hipblasTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + ) + +### +### END CMakeLists.txt +### diff --git a/hipblas/compute/hip_zgemm.c b/hipblas/compute/hip_zgemm.c new file mode 100644 index 000000000..8afd4b869 --- /dev/null +++ b/hipblas/compute/hip_zgemm.c @@ -0,0 +1,46 @@ +/** + * + * @file hip_zgemm.c + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon hip_zgemm GPU kernel + * + * @version 1.2.0 + * @author Florent Pruvost + * @author Mathieu Faverge + * @author Loris Lucido + * @date 2023-01-30 + * @precisions normal z -> c d s + * + */ +#include "hipblas.h" + +int +HIP_zgemm( cham_trans_t transa, cham_trans_t transb, + int m, int n, int k, + const hipDoubleComplex *alpha, + const hipDoubleComplex *A, int lda, + const hipDoubleComplex *B, int ldb, + const hipDoubleComplex *beta, + hipDoubleComplex *C, int ldc, + hipblasHandle_t handle ) +{ + hipblasStatus_t rc; + + rc = hipblasZgemm( handle, + chameleon_hipblas_const(transa), chameleon_hipblas_const(transb), + m, n, k, + HIPBLAS_VALUE(alpha), A, lda, + B, ldb, + HIPBLAS_VALUE(beta), C, ldc ); + + assert( rc == HIPBLAS_STATUS_SUCCESS ); + (void)rc; + return CHAMELEON_SUCCESS; +} diff --git a/hipblas/compute/hip_zhemm.c b/hipblas/compute/hip_zhemm.c new file mode 100644 index 000000000..30d722430 --- /dev/null +++ b/hipblas/compute/hip_zhemm.c @@ -0,0 +1,45 @@ +/** + * + * @file hip_zhemm.c + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon hip_zhemm GPU kernel + * + * @version 1.2.0 + * @author Florent Pruvost + * @author Mathieu Faverge + * @date 2022-02-22 + * @precisions normal z -> c + * + */ +#include "hipblas.h" + +int +HIP_zhemm( cham_side_t side, cham_uplo_t uplo, + int m, int n, + const hipDoubleComplex *alpha, + const hipDoubleComplex *A, int lda, + const hipDoubleComplex *B, int ldb, + const hipDoubleComplex *beta, + hipDoubleComplex *C, int ldc, + hipblasHandle_t handle ) +{ + hipblasStatus_t rc; + + rc = hipblasZhemm( handle, + chameleon_hipblas_const(side), chameleon_hipblas_const(uplo), + m, n, + HIPBLAS_VALUE(alpha), A, lda, + B, ldb, + HIPBLAS_VALUE(beta), C, ldc ); + + assert( rc == HIPBLAS_STATUS_SUCCESS ); + (void)rc; + return CHAMELEON_SUCCESS; +} diff --git a/hipblas/compute/hip_zher2k.c b/hipblas/compute/hip_zher2k.c new file mode 100644 index 000000000..601df7fe3 --- /dev/null +++ b/hipblas/compute/hip_zher2k.c @@ -0,0 +1,45 @@ +/** + * + * @file hip_zher2k.c + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon hip_zher2k GPU kernel + * + * @version 1.2.0 + * @author Florent Pruvost + * @author Mathieu Faverge + * @date 2022-02-22 + * @precisions normal z -> c + * + */ +#include "hipblas.h" + +int +HIP_zher2k( cham_uplo_t uplo, cham_trans_t trans, + int n, int k, + const hipDoubleComplex *alpha, + const hipDoubleComplex *A, int lda, + const hipDoubleComplex *B, int ldb, + const double *beta, + hipDoubleComplex *C, int ldc, + hipblasHandle_t handle ) +{ + hipblasStatus_t rc; + + rc = hipblasZher2k( handle, + chameleon_hipblas_const(uplo), chameleon_hipblas_const(trans), + n, k, + HIPBLAS_VALUE(alpha), A, lda, + B, ldb, + HIPBLAS_VALUE(beta), C, ldc ); + + assert( rc == HIPBLAS_STATUS_SUCCESS ); + (void)rc; + return CHAMELEON_SUCCESS; +} diff --git a/hipblas/compute/hip_zherk.c b/hipblas/compute/hip_zherk.c new file mode 100644 index 000000000..56693b307 --- /dev/null +++ b/hipblas/compute/hip_zherk.c @@ -0,0 +1,43 @@ +/** + * + * @file hip_zherk.c + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon hip_zherk GPU kernel + * + * @version 1.2.0 + * @author Florent Pruvost + * @author Mathieu Faverge + * @date 2022-02-22 + * @precisions normal z -> c + * + */ +#include "hipblas.h" + +int +HIP_zherk( cham_uplo_t uplo, cham_trans_t trans, + int n, int k, + const double *alpha, + const hipDoubleComplex *A, int lda, + const double *beta, + hipDoubleComplex *B, int ldb, + hipblasHandle_t handle ) +{ + hipblasStatus_t rc; + + rc = hipblasZherk( handle, + chameleon_hipblas_const(uplo), chameleon_hipblas_const(trans), + n, k, + HIPBLAS_VALUE(alpha), A, lda, + HIPBLAS_VALUE(beta), B, ldb ); + + assert( rc == HIPBLAS_STATUS_SUCCESS ); + (void)rc; + return CHAMELEON_SUCCESS; +} diff --git a/hipblas/compute/hip_zsymm.c b/hipblas/compute/hip_zsymm.c new file mode 100644 index 000000000..146412570 --- /dev/null +++ b/hipblas/compute/hip_zsymm.c @@ -0,0 +1,45 @@ +/** + * + * @file hip_zsymm.c + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon hip_zsymm GPU kernel + * + * @version 1.2.0 + * @author Florent Pruvost + * @author Mathieu Faverge + * @date 2022-02-22 + * @precisions normal z -> c d s + * + */ +#include "hipblas.h" + +int +HIP_zsymm( cham_side_t side, cham_uplo_t uplo, + int m, int n, + const hipDoubleComplex *alpha, + const hipDoubleComplex *A, int lda, + const hipDoubleComplex *B, int ldb, + const hipDoubleComplex *beta, + hipDoubleComplex *C, int ldc, + hipblasHandle_t handle ) +{ + hipblasStatus_t rc; + + rc = hipblasZsymm( handle, + chameleon_hipblas_const(side), chameleon_hipblas_const(uplo), + m, n, + HIPBLAS_VALUE(alpha), A, lda, + B, ldb, + HIPBLAS_VALUE(beta), C, ldc ); + + assert( rc == HIPBLAS_STATUS_SUCCESS ); + (void)rc; + return CHAMELEON_SUCCESS; +} diff --git a/hipblas/compute/hip_zsyr2k.c b/hipblas/compute/hip_zsyr2k.c new file mode 100644 index 000000000..5bef9817e --- /dev/null +++ b/hipblas/compute/hip_zsyr2k.c @@ -0,0 +1,45 @@ +/** + * + * @file hip_zsyr2k.c + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon hip_zsyr2k GPU kernel + * + * @version 1.2.0 + * @author Florent Pruvost + * @author Mathieu Faverge + * @date 2022-02-22 + * @precisions normal z -> c d s + * + */ +#include "hipblas.h" + +int +HIP_zsyr2k( cham_uplo_t uplo, cham_trans_t trans, + int n, int k, + const hipDoubleComplex *alpha, + const hipDoubleComplex *A, int lda, + const hipDoubleComplex *B, int ldb, + const hipDoubleComplex *beta, + hipDoubleComplex *C, int ldc, + hipblasHandle_t handle ) +{ + hipblasStatus_t rc; + + rc = hipblasZsyr2k( handle, + chameleon_hipblas_const(uplo), chameleon_hipblas_const(trans), + n, k, + HIPBLAS_VALUE(alpha), A, lda, + B, ldb, + HIPBLAS_VALUE(beta), C, ldc ); + + assert( rc == HIPBLAS_STATUS_SUCCESS ); + (void)rc; + return CHAMELEON_SUCCESS; +} diff --git a/hipblas/compute/hip_zsyrk.c b/hipblas/compute/hip_zsyrk.c new file mode 100644 index 000000000..44838f78b --- /dev/null +++ b/hipblas/compute/hip_zsyrk.c @@ -0,0 +1,43 @@ +/** + * + * @file hip_zsyrk.c + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon hip_zsyrk GPU kernel + * + * @version 1.2.0 + * @author Florent Pruvost + * @author Mathieu Faverge + * @date 2022-02-22 + * @precisions normal z -> c d s + * + */ +#include "hipblas.h" + +int +HIP_zsyrk( cham_uplo_t uplo, cham_trans_t trans, + int n, int k, + const hipDoubleComplex *alpha, + const hipDoubleComplex *A, int lda, + const hipDoubleComplex *beta, + hipDoubleComplex *B, int ldb, + hipblasHandle_t handle ) +{ + hipblasStatus_t rc; + + rc = hipblasZsyrk( handle, + chameleon_hipblas_const(uplo), chameleon_hipblas_const(trans), + n, k, + HIPBLAS_VALUE(alpha), A, lda, + HIPBLAS_VALUE(beta), B, ldb ); + + assert( rc == HIPBLAS_STATUS_SUCCESS ); + (void)rc; + return CHAMELEON_SUCCESS; +} diff --git a/hipblas/compute/hip_ztrmm.c b/hipblas/compute/hip_ztrmm.c new file mode 100644 index 000000000..9cc527904 --- /dev/null +++ b/hipblas/compute/hip_ztrmm.c @@ -0,0 +1,45 @@ +/** + * + * @file hip_ztrmm.c + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon hip_ztrmm GPU kernel + * + * @version 1.2.0 + * @author Florent Pruvost + * @author Mathieu Faverge + * @date 2022-02-22 + * @precisions normal z -> c d s + * + */ +#include "hipblas.h" + +int +HIP_ztrmm( cham_side_t side, cham_uplo_t uplo, + cham_trans_t transa, cham_diag_t diag, + int m, int n, + const hipDoubleComplex *alpha, + const hipDoubleComplex *A, int lda, + hipDoubleComplex *B, int ldb, + hipblasHandle_t handle ) +{ + hipblasStatus_t rc; + + rc = hipblasZtrmm( handle, + chameleon_hipblas_const(side), chameleon_hipblas_const(uplo), + chameleon_hipblas_const(transa), chameleon_hipblas_const(diag), + m, n, + HIPBLAS_VALUE(alpha), A, lda, + B, ldb ); + + assert( rc == HIPBLAS_STATUS_SUCCESS ); + (void)rc; + return CHAMELEON_SUCCESS; +} + diff --git a/hipblas/compute/hip_ztrsm.c b/hipblas/compute/hip_ztrsm.c new file mode 100644 index 000000000..cba7629c3 --- /dev/null +++ b/hipblas/compute/hip_ztrsm.c @@ -0,0 +1,45 @@ +/** + * + * @file hip_ztrsm.c + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon hip_ztrsm GPU kernel + * + * @version 1.2.0 + * @author Florent Pruvost + * @author Mathieu Faverge + * @author Loris Lucido + * @date 2023-01-30 + * @precisions normal z -> c d s + * + */ +#include "hipblas.h" + +int +HIP_ztrsm( cham_side_t side, cham_uplo_t uplo, + cham_trans_t transa, cham_diag_t diag, + int m, int n, + const hipDoubleComplex *alpha, + const hipDoubleComplex *A, int lda, + hipDoubleComplex *B, int ldb, + hipblasHandle_t handle ) +{ + hipblasStatus_t rc; + + rc = hipblasZtrsm( handle, + chameleon_hipblas_const(side), chameleon_hipblas_const(uplo), + chameleon_hipblas_const(transa), chameleon_hipblas_const(diag), + m, n, + HIPBLAS_VALUE(alpha), A, lda, + B, ldb ); + + assert( rc == HIPBLAS_STATUS_SUCCESS ); + (void)rc; + return CHAMELEON_SUCCESS; +} diff --git a/hipblas/compute/hipglobal.c b/hipblas/compute/hipglobal.c new file mode 100644 index 000000000..3c9fce602 --- /dev/null +++ b/hipblas/compute/hipglobal.c @@ -0,0 +1,128 @@ +/** + * + * @file hipglobal.c + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon global hipblas variables and functions + * + * @version 1.2.0 + * @author Mathieu Faverge + * @author Loris Lucido + * @date 2023-01-30 + * + */ +#include "hipblas.h" + +/** + * LAPACK Constants + */ +int chameleon_hipblas_constants[] = +{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 100 + 0, // 101: ChamRowMajor + 0, // 102: ChamColMajor + 0, 0, 0, 0, 0, 0, 0, 0, + HIPBLAS_OP_N, // 111: ChamNoTrans + HIPBLAS_OP_T, // 112: ChamTrans + HIPBLAS_OP_C, // 113: ChamConjTrans + 0, 0, 0, 0, 0, 0, 0, + HIPBLAS_FILL_MODE_UPPER, // 121: ChamUpper + HIPBLAS_FILL_MODE_LOWER, // 122: ChamLower + 0, // 123: ChamUpperLower + 0, 0, 0, 0, 0, 0, 0, + HIPBLAS_DIAG_NON_UNIT, // 131: ChamNonUnit + HIPBLAS_DIAG_UNIT, // 132: ChamUnit + 0, 0, 0, 0, 0, 0, 0, 0, + HIPBLAS_SIDE_LEFT, // 141: ChamLeft + HIPBLAS_SIDE_RIGHT, // 142: ChamRight + 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 151: + 0, // 152: + 0, // 153: + 0, // 154: + 0, // 155: + 0, // 156: + 0, // 157: ChamEps + 0, // 158: + 0, // 159: + 0, // 160: + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 171: ChamOneNorm + 0, // 172: ChamRealOneNorm + 0, // 173: ChamTwoNorm + 0, // 174: ChamFrobeniusNorm + 0, // 175: ChamInfNorm + 0, // 176: ChamRealInfNorm + 0, // 177: ChamMaxNorm + 0, // 178: ChamRealMaxNorm + 0, // 179 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 200 + 0, // 201: ChamDistUniform + 0, // 202: ChamDistSymmetric + 0, // 203: ChamDistNormal + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 240 + 0, // 241 ChamHermGeev + 0, // 242 ChamHermPoev + 0, // 243 ChamNonsymPosv + 0, // 244 ChamSymPosv + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 290 + 0, // 291 ChamNoPacking + 0, // 292 ChamPackSubdiag + 0, // 293 ChamPackSupdiag + 0, // 294 ChamPackColumn + 0, // 295 ChamPackRow + 0, // 296 ChamPackLowerBand + 0, // 297 ChamPackUpeprBand + 0, // 298 ChamPackAll + 0, // 299 + 0, // 300 + 0, // 301 ChamNoVec + 0, // 302 ChamVec, ChamSVDvrange + 0, // 303 ChamIvec, ChamSVDirange + 0, // 304 ChamAllVec, ChamSVDall + 0, // 305 ChamSVec + 0, // 306 ChamOVec + 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 390 + 0, // 391 Forward + 0, // 392 Backward + 0, 0, 0, 0, 0, 0, 0, 0, + 0, // 401 Columnwise + 0, // 402 Rowwise + 0, 0, 0, 0, 0, 0, 0, 0 // Remember to add a coma! +}; diff --git a/hipblas/eztrace_module/CMakeLists.txt b/hipblas/eztrace_module/CMakeLists.txt new file mode 100644 index 000000000..f46c2e28d --- /dev/null +++ b/hipblas/eztrace_module/CMakeLists.txt @@ -0,0 +1,79 @@ +### +# +# @file CMakeLists.txt +# +# @copyright 2009-2014 The University of Tennessee and The University of +# Tennessee Research Foundation. All rights reserved. +# @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +# Univ. Bordeaux. All rights reserved. +# +### +# +# @project CHAMELEON +# CHAMELEON is a software package provided by: +# Inria Bordeaux - Sud-Ouest, +# Univ. of Tennessee, +# King Abdullah Univesity of Science and Technology +# Univ. of California Berkeley, +# Univ. of Colorado Denver. +# +# @version 1.2.0 +# @author Florent Pruvost +# @author Mathieu Faverge +# @date 2022-02-22 +# +### + +if (NOT EZTRACE_FOUND) + find_package(EZTRACE) +endif() + +if (EZTRACE_FOUND AND EZTRACE_DIR_FOUND) + + set(EZTRACE_eztrace_create_plugin_DIR "EZTRACE_eztrace_create_plugin_DIR-NOTFOUND") + find_path(EZTRACE_eztrace_create_plugin_DIR + NAMES eztrace_create_plugin + HINTS ${EZTRACE_DIR_FOUND}/bin) + mark_as_advanced(EZTRACE_eztrace_create_plugin_DIR) + + if (EZTRACE_eztrace_create_plugin_DIR) + + set(EZTRACE_CREATE_PLUGIN "${EZTRACE_eztrace_create_plugin_DIR}/eztrace_create_plugin") + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/output + COMMAND ${EZTRACE_CREATE_PLUGIN} + ARGS ${CMAKE_CURRENT_SOURCE_DIR}/hipblas_eztrace_module + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/hipblas_eztrace_module + ) + add_custom_target( + eztrace-module-chameleon_hip-dir ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/output + ) + add_custom_command( + OUTPUT libeztrace-convert-chameleon_hip.so + COMMAND make + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/output + ) + add_custom_target( + eztrace-module-chameleon_hip-libs ALL + DEPENDS libeztrace-convert-chameleon_hip.so + ) + # installation + # ------------ + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/output/libeztrace-autostart-chameleon_hip.so + ${CMAKE_CURRENT_BINARY_DIR}/output/libeztrace-chameleon_hip.so + ${CMAKE_CURRENT_BINARY_DIR}/output/libeztrace-convert-chameleon_hip.so + DESTINATION ${EZTRACE_LIBRARY_DIRS} + ) + + endif (EZTRACE_eztrace_create_plugin_DIR) + +endif (EZTRACE_FOUND AND EZTRACE_DIR_FOUND) + +### +### END CMakeLists.txt +### diff --git a/hipblas/eztrace_module/hipblas_eztrace_module b/hipblas/eztrace_module/hipblas_eztrace_module new file mode 100644 index 000000000..2170a72da --- /dev/null +++ b/hipblas/eztrace_module/hipblas_eztrace_module @@ -0,0 +1,266 @@ +BEGIN_MODULE +NAME chameleon_hip +DESC "Module for Chameleon HIP functions" +ID 7771 + +int HIP_cgemm( + void* transa, void* transb, + int m, int n, int k, + void *alpha, + const void *A, int lda, + const void *B, int ldb, + void *beta, + void *C, int ldc, + void* stream); +int HIP_chemm( + void* side, void* uplo, + int m, int n, + void *alpha, + const void *A, int lda, + const void *B, int ldb, + void *beta, + void *C, int ldc, + void* stream); +int HIP_cher2k( + void* uplo, void* trans, + int n, int k, + void *alpha, + const void *A, int lda, + const void *B, int ldb, + float *beta, + void *C, int ldc, + void* stream); +int HIP_cherk( + void* uplo, void* trans, + int n, int k, + float *alpha, + const void *A, int lda, + float *beta, + void *B, int ldb, + void* stream); +int HIP_csymm( + void* side, void* uplo, + int m, int n, + void *alpha, + const void *A, int lda, + const void *B, int ldb, + void *beta, + void *C, int ldc, + void* stream); +int HIP_csyr2k( + void* uplo, void* trans, + int n, int k, + void *alpha, + const void *A, int lda, + const void *B, int ldb, + void *beta, + void *C, int ldc, + void* stream); +int HIP_csyrk( + void* uplo, void* trans, + int n, int k, + void *alpha, + const void *A, int lda, + void *beta, + void *C, int ldc, + void* stream); +int HIP_ctrmm( + void* side, void* uplo, + void* transa, void* diag, + int m, int n, + void *alpha, + const void *A, int lda, + void *B, int ldb, + void* stream); +int HIP_ctrsm( + void* side, void* uplo, + void* transa, void* diag, + int m, int n, + void *alpha, + const void *A, int lda, + void *B, int ldb, + void* stream); + +int HIP_dgemm( + void* transa, void* transb, + int m, int n, int k, + double *alpha, + const double *A, int lda, + const double *B, int ldb, + double *beta, + double *C, int ldc, + void* stream); +int HIP_dsymm( + void* side, void* uplo, + int m, int n, + double *alpha, + const double *A, int lda, + const double *B, int ldb, + double *beta, + double *C, int ldc, + void* stream); +int HIP_dsyr2k( + void* uplo, void* trans, + int n, int k, + double *alpha, + const double *A, int lda, + const double *B, int ldb, + double *beta, + double *C, int ldc, + void* stream); +int HIP_dsyrk( + void* uplo, void* trans, + int n, int k, + double *alpha, + const double *A, int lda, + double *beta, + double *B, int ldb, + void* stream); +int HIP_dtrmm( + void* side, void* uplo, + void* transa, void* diag, + int m, int n, + double *alpha, + const double *A, int lda, + double *B, int ldb, + void* stream); +int HIP_dtrsm( + void* side, void* uplo, + void* transa, void* diag, + int m, int n, + double *alpha, + const double *A, int lda, + double *B, int ldb, + void* stream); + +int HIP_sgemm( + void* transa, void* transb, + int m, int n, int k, + float *alpha, + const float *A, int lda, + const float *B, int ldb, + float *beta, + float *C, int ldc, + void* stream); +int HIP_ssymm( + void* side, void* uplo, + int m, int n, + float *alpha, + const float *A, int lda, + const float *B, int ldb, + float *beta, + float *C, int ldc, + void* stream); +int HIP_ssyr2k( + void* uplo, void* trans, + int n, int k, + float *alpha, + const float *A, int lda, + const float *B, int ldb, + float *beta, + float *C, int ldc, + void* stream); +int HIP_ssyrk( + void* uplo, void* trans, + int n, int k, + float *alpha, + const float *A, int lda, + float *beta, + float *B, int ldb, + void* stream); +int HIP_strmm( + void* side, void* uplo, + void* transa, void* diag, + int m, int n, + float *alpha, + const float *A, int lda, + float *B, int ldb, + void* stream); +int HIP_strsm( + void* side, void* uplo, + void* transa, void* diag, + int m, int n, + float *alpha, + const float *A, int lda, + float *B, int ldb, + void* stream); + +int HIP_zgemm( + void* transa, void* transb, + int m, int n, int k, + void *alpha, + const void *A, int lda, + const void *B, int ldb, + void *beta, + void *C, int ldc, + void* stream); +int HIP_zhemm( + void* side, void* uplo, + int m, int n, + void *alpha, + const void *A, int lda, + const void *B, int ldb, + void *beta, + void *C, int ldc, + void* stream); +int HIP_zher2k( + void* uplo, void* trans, + int n, int k, + void *alpha, + const void *A, int lda, + const void *B, int ldb, + double *beta, + void *C, int ldc, + void* stream); +int HIP_zherk( + void* uplo, void* trans, + int n, int k, + double *alpha, + const void *A, int lda, + double *beta, + void *B, int ldb, + void* stream); +int HIP_zsymm( + void* side, void* uplo, + int m, int n, + void *alpha, + const void *A, int lda, + const void *B, int ldb, + void *beta, + void *C, int ldc, + void* stream); +int HIP_zsyr2k( + void* uplo, void* trans, + int n, int k, + void *alpha, + const void *A, int lda, + const void *B, int ldb, + void *beta, + void *C, int ldc, + void* stream); +int HIP_zsyrk( + void* uplo, void* trans, + int n, int k, + void *alpha, + const void *A, int lda, + void *beta, + void *C, int ldc, + void* stream); +int HIP_ztrmm( + void* side, void* uplo, + void* transa, void* diag, + int m, int n, + void *alpha, + const void *A, int lda, + void *B, int ldb, + void* stream); +int HIP_ztrsm( + void* side, void* uplo, + void* transa, void* diag, + int m, int n, + void *alpha, + const void *A, int lda, + void *B, int ldb, + void* stream); + +END_MODULE diff --git a/hipblas/include/CMakeLists.txt b/hipblas/include/CMakeLists.txt new file mode 100644 index 000000000..ec1b8e3b4 --- /dev/null +++ b/hipblas/include/CMakeLists.txt @@ -0,0 +1,66 @@ +### +# +# @file CMakeLists.txt +# +# @copyright 2009-2014 The University of Tennessee and The University of +# Tennessee Research Foundation. All rights reserved. +# @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +# Univ. Bordeaux. All rights reserved. +# +### +# +# @project CHAMELEON +# CHAMELEON is a software package provided by: +# Inria Bordeaux - Sud-Ouest, +# Univ. of Tennessee, +# King Abdullah Univesity of Science and Technology +# Univ. of California Berkeley, +# Univ. of Colorado Denver. +# +# @version 1.2.0 +# @author Florent Pruvost +# @author Mathieu Faverge +# @author Loris Lucido +# @date 2023-01-30 +# +### + +# Generate header files +# --------------------- +set(HIPBLAS_HDRS_GENERATED "") +set(ZHDR + hipblas/hipblas_z.h +) +precisions_rules_py( + HIPBLAS_HDRS_GENERATED "${ZHDR}" + TARGETDIR hipblas + PRECISIONS "s;d;c;z;zc;ds" ) + +# Define the list of headers +# -------------------------- +set(HIPBLAS_HDRS + hipblas.h + ) + +# Add generated headers +# --------------------- +foreach( hdr_file ${HIPBLAS_HDRS_GENERATED} ) + list(APPEND HIPBLAS_HDRS ${CMAKE_CURRENT_BINARY_DIR}/${hdr_file}) +endforeach() + +# Force generation of headers +# --------------------------- +add_custom_target(hipblas_include ALL SOURCES ${HIPBLAS_HDRS}) +set(CHAMELEON_SOURCES_TARGETS "${CHAMELEON_SOURCES_TARGETS};hipblas_include" CACHE INTERNAL "List of targets of sources") + +# Installation +# ------------ +install( FILES hipblas.h + DESTINATION include ) + +install( FILES ${HIPBLAS_HDRS} + DESTINATION include/hipblas ) + +### +### END CMakeLists.txt +### diff --git a/hipblas/include/hipblas.h b/hipblas/include/hipblas.h new file mode 100644 index 000000000..333bbc2d9 --- /dev/null +++ b/hipblas/include/hipblas.h @@ -0,0 +1,82 @@ +/** + * + * @file hipblas.h + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon GPU kernels main header + * + * @version 1.2.0 + * @author Florent Pruvost + * @author Mathieu Faverge + * @author Nathalie Furmento + * @author Loris Lucido + * @date 2023-01-30 + * @precisions normal z -> c d s + * + */ +#ifndef _hipblas_h_ +#define _hipblas_h_ + +#include "chameleon/config.h" + +#if !defined(CHAMELEON_USE_HIP) +#error "This file should not be included" +#endif + +#include <stdio.h> +#include <math.h> +#include <string.h> +#include <assert.h> + +#include <hip/hip_runtime.h> +#include <hip/hip_complex.h> + +#include <hipblas/hipblas.h> + +#define HIPBLAS_SADDR(_a_) (&(_a_)) +#define HIPBLAS_VALUE(_a_) (_a_) + +/** + * CHAMELEON types and constants + */ +#include "chameleon/types.h" +#include "chameleon/struct.h" +#include "chameleon/constants.h" + +/** + * HIP BLAS headers + */ +BEGIN_C_DECLS + +#include "hipblas/hipblas_z.h" +#include "hipblas/hipblas_d.h" +#include "hipblas/hipblas_c.h" +#include "hipblas/hipblas_s.h" + +END_C_DECLS + +/** + * Coreblas Error + */ +#define hipblas_error(k, str) fprintf(stderr, "%s: Parameter %d / %s\n", __func__, k, str) + +/** + * LAPACK Constants + */ +BEGIN_C_DECLS + +extern char *chameleon_lapack_constants[]; +#define chameleon_lapack_const(chameleon_const) chameleon_lapack_constants[chameleon_const][0] + +extern int chameleon_hipblas_constants[]; +#define chameleon_hipblas_const(chameleon_const) chameleon_hipblas_constants[chameleon_const] + +END_C_DECLS + +#endif /* _hipblas_h_ */ diff --git a/hipblas/include/hipblas/hipblas_z.h b/hipblas/include/hipblas/hipblas_z.h new file mode 100644 index 000000000..647a0a7e5 --- /dev/null +++ b/hipblas/include/hipblas/hipblas_z.h @@ -0,0 +1,38 @@ +/** + * + * @file hipblas_z.h + * + * @copyright 2009-2014 The University of Tennessee and The University of + * Tennessee Research Foundation. All rights reserved. + * @copyright 2012-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon GPU CHAMELEON_Complex64_t kernels header + * + * @version 1.2.0 + * @author Florent Pruvost + * @author Mathieu Faverge + * @author Loris Lucido + * @date 2023-01-30 + * @precisions normal z -> c d s + * + */ +#ifndef _hipblas_z_h_ +#define _hipblas_z_h_ + +/** + * Declarations of hip kernels - alphabetical order + */ +int HIP_zgemm( cham_trans_t transa, cham_trans_t transb, int m, int n, int k, const hipDoubleComplex *alpha, const hipDoubleComplex *A, int lda, const hipDoubleComplex *B, int ldb, const hipDoubleComplex *beta, hipDoubleComplex *C, int ldc, hipblasHandle_t handle ); +int HIP_zhemm( cham_side_t side, cham_uplo_t uplo, int m, int n, const hipDoubleComplex *alpha, const hipDoubleComplex *A, int lda, const hipDoubleComplex *B, int ldb, const hipDoubleComplex *beta, hipDoubleComplex *C, int ldc, hipblasHandle_t handle ); +int HIP_zher2k( cham_uplo_t uplo, cham_trans_t trans, int n, int k, const hipDoubleComplex *alpha, const hipDoubleComplex *A, int lda, const hipDoubleComplex *B, int ldb, const double *beta, hipDoubleComplex *C, int ldc, hipblasHandle_t handle ); +int HIP_zherk( cham_uplo_t uplo, cham_trans_t trans, int n, int k, const double *alpha, const hipDoubleComplex *A, int lda, const double *beta, hipDoubleComplex *B, int ldb, hipblasHandle_t handle ); +int HIP_zsymm( cham_side_t side, cham_uplo_t uplo, int m, int n, const hipDoubleComplex *alpha, const hipDoubleComplex *A, int lda, const hipDoubleComplex *B, int ldb, const hipDoubleComplex *beta, hipDoubleComplex *C, int ldc, hipblasHandle_t handle ); +int HIP_zsyr2k( cham_uplo_t uplo, cham_trans_t trans, int n, int k, const hipDoubleComplex *alpha, const hipDoubleComplex *A, int lda, const hipDoubleComplex *B, int ldb, const hipDoubleComplex *beta, hipDoubleComplex *C, int ldc, hipblasHandle_t handle ); +int HIP_zsyrk( cham_uplo_t uplo, cham_trans_t trans, int n, int k, const hipDoubleComplex *alpha, const hipDoubleComplex *A, int lda, const hipDoubleComplex *beta, hipDoubleComplex *C, int ldc, hipblasHandle_t handle ); +int HIP_ztrmm( cham_side_t side, cham_uplo_t uplo, cham_trans_t transa, cham_diag_t diag, int m, int n, const hipDoubleComplex *alpha, const hipDoubleComplex *A, int lda, hipDoubleComplex *B, int ldb, hipblasHandle_t handle ); +int HIP_ztrsm( cham_side_t side, cham_uplo_t uplo, cham_trans_t transa, cham_diag_t diag, int m, int n, const hipDoubleComplex *alpha, const hipDoubleComplex *A, int lda, hipDoubleComplex *B, int ldb, hipblasHandle_t handle ); + +#endif /* _hipblas_z_h_ */ -- GitLab