diff --git a/doc/user/chapters/using.org b/doc/user/chapters/using.org index 8dff2f7468c17053244f1aa0016ad80afb01b9f8..2847cd286514d45a503c7b98480bc226f40ceebd 100644 --- a/doc/user/chapters/using.org +++ b/doc/user/chapters/using.org @@ -858,6 +858,19 @@ * *Map functions* * map: apply a user operator on each tile of the matrix + In addition, all *BLAS 3 routines* (gemm, hemm, her2k, herk, lauum, symm, + syr2k, syrk, trmm, trsm) can be called using an equivalent of the + (C)BLAS/LAPACK(E) API. The parameters are the same and the user just has + to add *CHAMELEON_* to the standard name of the routine. For example, in C + #+begin_src + CHAMELEON_Init(4,0); + CHAMELEON_cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, + N, NRHS, N, 1.0, A, N, X, N, -1.0, B, N); + CHAMELEON_Finalize(); + #+end_src + In Fortran, the function names are for example: ~CHAMELEON_blas_dgemm~ + instead of ~DGEMM~ and ~CHAMELEON_lapack_dlauum~ instead of ~DLAUUM~. + **** Options routines <<sec:options_routines>> diff --git a/lapack_api/CMakeLists.txt b/lapack_api/CMakeLists.txt index 9917a0399dc7c01698544a72d7227a66763842d6..5fcdd04507c678d1f5f9944ad7092c3a7e5d5705 100644 --- a/lapack_api/CMakeLists.txt +++ b/lapack_api/CMakeLists.txt @@ -57,6 +57,15 @@ install( FILES ${CHAMELEON_LAPACK_HDRS} set(LAPACK_SRCS_GENERATED "") set(ZSRC src/lapack_zgemm.c + src/lapack_zhemm.c + src/lapack_zher2k.c + src/lapack_zherk.c + src/lapack_zlauum.c + src/lapack_zsymm.c + src/lapack_zsyr2k.c + src/lapack_zsyrk.c + src/lapack_ztrmm.c + src/lapack_ztrsm.c ) precisions_rules_py(LAPACK_SRCS_GENERATED "${ZSRC}" PRECISIONS "${CHAMELEON_PRECISION}") diff --git a/lapack_api/include/chameleon/chameleon_zlapack.h b/lapack_api/include/chameleon/chameleon_zlapack.h index 71cc73ca90f7b473cf3b320f68efcfe367eb9312..77320305eca007db81104c32853f3b8c87d01824 100644 --- a/lapack_api/include/chameleon/chameleon_zlapack.h +++ b/lapack_api/include/chameleon/chameleon_zlapack.h @@ -27,12 +27,61 @@ BEGIN_C_DECLS /** * Declarations of math functions (LAPACK layout, Cblas/Lapacke interface) - alphabetical order */ -void CHAMELEON_cblas_zgemm( const CBLAS_ORDER Order, const CBLAS_TRANSPOSE TransA, const CBLAS_TRANSPOSE TransB, +void CHAMELEON_cblas_zgemm( const CBLAS_ORDER order, const CBLAS_TRANSPOSE transA, const CBLAS_TRANSPOSE transB, const int M, const int N, const int K, const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, const CHAMELEON_Complex64_t *B, const int ldb, const void *beta, CHAMELEON_Complex64_t *C, const int ldc ); +void CHAMELEON_cblas_zhemm( const CBLAS_ORDER order, const CBLAS_SIDE side, const CBLAS_UPLO uplo, + const int M, const int N, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb, + const void *beta, CHAMELEON_Complex64_t *C, const int ldc ); + +void CHAMELEON_cblas_zher2k( const CBLAS_ORDER order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, + const int N, const int K, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb, + const double beta, CHAMELEON_Complex64_t *C, const int ldc ); + +void CHAMELEON_cblas_zherk( const CBLAS_ORDER order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, + const int N, const int K, + const double alpha, const CHAMELEON_Complex64_t *A, const int lda, + const double beta, CHAMELEON_Complex64_t *C, const int ldc ); + +void CHAMELEON_cblas_zsymm( const CBLAS_ORDER order, const CBLAS_SIDE side, const CBLAS_UPLO uplo, + const int M, const int N, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb, + const void *beta, CHAMELEON_Complex64_t *C, const int ldc ); + +void CHAMELEON_cblas_zsyr2k( const CBLAS_ORDER order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, + const int N, const int K, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb, + const void *beta, CHAMELEON_Complex64_t *C, const int ldc ); + +void CHAMELEON_cblas_zsyrk( const CBLAS_ORDER order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, + const int N, const int K, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const void *beta, CHAMELEON_Complex64_t *C, const int ldc ); + +void CHAMELEON_cblas_ztrmm( const CBLAS_ORDER order, const CBLAS_SIDE side, const CBLAS_UPLO uplo, + const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, + const int M, const int N, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb ); + +void CHAMELEON_cblas_ztrsm( const CBLAS_ORDER order, const CBLAS_SIDE side, const CBLAS_UPLO uplo, + const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, + const int M, const int N, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb ); + +int CHAMELEON_lapacke_zlauum( int matrix_layout, char uplo, int N, + CHAMELEON_Complex64_t *A, int lda ); + END_C_DECLS #endif /* _chameleon_zlapack_h_ */ diff --git a/lapack_api/include/lapack_api_common.h b/lapack_api/include/lapack_api_common.h index bc46abf2beb3f07d70811d31cb7af092fad6e4b5..c298574fbc46808d995b1d1352c07fe16fa9c121 100644 --- a/lapack_api/include/lapack_api_common.h +++ b/lapack_api/include/lapack_api_common.h @@ -30,6 +30,9 @@ * */ -int chameleon_blastocblas_trans(const char* value); +int chameleon_blastocblas_trans(const char* trans); +int chameleon_blastocblas_side(const char* side); +int chameleon_blastocblas_uplo(const char* uplo); +int chameleon_blastocblas_diag(const char* diag); #endif /* _lapack_api_common_h_ */ diff --git a/lapack_api/src/lapack_api_common.c b/lapack_api/src/lapack_api_common.c index 5ab9e261e5ff0f12c6f5e3bc65024a4634fca146..f1773234e73dbac9afa92bb2941c46bf31975916 100644 --- a/lapack_api/src/lapack_api_common.c +++ b/lapack_api/src/lapack_api_common.c @@ -37,3 +37,57 @@ int chameleon_blastocblas_trans(const char* trans) return CHAMELEON_ERR_ILLEGAL_VALUE; } } + +/** + * @brief Convert the input char BLAS side parameter to a compatible parameter + * for the Cblas API. + * @param[in] uplo The input char BLAS side parameter + * @return The CBLAS equivalent parameter (CblasLeft or CblasRight). + */ +int chameleon_blastocblas_side(const char* side) +{ + if ( (*side == 'L') || (*side == 'l') ) { + return CblasLeft; + } else if ( (*side == 'R') || (*side == 'r') ) { + return CblasRight; + } else { + fprintf(stderr, "CHAMELEON ERROR: %s(): %s\n", "chameleon_blastocblas_side", "illegal value of BLAS side parameter"); + return CHAMELEON_ERR_ILLEGAL_VALUE; + } +} + +/** + * @brief Convert the input char BLAS uplo parameter to a compatible parameter + * for the Cblas API. + * @param[in] uplo The input char BLAS uplo parameter + * @return The CBLAS equivalent parameter (CblasUpper or CblasLower). + */ +int chameleon_blastocblas_uplo(const char* uplo) +{ + if ( (*uplo == 'U') || (*uplo == 'u') ) { + return CblasUpper; + } else if ( (*uplo == 'L') || (*uplo == 'l') ) { + return CblasLower; + } else { + fprintf(stderr, "CHAMELEON ERROR: %s(): %s\n", "chameleon_blastocblas_uplo", "illegal value of BLAS uplo parameter"); + return CHAMELEON_ERR_ILLEGAL_VALUE; + } +} + +/** + * @brief Convert the input char BLAS diag parameter to a compatible parameter + * for the Cblas API. + * @param[in] diag The input char BLAS diag parameter + * @return The CBLAS equivalent parameter (CblasUnit or CblasNonUnit). + */ +int chameleon_blastocblas_diag(const char* diag) +{ + if ( (*diag == 'U') || (*diag == 'u') ) { + return CblasUnit; + } else if ( (*diag == 'N') || (*diag == 'n') ) { + return CblasNonUnit; + } else { + fprintf(stderr, "CHAMELEON ERROR: %s(): %s\n", "chameleon_blastocblas_diag", "illegal value of BLAS diag parameter"); + return CHAMELEON_ERR_ILLEGAL_VALUE; + } +} diff --git a/lapack_api/src/lapack_zgemm.c b/lapack_api/src/lapack_zgemm.c index d3723b9617f6dd9461dc4dd19ed6411fdd2a63fe..86c22af92f60b11566271c80d2294b3ae4b6b910 100644 --- a/lapack_api/src/lapack_zgemm.c +++ b/lapack_api/src/lapack_zgemm.c @@ -17,6 +17,7 @@ * */ +#include "chameleon_lapack.h" #include "lapack_api_common.h" /* Fortran BLAS interface */ @@ -57,17 +58,21 @@ void CHAMELEON_blas_zgemm ( const char* transa, const char* transb, * ******************************************************************************* * - * @param[in] transA + * @param[in] order + * Specifies whether the matrices are row or column major, it must be + * set to CblasColMajor, the order supported in Chameleon. + * + * @param[in] TransA * Specifies whether the matrix A is transposed, not transposed or conjugate transposed: - * = ChamNoTrans: A is not transposed; - * = ChamTrans: A is transposed; - * = ChamConjTrans: A is conjugate transposed. + * = CblasNoTrans: A is not transposed; + * = CblasTrans: A is transposed; + * = CblasConjTrans: A is conjugate transposed. * - * @param[in] transB + * @param[in] TransB * Specifies whether the matrix B is transposed, not transposed or conjugate transposed: - * = ChamNoTrans: B is not transposed; - * = ChamTrans: B is transposed; - * = ChamConjTrans: B is conjugate transposed. + * = CblasNoTrans: B is not transposed; + * = CblasTrans: B is transposed; + * = CblasConjTrans: B is conjugate transposed. * * @param[in] M * M specifies the number of rows of the matrix op( A ) and of the matrix C. M >= 0. @@ -83,14 +88,14 @@ void CHAMELEON_blas_zgemm ( const char* transa, const char* transb, * alpha specifies the scalar alpha * * @param[in] A - * A is a LDA-by-ka matrix, where ka is K when transA = ChamNoTrans, + * A is a LDA-by-ka matrix, where ka is K when transA = CblasNoTrans, * and is M otherwise. * * @param[in] LDA * The leading dimension of the array A. LDA >= max(1,M). * * @param[in] B - * B is a LDB-by-kb matrix, where kb is N when transB = ChamNoTrans, + * B is a LDB-by-kb matrix, where kb is N when transB = CblasNoTrans, * and is K otherwise. * * @param[in] LDB @@ -106,11 +111,7 @@ void CHAMELEON_blas_zgemm ( const char* transa, const char* transb, * @param[in] LDC * The leading dimension of the array C. LDC >= max(1,M). * - ******************************************************************************* - * - * @retval CHAMELEON_SUCCESS successful exit - * - ******************************************************************************* + ****************************************************************************** * * @sa CHAMELEON_cblas_zgemm * @sa CHAMELEON_cblas_cgemm @@ -118,14 +119,15 @@ void CHAMELEON_blas_zgemm ( const char* transa, const char* transb, * @sa CHAMELEON_cblas_sgemm * */ -void CHAMELEON_cblas_zgemm( const CBLAS_ORDER Order, const CBLAS_TRANSPOSE TransA, const CBLAS_TRANSPOSE TransB, +void CHAMELEON_cblas_zgemm( const CBLAS_ORDER order, const CBLAS_TRANSPOSE transA, const CBLAS_TRANSPOSE transB, const int M, const int N, const int K, const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, const CHAMELEON_Complex64_t *B, const int ldb, const void *beta, CHAMELEON_Complex64_t *C, const int ldc ) { - if (Order != CblasColMajor){ - fprintf(stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_cblas_zgemm", "illegal value of order"); + if ( order != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_cblas_zgemm", "illegal value of order" ); + return; } #if defined(PRECISION_z) || defined(PRECISION_c) @@ -136,7 +138,7 @@ void CHAMELEON_cblas_zgemm( const CBLAS_ORDER Order, const CBLAS_TRANSPOSE Trans CHAMELEON_Complex64_t betac = beta; #endif - CHAMELEON_zgemm( (cham_trans_t)TransA, (cham_trans_t)TransB, M, N, K, + CHAMELEON_zgemm( (cham_trans_t)transA, (cham_trans_t)transB, M, N, K, alphac, (CHAMELEON_Complex64_t *)A, lda, (CHAMELEON_Complex64_t *)B, ldb, betac, (CHAMELEON_Complex64_t *)C, ldc ); diff --git a/lapack_api/src/lapack_zhemm.c b/lapack_api/src/lapack_zhemm.c new file mode 100644 index 0000000000000000000000000000000000000000..9a07c77646cf3f47a607f5ab2ea5cd60687bd234 --- /dev/null +++ b/lapack_api/src/lapack_zhemm.c @@ -0,0 +1,143 @@ +/** + * + * @file lapack_zhemm.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon blas and cblas api for hemm + * + * @version 1.2.0 + * @author Mathieu Faverge + * @author Florent Pruvost + * @date 2022-08-19 + * @precisions normal z -> c + * + */ + +#include "chameleon_lapack.h" +#include "lapack_api_common.h" + +/* Fortran BLAS interface */ + +#define CHAMELEON_blas_zhemm CHAMELEON_GLOBAL( chameleon_blas_zhemm, CHAMELEON_BLAS_Zhemm ) +void CHAMELEON_blas_zhemm ( const char* side, const char* uplo, + const int* m, const int* n, + const CHAMELEON_Complex64_t* alpha, const CHAMELEON_Complex64_t* a, const int* lda, + const CHAMELEON_Complex64_t* b, const int* ldb, + const CHAMELEON_Complex64_t* beta, CHAMELEON_Complex64_t* c, const int* ldc ) +{ + CHAMELEON_cblas_zhemm( CblasColMajor, + chameleon_blastocblas_side(side), + chameleon_blastocblas_uplo(uplo), + *m, *n, + CBLAS_SADDR(*alpha), a, *lda, + b, *ldb, + CBLAS_SADDR(*beta), c, *ldc ); +} + +/* C CBLAS interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_cblas_zhemm - Performs one of the matrix-matrix operations + * + * \f[ C = \alpha \times A \times B + \beta \times C \f] + * + * or + * + * \f[ C = \alpha \times B \times A + \beta \times C \f] + * + * where alpha and beta are scalars, A is an hermitian matrix and B and + * C are m by n matrices. + * + ******************************************************************************* + * + * @param[in] order + * Specifies whether the matrices are row or column major, it must be + * set to CblasColMajor, the order supported in Chameleon. + * + * @param[in] side + * Specifies whether the hermitian matrix A appears on the + * left or right in the operation as follows: + * = CblasLeft: \f[ C = \alpha \times A \times B + \beta \times C \f] + * = CblasRight: \f[ C = \alpha \times B \times A + \beta \times C \f] + * + * @param[in] uplo + * Specifies whether the upper or lower triangular part of + * the hermitian matrix A is to be referenced as follows: + * = CblasLower: Only the lower triangular part of the + * hermitian matrix A is to be referenced. + * = CblasUpper: Only the upper triangular part of the + * hermitian matrix A is to be referenced. + * + * @param[in] M + * Specifies the number of rows of the matrix C. M >= 0. + * + * @param[in] N + * Specifies the number of columns of the matrix C. N >= 0. + * + * @param[in] alpha + * Specifies the scalar alpha. + * + * @param[in] A + * A is a LDA-by-ka matrix, where ka is M when side = CblasLeft, + * and is N otherwise. Only the uplo triangular part is referenced. + * + * @param[in] LDA + * The leading dimension of the array A. LDA >= max(1,ka). + * + * @param[in] B + * B is a LDB-by-N matrix, where the leading M-by-N part of + * the array B must contain the matrix B. + * + * @param[in] LDB + * The leading dimension of the array B. LDB >= max(1,M). + * + * @param[in] beta + * Specifies the scalar beta. + * + * @param[in,out] C + * C is a LDC-by-N matrix. + * On exit, the array is overwritten by the M by N updated matrix. + * + * @param[in] LDC + * The leading dimension of the array C. LDC >= max(1,M). + * + ******************************************************************************* + * + * @sa CHAMELEON_cblas_zhemm + * @sa CHAMELEON_cblas_chemm + * @sa CHAMELEON_cblas_dhemm + * @sa CHAMELEON_cblas_shemm + * + */ +void CHAMELEON_cblas_zhemm( const CBLAS_ORDER order, const CBLAS_SIDE side, const CBLAS_UPLO uplo, + const int M, const int N, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb, + const void *beta, CHAMELEON_Complex64_t *C, const int ldc ) +{ + if ( order != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_cblas_zhemm", "illegal value of order" ); + return; + } + +#if defined(PRECISION_z) || defined(PRECISION_c) + CHAMELEON_Complex64_t alphac = *(CHAMELEON_Complex64_t *)alpha; + CHAMELEON_Complex64_t betac = *(CHAMELEON_Complex64_t *)beta; +#else + CHAMELEON_Complex64_t alphac = alpha; + CHAMELEON_Complex64_t betac = beta; +#endif + + CHAMELEON_zhemm( (cham_side_t)side, (cham_uplo_t)uplo, M, N, + alphac, (CHAMELEON_Complex64_t *)A, lda, + (CHAMELEON_Complex64_t *)B, ldb, + betac, (CHAMELEON_Complex64_t *)C, ldc ); +} diff --git a/lapack_api/src/lapack_zher2k.c b/lapack_api/src/lapack_zher2k.c new file mode 100644 index 0000000000000000000000000000000000000000..9154e970379796f8f7429800bbde60775d296659 --- /dev/null +++ b/lapack_api/src/lapack_zher2k.c @@ -0,0 +1,143 @@ +/** + * + * @file lapack_zher2k.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon blas and cblas api for her2k + * + * @version 1.2.0 + * @author Mathieu Faverge + * @author Florent Pruvost + * @date 2022-08-19 + * @precisions normal z -> c + * + */ + +#include "chameleon_lapack.h" +#include "lapack_api_common.h" + +/* Fortran BLAS interface */ + +#define CHAMELEON_blas_zher2k CHAMELEON_GLOBAL( chameleon_blas_zher2k, CHAMELEON_BLAS_Zher2k ) +void CHAMELEON_blas_zher2k ( const char* uplo, const char* trans, + const int* n, const int* k, + const CHAMELEON_Complex64_t* alpha, const CHAMELEON_Complex64_t* a, const int* lda, + const CHAMELEON_Complex64_t* b, const int* ldb, + const double* beta, CHAMELEON_Complex64_t* c, const int* ldc ) +{ + CHAMELEON_cblas_zher2k( CblasColMajor, + chameleon_blastocblas_uplo(uplo), + chameleon_blastocblas_trans(trans), + *n, *k, + CBLAS_SADDR(*alpha), a, *lda, + b, *ldb, + *beta, c, *ldc ); +} + +/* C CBLAS interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_cblas_zher2k - Performs one of the hermitian rank 2k operations + * + * \f[ C = \alpha [ op( A ) \times conjg( op( B )' )] + conjg( \alpha ) [ op( B ) \times conjg( op( A )' )] + \beta C \f], + * or + * \f[ C = \alpha [ conjg( op( A )' ) \times op( B ) ] + conjg( \alpha ) [ conjg( op( B )' ) \times op( A ) ] + \beta C \f], + * + * where op( X ) is one of + * + * op( X ) = X or op( X ) = conjg( X' ) + * + * where alpha and beta are real scalars, C is an n-by-n hermitian + * matrix and A and B are an n-by-k matrices the first case and k-by-n + * matrices in the second case. + * + ******************************************************************************* + * + * @param[in] order + * Specifies whether the matrices are row or column major, it must be + * set to CblasColMajor, the order supported in Chameleon. + * + * @param[in] uplo + * = CblasUpper: Upper triangle of C is stored; + * = CblasLower: Lower triangle of C is stored. + * + * @param[in] trans + * Specifies whether the matrix A is transposed or conjugate transposed: + * = CblasNoTrans: \f[ C = \alpha [ op( A ) \times conjg( op( B )' )] + conjg( \alpha ) [ op( B ) \times conjg( op( A )' )] + \beta C \f] + * = CblasConjTrans: \f[ C = \alpha [ conjg( op( A )' ) \times op( B ) ] + conjg( \alpha ) [ conjg( op( B )' ) \times op( A ) ] + \beta C \f] + * + * @param[in] N + * N specifies the order of the matrix C. N must be at least zero. + * + * @param[in] K + * K specifies the number of columns of the A and B matrices with trans = CblasNoTrans. + * K specifies the number of rows of the A and B matrices with trans = CblasTrans. + * + * @param[in] alpha + * alpha specifies the scalar alpha. + * + * @param[in] A + * A is a LDA-by-ka matrix, where ka is K when trans = CblasNoTrans, + * and is N otherwise. + * + * @param[in] LDA + * The leading dimension of the array A. LDA must be at least + * max( 1, N ), otherwise LDA must be at least max( 1, K ). + * + * @param[in] B + * B is a LDB-by-kb matrix, where kb is K when trans = CblasNoTrans, + * and is N otherwise. + * + * @param[in] LDB + * The leading dimension of the array B. LDB must be at least + * max( 1, N ), otherwise LDB must be at least max( 1, K ). + * + * @param[in] beta + * beta specifies the scalar beta. + * + * @param[in,out] C + * C is a LDC-by-N matrix. + * On exit, the array uplo part of the matrix is overwritten + * by the uplo part of the updated matrix. + * + * @param[in] LDC + * The leading dimension of the array C. LDC >= max( 1, N ). + * + ******************************************************************************* + * + * @sa CHAMELEON_cblas_zher2k + * @sa CHAMELEON_cblas_cher2k + * @sa CHAMELEON_cblas_dher2k + * @sa CHAMELEON_cblas_sher2k + * + */ +void CHAMELEON_cblas_zher2k( const CBLAS_ORDER order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, + const int N, const int K, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb, + const double beta, CHAMELEON_Complex64_t *C, const int ldc ) +{ + if ( order != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_cblas_zher2k", "illegal value of order" ); + return; + } + +#if defined(PRECISION_z) || defined(PRECISION_c) + CHAMELEON_Complex64_t alphac = *(CHAMELEON_Complex64_t *)alpha; +#else + CHAMELEON_Complex64_t alphac = alpha; +#endif + + CHAMELEON_zher2k( (cham_uplo_t)uplo, (cham_trans_t)trans, N, K, + alphac, (CHAMELEON_Complex64_t *)A, lda, + (CHAMELEON_Complex64_t *)B, ldb, + beta, (CHAMELEON_Complex64_t *)C, ldc ); +} diff --git a/lapack_api/src/lapack_zherk.c b/lapack_api/src/lapack_zherk.c new file mode 100644 index 0000000000000000000000000000000000000000..9b5b80a7f3f470d4804952426b5e5bfddbc8428b --- /dev/null +++ b/lapack_api/src/lapack_zherk.c @@ -0,0 +1,123 @@ +/** + * + * @file lapack_zherk.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon blas and cblas api for herk + * + * @version 1.2.0 + * @author Mathieu Faverge + * @author Florent Pruvost + * @date 2022-08-19 + * @precisions normal z -> c + * + */ + +#include "chameleon_lapack.h" +#include "lapack_api_common.h" + +/* Fortran BLAS interface */ + +#define CHAMELEON_blas_zherk CHAMELEON_GLOBAL( chameleon_blas_zherk, CHAMELEON_BLAS_Zherk ) +void CHAMELEON_blas_zherk ( const char* uplo, const char* trans, + const int* n, const int* k, + const double* alpha, const CHAMELEON_Complex64_t* a, const int* lda, + const double* beta, CHAMELEON_Complex64_t* c, const int* ldc ) +{ + CHAMELEON_cblas_zherk( CblasColMajor, + chameleon_blastocblas_uplo(uplo), + chameleon_blastocblas_trans(trans), + *n, *k, + *alpha, a, *lda, + *beta, c, *ldc ); +} + +/* C CBLAS interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_cblas_zherk - Performs one of the hermitian rank k operations + * + * \f[ C = \alpha [ op( A ) \times conjg( op( A )' )] + \beta C \f], + * + * where op( X ) is one of + * + * op( X ) = X or op( X ) = conjg( X' ) + * + * where alpha and beta are real scalars, C is an n-by-n hermitian + * matrix and A is an n-by-k matrix in the first case and a k-by-n + * matrix in the second case. + * + ******************************************************************************* + * + * @param[in] order + * Specifies whether the matrices are row or column major, it must be + * set to CblasColMajor, the order supported in Chameleon. + * + * @param[in] uplo + * = CblasUpper: Upper triangle of C is stored; + * = CblasLower: Lower triangle of C is stored. + * + * @param[in] trans + * Specifies whether the matrix A is transposed or conjugate transposed: + * = CblasNoTrans: A is not transposed; + * = CblasConjTrans: A is conjugate transposed. + * + * @param[in] N + * N specifies the order of the matrix C. N must be at least zero. + * + * @param[in] K + * K specifies the number of columns of the matrix op( A ). + * + * @param[in] alpha + * alpha specifies the scalar alpha. + * + * @param[in] A + * A is a LDA-by-ka matrix, where ka is K when trans = CblasNoTrans, + * and is N otherwise. + * + * @param[in] LDA + * The leading dimension of the array A. LDA must be at least + * max( 1, N ) if trans == CblasNoTrans, otherwise LDA must + * be at least max( 1, K ). + * + * @param[in] beta + * beta specifies the scalar beta + * + * @param[in,out] C + * C is a LDC-by-N matrix. + * On exit, the array uplo part of the matrix is overwritten + * by the uplo part of the updated matrix. + * + * @param[in] LDC + * The leading dimension of the array C. LDC >= max( 1, N ). + * + ******************************************************************************* + * + * @sa CHAMELEON_cblas_zherk + * @sa CHAMELEON_cblas_cherk + * @sa CHAMELEON_cblas_dherk + * @sa CHAMELEON_cblas_sherk + * + */ +void CHAMELEON_cblas_zherk( const CBLAS_ORDER order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, + const int N, const int K, + const double alpha, const CHAMELEON_Complex64_t *A, const int lda, + const double beta, CHAMELEON_Complex64_t *C, const int ldc ) +{ + if ( order != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_cblas_zherk", "illegal value of order" ); + return; + } + + CHAMELEON_zherk( (cham_uplo_t)uplo, (cham_trans_t)trans, N, K, + alpha, (CHAMELEON_Complex64_t *)A, lda, + beta, (CHAMELEON_Complex64_t *)C, ldc ); +} diff --git a/lapack_api/src/lapack_zlauum.c b/lapack_api/src/lapack_zlauum.c new file mode 100644 index 0000000000000000000000000000000000000000..4216edcd4c23317392c69f6f528b28ea437fc634 --- /dev/null +++ b/lapack_api/src/lapack_zlauum.c @@ -0,0 +1,97 @@ +/** + * + * @file lapack_zlauum.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon lapack and lapacke api for lauum + * + * @version 1.2.0 + * @author Mathieu Faverge + * @author Florent Pruvost + * @date 2022-08-19 + * @precisions normal z -> s d c + * + */ + +#include "chameleon_lapack.h" +#include "lapack_api_common.h" + +/* Fortran LAPACK interface */ + +#define CHAMELEON_lapack_zlauum CHAMELEON_GLOBAL( chameleon_lapack_zlauum, CHAMELEON_BLAS_Zlauum ) +void CHAMELEON_lapack_zlauum ( const char* uplo, const int* n, + CHAMELEON_Complex64_t* a, const int* lda, + int* info ) +{ + *info = CHAMELEON_lapacke_zlauum( CblasColMajor, + *uplo, *n, a, *lda ); +} + +/* C CBLAS interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_lapacke_zlauum - Computes the product U * U' or L' * L, where the triangular + * factor U or L is stored in the upper or lower triangular part of + * the array A. + * + * If UPLO = 'U' or 'u' then the upper triangle of the result is stored, + * overwriting the factor U in A. + * If UPLO = 'L' or 'l' then the lower triangle of the result is stored, + * overwriting the factor L in A. + * + ******************************************************************************* + * + * @param[in] matrix_layout + * Specifies whether the matrices are row or column major, it must be + * set to LAPACK_COL_MAJOR or CblasColMajor (102), the matrix_layout + * supported in Chameleon. + * + * @param[in] uplo + * = 'U' or 'u': Upper triangular + * = 'L' or 'l': Lower triangular + * + * @param[in] N + * The order of the triangular factor U or L. N >= 0. + * + * @param[in,out] A + * On entry, the triangular factor U or L. + * On exit, if UPLO = 'U', the upper triangle of A is + * overwritten with the upper triangle of the product U * U'; + * if UPLO = 'L', the lower triangle of A is overwritten with + * the lower triangle of the product L' * L. + * + * @param[in] LDA + * The leading dimension of the array A. LDA >= max(1,N). + * + ******************************************************************************* + * + * @retval =0 successful exit + * @retval <0 if -i, the i-th argument had an illegal value + * + ******************************************************************************* + * + * @sa CHAMELEON_lapacke_zlauum + * @sa CHAMELEON_lapacke_clauum + * @sa CHAMELEON_lapacke_dlauum + * @sa CHAMELEON_lapacke_slauum + * + */ +int CHAMELEON_lapacke_zlauum( int matrix_layout, char uplo, int N, + CHAMELEON_Complex64_t *A, int lda ) +{ + if ( matrix_layout != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_lapacke_zlauum", "illegal value of matrix_layout" ); + return; + } + + return CHAMELEON_zlauum( (cham_uplo_t)chameleon_blastocblas_uplo(&uplo), N, + (CHAMELEON_Complex64_t *)A, lda ); +} diff --git a/lapack_api/src/lapack_zsymm.c b/lapack_api/src/lapack_zsymm.c new file mode 100644 index 0000000000000000000000000000000000000000..37e31a1f3b97c5b06d6ac6ad839f3fe9f2a0fda2 --- /dev/null +++ b/lapack_api/src/lapack_zsymm.c @@ -0,0 +1,143 @@ +/** + * + * @file lapack_zsymm.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon blas and cblas api for symm + * + * @version 1.2.0 + * @author Mathieu Faverge + * @author Florent Pruvost + * @date 2022-08-18 + * @precisions normal z -> s d c + * + */ + +#include "chameleon_lapack.h" +#include "lapack_api_common.h" + +/* Fortran BLAS interface */ + +#define CHAMELEON_blas_zsymm CHAMELEON_GLOBAL( chameleon_blas_zsymm, CHAMELEON_BLAS_Zsymm ) +void CHAMELEON_blas_zsymm ( const char* side, const char* uplo, + const int* m, const int* n, + const CHAMELEON_Complex64_t* alpha, const CHAMELEON_Complex64_t* a, const int* lda, + const CHAMELEON_Complex64_t* b, const int* ldb, + const CHAMELEON_Complex64_t* beta, CHAMELEON_Complex64_t* c, const int* ldc ) +{ + CHAMELEON_cblas_zsymm( CblasColMajor, + chameleon_blastocblas_side(side), + chameleon_blastocblas_uplo(uplo), + *m, *n, + CBLAS_SADDR(*alpha), a, *lda, + b, *ldb, + CBLAS_SADDR(*beta), c, *ldc ); +} + +/* C CBLAS interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_cblas_zsymm - Performs one of the matrix-matrix operations + * + * \f[ C = \alpha \times A \times B + \beta \times C \f] + * + * or + * + * \f[ C = \alpha \times B \times A + \beta \times C \f] + * + * where alpha and beta are scalars, A is a symmetric matrix and B and + * C are m by n matrices. + * + ******************************************************************************* + * + * @param[in] order + * Specifies whether the matrices are row or column major, it must be + * set to CblasColMajor, the order supported in Chameleon. + * + * @param[in] side + * Specifies whether the symmetric matrix A appears on the + * left or right in the operation as follows: + * = CblasLeft: \f[ C = \alpha \times A \times B + \beta \times C \f] + * = CblasRight: \f[ C = \alpha \times B \times A + \beta \times C \f] + * + * @param[in] uplo + * Specifies whether the upper or lower triangular part of + * the symmetric matrix A is to be referenced as follows: + * = CblasLower: Only the lower triangular part of the + * symmetric matrix A is to be referenced. + * = CblasUpper: Only the upper triangular part of the + * symmetric matrix A is to be referenced. + * + * @param[in] M + * Specifies the number of rows of the matrix C. M >= 0. + * + * @param[in] N + * Specifies the number of columns of the matrix C. N >= 0. + * + * @param[in] alpha + * Specifies the scalar alpha. + * + * @param[in] A + * A is a LDA-by-ka matrix, where ka is M when side = CblasLeft, + * and is N otherwise. Only the uplo triangular part is referenced. + * + * @param[in] LDA + * The leading dimension of the array A. LDA >= max(1,ka). + * + * @param[in] B + * B is a LDB-by-N matrix, where the leading M-by-N part of + * the array B must contain the matrix B. + * + * @param[in] LDB + * The leading dimension of the array B. LDB >= max(1,M). + * + * @param[in] beta + * Specifies the scalar beta. + * + * @param[in,out] C + * C is a LDC-by-N matrix. + * On exit, the array is overwritten by the M by N updated matrix. + * + * @param[in] LDC + * The leading dimension of the array C. LDC >= max(1,M). + * + ****************************************************************************** + * + * @sa CHAMELEON_cblas_zsymm + * @sa CHAMELEON_cblas_csymm + * @sa CHAMELEON_cblas_dsymm + * @sa CHAMELEON_cblas_ssymm + * + */ +void CHAMELEON_cblas_zsymm( const CBLAS_ORDER order, const CBLAS_SIDE side, const CBLAS_UPLO uplo, + const int M, const int N, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb, + const void *beta, CHAMELEON_Complex64_t *C, const int ldc ) +{ + if ( order != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_cblas_zsymm", "illegal value of order" ); + return; + } + +#if defined(PRECISION_z) || defined(PRECISION_c) + CHAMELEON_Complex64_t alphac = *(CHAMELEON_Complex64_t *)alpha; + CHAMELEON_Complex64_t betac = *(CHAMELEON_Complex64_t *)beta; +#else + CHAMELEON_Complex64_t alphac = alpha; + CHAMELEON_Complex64_t betac = beta; +#endif + + CHAMELEON_zsymm( (cham_side_t)side, (cham_uplo_t)uplo, M, N, + alphac, (CHAMELEON_Complex64_t *)A, lda, + (CHAMELEON_Complex64_t *)B, ldb, + betac, (CHAMELEON_Complex64_t *)C, ldc ); +} diff --git a/lapack_api/src/lapack_zsyr2k.c b/lapack_api/src/lapack_zsyr2k.c new file mode 100644 index 0000000000000000000000000000000000000000..15f55c7106884acaf9533a812f99d638a3e16d10 --- /dev/null +++ b/lapack_api/src/lapack_zsyr2k.c @@ -0,0 +1,141 @@ +/** + * + * @file lapack_zsyr2k.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon blas and cblas api for syr2k + * + * @version 1.2.0 + * @author Mathieu Faverge + * @author Florent Pruvost + * @date 2022-08-19 + * @precisions normal z -> s d c + * + */ + +#include "chameleon_lapack.h" +#include "lapack_api_common.h" + +/* Fortran BLAS interface */ + +#define CHAMELEON_blas_zsyr2k CHAMELEON_GLOBAL( chameleon_blas_zsyr2k, CHAMELEON_BLAS_Zsyr2k ) +void CHAMELEON_blas_zsyr2k ( const char* uplo, const char* trans, + const int* n, const int* k, + const CHAMELEON_Complex64_t* alpha, const CHAMELEON_Complex64_t* a, const int* lda, + const CHAMELEON_Complex64_t* b, const int* ldb, + const CHAMELEON_Complex64_t* beta, CHAMELEON_Complex64_t* c, const int* ldc ) +{ + CHAMELEON_cblas_zsyr2k( CblasColMajor, + chameleon_blastocblas_uplo(uplo), + chameleon_blastocblas_trans(trans), + *n, *k, + CBLAS_SADDR(*alpha), a, *lda, + b, *ldb, + CBLAS_SADDR(*beta), c, *ldc ); +} + +/* C CBLAS interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_cblas_zsyr2k - Performs one of the symmetric rank 2k operations + * + * \f[ C = \alpha [ A \times B' ] + \alpha [ B \times A' ] + \beta C \f], + * or + * \f[ C = \alpha [ A' \times B ] + \alpha [ B' \times A ] + \beta C \f], + * + * where alpha and beta are real scalars, C is an n-by-n symmetric + * matrix and A and B are an n-by-k matrices the first case and k-by-n + * matrices in the second case. + * + ******************************************************************************* + * + * @param[in] order + * Specifies whether the matrices are row or column major, it must be + * set to CblasColMajor, the order supported in Chameleon. + * + * @param[in] uplo + * = CblasUpper: Upper triangle of C is stored; + * = CblasLower: Lower triangle of C is stored. + * + * @param[in] trans + * Specifies the operation to be performed as follows: + * = CblasNoTrans: \f[ C = \alpha [ A \times B' ] + \alpha [ B \times A' ] + \beta C \f] + * = CblasTrans: \f[ C = \alpha [ A' \times B ] + \alpha [ B' \times A ] + \beta C \f] + * + * @param[in] N + * N specifies the order of the matrix C. N must be at least zero. + * + * @param[in] K + * K specifies the number of columns of the A and B matrices with trans = CblasNoTrans. + * K specifies the number of rows of the A and B matrices with trans = CblasTrans. + * + * @param[in] alpha + * alpha specifies the scalar alpha. + * + * @param[in] A + * A is a LDA-by-ka matrix, where ka is K when trans = CblasNoTrans, + * and is N otherwise. + * + * @param[in] LDA + * The leading dimension of the array A. LDA must be at least + * max( 1, N ), otherwise LDA must be at least max( 1, K ). + * + * @param[in] B + * B is a LDB-by-kb matrix, where kb is K when trans = CblasNoTrans, + * and is N otherwise. + * + * @param[in] LDB + * The leading dimension of the array B. LDB must be at least + * max( 1, N ), otherwise LDB must be at least max( 1, K ). + * + * @param[in] beta + * beta specifies the scalar beta. + * + * @param[in,out] C + * C is a LDC-by-N matrix. + * On exit, the array uplo part of the matrix is overwritten + * by the uplo part of the updated matrix. + * + * @param[in] LDC + * The leading dimension of the array C. LDC >= max( 1, N ). + * + ******************************************************************************* + * + * @sa CHAMELEON_cblas_zsyr2k + * @sa CHAMELEON_cblas_csyr2k + * @sa CHAMELEON_cblas_dsyr2k + * @sa CHAMELEON_cblas_ssyr2k + * + */ +void CHAMELEON_cblas_zsyr2k( const CBLAS_ORDER order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, + const int N, const int K, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb, + const void *beta, CHAMELEON_Complex64_t *C, const int ldc ) +{ + if ( order != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_cblas_zsyr2k", "illegal value of order" ); + return; + } + +#if defined(PRECISION_z) || defined(PRECISION_c) + CHAMELEON_Complex64_t alphac = *(CHAMELEON_Complex64_t *)alpha; + CHAMELEON_Complex64_t betac = *(CHAMELEON_Complex64_t *)beta; +#else + CHAMELEON_Complex64_t alphac = alpha; + CHAMELEON_Complex64_t betac = beta; +#endif + + CHAMELEON_zsyr2k( (cham_uplo_t)uplo, (cham_trans_t)trans, N, K, + alphac, (CHAMELEON_Complex64_t *)A, lda, + (CHAMELEON_Complex64_t *)B, ldb, + betac, (CHAMELEON_Complex64_t *)C, ldc ); +} diff --git a/lapack_api/src/lapack_zsyrk.c b/lapack_api/src/lapack_zsyrk.c new file mode 100644 index 0000000000000000000000000000000000000000..9ac63d931bc94596e78de1ddd30f9de6a307d97d --- /dev/null +++ b/lapack_api/src/lapack_zsyrk.c @@ -0,0 +1,129 @@ +/** + * + * @file lapack_zsyrk.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon blas and cblas api for syrk + * + * @version 1.2.0 + * @author Mathieu Faverge + * @author Florent Pruvost + * @date 2022-08-19 + * @precisions normal z -> s d c + * + */ + +#include "chameleon_lapack.h" +#include "lapack_api_common.h" + +/* Fortran BLAS interface */ + +#define CHAMELEON_blas_zsyrk CHAMELEON_GLOBAL( chameleon_blas_zsyrk, CHAMELEON_BLAS_Zsyrk ) +void CHAMELEON_blas_zsyrk ( const char* uplo, const char* trans, + const int* n, const int* k, + const CHAMELEON_Complex64_t* alpha, const CHAMELEON_Complex64_t* a, const int* lda, + const CHAMELEON_Complex64_t* beta, CHAMELEON_Complex64_t* c, const int* ldc ) +{ + CHAMELEON_cblas_zsyrk( CblasColMajor, + chameleon_blastocblas_uplo(uplo), + chameleon_blastocblas_trans(trans), + *n, *k, + CBLAS_SADDR(*alpha), a, *lda, + CBLAS_SADDR(*beta), c, *ldc ); +} + +/* C CBLAS interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_cblas_zsyrk - Performs one of the symmetric rank k operations + * + * \f[ C = \alpha [ A \times A' ] + \beta C \f] + * or + * \f[ C = \alpha [ A' \times A ] + \beta C \f] + * + * where alpha and beta are real scalars, C is an n-by-n symmetric + * matrix and A is an n-by-k matrix in the first case and a k-by-n + * matrix in the second case. + * + ******************************************************************************* + * + * @param[in] order + * Specifies whether the matrices are row or column major, it must be + * set to CblasColMajor, the order supported in Chameleon. + * + * @param[in] uplo + * = CblasUpper: Upper triangle of C is stored; + * = CblasLower: Lower triangle of C is stored. + * + * @param[in] trans + * Specifies the operation to be performed as follows: + * = CblasNoTrans: \f[ C = \alpha [ A \times A' ] + \beta C \f] + * = CblasTrans: \f[ C = \alpha [ A' \times A ] + \beta C \f] + * + * @param[in] N + * N specifies the order of the matrix C. N must be at least zero. + * + * @param[in] K + * K specifies the number of columns of the matrix A. + * + * @param[in] alpha + * alpha specifies the scalar alpha. + * + * @param[in] A + * A is a LDA-by-ka matrix, where ka is K when trans = CblasNoTrans, + * and is N otherwise. + * + * @param[in] LDA + * The leading dimension of the array A. LDA must be at least + * max( 1, N ) if trans == CblasNoTrans, otherwise LDA must + * be at least max( 1, K ). + * + * @param[in] beta + * beta specifies the scalar beta + * + * @param[in,out] C + * C is a LDC-by-N matrix. + * On exit, the array uplo part of the matrix is overwritten + * by the uplo part of the updated matrix. + * + * @param[in] LDC + * The leading dimension of the array C. LDC >= max( 1, N ). + * + ******************************************************************************* + * + * @sa CHAMELEON_cblas_zsyrk + * @sa CHAMELEON_cblas_csyrk + * @sa CHAMELEON_cblas_dsyrk + * @sa CHAMELEON_cblas_ssyrk + * + */ +void CHAMELEON_cblas_zsyrk( const CBLAS_ORDER order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, + const int N, const int K, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const void *beta, CHAMELEON_Complex64_t *C, const int ldc ) +{ + if ( order != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_cblas_zsyrk", "illegal value of order" ); + return; + } + +#if defined(PRECISION_z) || defined(PRECISION_c) + CHAMELEON_Complex64_t alphac = *(CHAMELEON_Complex64_t *)alpha; + CHAMELEON_Complex64_t betac = *(CHAMELEON_Complex64_t *)beta; +#else + CHAMELEON_Complex64_t alphac = alpha; + CHAMELEON_Complex64_t betac = beta; +#endif + + CHAMELEON_zsyrk( (cham_uplo_t)uplo, (cham_trans_t)trans, N, K, + alphac, (CHAMELEON_Complex64_t *)A, lda, + betac, (CHAMELEON_Complex64_t *)C, ldc ); +} diff --git a/lapack_api/src/lapack_ztrmm.c b/lapack_api/src/lapack_ztrmm.c new file mode 100644 index 0000000000000000000000000000000000000000..4e571213db1edf0bafdc80dee85ce7dea6fee097 --- /dev/null +++ b/lapack_api/src/lapack_ztrmm.c @@ -0,0 +1,137 @@ +/** + * + * @file lapack_ztrmm.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon blas and cblas api for trmm + * + * @version 1.2.0 + * @author Mathieu Faverge + * @author Florent Pruvost + * @date 2022-08-18 + * @precisions normal z -> s d c + * + */ + +#include "chameleon_lapack.h" +#include "lapack_api_common.h" + +/* Fortran BLAS interface */ + +#define CHAMELEON_blas_ztrmm CHAMELEON_GLOBAL( chameleon_blas_ztrmm, CHAMELEON_BLAS_Ztrmm ) +void CHAMELEON_blas_ztrmm ( const char* side, const char* uplo, + const char* trans, const char* diag, + const int* m, const int* n, + const CHAMELEON_Complex64_t* alpha, const CHAMELEON_Complex64_t* a, const int* lda, + const CHAMELEON_Complex64_t* b, const int* ldb ) +{ + CHAMELEON_cblas_ztrmm( CblasColMajor, + chameleon_blastocblas_side(side), + chameleon_blastocblas_uplo(uplo), + chameleon_blastocblas_side(trans), + chameleon_blastocblas_diag(diag), + *m, *n, + CBLAS_SADDR(*alpha), a, *lda, + b, *ldb ); +} + +/* C CBLAS interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_cblas_ztrmm - Computes B = alpha*op( A )*B or B = alpha*B*op( A ). + * + ******************************************************************************* + * + * @param[in] order + * Specifies whether the matrices are row or column major, it must be + * set to CblasColMajor, the order supported in Chameleon. + * + * @param[in] side + * Specifies whether A appears on the left or on the right of X: + * = CblasLeft: A*X = B + * = CblasRight: X*A = B + * + * @param[in] uplo + * Specifies whether the matrix A is upper triangular or lower triangular: + * = CblasUpper: Upper triangle of A is stored; + * = CblasLower: Lower triangle of A is stored. + * + * @param[in] trans + * Specifies whether the matrix A is transposed, not transposed or conjugate transposed: + * = CblasNoTrans: A is transposed; + * = CblasTrans: A is not transposed; + * = CblasConjTrans: A is conjugate transposed. + * + * @param[in] diag + * Specifies whether or not A is unit triangular: + * = CblasNonUnit: A is non unit; + * = CblasUnit: A us unit. + * + * @param[in] N + * The order of the matrix A. N >= 0. + * + * @param[in] NRHS + * The number of right hand sides, i.e., the number of columns of the matrix B if side = CblasLeft or + * the number of rows of the matrix B if side = CblasRight. NRHS >= 0. + * + * @param[in] alpha + * alpha specifies the scalar alpha. + * + * @param[in] A + * The triangular matrix A. If uplo = CblasUpper, the leading N-by-N upper triangular + * part of the array A contains the upper triangular matrix, and the strictly lower + * triangular part of A is not referenced. If uplo = CblasLower, the leading N-by-N + * lower triangular part of the array A contains the lower triangular matrix, and the + * strictly upper triangular part of A is not referenced. If diag = CblasUnit, the + * diagonal elements of A are also not referenced and are assumed to be 1. + * + * @param[in] LDA + * The leading dimension of the array A. LDA >= max(1,N). + * + * @param[in,out] B + * On entry, the N-by-NRHS right hand side matrix B. + * On exit, if return value = 0, the N-by-NRHS solution matrix X if side = CblasLeft + * or the NRHS-by-N matrix X if side = CblasRight. + * + * @param[in] LDB + * The leading dimension of the array B. LDB >= max(1,N). + * + ******************************************************************************* + * + * @sa CHAMELEON_cblas_ztrmm + * @sa CHAMELEON_cblas_ctrmm + * @sa CHAMELEON_cblas_dtrmm + * @sa CHAMELEON_cblas_strmm + * + */ +void CHAMELEON_cblas_ztrmm( const CBLAS_ORDER order, const CBLAS_SIDE side, const CBLAS_UPLO uplo, + const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, + const int M, const int N, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb ) +{ + if ( order != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_cblas_ztrmm", "illegal value of order" ); + return; + } + +#if defined(PRECISION_z) || defined(PRECISION_c) + CHAMELEON_Complex64_t alphac = *(CHAMELEON_Complex64_t *)alpha; +#else + CHAMELEON_Complex64_t alphac = alpha; +#endif + + CHAMELEON_ztrmm( (cham_side_t)side, (cham_uplo_t)uplo, + (cham_trans_t)trans, (cham_diag_t)diag, + M, N, + alphac, (CHAMELEON_Complex64_t *)A, lda, + (CHAMELEON_Complex64_t *)B, ldb ); +} diff --git a/lapack_api/src/lapack_ztrsm.c b/lapack_api/src/lapack_ztrsm.c new file mode 100644 index 0000000000000000000000000000000000000000..08c337093af1cd0d5687939997dd29ffd32104dd --- /dev/null +++ b/lapack_api/src/lapack_ztrsm.c @@ -0,0 +1,157 @@ +/** + * + * @file lapack_ztrsm.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon blas and cblas api for trsm + * + * @version 1.2.0 + * @author Mathieu Faverge + * @author Florent Pruvost + * @date 2022-08-19 + * @precisions normal z -> s d c + * + */ + +#include "chameleon_lapack.h" +#include "lapack_api_common.h" + +/* Fortran BLAS interface */ + +#define CHAMELEON_blas_ztrsm CHAMELEON_GLOBAL( chameleon_blas_ztrsm, CHAMELEON_BLAS_Ztrsm ) +void CHAMELEON_blas_ztrsm ( const char* side, const char* uplo, + const char* trans, const char* diag, + const int* m, const int* n, + const CHAMELEON_Complex64_t* alpha, const CHAMELEON_Complex64_t* a, const int* lda, + const CHAMELEON_Complex64_t* b, const int* ldb ) +{ + CHAMELEON_cblas_ztrsm( CblasColMajor, + chameleon_blastocblas_side(side), + chameleon_blastocblas_uplo(uplo), + chameleon_blastocblas_side(trans), + chameleon_blastocblas_diag(diag), + *m, *n, + CBLAS_SADDR(*alpha), a, *lda, + b, *ldb ); +} + +/* C CBLAS interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_cblas_ztrsm - Solves one of the matrix equations + * op( A )*X = alpha*B, or X*op( A ) = alpha*B, + * + * where alpha is a scalar, X and B are m by n matrices, A is a unit, or + * non-unit, upper or lower triangular matrix and op( A ) is one of + * + * op( A ) = A or op( A ) = A**T or op( A ) = A**H. + * + * The matrix X is overwritten on B. + * + ******************************************************************************* + * + * @param[in] order + * Specifies whether the matrices are row or column major, it must be + * set to CblasColMajor, the order supported in Chameleon. + * + * @param[in] side + * Specifies whether op(A) appears on the left or on the right of X: + * = CblasLeft: op(A) * X = B + * = CblasRight: X * op(A) = B + * + * @param[in] uplo + * Specifies whether the matrix A is upper triangular or lower triangular: + * = CblasUpper: A is an upper triangular matrix. + * = CblasLower: A is a lower triangular matrix. + * + * @param[in] trans + * Specifies the form of op( A ) to be used in the matrix + * multiplication as follows: + * = CblasNoTrans: op( A ) = A. + * = CblasTrans: op( A ) = A**T. + * = CblasConjTrans: op( A ) = A**H. + * + * @param[in] diag + * Specifies whether or not A is unit triangular: + * = CblasNonUnit: A is assumed to be unit triangular. + * = CblasUnit: A is not assumed to be unit triangular. + * + * @param[in] M + * M specifies the number of rows of B. M must be at least zero. + * + * @param[in] N + * N specifies the number of columns of B. N must be at least zero. + * + * @param[in] alpha + * alpha specifies the scalar alpha. When alpha is zero then A is not + * referenced and B need not be set before entry. + * + * @param[in] A + * The triangular matrix A of dimension lda-by-k, + * where k is M when side = CblasLeft + * and k is N when side = CblasRight + * Before entry with uplo = CblasUpper, the leading k-by-k upper + * triangular part of the array A must contain the upper triangular + * matrix and the strictly lower triangular part of A is not + * referenced. + * Before entry with uplo = CblasLower, the leading k-by-k lower + * triangular part of the array A must contain the lower triangular + * matrix and the strictly upper triangular part of A is not + * referenced. + * Note that when diag = CblasUnit, the diagonal elements of A are not + * referenced either, but are assumed to be unity. + * + * @param[in] LDA + * LDA specifies the first dimension of A. When side = CblasLeft then + * LDA must be at least max( 1, M ), when side = CblasRight then LDA + * must be at least max( 1, N ). + * + * @param[in,out] B + * The matrix B of dimension LDB-by-N. + * Before entry, the leading m by n part of the array B must contain + * the right-hand side matrix B, and on exit is overwritten by the + * solution matrix X. + * + * @param[in] LDB + * LDB specifies the first dimension of B. LDB must be at least + * max( 1, M ). + * + ******************************************************************************* + * + * @sa CHAMELEON_cblas_ztrsm + * @sa CHAMELEON_cblas_ctrsm + * @sa CHAMELEON_cblas_dtrsm + * @sa CHAMELEON_cblas_strsm + * + */ +void CHAMELEON_cblas_ztrsm( const CBLAS_ORDER order, const CBLAS_SIDE side, const CBLAS_UPLO uplo, + const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, + const int M, const int N, + const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, + const CHAMELEON_Complex64_t *B, const int ldb ) +{ + if ( order != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_cblas_ztrsm", "illegal value of order" ); + return; + } + +#if defined(PRECISION_z) || defined(PRECISION_c) + CHAMELEON_Complex64_t alphac = *(CHAMELEON_Complex64_t *)alpha; +#else + CHAMELEON_Complex64_t alphac = alpha; +#endif + + CHAMELEON_ztrsm( (cham_side_t)side, (cham_uplo_t)uplo, + (cham_trans_t)trans, (cham_diag_t)diag, + M, N, + alphac, (CHAMELEON_Complex64_t *)A, lda, + (CHAMELEON_Complex64_t *)B, ldb ); +} diff --git a/testing/testing_zhemm.c b/testing/testing_zhemm.c index 6b1c25699cea21661747ce437c814675422b79f7..f653fa17afe17119ced290d3c0dd992c5e3c46f6 100644 --- a/testing/testing_zhemm.c +++ b/testing/testing_zhemm.c @@ -127,6 +127,7 @@ testing_zhemm_std( run_arg_list_t *args, int check ) int hres = 0; /* Read arguments */ + int api = parameters_getvalue_int( "api" ); int nb = run_arg_get_int( args, "nb", 320 ); cham_side_t side = run_arg_get_side( args, "side", ChamLeft ); cham_uplo_t uplo = run_arg_get_uplo( args, "uplo", ChamUpper ); @@ -173,7 +174,21 @@ testing_zhemm_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_zhemm( side, M, N ) ); #else testing_start( &test_data ); - hres = CHAMELEON_zhemm( side, uplo, M, N, alpha, A, LDA, B, LDB, beta, C, LDC ); + switch ( api ) { + case 1: + hres = CHAMELEON_zhemm( side, uplo, M, N, alpha, A, LDA, B, LDB, beta, C, LDC ); + break; + case 2: + CHAMELEON_cblas_zhemm( CblasColMajor, (CBLAS_SIDE)side, (CBLAS_UPLO)uplo, M, N, + CBLAS_SADDR(alpha), A, LDA, B, LDB, CBLAS_SADDR(beta), C, LDC ); + break; + default: + if ( CHAMELEON_Comm_rank() == 0 ) { + fprintf( stderr, + "SKIPPED: This function can only be used with the option --api 1 or --api 2.\n" ); + } + return -1; + } test_data.hres = hres; testing_stop( &test_data, flops_zhemm( side, M, N ) ); diff --git a/testing/testing_zher2k.c b/testing/testing_zher2k.c index 52f9b7e850aa180ddd6a0663d6d093293d0f4953..877dc5e2a10cf9556c3692702c9a1bcb0e6c4845 100644 --- a/testing/testing_zher2k.c +++ b/testing/testing_zher2k.c @@ -129,6 +129,7 @@ testing_zher2k_std( run_arg_list_t *args, int check ) int hres = 0; /* Read arguments */ + int api = parameters_getvalue_int( "api" ); int nb = run_arg_get_int( args, "nb", 320 ); cham_trans_t trans = run_arg_get_trans( args, "trans", ChamNoTrans ); cham_uplo_t uplo = run_arg_get_uplo( args, "uplo", ChamUpper ); @@ -186,7 +187,21 @@ testing_zher2k_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_zher2k( K, N ) ); #else testing_start( &test_data ); - hres = CHAMELEON_zher2k( uplo, trans, N, K, alpha, A, LDA, B, LDB, beta, C, LDC ); + switch ( api ) { + case 1: + hres = CHAMELEON_zher2k( uplo, trans, N, K, alpha, A, LDA, B, LDB, beta, C, LDC ); + break; + case 2: + CHAMELEON_cblas_zher2k( CblasColMajor, (CBLAS_UPLO)uplo, (CBLAS_TRANSPOSE)trans, N, K, + CBLAS_SADDR(alpha), A, LDA, B, LDB, beta, C, LDC ); + break; + default: + if ( CHAMELEON_Comm_rank() == 0 ) { + fprintf( stderr, + "SKIPPED: This function can only be used with the option --api 1 or --api 2.\n" ); + } + return -1; + } test_data.hres = hres; testing_stop( &test_data, flops_zher2k( K, N ) ); diff --git a/testing/testing_zherk.c b/testing/testing_zherk.c index 6dc56c2de270d11b738423131f2c18c046311107..d17ccc4265d1cff5da6d5069a19850a793ef9cc4 100644 --- a/testing/testing_zherk.c +++ b/testing/testing_zherk.c @@ -122,6 +122,7 @@ testing_zherk_std( run_arg_list_t *args, int check ) int hres = 0; /* Read arguments */ + int api = parameters_getvalue_int( "api" ); int nb = run_arg_get_int( args, "nb", 320 ); cham_trans_t trans = run_arg_get_trans( args, "trans", ChamNoTrans ); cham_uplo_t uplo = run_arg_get_uplo( args, "uplo", ChamUpper ); @@ -172,7 +173,21 @@ testing_zherk_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_zherk( N, K ) ); #else testing_start( &test_data ); - hres = CHAMELEON_zherk( uplo, trans, N, K, alpha, A, LDA, beta, C, LDC ); + switch ( api ) { + case 1: + hres = CHAMELEON_zherk( uplo, trans, N, K, alpha, A, LDA, beta, C, LDC ); + break; + case 2: + CHAMELEON_cblas_zherk( CblasColMajor, (CBLAS_UPLO)uplo, (CBLAS_TRANSPOSE)trans, N, K, + alpha, A, LDA, beta, C, LDC ); + break; + default: + if ( CHAMELEON_Comm_rank() == 0 ) { + fprintf( stderr, + "SKIPPED: This function can only be used with the option --api 1 or --api 2.\n" ); + } + return -1; + } test_data.hres = hres; testing_stop( &test_data, flops_zherk( N, K ) ); diff --git a/testing/testing_zlauum.c b/testing/testing_zlauum.c index 71859dbcd40f5dc79eb7bcf3b60d5c5ba3a653d9..4437b01f45d2063da3f85faf04ff5818e5900e51 100644 --- a/testing/testing_zlauum.c +++ b/testing/testing_zlauum.c @@ -21,6 +21,9 @@ #include "testings.h" #include "testing_zcheck.h" #include <chameleon/flops.h> +#if !defined(CHAMELEON_SIMULATION) +#include <coreblas.h> +#endif static cham_fixdbl_t flops_zlauum( int N ) @@ -91,6 +94,7 @@ testing_zlauum_std( run_arg_list_t *args, int check ) int hres = 0; /* Read arguments */ + int api = parameters_getvalue_int( "api" ); int nb = run_arg_get_int( args, "nb", 320 ); cham_uplo_t uplo = run_arg_get_uplo( args, "uplo", ChamUpper ); int N = run_arg_get_int( args, "N", 1000 ); @@ -110,7 +114,22 @@ testing_zlauum_std( run_arg_list_t *args, int check ) /* Calculates the matrix product */ testing_start( &test_data ); - hres = CHAMELEON_zlauum( uplo, N, A, LDA ); + switch ( api ) { + case 1: + hres = CHAMELEON_zlauum( uplo, N, A, LDA ); + break; +#if !defined(CHAMELEON_SIMULATION) + case 2: + CHAMELEON_lapacke_zlauum( CblasColMajor, chameleon_lapack_const(uplo), N, A, LDA ); + break; +#endif + default: + if ( CHAMELEON_Comm_rank() == 0 ) { + fprintf( stderr, + "SKIPPED: This function can only be used with the option --api 1 or --api 2.\n" ); + } + return -1; + } test_data.hres = hres; testing_stop( &test_data, flops_zlauum( N ) ); diff --git a/testing/testing_zsymm.c b/testing/testing_zsymm.c index a4d94002c865edce86c4d7fc1efee3bb2a4bac07..1c1cafe6dc89e2ef46d93db7e4e970761ef6435e 100644 --- a/testing/testing_zsymm.c +++ b/testing/testing_zsymm.c @@ -127,6 +127,7 @@ testing_zsymm_std( run_arg_list_t *args, int check ) int hres = 0; /* Read arguments */ + int api = parameters_getvalue_int( "api" ); int nb = run_arg_get_int( args, "nb", 320 ); cham_side_t side = run_arg_get_side( args, "side", ChamLeft ); cham_uplo_t uplo = run_arg_get_uplo( args, "uplo", ChamUpper ); @@ -173,7 +174,21 @@ testing_zsymm_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_zsymm( side, M, N ) ); #else testing_start( &test_data ); - hres = CHAMELEON_zsymm( side, uplo, M, N, alpha, A, LDA, B, LDB, beta, C, LDC ); + switch ( api ) { + case 1: + hres = CHAMELEON_zsymm( side, uplo, M, N, alpha, A, LDA, B, LDB, beta, C, LDC ); + break; + case 2: + CHAMELEON_cblas_zsymm( CblasColMajor, (CBLAS_SIDE)side, (CBLAS_UPLO)uplo, M, N, + CBLAS_SADDR(alpha), A, LDA, B, LDB, CBLAS_SADDR(beta), C, LDC ); + break; + default: + if ( CHAMELEON_Comm_rank() == 0 ) { + fprintf( stderr, + "SKIPPED: This function can only be used with the option --api 1 or --api 2.\n" ); + } + return -1; + } test_data.hres = hres; testing_stop( &test_data, flops_zsymm( side, M, N ) ); diff --git a/testing/testing_zsyr2k.c b/testing/testing_zsyr2k.c index 44437ec6680937199b54ade9b8a4494a91627074..a1b790e320680e8a30fba89cf13f42c6cf7f1d8b 100644 --- a/testing/testing_zsyr2k.c +++ b/testing/testing_zsyr2k.c @@ -129,6 +129,7 @@ testing_zsyr2k_std( run_arg_list_t *args, int check ) int hres = 0; /* Read arguments */ + int api = parameters_getvalue_int( "api" ); int nb = run_arg_get_int( args, "nb", 320 ); cham_trans_t trans = run_arg_get_trans( args, "trans", ChamNoTrans ); cham_uplo_t uplo = run_arg_get_uplo( args, "uplo", ChamUpper ); @@ -186,7 +187,21 @@ testing_zsyr2k_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_zher2k( N, K ) ); #else testing_start( &test_data ); - hres = CHAMELEON_zsyr2k( uplo, trans, N, K, alpha, A, LDA, B, LDB, beta, C, LDC ); + switch ( api ) { + case 1: + hres = CHAMELEON_zsyr2k( uplo, trans, N, K, alpha, A, LDA, B, LDB, beta, C, LDC ); + break; + case 2: + CHAMELEON_cblas_zsyr2k( CblasColMajor, (CBLAS_UPLO)uplo, (CBLAS_TRANSPOSE)trans, N, K, + CBLAS_SADDR(alpha), A, LDA, B, LDB, CBLAS_SADDR(beta), C, LDC ); + break; + default: + if ( CHAMELEON_Comm_rank() == 0 ) { + fprintf( stderr, + "SKIPPED: This function can only be used with the option --api 1 or --api 2.\n" ); + } + return -1; + } test_data.hres = hres; testing_stop( &test_data, flops_zher2k( N, K ) ); diff --git a/testing/testing_zsyrk.c b/testing/testing_zsyrk.c index 9000c452dfa1f5db90499985673d6739258c45a7..09269ec267ab3f949b2df98d95c0650143b0471c 100644 --- a/testing/testing_zsyrk.c +++ b/testing/testing_zsyrk.c @@ -122,6 +122,7 @@ testing_zsyrk_std( run_arg_list_t *args, int check ) int hres = 0; /* Read arguments */ + int api = parameters_getvalue_int( "api" ); int nb = run_arg_get_int( args, "nb", 320 ); cham_trans_t trans = run_arg_get_trans( args, "trans", ChamNoTrans ); cham_uplo_t uplo = run_arg_get_uplo( args, "uplo", ChamUpper ); @@ -171,7 +172,21 @@ testing_zsyrk_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_zsyrk( K, N ) ); #else testing_start( &test_data ); - hres = CHAMELEON_zsyrk( uplo, trans, N, K, alpha, A, LDA, beta, C, LDC ); + switch ( api ) { + case 1: + hres = CHAMELEON_zsyrk( uplo, trans, N, K, alpha, A, LDA, beta, C, LDC ); + break; + case 2: + CHAMELEON_cblas_zsyrk( CblasColMajor, (CBLAS_UPLO)uplo, (CBLAS_TRANSPOSE)trans, N, K, + CBLAS_SADDR(alpha), A, LDA, CBLAS_SADDR(beta), C, LDC ); + break; + default: + if ( CHAMELEON_Comm_rank() == 0 ) { + fprintf( stderr, + "SKIPPED: This function can only be used with the option --api 1 or --api 2.\n" ); + } + return -1; + } test_data.hres = hres; testing_stop( &test_data, flops_zsyrk( K, N ) ); diff --git a/testing/testing_ztrmm.c b/testing/testing_ztrmm.c index 1a38de09bd674e823b7b7c658fa42625e4bd8009..b9b0a5d48f716c392f9070895b10b6618d4b6506 100644 --- a/testing/testing_ztrmm.c +++ b/testing/testing_ztrmm.c @@ -117,6 +117,7 @@ testing_ztrmm_std( run_arg_list_t *args, int check ) int hres = 0; /* Read arguments */ + int api = parameters_getvalue_int( "api" ); int nb = run_arg_get_int( args, "nb", 320 ); cham_trans_t trans = run_arg_get_trans( args, "trans", ChamNoTrans ); cham_side_t side = run_arg_get_side( args, "side", ChamLeft ); @@ -157,7 +158,22 @@ testing_ztrmm_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_ztrmm( side, N, M ) ); #else testing_start( &test_data ); - hres = CHAMELEON_ztrmm( side, uplo, trans, diag, M, N, alpha, A, LDA, B, LDB ); + switch ( api ) { + case 1: + hres = CHAMELEON_ztrmm( side, uplo, trans, diag, M, N, alpha, A, LDA, B, LDB ); + break; + case 2: + CHAMELEON_cblas_ztrmm( CblasColMajor, (CBLAS_SIDE)side, (CBLAS_UPLO)uplo, + (CBLAS_TRANSPOSE)trans, (CBLAS_DIAG)diag, M, N, + CBLAS_SADDR(alpha), A, LDA, B, LDB ); + break; + default: + if ( CHAMELEON_Comm_rank() == 0 ) { + fprintf( stderr, + "SKIPPED: This function can only be used with the option --api 1 or --api 2.\n" ); + } + return -1; + } test_data.hres = hres; testing_stop( &test_data, flops_ztrmm( side, N, M ) ); diff --git a/testing/testing_ztrsm.c b/testing/testing_ztrsm.c index 3bff1b5a4c8c4f5638f65ba585028e2b376ca26b..868e1640196310bf6157e42ee9e50a17a0acb9ed 100644 --- a/testing/testing_ztrsm.c +++ b/testing/testing_ztrsm.c @@ -111,6 +111,7 @@ testing_ztrsm_std( run_arg_list_t *args, int check ) int hres = 0; /* Read arguments */ + int api = parameters_getvalue_int( "api" ); int nb = run_arg_get_int( args, "nb", 320 ); cham_trans_t trans = run_arg_get_trans( args, "trans", ChamNoTrans ); cham_side_t side = run_arg_get_side( args, "side", ChamLeft ); @@ -149,7 +150,22 @@ testing_ztrsm_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_ztrsm( side, M, N ) ); #else testing_start( &test_data ); - hres = CHAMELEON_ztrsm( side, uplo, trans, diag, M, N, alpha, A, LDA, B, LDB ); + switch ( api ) { + case 1: + hres = CHAMELEON_ztrsm( side, uplo, trans, diag, M, N, alpha, A, LDA, B, LDB ); + break; + case 2: + CHAMELEON_cblas_ztrsm( CblasColMajor, (CBLAS_SIDE)side, (CBLAS_UPLO)uplo, + (CBLAS_TRANSPOSE)trans, (CBLAS_DIAG)diag, M, N, + CBLAS_SADDR(alpha), A, LDA, B, LDB ); + break; + default: + if ( CHAMELEON_Comm_rank() == 0 ) { + fprintf( stderr, + "SKIPPED: This function can only be used with the option --api 1 or --api 2.\n" ); + } + return -1; + } test_data.hres = hres; testing_stop( &test_data, flops_ztrsm( side, M, N ) );