diff --git a/testing/testing_zcheck.c b/testing/testing_zcheck.c index 35b044b4a870930805e3d95f46977081e8e6622e..7569e18cd57a602f491945d57327423c43f4c1a4 100644 --- a/testing/testing_zcheck.c +++ b/testing/testing_zcheck.c @@ -2,7 +2,7 @@ * * @file testing_zcheck.c * - * @copyright 2019-2021 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * @copyright 2019-2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, * Univ. Bordeaux. All rights reserved. * *** @@ -14,7 +14,8 @@ * @author Florent Pruvost * @author Mathieu Faverge * @author Nathalie Furmento - * @date 2020-12-01 + * @author Alycia Lisito + * @date 2022-02-08 * @precisions normal z -> c d s * */ @@ -168,14 +169,75 @@ int check_zmatrices( run_arg_list_t *args, cham_uplo_t uplo, CHAM_desc_t *descA, * ******************************************************************************* */ + +int check_znorm_std( cham_mtxtype_t matrix_type, cham_normtype_t norm_type, cham_uplo_t uplo, + cham_diag_t diag, double norm_cham, int M, int N, CHAMELEON_Complex64_t *A, int LDA ) +{ + int info_solution = 0; + double *work = (double*) malloc(chameleon_max(M, N)*sizeof(double)); + double norm_lapack; + double result; + double eps = LAPACKE_dlamch_work('e'); + + /* Computes the norm with the LAPACK function */ + switch (matrix_type) { + case ChamGeneral: + norm_lapack = LAPACKE_zlange_work( LAPACK_COL_MAJOR, chameleon_lapack_const(norm_type), M, N, A, LDA, work ); + break; +#if defined(PRECISION_z) || defined(PRECISION_c) + case ChamHermitian: + norm_lapack = LAPACKE_zlanhe_work( LAPACK_COL_MAJOR, chameleon_lapack_const(norm_type), chameleon_lapack_const(uplo), M, A, LDA, work ); + break; +#endif + case ChamSymmetric: + norm_lapack = LAPACKE_zlansy_work( LAPACK_COL_MAJOR, chameleon_lapack_const(norm_type), chameleon_lapack_const(uplo), M, A, LDA, work ); + break; + case ChamTriangular: + norm_lapack = LAPACKE_zlantr_work( LAPACK_COL_MAJOR, chameleon_lapack_const(norm_type), chameleon_lapack_const(uplo), chameleon_lapack_const(diag), M, N, A, LDA, work ); + break; + default: + fprintf(stderr, "check_znorm: mtxtype(%d) unsupported\n", matrix_type ); + free( work ); + return 1; + } + + /* Compares the norms */ + result = fabs( norm_cham - norm_lapack ) / ( norm_lapack * eps ); + + switch(norm_type) { + case ChamInfNorm: + /* Sum order on the line can differ */ + result = result / (double)N; + break; + case ChamOneNorm: + /* Sum order on the column can differ */ + result = result / (double)M; + break; + case ChamFrobeniusNorm: + /* Sum order on every element can differ */ + result = result / ((double)M * (double)N); + break; + case ChamMaxNorm: + default: + /* result should be perfectly equal */ + ; + } + + info_solution = ( result < 1 ) ? 0 : 1; + + free(work); + + return info_solution; +} + int check_znorm( run_arg_list_t *args, cham_mtxtype_t matrix_type, cham_normtype_t norm_type, cham_uplo_t uplo, cham_diag_t diag, double norm_cham, CHAM_desc_t *descA ) { - int info_solution = 0; - int M = descA->m; - int N = descA->n; - int LDA = descA->m; - int rank = CHAMELEON_Comm_rank(); + int info_solution = 0; + int M = descA->m; + int N = descA->n; + int LDA = descA->m; + int rank = CHAMELEON_Comm_rank(); CHAMELEON_Complex64_t *A = NULL; if ( rank == 0 ) { @@ -184,61 +246,8 @@ int check_znorm( run_arg_list_t *args, cham_mtxtype_t matrix_type, cham_normtype /* Converts the matrix to LAPACK layout in order to use the LAPACK norm function */ CHAMELEON_zDesc2Lap( uplo, descA, A, LDA ); - if ( rank == 0 ) { - double *work = (double*) malloc(chameleon_max(M, N)*sizeof(double)); - double norm_lapack; - double result; - double eps = LAPACKE_dlamch_work('e'); - - /* Computes the norm with the LAPACK function */ - switch (matrix_type) { - case ChamGeneral: - norm_lapack = LAPACKE_zlange_work( LAPACK_COL_MAJOR, chameleon_lapack_const(norm_type), M, N, A, LDA, work ); - break; -#if defined(PRECISION_z) || defined(PRECISION_c) - case ChamHermitian: - norm_lapack = LAPACKE_zlanhe_work( LAPACK_COL_MAJOR, chameleon_lapack_const(norm_type), chameleon_lapack_const(uplo), M, A, LDA, work ); - break; -#endif - case ChamSymmetric: - norm_lapack = LAPACKE_zlansy_work( LAPACK_COL_MAJOR, chameleon_lapack_const(norm_type), chameleon_lapack_const(uplo), M, A, LDA, work ); - break; - case ChamTriangular: - norm_lapack = LAPACKE_zlantr_work( LAPACK_COL_MAJOR, chameleon_lapack_const(norm_type), chameleon_lapack_const(uplo), chameleon_lapack_const(diag), M, N, A, LDA, work ); - break; - default: - fprintf(stderr, "check_znorm: mtxtype(%d) unsupported\n", matrix_type ); - free( work ); - return 1; - } - - /* Compares the norms */ - result = fabs( norm_cham - norm_lapack ) / ( norm_lapack * eps ); - - switch(norm_type) { - case ChamInfNorm: - /* Sum order on the line can differ */ - result = result / (double)N; - break; - case ChamOneNorm: - /* Sum order on the column can differ */ - result = result / (double)M; - break; - case ChamFrobeniusNorm: - /* Sum order on every element can differ */ - result = result / ((double)M * (double)N); - break; - case ChamMaxNorm: - default: - /* result should be perfectly equal */ - ; - } - - info_solution = ( result < 1 ) ? 0 : 1; - - free(work); - free(A); + info_solution = check_znorm_std( matrix_type, norm_type, uplo, diag, norm_cham, M, N, A, LDA ); } /* Broadcasts the result from the main processus */ diff --git a/testing/testing_zcheck.h b/testing/testing_zcheck.h index 8fe4675e24457f2076828de5e1f1d5e2d5e31b45..4f86784dfd58d4fe7be29d90c4f18a7dc1b7e5ab 100644 --- a/testing/testing_zcheck.h +++ b/testing/testing_zcheck.h @@ -2,7 +2,7 @@ * * @file testing_zcheck.h * - * @copyright 2019-2021 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * @copyright 2019-2022 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, * Univ. Bordeaux. All rights reserved. * *** @@ -14,7 +14,8 @@ * @author Florent Pruvost * @author Mathieu Faverge * @author Nathalie Furmento - * @date 2020-12-01 + * @author Alycia Lisito + * @date 2022-02-08 * @precisions normal z -> c d s * */ @@ -36,6 +37,8 @@ #if defined(CHAMELEON_SIMULATION) static inline int check_zmatrices ( run_arg_list_t *args, cham_uplo_t uplo, CHAM_desc_t *descA, CHAM_desc_t *descB ) { return 0; } +static inline int check_znorm_std ( cham_mtxtype_t matrix_type, cham_normtype_t norm_type, cham_uplo_t uplo, + cham_diag_t diag, double norm_cham, int M, int N, CHAMELEON_Complex64_t *A, int LDA ) { return 0; } static inline int check_znorm ( run_arg_list_t *args, cham_mtxtype_t mtxtype, cham_normtype_t norm_type, cham_uplo_t uplo, cham_diag_t diag, double norm_cham, CHAM_desc_t *descA ) { return 0; } static inline int check_zsum ( run_arg_list_t *args, cham_uplo_t uplo, cham_trans_t trans, CHAMELEON_Complex64_t alpha, CHAM_desc_t *descA, @@ -77,6 +80,8 @@ static inline int check_zxxpd ( run_arg_list_t *args, #else /* !defined(CHAMELEON_SIMULATION) */ int check_zmatrices ( run_arg_list_t *args, cham_uplo_t uplo, CHAM_desc_t *descA, CHAM_desc_t *descB ); +int check_znorm_std ( cham_mtxtype_t matrix_type, cham_normtype_t norm_type, cham_uplo_t uplo, + cham_diag_t diag, double norm_cham, int M, int N, CHAMELEON_Complex64_t *A, int LDA ); int check_znorm ( run_arg_list_t *args, cham_mtxtype_t mtxtype, cham_normtype_t norm_type, cham_uplo_t uplo, cham_diag_t diag, double norm_cham, CHAM_desc_t *descA ); int check_zsum ( run_arg_list_t *args, cham_uplo_t uplo, cham_trans_t trans, CHAMELEON_Complex64_t alpha, CHAM_desc_t *descA, diff --git a/testing/testing_zlange.c b/testing/testing_zlange.c index e4a9195e0a3e625eee9a8ca70f222baf9f1facbd..404c7d3f5fe475b43eacf7cadf9f3fa2dde05413 100644 --- a/testing/testing_zlange.c +++ b/testing/testing_zlange.c @@ -123,6 +123,7 @@ testing_zlange_std( run_arg_list_t *args, int check ) int seedA = run_arg_get_int( args, "seedA", random() ); /* Descriptors */ + double norm; CHAMELEON_Complex64_t *A; CHAMELEON_Set( CHAMELEON_TILE_SIZE, nb ); @@ -135,14 +136,13 @@ testing_zlange_std( run_arg_list_t *args, int check ) /* Calculates the norm */ testing_start( &test_data ); - CHAMELEON_zlange( norm_type, M, N, A, LDA ); + norm = CHAMELEON_zlange( norm_type, M, N, A, LDA ); test_data.hres = hres; testing_stop( &test_data, flops_zlange( norm_type, M, N ) ); /* Checks the solution */ if ( check ) { - // hres = check_znorm( args, ChamGeneral, norm_type, ChamUpperLower, - // ChamNonUnit, norm, descA ); + hres = check_znorm_std( ChamGeneral, norm_type, ChamUpperLower, ChamNonUnit, norm, M, N, A, LDA ); } free( A ); diff --git a/testing/testing_zlanhe.c b/testing/testing_zlanhe.c index 0af08b67b93ae8fb4fc73a96d3c2c1b4dfc18272..a761f5a0c7e19be5486a9973eee6bd8ef99af4c8 100644 --- a/testing/testing_zlanhe.c +++ b/testing/testing_zlanhe.c @@ -123,6 +123,7 @@ testing_zlanhe_std( run_arg_list_t *args, int check ) double bump = testing_dalea(); /* Descriptors */ + double norm; CHAMELEON_Complex64_t *A; bump = run_arg_get_complex64( args, "bump", bump ); @@ -137,13 +138,13 @@ testing_zlanhe_std( run_arg_list_t *args, int check ) /* Calculates the norm */ testing_start( &test_data ); - CHAMELEON_zlanhe( norm_type, uplo, N, A, LDA ); + norm = CHAMELEON_zlanhe( norm_type, uplo, N, A, LDA ); test_data.hres = hres; testing_stop( &test_data, flops_zlanhe( norm_type, N ) ); /* Checks the solution */ if ( check ) { - // hres = check_znorm( args, ChamHermitian, norm_type, uplo, ChamNonUnit, norm, descA ); + hres = check_znorm_std( ChamHermitian, norm_type, uplo, ChamNonUnit, norm, N, N, A, LDA ); } free( A ); diff --git a/testing/testing_zlansy.c b/testing/testing_zlansy.c index 03f6255e0af81b199a0ce9aa7a7c58de52d5cbd8..aaef481f2b93404ae2f5b726ec5ded3214ac1c26 100644 --- a/testing/testing_zlansy.c +++ b/testing/testing_zlansy.c @@ -123,6 +123,7 @@ testing_zlansy_std( run_arg_list_t *args, int check ) CHAMELEON_Complex64_t bump = testing_zalea(); /* Descriptors */ + double norm; CHAMELEON_Complex64_t *A; bump = run_arg_get_complex64( args, "bump", bump ); @@ -137,13 +138,13 @@ testing_zlansy_std( run_arg_list_t *args, int check ) /* Calculates the norm */ testing_start( &test_data ); - CHAMELEON_zlansy( norm_type, uplo, N, A, LDA ); + norm = CHAMELEON_zlansy( norm_type, uplo, N, A, LDA ); test_data.hres = hres; testing_stop( &test_data, flops_zlansy( norm_type, N ) ); /* Checks the solution */ if ( check ) { - // hres = check_znorm( args, ChamSymmetric, norm_type, uplo, ChamNonUnit, norm, descA ); + hres = check_znorm_std( ChamSymmetric, norm_type, uplo, ChamNonUnit, norm, N, N, A, LDA ); } free( A ); diff --git a/testing/testing_zlantr.c b/testing/testing_zlantr.c index 2d8d297627a7f539c26d36c8b7cecd69dc63ed68..ce6ce9e7f80b930bf5c085b9c695046bbe10e5b6 100644 --- a/testing/testing_zlantr.c +++ b/testing/testing_zlantr.c @@ -146,6 +146,7 @@ testing_zlantr_std( run_arg_list_t *args, int check ) int seedA = run_arg_get_int( args, "seedA", random() ); /* Descriptors */ + double norm; CHAMELEON_Complex64_t *A; CHAMELEON_Set( CHAMELEON_TILE_SIZE, nb ); @@ -158,13 +159,13 @@ testing_zlantr_std( run_arg_list_t *args, int check ) /* Calculates the norm */ testing_start( &test_data ); - CHAMELEON_zlantr( norm_type, uplo, diag, M, N, A, LDA ); + norm = CHAMELEON_zlantr( norm_type, uplo, diag, M, N, A, LDA ); test_data.hres = hres; testing_stop( &test_data, flops_zlantr( norm_type, uplo, M, N ) ); /* Checks the solution */ if ( check ) { - // hres = check_znorm( args, ChamTriangular, norm_type, uplo, diag, norm, descA ); + hres = check_znorm_std( ChamTriangular, norm_type, uplo, diag, norm, M, N, A, LDA ); } free( A );