Introducing upgrated BLIS GTestSuite.

Key features:
- able to test both static and dynamic libraries
- able to test BLAS, CBLAS and BLIS-typed interface
- can use any CBLAS library for reference results
- can build and/or run tests depending on the BLAS level or a specific API

AMD-Internal: [CPUPL-2732]
Change-Id: Ibe0d7938e06081526bbc54d3182ac7d17affdaf6
This commit is contained in:
Eleni Vlachopoulou
2023-02-22 01:08:32 +05:30
parent f7b9bc734e
commit 155a64e734
439 changed files with 23652 additions and 51066 deletions

View File

@@ -0,0 +1,250 @@
#include "common/testing_basics.h"
#include "common/type_info.h"
namespace testinghelpers {
/**
* Function that tests the compatibility of integer types.
*/
void int_compatibility(){
#if TEST_BLIS_TYPED
static_assert(sizeof(gtint_t)==sizeof(dim_t),"Mismatch of integer types.");
#else
static_assert(sizeof(gtint_t)==sizeof(f77_int),"Mismatch of integer types.");
#endif
}
void char_to_blis_trans( char trans, trans_t* blis_trans )
{
if ( trans == 'n' || trans == 'N' ) *blis_trans = BLIS_NO_TRANSPOSE;
else if ( trans == 't' || trans == 'T' ) *blis_trans = BLIS_TRANSPOSE;
else if ( trans == 'c' || trans == 'C' ) *blis_trans = BLIS_CONJ_TRANSPOSE;
else if ( trans == 'h' || trans == 'H' )
{
throw std::invalid_argument("Error in file src/common/testing_basics.cpp in function char_to_blis_trans(): trans == 'h'. "
"To test BLIS-typed interface for this parameter be aware that this is not "
"a BLAS/CBLAS option. In BLAS/CBLAS interface 'c' is conjugate transpose (Hermitian), "
"while in BLIS_typed this would be 'h'. "
"To implement this option, please modify ref_*.cpp to use the correct matrix.");
}
else
{
throw std::invalid_argument("Error in file src/common/testing_basics.cpp in function char_to_blis_trans():"
"Invalid input.");
}
}
void char_to_blis_conj( char conj, conj_t* blis_conj )
{
if ( conj == 'n' || conj == 'N' ) *blis_conj = BLIS_NO_CONJUGATE;
else if ( conj == 'c' || conj == 'C' ) *blis_conj = BLIS_CONJUGATE;
else
{
throw std::invalid_argument("Error in file src/common/testing_basics.cpp in function char_to_blis_conj():"
"Invalid input.");
}
}
void char_to_blis_side( char side, side_t* blis_side )
{
if ( side == 'l' || side == 'L' ) *blis_side = BLIS_LEFT;
else if ( side == 'r' || side == 'R' ) *blis_side = BLIS_RIGHT;
else
{
throw std::invalid_argument("Error in file src/common/testing_basics.cpp in function char_to_blis_side():"
"Invalid input.");
}
}
void char_to_blis_uplo( char uplo, uplo_t* blis_uplo )
{
if ( uplo == 'l' || uplo == 'L' ) *blis_uplo = BLIS_LOWER;
else if ( uplo == 'u' || uplo == 'U' ) *blis_uplo = BLIS_UPPER;
else
{
throw std::invalid_argument("Error in file src/common/testing_basics.cpp in function char_to_blis_uplo():"
"Invalid input.");
}
}
void char_to_blis_diag( char diag, diag_t* blis_diag )
{
if ( diag == 'n' || diag == 'N' ) *blis_diag = BLIS_NONUNIT_DIAG;
else if ( diag == 'u' || diag == 'U' ) *blis_diag = BLIS_UNIT_DIAG;
else
{
throw std::invalid_argument("Error in file src/common/testing_basics.cpp in function char_to_blis_diag():"
"Invalid input.");
}
}
/**
* @brief Returns the size of a buffer which has strides.
*
* @param n length of vector
* @param incx increment
* @return gtint_t dimension of the buffer that stored a vector with length n and increment incx
*/
gtint_t buff_dim(gtint_t n, gtint_t incx) {
return (n*std::abs(incx) - (std::abs(incx)-1));
}
gtint_t matsize(char storage, char trans, gtint_t m, gtint_t n, gtint_t ldm )
{
gtint_t km;
if( (storage == 'c') || (storage == 'C') ) {
/*Column_Major*/
km = chktrans( trans ) ? m : n ;
}
else {
/*Row_Major*/
km = chktrans( trans ) ? n : m ;
}
return (km*ldm);
}
/**
* Returns the leading dimension of a matrix depending on the storage type,
* whether it is transpose or not, and the size of rows and columns.
*
* @param storage specifies the storage format of matrix in memory.
* @param trns specifies the form of given matrix.
* @param m specifies the number of rows of given matrix.
* @param n specifies the number of columns of given matrix.
* @param inc specifies the increment of the leading dimension.
*/
gtint_t get_leading_dimension(char storage, char trans, gtint_t m, gtint_t n, gtint_t inc)
{
gtint_t lda;
if( (storage == 'c') || (storage == 'C') ) //column-major order
{
if ((trans == 'n')||(trans == 'N'))
lda = std::max(gtint_t(1),m) + inc;
else
lda = std::max(gtint_t(1),n) + inc;
}
else //row-major order
{
if ((trans == 'n')||(trans == 'N'))
lda = std::max(gtint_t(1),n) + inc;
else
lda = std::max(gtint_t(1),m) + inc;
}
return lda;
}
bool chktrans( char trns )
{
return (!(trns=='n'));
}
bool chknotrans( char trns )
{
trans_t trans;
char_to_blis_trans( trns, &trans );
return ( bool )
( ( trans & BLIS_TRANS_BIT ) == BLIS_BITVAL_NO_TRANS );
}
bool chkconjtrans( char trns )
{
trans_t trans;
char_to_blis_trans( trns, &trans );
return ( bool )
( ( ( trans & BLIS_CONJ_BIT ) & ( trans & BLIS_TRANS_BIT ) ) == BLIS_BITVAL_CONJ_TRANS );
}
bool chktransconj( char trns )
{
trans_t trans;
char_to_blis_trans( trns, &trans );
return ( bool )
( ( trans & BLIS_CONJ_BIT ) == BLIS_BITVAL_CONJ );
}
bool chkconj( char conjx )
{
conj_t conj;
char_to_blis_conj( conjx, &conj );
return ( bool )
( ( conj & BLIS_CONJ_BIT ) == BLIS_BITVAL_CONJ );
}
bool chkupper( char uplo )
{
uplo_t uploa;
char_to_blis_uplo( uplo, &uploa );
return ( bool ) ( uploa == BLIS_UPPER );
}
bool chklower( char uplo )
{
uplo_t uploa;
char_to_blis_uplo( uplo, &uploa );
return ( bool ) ( uploa == BLIS_LOWER );
}
bool chkunitdiag( char diag )
{
diag_t diaga;
char_to_blis_diag( diag, &diaga );
return ( bool ) ( diaga == BLIS_BITVAL_UNIT_DIAG );
}
bool chknonunitdiag( char diag )
{
diag_t diaga;
char_to_blis_diag( diag, &diaga );
return ( bool ) ( diaga == BLIS_BITVAL_NONUNIT_DIAG );
}
bool chksideleft( char mside )
{
side_t side;
char_to_blis_side( mside, &side );
return ( bool ) ( side == BLIS_LEFT );
}
bool chksideright( char mside )
{
side_t side;
char_to_blis_side( mside, &side );
return ( bool ) ( side == BLIS_RIGHT );
}
void swap_dims_with_trans( char trans,
gtint_t m, gtint_t n, gtint_t rs, gtint_t cs,
gtint_t* mt, gtint_t* nt, gtint_t* rst, gtint_t* cst )
{
if ( chktrans( trans ) ) { *mt = n; *nt = m; *rst = cs; *cst = rs; }
else { *mt = m; *nt = n; *rst = rs; *cst = cs; }
}
void swap_strides_with_trans( char trans,
gtint_t rs, gtint_t cs,
gtint_t* rst, gtint_t* cst )
{
if ( chktrans( trans ) ) {*rst = cs; *cst = rs; }
else {*rst = rs; *cst = cs; }
}
void swap_dims( gtint_t* x, gtint_t* y )
{
gtint_t temp = *x;
*x = *y;
*y = temp;
}
void set_dims( char trans, gtint_t m, gtint_t n, gtint_t* mt, gtint_t* nt )
{
if ( chktrans( trans ) ) { *mt = n; *nt = m; }
else { *mt = m; *nt = n; }
}
void set_dim_with_side( char side, gtint_t m, gtint_t n, gtint_t* dim )
{
if ( chksideleft( side ) ) *dim = m;
else *dim = n;
}
} //end of namespace testinghelpers