diff --git a/testing/chameleon_ztesting.c b/testing/chameleon_ztesting.c index 26dd3994e8f0cd619ec41a779cab095e20b412d4..5b04ef34de6a16a91cb174d55d8bbbc5051ae6b6 100644 --- a/testing/chameleon_ztesting.c +++ b/testing/chameleon_ztesting.c @@ -158,6 +158,11 @@ int main (int argc, char **argv) { testing_options_init( &options ); +#if !defined(CHAMELEON_SIMULATION) + /* Let's initialize the accuracy for the checks */ + testing_setaccuracy( LAPACKE_dlamch_work('e') ); +#endif + rc = CHAMELEON_Init( options.threads, options.gpus ); if ( rc != CHAMELEON_SUCCESS ) { fprintf( stderr, "CHAMELEON_Init failed and returned %d.\n", rc ); diff --git a/testing/testing_zcheck.h b/testing/testing_zcheck.h index ab8d86977e5805fca7e649843a26040487a20fbe..7d5518c7a1ee4f353b0480d89537ef4535020836 100644 --- a/testing/testing_zcheck.h +++ b/testing/testing_zcheck.h @@ -100,9 +100,9 @@ static inline int check_zqc_std ( run_arg_list_t *args, cham_side_t side, CHAMELEON_Complex64_t *C, CHAMELEON_Complex64_t *CC, int LDC, CHAMELEON_Complex64_t *Q, int LDQ ) { return 0; } /* SVD check */ -static inline int check_zgesvd_std ( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, int M, int N, CHAMELEON_Complex64_t *Ainit, CHAMELEON_Complex64_t *A, int LDA, +static inline int check_zgesvd_std ( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, int M, int N, CHAMELEON_Complex64_t *Ainit, CHAMELEON_Complex64_t *A, int LDA, double *Sinit, double *S, CHAMELEON_Complex64_t *U, int LDU, CHAMELEON_Complex64_t *Vt, int LDVt ) { return 0; } -static inline int check_zgesvd ( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, CHAM_desc_t *descAinit, CHAM_desc_t *descA, +static inline int check_zgesvd ( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, CHAM_desc_t *descAinit, CHAM_desc_t *descA, double *Sinit, double *S, CHAMELEON_Complex64_t *U, int LDU, CHAMELEON_Complex64_t *Vt, int LDVt ) { return 0; } /* Polar decomposition check */ @@ -179,9 +179,9 @@ int check_zqc_std ( run_arg_list_t *args, cham_side_t side, cham_trans_t t CHAMELEON_Complex64_t *C, CHAMELEON_Complex64_t *CC, int LDC, CHAMELEON_Complex64_t *Q, int LDQ ); /* SVD check */ -int check_zgesvd_std ( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, int M, int N, CHAMELEON_Complex64_t *Ainit, CHAMELEON_Complex64_t *A, int LDA, +int check_zgesvd_std ( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, int M, int N, CHAMELEON_Complex64_t *Ainit, CHAMELEON_Complex64_t *A, int LDA, double *Sinit, double *S, CHAMELEON_Complex64_t *U, int LDU, CHAMELEON_Complex64_t *Vt, int LDVt ); -int check_zgesvd ( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, CHAM_desc_t *descAinit, CHAM_desc_t *descA, +int check_zgesvd ( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, CHAM_desc_t *descAinit, CHAM_desc_t *descA, double *Sinit, double *S, CHAMELEON_Complex64_t *U, int LDU, CHAMELEON_Complex64_t *Vt, int LDVt ); /* Polar decomposition check */ int check_zgepdf_qr ( run_arg_list_t *args, CHAM_desc_t *descA1, CHAM_desc_t *descA2, diff --git a/testing/testing_zcheck_aux.c b/testing/testing_zcheck_aux.c index fa2da78b9ed0a0ee295f00bc601d93f65bc551bd..903cfb52cef0090dcddcfad1ef87508c7384fbba 100644 --- a/testing/testing_zcheck_aux.c +++ b/testing/testing_zcheck_aux.c @@ -81,7 +81,7 @@ int check_zmatrices_std( run_arg_list_t *args, cham_uplo_t uplo, int M, int N, C { int info_solution = 0; double Anorm, Rnorm, result; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); double *work = (double *)malloc( LDA*N*sizeof(double) ); @@ -237,7 +237,7 @@ int check_znorm_std( run_arg_list_t *args, cham_mtxtype_t matrix_type, cham_norm double *work = (double*) malloc(chameleon_max(M, N)*sizeof(double)); double norm_lapack; double result; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); /* Computes the norm with the LAPACK function */ switch (matrix_type) { @@ -427,7 +427,7 @@ int check_zsum_std( run_arg_list_t *args, cham_uplo_t uplo, cham_trans_t trans, Binitnorm = LAPACKE_zlantr( LAPACK_COL_MAJOR, 'M', chameleon_lapack_const(uplo), 'N', M, N, Bref, LDB ); } - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); double *work = malloc(chameleon_max(M, N)* sizeof(double)); /* Makes the sum with the core function */ @@ -690,7 +690,7 @@ int check_zrankk_std( run_arg_list_t *args, int M, int N, int K, CHAMELEON_Compl int info_solution = 0; int minMN = chameleon_min(M, N); double Anorm, Rnorm, result; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); Anorm = LAPACKE_zlange( LAPACK_COL_MAJOR, 'F', M, N, A, LDA ); diff --git a/testing/testing_zcheck_blas.c b/testing/testing_zcheck_blas.c index 44adb668831afa2e5446a1ff2ddd11ff4bccadf7..53961c68a776a912308eff7204d1ee7e47af6203 100644 --- a/testing/testing_zcheck_blas.c +++ b/testing/testing_zcheck_blas.c @@ -119,7 +119,7 @@ int check_zgemm_std( run_arg_list_t *args, cham_trans_t transA, cham_trans_t tra /* Computes the norms for comparing */ Crefnorm = LAPACKE_zlange_work( LAPACK_COL_MAJOR, 'M', M, N, Cref, LDC, NULL ); - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); /* Makes the multiplication with the core function */ cblas_zgemm( CblasColMajor, (CBLAS_TRANSPOSE)transA, (CBLAS_TRANSPOSE)transB, M, N, K, @@ -331,7 +331,7 @@ int check_zsymm_std( run_arg_list_t *args, cham_mtxtype_t matrix_type, cham_side Crefnorm = LAPACKE_zlange_work( LAPACK_COL_MAJOR, 'M', M, N, Cref, LDC, NULL ); Cchamnorm = LAPACKE_zlange_work( LAPACK_COL_MAJOR, 'M', M, N, C, LDC, NULL ); - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); /* Makes the multiplication with the core function */ #if defined(PRECISION_z) || defined(PRECISION_c) @@ -552,7 +552,7 @@ int check_zsyrk_std( run_arg_list_t *args, cham_mtxtype_t matrix_type, cham_uplo Cchamnorm = LAPACKE_zlansy_work( LAPACK_COL_MAJOR, 'I', chameleon_lapack_const(uplo), N, C, LDC, work ); } - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); double ABnorm; /* Makes the multiplication with the core function */ @@ -787,7 +787,7 @@ int check_ztrmm_std( run_arg_list_t *args, int check_func, cham_side_t side, cha double Anorm, Bnorm, Rnorm, result; char normTypeA, normTypeB; double *work; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); /* Computes the norms for comparing */ if ( side == ChamLeft ) { diff --git a/testing/testing_zcheck_facto.c b/testing/testing_zcheck_facto.c index a9ad49b3ab0e92aa277404ec94699ac984d7fede..7ebbf4832f11630a6e32bcdb304d70f25039d733 100644 --- a/testing/testing_zcheck_facto.c +++ b/testing/testing_zcheck_facto.c @@ -28,7 +28,6 @@ #if !defined(CHAMELEON_SIMULATION) -#include <coreblas/lapacke.h> #if defined(CHAMELEON_USE_MPI) #include <mpi.h> #endif @@ -66,7 +65,7 @@ int check_zlauum( run_arg_list_t *args, cham_uplo_t uplo, CHAM_desc_t *descA, CH { int info_local, info_global; int N = descA->n; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); double result, Anorm, AAtnorm, Rnorm; CHAM_desc_t *descAt; @@ -202,7 +201,7 @@ int check_zxxtrf( run_arg_list_t *args, cham_mtxtype_t matrix_type, cham_uplo_t int M = descA->m; int N = descA->n; double Anorm, Rnorm, result; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); CHAM_desc_t *descL, *descU; cham_trans_t transL = ChamNoTrans; @@ -396,7 +395,7 @@ int check_zsolve( run_arg_list_t *args, cham_mtxtype_t matrix_type, cham_trans_t int M = descA->m; int N = descA->n; double Anorm, Bnorm, Xnorm, Rnorm, result = 0; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); cham_normtype_t norm = (trans == ChamNoTrans) ? ChamOneNorm : ChamInfNorm; /* Computes the norms */ @@ -559,7 +558,7 @@ int check_ztrtri( run_arg_list_t *args, cham_mtxtype_t matrix_type, cham_uplo_t cham_uplo_t uplo_inv; CHAM_desc_t *descI, *descB = NULL; double Rnorm, Anorm, Ainvnorm, result; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); int N = descA0->m; /* Creates an identity matrix */ diff --git a/testing/testing_zcheck_polar_decomp.c b/testing/testing_zcheck_polar_decomp.c index b8469b232136314c03806227e848a961c096526b..6c83966f2ccf2abba9c3f9065db4977c903b8cb8 100644 --- a/testing/testing_zcheck_polar_decomp.c +++ b/testing/testing_zcheck_polar_decomp.c @@ -28,7 +28,6 @@ #if !defined(CHAMELEON_SIMULATION) -#include <coreblas/lapacke.h> #if defined(CHAMELEON_USE_MPI) #include <mpi.h> #endif @@ -79,7 +78,7 @@ int check_zgepdf_qr( run_arg_list_t *args, CHAM_desc_t *descA1, CHAM_desc_t *des int N = descQ1->n; int K = descAF1->n; double result, Anorm, A1norm, A2norm, Rnorm; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); CHAM_desc_t *descR, *subR, *subAF; /* @@ -187,7 +186,7 @@ int check_zxxpd( run_arg_list_t *args, { int info_local, info_global; double Anorm, Rnorm, result; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); /* Compute ||A|| */ Anorm = CHAMELEON_zlange_Tile( ChamFrobeniusNorm, descA ); diff --git a/testing/testing_zcheck_qr_lq.c b/testing/testing_zcheck_qr_lq.c index 9676a3c4921c94ead85657bf430c6e528ec85fb6..118f4a2ef37803a6d0c043fe0043d9358ab3a0dc 100644 --- a/testing/testing_zcheck_qr_lq.c +++ b/testing/testing_zcheck_qr_lq.c @@ -28,7 +28,6 @@ #if !defined(CHAMELEON_SIMULATION) -#include <coreblas/lapacke.h> #if defined(CHAMELEON_USE_MPI) #include <mpi.h> #endif @@ -59,7 +58,7 @@ int check_zortho( run_arg_list_t *args, CHAM_desc_t *descQ ) int N = descQ->n; int minMN = chameleon_min(M, N); double result, normR; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); CHAM_desc_t *descI, *subI; /* Builds the identity */ @@ -176,7 +175,7 @@ int check_zgelqf( run_arg_list_t *args, CHAM_desc_t *descA, CHAM_desc_t *descAF, int N = descQ->n; int K = chameleon_min( descA->m, descA->n ); double result, Anorm, Rnorm; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); CHAM_desc_t *descL; int full_lq = ( M == N ) ? 1 : 0; @@ -347,7 +346,7 @@ int check_zgeqrf( run_arg_list_t *args, CHAM_desc_t *descA, CHAM_desc_t *descAF, int N = descQ->n; int K = chameleon_min( descA->m, descA->n ); double result, Anorm, Rnorm; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); CHAM_desc_t *descR; int full_qr = ( M == N ) ? 1 : 0; @@ -523,7 +522,7 @@ int check_zqc( run_arg_list_t *args, cham_side_t side, cham_trans_t trans, int info_local, info_global; int M = descQ->m; double Cnorm, Qnorm, CCnorm, Rnorm, result; - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); Cnorm = CHAMELEON_zlange_Tile( ChamOneNorm, descC ); Qnorm = CHAMELEON_zlange_Tile( ChamOneNorm, descQ ); @@ -667,7 +666,7 @@ int check_zgeqrs( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t *descA, int maxMNK = chameleon_max( M, chameleon_max( N, NRHS ) ); double Rnorm, result; double Anorm = CHAMELEON_zlange_Tile( ChamOneNorm, descA ); - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); CHAMELEON_Get( CHAMELEON_TILE_SIZE, &nb ); @@ -753,7 +752,7 @@ int check_zgelqs( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t *descA, int maxMNK = chameleon_max( M, chameleon_max( N, NRHS ) ); double Rnorm, result; double Anorm = CHAMELEON_zlange_Tile( ChamOneNorm, descA ); - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); CHAMELEON_Get( CHAMELEON_TILE_SIZE, &nb ); @@ -879,13 +878,13 @@ int check_zgels( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t *descA, C * * @param[in] X * The matrix X. - * + * * @param[in] LDX * The leading dimension of the matrix X. * * @param[in] B * The matrix B. - * + * * @param[in] LDB * The leading dimension fo the matrix B. * diff --git a/testing/testing_zcheck_svd.c b/testing/testing_zcheck_svd.c index d6c0aa499d5429435357bf10884678414624cf92..a5baa10a0a353f663d6d93f5b7f5d07dee696b9f 100644 --- a/testing/testing_zcheck_svd.c +++ b/testing/testing_zcheck_svd.c @@ -24,7 +24,6 @@ #if !defined(CHAMELEON_SIMULATION) -#include <coreblas/lapacke.h> #if defined(CHAMELEON_USE_MPI) #include <mpi.h> #endif @@ -38,7 +37,7 @@ * @ingroup testing * * @brief Checks if the Chameleon SVD algorithm works: Ainit = U * mat( S ) * Vt. - * - U and Vt should be orthogonal. + * - U and Vt should be orthogonal. * - Sinit and S should be the same. * - Ainit = U * mat( S ) * Vt. * @@ -46,7 +45,7 @@ * * @param[in] jobu * Specifies options for computing all or part of the matrix U. - * + * * @param[in] jobvt * Specifies options for computing all or part of the matrix V^H. * @@ -58,22 +57,22 @@ * * @param[in] Ainit * The matrix Ainit (initial matrix A). - * + * * @param[in] A - * The matrix A after the SVD, can contain parts of the matrix U or Vt + * The matrix A after the SVD, can contain parts of the matrix U or Vt * or nothing (depending on the values of jobu and jobvt). * * @param[in] LDA * The leading dimension of the matrices A and Ainit. * * @param[in] Sinit - * The vector with the singular values of the matrix Ainit + * The vector with the singular values of the matrix Ainit * (contains the K = min(M, N) singular values of Ainit). - * + * * @param[in] S - * The vector with the singular values of the matrix Ainit + * The vector with the singular values of the matrix Ainit * computed by the Chameleon SVD algorithm. - * + * * @param[in] U * The orthogonal matrix U computed by the Chameleon SVD algorithm can * contain all of U, a part of U or nothing (NULL) depending on the value of jobu; @@ -98,14 +97,14 @@ * ******************************************************************************* */ -int check_zgesvd_std( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, int M, int N, CHAMELEON_Complex64_t *Ainit, CHAMELEON_Complex64_t *A, int LDA, +int check_zgesvd_std( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, int M, int N, CHAMELEON_Complex64_t *Ainit, CHAMELEON_Complex64_t *A, int LDA, double *Sinit, double *S, CHAMELEON_Complex64_t *U, int LDU, CHAMELEON_Complex64_t *Vt, int LDVt ) { int info_solution = 0; double result; int k; int K = chameleon_min(M, N); - double eps = LAPACKE_dlamch_work('e'); + cham_fixdbl_t eps = testing_getaccuracy(); /* Checks if U is orthogonal */ switch ( jobu ) { @@ -174,7 +173,7 @@ int check_zgesvd_std( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, i * @ingroup testing * * @brief Checks if the Chameleon SVD algorithm works: descAinit = U * mat( S ) * Vt. - * - U and Vt should be orthogonal. + * - U and Vt should be orthogonal. * - Sinit and S should be the same. * - descAinit = U * mat( S ) * Vt. * @@ -182,25 +181,25 @@ int check_zgesvd_std( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, i * * @param[in] jobu * Specifies options for computing all or part of the matrix U. - * + * * @param[in] jobvt * Specifies options for computing all or part of the matrix V^H. * * @param[in] descAinit * The descriptor of the matrix Ainit (initial matrix A). - * + * * @param[in] descA - * The descriptor of the matrix A after the SVD, can contain parts of the matrix + * The descriptor of the matrix A after the SVD, can contain parts of the matrix * U or Vt or nothing (depending on the values of jobu and jobvt). * * @param[in] Sinit - * The vector with the singular values of the matrix Ainit + * The vector with the singular values of the matrix Ainit * (contains the K = min(M, N) singular values of Ainit). - * + * * @param[in] S - * The vector with the singular values of the matrix Ainit + * The vector with the singular values of the matrix Ainit * computed by the Chameleon SVD algorithm. - * + * * @param[in] U * The orthogonal matrix U computed by the Chameleon SVD algorithm can * contain all of U, a part of U or nothing (NULL) depending on the value of jobu; @@ -225,7 +224,7 @@ int check_zgesvd_std( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, i * ******************************************************************************* */ -int check_zgesvd( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, CHAM_desc_t *descAinit, CHAM_desc_t *descA, +int check_zgesvd( run_arg_list_t *args, cham_job_t jobu, cham_job_t jobvt, CHAM_desc_t *descAinit, CHAM_desc_t *descA, double *Sinit, double *S, CHAMELEON_Complex64_t *U, int LDU, CHAMELEON_Complex64_t *Vt, int LDVt ) { int info_solution; diff --git a/testing/testings.c b/testing/testings.c index b44047e6708402da7a822597b238a8113310338e..b85c15ed626576ed8833bbb22ee0feedd0e51071 100644 --- a/testing/testings.c +++ b/testing/testings.c @@ -24,6 +24,11 @@ extern testing_options_t options; */ static testing_t *testings = NULL; +/** + * @brief Accuracy required to validate the tests + */ +static cham_fixdbl_t testing_accuracy = -1.; + /** * @brief Function to register a new testing */ @@ -227,3 +232,32 @@ testing_stop( testdata_t *tdata, cham_fixdbl_t flops ) CHAMELEON_Resume(); #endif } + +/** + * @brief Return the accuracy wanted to validate the tests + */ +cham_fixdbl_t +testing_getaccuracy() +{ +#if !defined(CHAMELEON_SIMULATION) + if ( testing_accuracy < 0. ) { + fprintf( stderr, "WARNING: Accuracy has not been initialized yet. Please call testing_setaccuracy() prior to calling testing_getaccuracy()\n" ); + assert( 0 ); + } +#endif + return testing_accuracy; +} + +/** + * @brief Set the global accuracy wanted to validate the tests + */ +void +testing_setaccuracy( cham_fixdbl_t accuracy ) +{ + if ( accuracy <= 0. ) { + fprintf( stderr, "WARNING: accuracy must be > 0.\n" ); + return; + } + testing_accuracy = accuracy; +} + diff --git a/testing/testings.h b/testing/testings.h index a1b9c06488c06aab24ff9db9f31a3fb8338ef024..f9acae9172e65f2a086b81131cc984106deb9255 100644 --- a/testing/testings.h +++ b/testing/testings.h @@ -290,4 +290,7 @@ void testing_start( testdata_t *tdata ); void testing_stop( testdata_t *tdata, cham_fixdbl_t flops ); void testing_options_init( testing_options_t *options ); +cham_fixdbl_t testing_getaccuracy(); +void testing_setaccuracy( cham_fixdbl_t accuracy ); + #endif /* _testings_h_ */ diff --git a/testing/vendor_ztesting.c b/testing/vendor_ztesting.c index f2a1b78dcadf86c51c8435158367d1e65274e144..5998822501b30757a857169d823a733c78395f4f 100644 --- a/testing/vendor_ztesting.c +++ b/testing/vendor_ztesting.c @@ -116,6 +116,11 @@ int main (int argc, char **argv) { testing_options_init( &options ); +#if !defined(CHAMELEON_SIMULATION) + /* Let's initialize the accuracy for the checks */ + testing_setaccuracy( LAPACKE_dlamch_work('e') ); +#endif + rc = CHAMELEON_Init( options.threads, 0 ); if ( rc != CHAMELEON_SUCCESS ) { fprintf( stderr, "CHAMELEON_Init failed and returned %d.\n", rc );