Mentions légales du service

Skip to content
Snippets Groups Projects
Commit c0ce8e9f authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Merge branch 'blaslapack_api' into 'master'

Validate first algorithm gemm cblas and blas interfaces.

See merge request solverstack/chameleon!312
parents f1cc59ee 1e33a0fd
No related branches found
No related tags found
No related merge requests found
Showing
with 324 additions and 32 deletions
......@@ -81,6 +81,7 @@ subs = {
('', 'ORGLQ', 'ORGLQ', 'UNGLQ', 'UNGLQ' ),
('', 'SYEV', 'SYEV', 'HEEV', 'HEEV' ),
('', 'SYG', 'SYG', 'HEG', 'HEG' ),
('', 'const float ', 'const double ', 'const void \*', 'const void \*' ),
]
+ _extra_blas
+ _extra_BLAS
......
......@@ -264,10 +264,22 @@ precisions_rules_py(CONTROL_SRCS_GENERATED "${ZSRC}"
PRECISIONS "${CHAMELEON_PRECISION}"
TARGETDIR "control" )
set(LAPACK_API_SRCS_GENERATED "")
set(ZSRC
lapack_api/lapack_zgemm.c
)
precisions_rules_py(LAPACK_API_SRCS_GENERATED "${ZSRC}"
PRECISIONS "${CHAMELEON_PRECISION}")
set(LAPACK_API_SRCS
${LAPACK_API_SRCS_GENERATED}
lapack_api/lapack_api_common.c
)
set(CHAMELEON_SRCS
${CHAMELEON_CONTROL}
${CHAMELEON_SRCS_GENERATED}
${CONTROL_SRCS_GENERATED}
${LAPACK_API_SRCS}
)
# Generate the chameleon fortran sources for all possible precisions
......@@ -309,7 +321,7 @@ add_dependencies(chameleon
)
target_include_directories(chameleon PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lapack_api>
$<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/control>
......@@ -329,7 +341,9 @@ elseif(CHAMELEON_SCHED_QUARK)
elseif(CHAMELEON_SCHED_OPENMP)
target_link_libraries(chameleon PUBLIC chameleon_openmp)
endif()
if (NOT CHAMELEON_SIMULATION)
if (CHAMELEON_SIMULATION)
target_include_directories(chameleon PUBLIC $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/coreblas/include>)
else()
target_link_libraries(chameleon PUBLIC coreblas)
endif()
target_link_libraries(chameleon PUBLIC hqr)
......
/**
*
* @file lapack_api_common.c
*
* @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
***
*
* @brief Chameleon blas/lapack and cblas/lapack api common functions
*
* @version 1.2.0
* @author Mathieu Faverge
* @author Florent Pruvost
* @date 2022-04-22
*
*/
#include "lapack_api_common.h"
/**
* @brief Convert the input char BLAS trans parameter to a compatible parameter
* for the Cblas API.
* @param[in] trans The input char BLAS trans parameter
* @return The CBLAS equivalent parameter (CblasNoTrans, CblasTrans or
* CblasConjTrans).
*/
int chameleon_blastocblas_trans(const char* trans)
{
if ( (*trans == 'N') || (*trans == 'n') ) {
return CblasNoTrans;
} else if ( (*trans == 'T') || (*trans == 't') ) {
return CblasTrans;
} else if ( (*trans == 'C') || (*trans == 'c') ) {
return CblasConjTrans;
} else {
chameleon_error("chameleon_blastocblas_trans", "illegal value of BLAS transpose parameter");
return CHAMELEON_ERR_ILLEGAL_VALUE;
}
}
/**
*
* @file lapack_api_common.h
*
* @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux.
* All rights reserved.
*
***
*
* @brief Chameleon blas/lapack and cblas/lapack api common internal functions
*
* @version 1.2.0
* @author Mathieu Faverge
* @author Florent Pruvost
* @date 2022-04-22
*
*/
#ifndef _lapack_api_common_h_
#define _lapack_api_common_h_
#include "chameleon.h"
#include "chameleon/mangling.h"
#include "control/auxiliary.h"
/**
*
* @defgroup CHAMELEON_LAPACK_API
* @brief Linear algebra routines exposed to users. LAPACK matrix data storage
*
*/
int chameleon_blastocblas_trans(const char* value);
#endif /* _lapack_api_common_h_ */
/**
*
* @file lapack_zgemm.c
*
* @copyright 2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
***
*
* @brief Chameleon blas and cblas api for gemm
*
* @version 1.2.0
* @author Mathieu Faverge
* @author Florent Pruvost
* @date 2022-04-22
* @precisions normal z -> s d c
*
*/
#include "lapack_api_common.h"
/* Fortran BLAS interface */
#define CHAMELEON_blas_zgemm CHAMELEON_GLOBAL( chameleon_blas_zgemm, CHAMELEON_BLAS_ZGEMM )
void CHAMELEON_blas_zgemm ( const char* transa, const char* transb,
const int* m, 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_zgemm( CblasColMajor,
chameleon_blastocblas_trans(transa),
chameleon_blastocblas_trans(transb),
*m, *n, *k,
CBLAS_SADDR(*alpha), a, *lda,
b, *ldb,
CBLAS_SADDR(*beta), c, *ldc );
}
/* C CBLAS interface */
/**
********************************************************************************
*
* @ingroup CHAMELEON_LAPACK_API
*
* CHAMELEON_cblas_zgemm - Performs one of the matrix-matrix operations
*
* \f[ C = \alpha [op( A )\times op( B )] + \beta C \f],
*
* where op( X ) is one of
*
* op( X ) = X or op( X ) = X' or op( X ) = conjg( X' )
*
* alpha and beta are scalars, and A, B and C are matrices, with op( A )
* an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
*
*******************************************************************************
*
* @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.
*
* @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.
*
* @param[in] M
* M specifies the number of rows of the matrix op( A ) and of the matrix C. M >= 0.
*
* @param[in] N
* N specifies the number of columns of the matrix op( B ) and of the matrix C. N >= 0.
*
* @param[in] K
* K specifies the number of columns of the matrix op( A ) and the number of rows of
* the matrix op( B ). K >= 0.
*
* @param[in] alpha
* alpha specifies the scalar alpha
*
* @param[in] A
* A is a LDA-by-ka matrix, where ka is K when transA = ChamNoTrans,
* 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,
* and is K otherwise.
*
* @param[in] LDB
* The leading dimension of the array B. LDB >= max(1,N).
*
* @param[in] beta
* 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 matrix ( alpha*op( A )*op( B ) + beta*C )
*
* @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
* @sa CHAMELEON_cblas_dgemm
* @sa CHAMELEON_cblas_sgemm
*
*/
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){
chameleon_error("CHAMELEON_cblas_zgemm", "illegal value of order");
}
#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_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 );
}
......@@ -20,7 +20,6 @@
* @precisions normal z -> c d s
*
*/
#include "coreblas/cblas.h"
#include <math.h>
#include "coreblas.h"
......
......@@ -24,7 +24,6 @@
* @precisions normal z -> c d s
*
*/
#include "coreblas/cblas.h"
#include "coreblas/lapacke.h"
#include "coreblas.h"
......
......@@ -20,7 +20,6 @@
*
*/
#include "coreblas.h"
#include "coreblas/cblas.h"
#include <math.h>
/**
......
......@@ -23,7 +23,6 @@
* @precisions normal z -> c d s
*
*/
#include "coreblas/cblas.h"
#include "coreblas/lapacke.h"
#include "coreblas.h"
......
......@@ -18,7 +18,6 @@
* @precisions normal z -> c d s
*
*/
#include "coreblas/cblas.h"
#include "coreblas/lapacke.h"
#include "coreblas.h"
......
......@@ -23,7 +23,6 @@
* @precisions normal z -> c d s
*
*/
#include "coreblas/cblas.h"
#include "coreblas/lapacke.h"
#include "coreblas.h"
......
......@@ -24,7 +24,6 @@
* @precisions normal z -> c d s
*
*/
#include "coreblas/cblas.h"
#include "coreblas.h"
/**
......
......@@ -20,7 +20,6 @@
* @precisions normal z -> c d s
*
*/
#include "coreblas/cblas.h"
#include <math.h>
#include "coreblas.h"
......
......@@ -25,7 +25,6 @@
*
*/
#include "coreblas.h"
#include "coreblas/cblas.h"
#include <math.h>
/**
......
......@@ -29,14 +29,7 @@
#include <string.h>
#include <assert.h>
/**
* CBLAS requires for scalar arguments to be passed
* by address rather than by value
*/
#ifndef CBLAS_SADDR
#define CBLAS_SADDR( _val_ ) &(_val_)
#endif
#include "coreblas/cblas.h"
#include "coreblas/cblas_wrapper.h"
/**
* CHAMELEON types and constants
......@@ -68,14 +61,6 @@ END_C_DECLS
assert(0); \
} while(0)
/**
* CBlas enum
*/
#define CBLAS_TRANSPOSE enum CBLAS_TRANSPOSE
#define CBLAS_UPLO enum CBLAS_UPLO
#define CBLAS_DIAG enum CBLAS_DIAG
#define CBLAS_SIDE enum CBLAS_SIDE
/**
* LAPACK Constants
*/
......
/**
*
* @file cblas_wrapper.h
*
* @copyright 2009-2014 The University of Tennessee and The University of
* Tennessee Research Foundation. All rights reserved.
* @copyright 2012-2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
***
*
* @brief Chameleon cblas header wrapper
*
* @version 1.2.0
* @author Cedric Castagnede
* @author Florent Pruvost
* @author Mathieu Faverge
* @date 2022-02-22
*
*/
#ifndef _cblas_wrapper_h_
#define _cblas_wrapper_h_
/**
* CBLAS requires for scalar arguments to be passed
* by address rather than by value
*/
#ifndef CBLAS_SADDR
#define CBLAS_SADDR( _val_ ) &(_val_)
#endif
#include "coreblas/cblas.h"
/**
* CBlas enum
*/
#define CBLAS_ORDER enum CBLAS_ORDER
#define CBLAS_TRANSPOSE enum CBLAS_TRANSPOSE
#define CBLAS_UPLO enum CBLAS_UPLO
#define CBLAS_DIAG enum CBLAS_DIAG
#define CBLAS_SIDE enum CBLAS_SIDE
#endif /* _cblas_wrapper_h_ */
......@@ -30,10 +30,11 @@
# ----------------------------------------------------------
set(CHAMELEON_HDRS_GENERATED "")
set(ZHDR
chameleon/chameleon_z.h
chameleon/chameleon_zc.h
chameleon/tasks_z.h
chameleon/tasks_zc.h
chameleon/chameleon_z.h
chameleon/chameleon_zc.h
chameleon/chameleon_zlapack.h
chameleon/tasks_z.h
chameleon/tasks_zc.h
)
precisions_rules_py(CHAMELEON_HDRS_GENERATED "${ZHDR}"
......
......@@ -68,6 +68,11 @@ typedef struct gepdf_info_s {
#include "chameleon/chameleon_zc.h"
#include "chameleon/chameleon_ds.h"
#include "chameleon/chameleon_zlapack.h"
#include "chameleon/chameleon_clapack.h"
#include "chameleon/chameleon_dlapack.h"
#include "chameleon/chameleon_slapack.h"
BEGIN_C_DECLS
/* ****************************************************************************
......
/**
*
* @file chameleon_zlapack.h
*
* @copyright 2022-2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
***
*
* @brief Chameleon blas/lapack and cblas/lapack api functions
*
* @version 1.2.0
* @author Mathieu Faverge
* @author Florent Pruvost
* @date 2022-04-26
* @precisions normal z -> c d s
*
*/
#ifndef _chameleon_zlapack_h_
#define _chameleon_zlapack_h_
#include "coreblas/cblas_wrapper.h"
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,
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 );
END_C_DECLS
#endif /* _chameleon_zlapack_h_ */
......@@ -48,7 +48,7 @@ parameter_t parameters[] = {
{ "async", "Switch to the Async interface", 's', PARAM_OPTION, 0, 0, TestValInt, {0}, NULL, pread_int, sprint_int },
{ "splitsub", "Split the task submission and execution stages", 'S', PARAM_OPTION, 0, 0, TestValInt, {0}, NULL, pread_int, sprint_int },
{ "generic", "Switch to the non optimized generic algorithms", -35, PARAM_OPTION, 0, 0, TestValInt, {0}, NULL, pread_int, sprint_int },
{ "api", "Select the API to test (0: Descriptors, 1: Standard)", -36, PARAM_OPTION, 1, 3, TestValInt, {0}, NULL, pread_int, sprint_int },
{ "api", "Select the API to test (0: Descriptors, 1: Standard, 2: Lapack)", -36, PARAM_OPTION, 1, 3, TestValInt, {0}, NULL, pread_int, sprint_int },
#endif
{ NULL, "Machine parameters", 0, PARAM_OPTION, 0, 0, 0, {0}, NULL, NULL, NULL },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment