diff --git a/lapack_api/CMakeLists.txt b/lapack_api/CMakeLists.txt index 5fcdd04507c678d1f5f9944ad7092c3a7e5d5705..4bf4b0836d8b506da49363341896858083c4ec8f 100644 --- a/lapack_api/CMakeLists.txt +++ b/lapack_api/CMakeLists.txt @@ -60,6 +60,8 @@ set(ZSRC src/lapack_zhemm.c src/lapack_zher2k.c src/lapack_zherk.c + src/lapack_zlacpy.c + src/lapack_zlaset.c src/lapack_zlauum.c src/lapack_zsymm.c src/lapack_zsyr2k.c diff --git a/lapack_api/include/chameleon/chameleon_zlapack.h b/lapack_api/include/chameleon/chameleon_zlapack.h index 77320305eca007db81104c32853f3b8c87d01824..02c4fec407f8202a129b675e283f18cb83de83df 100644 --- a/lapack_api/include/chameleon/chameleon_zlapack.h +++ b/lapack_api/include/chameleon/chameleon_zlapack.h @@ -79,6 +79,15 @@ 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 ); + +int CHAMELEON_lapacke_zlaset( int matrix_layout, char uplo, int M, int N, + const CHAMELEON_Complex64_t alpha, const CHAMELEON_Complex64_t beta, + CHAMELEON_Complex64_t *A, int lda ); + int CHAMELEON_lapacke_zlauum( int matrix_layout, char uplo, int N, CHAMELEON_Complex64_t *A, int lda ); diff --git a/lapack_api/src/lapack_zlacpy.c b/lapack_api/src/lapack_zlacpy.c new file mode 100644 index 0000000000000000000000000000000000000000..f8feb6d5d4a49efb109ee2cfc7a2fb135df8075e --- /dev/null +++ b/lapack_api/src/lapack_zlacpy.c @@ -0,0 +1,104 @@ +/** + * + * @file lapack_zlacpy.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon lapack and lapacke api for lacpy + * + * @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_zlacpy CHAMELEON_GLOBAL( chameleon_lapack_zlacpy, CHAMELEON_BLAS_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 ) +{ + CHAMELEON_lapacke_zlacpy( CblasColMajor, + *uplo, *m, *n, + a, *lda, + b, *ldb ); +} + +/* C LAPACKE interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_lapacke_zlacpy - copies all or part of a two-dimensional matrix A to another + * matrix 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 the part of the matrix A to be copied to B. + * = 'U' or 'u': Upper triangular + * = 'L' or 'l': Lower triangular + * Otherwise, all of the matrix A is copied. + * + * @param[in] M + * The number of rows of the matrix A. M >= 0. + * + * @param[in] N + * The number of columns of the matrix A. N >= 0. + * + * @param[in] A + * The M-by-N matrix A. If uplo = 'U', only the upper triangle or + * trapezoid is accessed; if uplo = 'L', only the lower triangle or + * trapezoid is accessed. + * + * @param[in] LDA + * The leading dimension of the array A. LDA >= max(1,M). + * + * @param[out] B + * The M-by-N matrix B. + * On exit, B = A in the locations specified by uplo. + * + * @param[in] LDB + * The leading dimension of the array B. LDB >= max(1,M). + * + ******************************************************************************* + * + * @retval =0 successful exit + * @retval <0 if -i, the i-th argument had an illegal value + * + ******************************************************************************* + * + * @sa CHAMELEON_lapacke_zlacpy + * @sa CHAMELEON_lapacke_clacpy + * @sa CHAMELEON_lapacke_dlacpy + * @sa CHAMELEON_lapacke_slacpy + * + */ +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 ) +{ + if ( matrix_layout != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_lapacke_zlacpy", "illegal value of matrix_layout" ); + return -1; + } + + return CHAMELEON_zlacpy( (cham_uplo_t)chameleon_blastocblas_uplo(&uplo), + M, N, (CHAMELEON_Complex64_t *)A, lda, B, ldb ); +} diff --git a/lapack_api/src/lapack_zlaset.c b/lapack_api/src/lapack_zlaset.c new file mode 100644 index 0000000000000000000000000000000000000000..1813b8c26ca4747965512eafd7f7003d5e213a91 --- /dev/null +++ b/lapack_api/src/lapack_zlaset.c @@ -0,0 +1,103 @@ +/** + * + * @file lapack_zlaset.c + * + * @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + *** + * + * @brief Chameleon lapack and lapacke api for laset + * + * @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_zlaset CHAMELEON_GLOBAL( chameleon_lapack_zlaset, CHAMELEON_BLAS_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 ) +{ + CHAMELEON_lapacke_zlaset( CblasColMajor, + *uplo, *m, *n, + *alpha, *beta, + a, *lda ); +} + +/* C LAPACKE interface */ + +/** + ******************************************************************************** + * + * @ingroup CHAMELEON_LAPACK_API + * + * CHAMELEON_lapacke_zlaset - The routine initializes an m-by-n matrix A to + * beta on the diagonal and alpha on the off-diagonals. + * + ******************************************************************************* + * + * @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 the part of the matrix A . + * = 'U' or 'u': Upper triangular + * = 'L' or 'l': Lower triangular + * Otherwise, all of the matrix A is set. + * + * @param[in] M + * The number of rows of the matrix A. M >= 0. + * + * @param[in] N + * The number of columns of the matrix A. N >= 0. + * + * @param[in] alpha + * All the off diagonal array elements are set to alpha. + * + * @param[in] beta + * All the diagonal array elements are set to beta. + * + * @param[in,out] A + * On entry, the m by n matrix A. + * On exit, A(i,j) = ALPHA, 1 <= i <= m, 1 <= j <= n, i.ne.j; + * A(i,i) = BETA, 1 <= i <= min(m,n) + * + * @param[in] LDA + * The leading dimension of the array A. LDA >= max(1,M). + * + ******************************************************************************* + * + * @retval =0 successful exit + * @retval <0 if -i, the i-th argument had an illegal value + * + ******************************************************************************* + * + * @sa CHAMELEON_lapacke_zlaset + * @sa CHAMELEON_lapacke_claset + * @sa CHAMELEON_lapacke_dlaset + * @sa CHAMELEON_lapacke_slaset + * + */ +int CHAMELEON_lapacke_zlaset( int matrix_layout, char uplo, int M, int N, + const CHAMELEON_Complex64_t alpha, const CHAMELEON_Complex64_t beta, + CHAMELEON_Complex64_t *A, int lda ) +{ + if ( matrix_layout != CblasColMajor ){ + fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_lapacke_zlaset", "illegal value of matrix_layout" ); + return -1; + } + + return CHAMELEON_zlaset( (cham_uplo_t)chameleon_blastocblas_uplo(&uplo), + M, N, alpha, beta, A, lda ); +} diff --git a/lapack_api/src/lapack_zlauum.c b/lapack_api/src/lapack_zlauum.c index 4216edcd4c23317392c69f6f528b28ea437fc634..c35b346600afd6ce62f43ea1729e7fc9f72e0e9f 100644 --- a/lapack_api/src/lapack_zlauum.c +++ b/lapack_api/src/lapack_zlauum.c @@ -31,7 +31,7 @@ void CHAMELEON_lapack_zlauum ( const char* uplo, const int* n, *uplo, *n, a, *lda ); } -/* C CBLAS interface */ +/* C LAPACKE interface */ /** ******************************************************************************** @@ -89,7 +89,7 @@ int CHAMELEON_lapacke_zlauum( int matrix_layout, char uplo, int N, { if ( matrix_layout != CblasColMajor ){ fprintf( stderr, "CHAMELEON ERROR: %s(): %s\n", "CHAMELEON_lapacke_zlauum", "illegal value of matrix_layout" ); - return; + return -1; } return CHAMELEON_zlauum( (cham_uplo_t)chameleon_blastocblas_uplo(&uplo), N, diff --git a/testing/testing_zlacpy.c b/testing/testing_zlacpy.c index 963a62519796c5400aa694169282438bae9e6384..52174f9f3e4e1e3761363db00ab2e61687137f8e 100644 --- a/testing/testing_zlacpy.c +++ b/testing/testing_zlacpy.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_zlacpy( cham_uplo_t uplo, int M, int N ) @@ -120,6 +123,7 @@ testing_zlacpy_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 ); @@ -144,7 +148,22 @@ testing_zlacpy_std( run_arg_list_t *args, int check ) /* Makes a copy of descA to descB */ testing_start( &test_data ); - hres = CHAMELEON_zlacpy( uplo, M, N, A, LDA, B, LDB ); + switch ( api ) { + case 1: + hres = CHAMELEON_zlacpy( uplo, M, N, A, LDA, B, LDB ); + break; +#if !defined(CHAMELEON_SIMULATION) + case 2: + CHAMELEON_lapacke_zlacpy( CblasColMajor, chameleon_lapack_const(uplo), M, N, A, LDA, B, 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_zlacpy( uplo, M, N ) );