diff --git a/doc/user/chapters/using.org b/doc/user/chapters/using.org index 1d36408cb79ee661d250818606adb13a043fd4d0..721b99ad524b3b9443cc3b323c9ce237776b1f89 100644 --- a/doc/user/chapters/using.org +++ b/doc/user/chapters/using.org @@ -863,10 +863,11 @@ * *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 + In addition, all *BLAS 3 routines* ~gemm~, ~hemm~, ~her2k~, ~herk~, ~lauum~, ~symm~, + ~syr2k~, ~syrk~, ~trmm~, ~trsm~ and *LAPACK* ~lacpy~, ~laset~, ~posv~, ~potrf~, ~potri~, + ~potrs~, ~trtri~ 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, @@ -874,7 +875,7 @@ 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~. + instead of ~DGEMM~ and ~CHAMELEON_lapack_dposv~ instead of ~DPOSV~. **** Options routines <<sec:options_routines>> diff --git a/lapack_api/CMakeLists.txt b/lapack_api/CMakeLists.txt index 4bf4b0836d8b506da49363341896858083c4ec8f..4a5857c3e57b061010674a9d0c20e5acd0a557ac 100644 --- a/lapack_api/CMakeLists.txt +++ b/lapack_api/CMakeLists.txt @@ -63,11 +63,16 @@ set(ZSRC src/lapack_zlacpy.c src/lapack_zlaset.c src/lapack_zlauum.c + src/lapack_zposv.c + src/lapack_zpotrf.c + src/lapack_zpotri.c + src/lapack_zpotrs.c src/lapack_zsymm.c src/lapack_zsyr2k.c src/lapack_zsyrk.c src/lapack_ztrmm.c src/lapack_ztrsm.c + src/lapack_ztrtri.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 02c4fec407f8202a129b675e283f18cb83de83df..27c23124432ae6373bd266aed0108a97a2b50c39 100644 --- a/lapack_api/include/chameleon/chameleon_zlapack.h +++ b/lapack_api/include/chameleon/chameleon_zlapack.h @@ -79,7 +79,6 @@ void CHAMELEON_cblas_ztrsm( const CBLAS_ORDER order, const CBLAS_SIDE side, cons const void *alpha, const CHAMELEON_Complex64_t *A, const int lda, const CHAMELEON_Complex64_t *B, const int ldb ); - int CHAMELEON_lapacke_zlacpy( int matrix_layout, char uplo, int M, int N, const CHAMELEON_Complex64_t *A, int lda, CHAMELEON_Complex64_t *B, int ldb ); @@ -91,6 +90,23 @@ int CHAMELEON_lapacke_zlaset( int matrix_layout, char uplo, int M, int N, int CHAMELEON_lapacke_zlauum( int matrix_layout, char uplo, int N, CHAMELEON_Complex64_t *A, int lda ); +int CHAMELEON_lapacke_zposv( int matrix_layout, char uplo, int N, int NRHS, + CHAMELEON_Complex64_t *A, int lda, + CHAMELEON_Complex64_t *B, int ldb ); + +int CHAMELEON_lapacke_zpotrf( int matrix_layout, char uplo, int N, + CHAMELEON_Complex64_t *A, int lda ); + +int CHAMELEON_lapacke_zpotri( int matrix_layout, char uplo, int N, + CHAMELEON_Complex64_t *A, int lda ); + +int CHAMELEON_lapacke_zpotrs( int matrix_layout, char uplo, int N, int NRHS, + const CHAMELEON_Complex64_t *A, int lda, + CHAMELEON_Complex64_t *B, int ldb ); + +int CHAMELEON_lapacke_ztrtri( int matrix_layout, char uplo, char diag, int N, + CHAMELEON_Complex64_t *A, int lda ); + END_C_DECLS #endif /* _chameleon_zlapack_h_ */ diff --git a/lapack_api/src/lapack_zhemm.c b/lapack_api/src/lapack_zhemm.c index 9a07c77646cf3f47a607f5ab2ea5cd60687bd234..fbd99b5744e0d1e27c4745b841db2e271dca39b6 100644 --- a/lapack_api/src/lapack_zhemm.c +++ b/lapack_api/src/lapack_zhemm.c @@ -22,7 +22,7 @@ /* Fortran BLAS interface */ -#define CHAMELEON_blas_zhemm CHAMELEON_GLOBAL( chameleon_blas_zhemm, CHAMELEON_BLAS_Zhemm ) +#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, diff --git a/lapack_api/src/lapack_zher2k.c b/lapack_api/src/lapack_zher2k.c index 9154e970379796f8f7429800bbde60775d296659..4fd98ae53b69ad3739209479cfba5cdd1fd5dd5f 100644 --- a/lapack_api/src/lapack_zher2k.c +++ b/lapack_api/src/lapack_zher2k.c @@ -22,7 +22,7 @@ /* Fortran BLAS interface */ -#define CHAMELEON_blas_zher2k CHAMELEON_GLOBAL( chameleon_blas_zher2k, CHAMELEON_BLAS_Zher2k ) +#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, diff --git a/lapack_api/src/lapack_zherk.c b/lapack_api/src/lapack_zherk.c index 9b5b80a7f3f470d4804952426b5e5bfddbc8428b..10345bb85606ab9f82440110a2bc546b5ef5195d 100644 --- a/lapack_api/src/lapack_zherk.c +++ b/lapack_api/src/lapack_zherk.c @@ -22,7 +22,7 @@ /* Fortran BLAS interface */ -#define CHAMELEON_blas_zherk CHAMELEON_GLOBAL( chameleon_blas_zherk, CHAMELEON_BLAS_Zherk ) +#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, diff --git a/lapack_api/src/lapack_zlacpy.c b/lapack_api/src/lapack_zlacpy.c index f8feb6d5d4a49efb109ee2cfc7a2fb135df8075e..e027ebef9ec3c28be50f1ff3a12bfd036cf9c22c 100644 --- a/lapack_api/src/lapack_zlacpy.c +++ b/lapack_api/src/lapack_zlacpy.c @@ -22,7 +22,7 @@ /* Fortran LAPACK interface */ -#define CHAMELEON_lapack_zlacpy CHAMELEON_GLOBAL( chameleon_lapack_zlacpy, CHAMELEON_BLAS_Zlacpy ) +#define CHAMELEON_lapack_zlacpy CHAMELEON_GLOBAL( chameleon_lapack_zlacpy, CHAMELEON_LAPACK_ZLACPY ) void CHAMELEON_lapack_zlacpy ( const char* uplo, const int* m, const int* n, const CHAMELEON_Complex64_t* a, const int* lda, CHAMELEON_Complex64_t* b, const int* ldb ) diff --git a/lapack_api/src/lapack_zlaset.c b/lapack_api/src/lapack_zlaset.c index 1813b8c26ca4747965512eafd7f7003d5e213a91..adc5036c02b0a517e44da314459fa52038b94423 100644 --- a/lapack_api/src/lapack_zlaset.c +++ b/lapack_api/src/lapack_zlaset.c @@ -22,7 +22,7 @@ /* Fortran LAPACK interface */ -#define CHAMELEON_lapack_zlaset CHAMELEON_GLOBAL( chameleon_lapack_zlaset, CHAMELEON_BLAS_Zlaset ) +#define CHAMELEON_lapack_zlaset CHAMELEON_GLOBAL( chameleon_lapack_zlaset, CHAMELEON_LAPACK_ZLASET ) void CHAMELEON_lapack_zlaset ( const char* uplo, const int* m, const int* n, const CHAMELEON_Complex64_t* alpha, const CHAMELEON_Complex64_t* beta, CHAMELEON_Complex64_t* a, const int* lda ) diff --git a/lapack_api/src/lapack_zlauum.c b/lapack_api/src/lapack_zlauum.c index c35b346600afd6ce62f43ea1729e7fc9f72e0e9f..d4c46cba4ae229ab0cee7f4d1bbe9f039c1cd4a0 100644 --- a/lapack_api/src/lapack_zlauum.c +++ b/lapack_api/src/lapack_zlauum.c @@ -22,7 +22,7 @@ /* Fortran LAPACK interface */ -#define CHAMELEON_lapack_zlauum CHAMELEON_GLOBAL( chameleon_lapack_zlauum, CHAMELEON_BLAS_Zlauum ) +#define CHAMELEON_lapack_zlauum CHAMELEON_GLOBAL( chameleon_lapack_zlauum, CHAMELEON_LAPACK_ZLAUUM ) void CHAMELEON_lapack_zlauum ( const char* uplo, const int* n, CHAMELEON_Complex64_t* a, const int* lda, int* info ) diff --git a/lapack_api/src/lapack_zposv.c b/lapack_api/src/lapack_zposv.c new file mode 100644 index 0000000000000000000000000000000000000000..4894b1a3ee06fd82997715eb3525175d5c3eb080 --- /dev/null +++ b/lapack_api/src/lapack_zposv.c @@ -0,0 +1,118 @@ +/** + * + * @file lapack_zposv.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon lapack and lapacke api for posv + * + * @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_zposv CHAMELEON_GLOBAL( chameleon_lapack_zposv, CHAMELEON_LAPACK_ZPOSV ) +void CHAMELEON_lapack_zposv ( const char* uplo, const int* n, const int* nrhs, + CHAMELEON_Complex64_t* a, const int* lda, + CHAMELEON_Complex64_t* b, const int* ldb, + int* info ) +{ + *info = CHAMELEON_lapacke_zposv( CblasColMajor, + *uplo, *n, *nrhs, a, *lda, b, *ldb ); +} + +/* C LAPACKE interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_lapacke_zposv - Computes the solution to a system of linear equations A * X = B, + * where A is an N-by-N symmetric positive definite (or Hermitian positive definite + * in the complex case) matrix and X and B are N-by-NRHS matrices. + * The Cholesky decomposition is used to factor A as + * + * \f[ A = \{_{L\times L^H, if uplo = ChamLower}^{U^H\times U, if uplo = ChamUpper} \f] + * + * where U is an upper triangular matrix and L is a lower triangular matrix. + * The factored form of A is then used to solve the system of equations A * X = B. + * + ******************************************************************************* + * + * @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 + * Specifies whether the matrix A is upper triangular or lower triangular: + * = 'U' or 'u': Upper triangle of A is stored; + * = 'L' or 'l': Lower triangle of A is stored. + * + * @param[in] N + * The number of linear equations, i.e., 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. NRHS >= 0. + * + * @param[in,out] A + * On entry, the symmetric positive definite (or Hermitian) matrix A. + * If UPLO = 'U', the leading N-by-N upper triangular part of A + * contains the upper triangular part of the matrix A, and the + * strictly lower triangular part of A is not referenced. + * If UPLO = 'L', the leading N-by-N lower triangular part of A + * contains the lower triangular part of the matrix A, and the + * strictly upper triangular part of A is not referenced. + * On exit, if return value = 0, the factor U or L from the Cholesky factorization + * A = U^H*U or A = L*L^H. + * + * @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. + * + * @param[in] LDB + * The leading dimension of the array B. LDB >= max(1,N). + * + ******************************************************************************* + * + * @retval =0 successful exit + * @retval <0 if -i, the i-th argument had an illegal value + * @retval >0 if i, the leading minor of order i of A is not + positive definite, so the factorization could not be + completed, and the solution has not been computed. + * + ******************************************************************************* + * + * @sa CHAMELEON_lapacke_zposv + * @sa CHAMELEON_lapacke_cposv + * @sa CHAMELEON_lapacke_dposv + * @sa CHAMELEON_lapacke_sposv + * + */ +int CHAMELEON_lapacke_zposv( int matrix_layout, char uplo, int N, int NRHS, + CHAMELEON_Complex64_t *A, int lda, + CHAMELEON_Complex64_t *B, int ldb ) +{ + if ( matrix_layout != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_lapacke_zposv", "illegal value of matrix_layout" ); + return -1; + } + + return CHAMELEON_zposv( (cham_uplo_t)chameleon_blastocblas_uplo(&uplo), + N, NRHS, A, lda, B, ldb ); +} diff --git a/lapack_api/src/lapack_zpotrf.c b/lapack_api/src/lapack_zpotrf.c new file mode 100644 index 0000000000000000000000000000000000000000..de9d20e9eb423169ee21ea6b997e5513373dac29 --- /dev/null +++ b/lapack_api/src/lapack_zpotrf.c @@ -0,0 +1,102 @@ +/** + * + * @file lapack_zpotrf.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon lapack and lapacke api for potrf + * + * @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_zpotrf CHAMELEON_GLOBAL( chameleon_lapack_zpotrf, CHAMELEON_LAPACK_ZPOTRF ) +void CHAMELEON_lapack_zpotrf ( const char* uplo, const int* n, + CHAMELEON_Complex64_t* a, const int* lda, + int* info ) +{ + *info = CHAMELEON_lapacke_zpotrf( CblasColMajor, *uplo, *n, a, *lda ); +} + +/* C LAPACKE interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_lapacke_zpotrf - Computes the Cholesky factorization of a symmetric positive definite + * (or Hermitian positive definite in the complex case) matrix A. + * The factorization has the form + * + * \f[ A = \{_{L\times L^H, if uplo = ChamLower}^{U^H\times U, if uplo = ChamUpper} \f] + * + * where U is an upper triangular matrix and L is a lower triangular matrix. + * + ******************************************************************************* + * + * @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 + * Specifies whether the matrix A is upper triangular or lower triangular: + * = 'U' or 'u': Upper triangle of A is stored; + * = 'L' or 'l': Lower triangle of A is stored. + * + * @param[in] N + * The order of the matrix A. N >= 0. + * + * @param[in,out] A + * On entry, the symmetric positive definite (or Hermitian) matrix A. + * If uplo = 'U', the leading N-by-N upper triangular part of A + * contains the upper triangular part of the matrix A, and the strictly lower triangular + * part of A is not referenced. + * If UPLO = 'L', the leading N-by-N lower triangular part of A contains the lower + * triangular part of the matrix A, and the strictly upper triangular part of A is not + * referenced. + * On exit, if return value = 0, the factor U or L from the Cholesky factorization + * A = U^H*U or A = L*L^H. + * + * @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 + * @retval >0 if i, the leading minor of order i of A is not positive definite, so the + * factorization could not be completed, and the solution has not been computed. + * + ******************************************************************************* + * + * @sa CHAMELEON_lapacke_zpotrf + * @sa CHAMELEON_lapacke_cpotrf + * @sa CHAMELEON_lapacke_dpotrf + * @sa CHAMELEON_lapacke_spotrf + * + */ +int CHAMELEON_lapacke_zpotrf( 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_zpotrf", "illegal value of matrix_layout" ); + return -1; + } + + return CHAMELEON_zpotrf( (cham_uplo_t)chameleon_blastocblas_uplo(&uplo), + N, A, lda ); +} diff --git a/lapack_api/src/lapack_zpotri.c b/lapack_api/src/lapack_zpotri.c new file mode 100644 index 0000000000000000000000000000000000000000..d7595dfd73203fca75f426024650fca906102b57 --- /dev/null +++ b/lapack_api/src/lapack_zpotri.c @@ -0,0 +1,98 @@ +/** + * + * @file lapack_zpotri.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon lapack and lapacke api for potri + * + * @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_zpotri CHAMELEON_GLOBAL( chameleon_lapack_zpotri, CHAMELEON_LAPACK_ZPOTRI ) +void CHAMELEON_lapack_zpotri ( const char* uplo, const int* n, + CHAMELEON_Complex64_t* a, const int* lda, + int* info ) +{ + *info = CHAMELEON_lapacke_zpotri( CblasColMajor, *uplo, *n, a, *lda ); +} + +/* C LAPACKE interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_lapacke_zpotri - Computes the inverse of a symmetric (Hermitian) + * positive-definite matrix using the Cholesky factorization. Before calling + * this routine, call potrf to factorize. + * + ******************************************************************************* + * + * @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 + * Specifies whether the matrix A is upper triangular or lower triangular: + * = 'U' or 'u': Upper triangle of A is stored; + * = 'L' or 'l': Lower triangle of A is stored. + * + * @param[in] N + * The order of the matrix A. N >= 0. + * + * @param[in,out] A + * On entry, the symmetric positive definite (or Hermitian) matrix A. + * If uplo = 'U', the leading N-by-N upper triangular part of A + * contains the upper triangular part of the matrix A, and the strictly lower triangular + * part of A is not referenced. + * If UPLO = 'L', the leading N-by-N lower triangular part of A contains the lower + * triangular part of the matrix A, and the strictly upper triangular part of A is not + * referenced. + * On exit, if return value = 0, the factor U or L from the Cholesky factorization + * A = U^H*U or A = L*L^H. + * + * @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 + * @retval >0 if i, the leading minor of order i of A is not positive definite, so the + * factorization could not be completed, and the solution has not been computed. + * + ******************************************************************************* + * + * @sa CHAMELEON_lapacke_zpotri + * @sa CHAMELEON_lapacke_cpotri + * @sa CHAMELEON_lapacke_dpotri + * @sa CHAMELEON_lapacke_spotri + * + */ +int CHAMELEON_lapacke_zpotri( 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_zpotri", "illegal value of matrix_layout" ); + return -1; + } + + return CHAMELEON_zpotri( (cham_uplo_t)chameleon_blastocblas_uplo(&uplo), + N, A, lda ); +} diff --git a/lapack_api/src/lapack_zpotrs.c b/lapack_api/src/lapack_zpotrs.c new file mode 100644 index 0000000000000000000000000000000000000000..d8fe9a5ce2e6adf11c41ef66a472a8e4d7ff3a15 --- /dev/null +++ b/lapack_api/src/lapack_zpotrs.c @@ -0,0 +1,102 @@ +/** + * + * @file lapack_zpotrs.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon lapack and lapacke api for potrs + * + * @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_zpotrs CHAMELEON_GLOBAL( chameleon_lapack_zpotrs, CHAMELEON_LAPACK_ZPOTRS ) +void CHAMELEON_lapack_zpotrs ( const char* uplo, const int* n, const int* nrhs, + const CHAMELEON_Complex64_t* a, const int* lda, + CHAMELEON_Complex64_t* b, const int* ldb, + int* info ) +{ + *info = CHAMELEON_lapacke_zpotrs( CblasColMajor, + *uplo, *n, *nrhs, a, *lda, b, *ldb ); +} + +/* C LAPACKE interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_lapacke_zpotrs - Solves a system of linear equations A * X = B with a symmetric positive + * definite (or Hermitian positive definite in the complex case) matrix A using the Cholesky + * factorization A = U^H*U or A = L*L^H computed by CHAMELEON_zpotrf. + * + ******************************************************************************* + * + * @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 + * Specifies whether the matrix A is upper triangular or lower triangular: + * = 'U' or 'u': Upper triangle of A is stored; + * = 'L' or 'l': Lower triangle of A is stored. + * +* @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. NRHS >= 0. + * + * @param[in] A + * The triangular factor U or L from the Cholesky factorization A = U^H*U or A = L*L^H, + * computed by CHAMELEON_lapacke_zpotrf. + * + * @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. + * + * @param[in] LDB + * The leading dimension of the array B. LDB >= max(1,N). + * + ******************************************************************************* + * + * @retval =0 successful exit + * @retval <0 if -i, the i-th argument had an illegal value + * + ******************************************************************************* + * + * @sa CHAMELEON_lapacke_zpotrs + * @sa CHAMELEON_lapacke_cpotrs + * @sa CHAMELEON_lapacke_dpotrs + * @sa CHAMELEON_lapacke_spotrs + * + */ +int CHAMELEON_lapacke_zpotrs( int matrix_layout, char uplo, int N, int NRHS, + const CHAMELEON_Complex64_t *A, int lda, + CHAMELEON_Complex64_t *B, int ldb ) +{ + if ( matrix_layout != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_lapacke_zpotrs", "illegal value of matrix_layout" ); + return -1; + } + + return CHAMELEON_zpotrs( (cham_uplo_t)chameleon_blastocblas_uplo(&uplo), + N, NRHS, (CHAMELEON_Complex64_t *)A, lda, B, ldb ); +} diff --git a/lapack_api/src/lapack_zsymm.c b/lapack_api/src/lapack_zsymm.c index 37e31a1f3b97c5b06d6ac6ad839f3fe9f2a0fda2..5bcc133b92dfe8a112bce29335650b2866e12c23 100644 --- a/lapack_api/src/lapack_zsymm.c +++ b/lapack_api/src/lapack_zsymm.c @@ -22,7 +22,7 @@ /* Fortran BLAS interface */ -#define CHAMELEON_blas_zsymm CHAMELEON_GLOBAL( chameleon_blas_zsymm, CHAMELEON_BLAS_Zsymm ) +#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, diff --git a/lapack_api/src/lapack_zsyr2k.c b/lapack_api/src/lapack_zsyr2k.c index 15f55c7106884acaf9533a812f99d638a3e16d10..10908fad9bf3a5be177c3f40621209dd6932f306 100644 --- a/lapack_api/src/lapack_zsyr2k.c +++ b/lapack_api/src/lapack_zsyr2k.c @@ -22,7 +22,7 @@ /* Fortran BLAS interface */ -#define CHAMELEON_blas_zsyr2k CHAMELEON_GLOBAL( chameleon_blas_zsyr2k, CHAMELEON_BLAS_Zsyr2k ) +#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, diff --git a/lapack_api/src/lapack_zsyrk.c b/lapack_api/src/lapack_zsyrk.c index 9ac63d931bc94596e78de1ddd30f9de6a307d97d..812c5f78d8cab521ded7bfefff68d6a324c00156 100644 --- a/lapack_api/src/lapack_zsyrk.c +++ b/lapack_api/src/lapack_zsyrk.c @@ -22,7 +22,7 @@ /* Fortran BLAS interface */ -#define CHAMELEON_blas_zsyrk CHAMELEON_GLOBAL( chameleon_blas_zsyrk, CHAMELEON_BLAS_Zsyrk ) +#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, diff --git a/lapack_api/src/lapack_ztrmm.c b/lapack_api/src/lapack_ztrmm.c index 4e571213db1edf0bafdc80dee85ce7dea6fee097..f35081d9d18ddd501d036727af12e6777d2f9079 100644 --- a/lapack_api/src/lapack_ztrmm.c +++ b/lapack_api/src/lapack_ztrmm.c @@ -22,7 +22,7 @@ /* Fortran BLAS interface */ -#define CHAMELEON_blas_ztrmm CHAMELEON_GLOBAL( chameleon_blas_ztrmm, CHAMELEON_BLAS_Ztrmm ) +#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, diff --git a/lapack_api/src/lapack_ztrsm.c b/lapack_api/src/lapack_ztrsm.c index 08c337093af1cd0d5687939997dd29ffd32104dd..f00521ef65a8f4795fddf468ca14925f2ed686e0 100644 --- a/lapack_api/src/lapack_ztrsm.c +++ b/lapack_api/src/lapack_ztrsm.c @@ -22,7 +22,7 @@ /* Fortran BLAS interface */ -#define CHAMELEON_blas_ztrsm CHAMELEON_GLOBAL( chameleon_blas_ztrsm, CHAMELEON_BLAS_Ztrsm ) +#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, diff --git a/lapack_api/src/lapack_ztrtri.c b/lapack_api/src/lapack_ztrtri.c new file mode 100644 index 0000000000000000000000000000000000000000..acc665efeebfd2ca95ec72c26d7b848f2de5bb33 --- /dev/null +++ b/lapack_api/src/lapack_ztrtri.c @@ -0,0 +1,104 @@ +/** + * + * @file lapack_ztrtri.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon lapack and lapacke api for trtri + * + * @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_ztrtri CHAMELEON_GLOBAL( chameleon_lapack_ztrtri, CHAMELEON_LAPACK_ZTRTRI ) +void CHAMELEON_lapack_ztrtri ( const char* uplo, const char* diag, const int* n, + CHAMELEON_Complex64_t* a, const int* lda, + int* info ) +{ + *info = CHAMELEON_lapacke_ztrtri( CblasColMajor, + *uplo, *diag, *n, a, *lda ); +} + +/* C LAPACKE interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_lapacke_ztrtri - Computes the inverse of a complex upper or lower + * triangular matrix 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 triangle of A is stored; + * = 'L' or 'l': Lower triangle of A is stored. + * + * @param[in] diag + * = 'N', then A is not a unit triangular matrix; + * = 'U', A is unit triangular: diagonal elements of A are assumed to + * be 1 and not referenced in the array a. + * + * @param[in] N + * The order of the matrix A. N >= 0. + * + * @param[in,out] A + * On entry, the triangular matrix A. If UPLO = 'U', 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 = + * 'L', 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 = + * 'U', the diagonal elements of A are also not referenced and + * are assumed to be 1. On exit, the (triangular) inverse of + * the original matrix, in the same storage format. + * + * @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 + * @retval >0 if i, A(i,i) is exactly zero. The triangular + * matrix is singular and its inverse can not be computed. + * + ******************************************************************************* + * + * @sa CHAMELEON_lapacke_ztrtri + * @sa CHAMELEON_lapacke_ctrtri + * @sa CHAMELEON_lapacke_dtrtri + * @sa CHAMELEON_lapacke_strtri + * + */ +int CHAMELEON_lapacke_ztrtri( int matrix_layout, char uplo, char diag, int N, + CHAMELEON_Complex64_t *A, int lda ) +{ + if ( matrix_layout != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_lapacke_ztrtri", "illegal value of matrix_layout" ); + return -1; + } + + return CHAMELEON_ztrtri( (cham_uplo_t)chameleon_blastocblas_uplo(&uplo), + (cham_diag_t)chameleon_blastocblas_diag(&diag), + N, A, lda ); +} diff --git a/testing/testing_zposv.c b/testing/testing_zposv.c index 6cf198eca5ea08b49fd25f700d37d62b7c845c99..eb6b343f9e6596bb07f74d95840e584edada1349 100644 --- a/testing/testing_zposv.c +++ b/testing/testing_zposv.c @@ -22,9 +22,11 @@ #include "testings.h" #include "testing_zcheck.h" #include <chameleon/flops.h> +#if !defined(CHAMELEON_SIMULATION) +#include <coreblas.h> #if defined(CHAMELEON_TESTINGS_VENDOR) #include <coreblas/lapacke.h> -#include <coreblas.h> +#endif #endif static cham_fixdbl_t @@ -119,6 +121,7 @@ testing_zposv_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 ); @@ -149,7 +152,22 @@ testing_zposv_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_zposv( N, NRHS ) ); #else testing_start( &test_data ); - hres = CHAMELEON_zposv( uplo, N, NRHS, A, LDA, X, LDB ); + switch ( api ) { + case 1: + hres = CHAMELEON_zposv( uplo, N, NRHS, A, LDA, X, LDB ); + break; +#if !defined(CHAMELEON_SIMULATION) + case 2: + CHAMELEON_lapacke_zposv( CblasColMajor, chameleon_lapack_const(uplo), N, NRHS, A, LDA, X, LDB ); + 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_zposv( N, NRHS ) ); diff --git a/testing/testing_zpotrf.c b/testing/testing_zpotrf.c index 505a95f511095ddf165e51606a0d5bd76177bfad..ddffda46ee43ef82d34bc76c34c2df67178ab5dc 100644 --- a/testing/testing_zpotrf.c +++ b/testing/testing_zpotrf.c @@ -21,9 +21,11 @@ #include "testings.h" #include "testing_zcheck.h" #include <chameleon/flops.h> +#if !defined(CHAMELEON_SIMULATION) +#include <coreblas.h> #if defined(CHAMELEON_TESTINGS_VENDOR) #include <coreblas/lapacke.h> -#include <coreblas.h> +#endif #endif #if !defined(CHAMELEON_TESTINGS_VENDOR) @@ -92,6 +94,7 @@ testing_zpotrf_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 ); @@ -117,7 +120,22 @@ testing_zpotrf_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_zpotrf( N ) ); #else testing_start( &test_data ); - hres = CHAMELEON_zpotrf( uplo, N, A, LDA ); + switch ( api ) { + case 1: + hres = CHAMELEON_zpotrf( uplo, N, A, LDA ); + break; +#if !defined(CHAMELEON_SIMULATION) + case 2: + CHAMELEON_lapacke_zpotrf( 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_zpotrf( N ) ); diff --git a/testing/testing_zpotri.c b/testing/testing_zpotri.c index 012a97cd89e79a1ff47ea51d31dcd552d63b0109..172e960e0da6188b1383be5a17f22bc21cc40c41 100644 --- a/testing/testing_zpotri.c +++ b/testing/testing_zpotri.c @@ -23,9 +23,11 @@ #include "testings.h" #include "testing_zcheck.h" #include <chameleon/flops.h> +#if !defined(CHAMELEON_SIMULATION) +#include <coreblas.h> #if defined(CHAMELEON_TESTINGS_VENDOR) #include <coreblas/lapacke.h> -#include <coreblas.h> +#endif #endif #if !defined(CHAMELEON_TESTINGS_VENDOR) @@ -96,6 +98,7 @@ testing_zpotri_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 ); @@ -128,7 +131,22 @@ testing_zpotri_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_zpotri( N ) ); #else testing_start( &test_data ); - hres += CHAMELEON_zpotri( uplo, N, A, LDA ); + switch ( api ) { + case 1: + hres += CHAMELEON_zpotri( uplo, N, A, LDA ); + break; +#if !defined(CHAMELEON_SIMULATION) + case 2: + CHAMELEON_lapacke_zpotri( 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_zpotri( N ) ); diff --git a/testing/testing_zpotrs.c b/testing/testing_zpotrs.c index f1a49a483052561d9032c2e053cf30b267873aa4..90126dba94eda005938dc3f16fe791bfd4246d70 100644 --- a/testing/testing_zpotrs.c +++ b/testing/testing_zpotrs.c @@ -22,9 +22,11 @@ #include "testings.h" #include "testing_zcheck.h" #include <chameleon/flops.h> +#if !defined(CHAMELEON_SIMULATION) +#include <coreblas.h> #if defined(CHAMELEON_TESTINGS_VENDOR) #include <coreblas/lapacke.h> -#include <coreblas.h> +#endif #endif #if !defined(CHAMELEON_TESTINGS_VENDOR) @@ -108,6 +110,7 @@ testing_zpotrs_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 ); @@ -145,7 +148,22 @@ testing_zpotrs_std( run_arg_list_t *args, int check ) testing_stop( &test_data, flops_zpotrs( N, NRHS ) ); #else testing_start( &test_data ); - hres += CHAMELEON_zpotrs( uplo, N, NRHS, A, LDA, X, LDB ); + switch ( api ) { + case 1: + hres += CHAMELEON_zpotrs( uplo, N, NRHS, A, LDA, X, LDB ); + break; +#if !defined(CHAMELEON_SIMULATION) + case 2: + CHAMELEON_lapacke_zpotrs( CblasColMajor, chameleon_lapack_const(uplo), N, NRHS, A, LDA, X, LDB ); + 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_zpotrs( N, NRHS ) ); diff --git a/testing/testing_ztrtri.c b/testing/testing_ztrtri.c index 521fe54ed3738cd189216ed6ffe929a4620f6e21..490d245c7aa230317320fa7e257ed62025dbc884 100644 --- a/testing/testing_ztrtri.c +++ b/testing/testing_ztrtri.c @@ -21,6 +21,9 @@ #include "testings.h" #include "testing_zcheck.h" #include <chameleon/flops.h> +#if !defined(CHAMELEON_SIMULATION) +#include <coreblas.h> +#endif int testing_ztrtri_desc( run_arg_list_t *args, int check ) @@ -87,6 +90,7 @@ testing_ztrtri_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 ); cham_diag_t diag = run_arg_get_diag( args, "diag", ChamNonUnit ); @@ -107,7 +111,22 @@ testing_ztrtri_std( run_arg_list_t *args, int check ) /* Calculates the inversed matrices */ testing_start( &test_data ); - hres = CHAMELEON_ztrtri( uplo, diag, N, A, LDA ); + switch ( api ) { + case 1: + hres = CHAMELEON_ztrtri( uplo, diag, N, A, LDA ); + break; +#if !defined(CHAMELEON_SIMULATION) + case 2: + CHAMELEON_lapacke_ztrtri( CblasColMajor, chameleon_lapack_const(uplo), chameleon_lapack_const(diag), 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_ztrtri( N ) );