From 9436e43dc27790f236cf1394336bb7c242967916 Mon Sep 17 00:00:00 2001 From: Alycia Lisito <alycia.lisito@inria.fr> Date: Fri, 4 Feb 2022 17:22:01 +0100 Subject: [PATCH] testing: add standard api to hemm --- testing/testing_zhemm.c | 81 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/testing/testing_zhemm.c b/testing/testing_zhemm.c index 0d01232b2..9fc000642 100644 --- a/testing/testing_zhemm.c +++ b/testing/testing_zhemm.c @@ -2,7 +2,7 @@ * * @file testing_zhemm.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. * *** @@ -13,7 +13,8 @@ * @author Lucas Barros de Assis * @author Florent Pruvost * @author Mathieu Faverge - * @date 2020-11-19 + * @author Alycia Lisito + * @date 2022-02-04 * @precisions normal z -> c * */ @@ -113,6 +114,80 @@ testing_zhemm_desc( run_arg_list_t *args, int check ) return hres; } +int +testing_zhemm_std( run_arg_list_t *args, int check ) +{ + testdata_t test_data = { .args = args }; + int hres = 0; + + /* Read arguments */ + int nb = run_arg_get_int( args, "nb", 320 ); + cham_side_t side = run_arg_get_side( args, "side", ChamLeft ); + cham_uplo_t uplo = run_arg_get_uplo( args, "uplo", ChamUpper ); + int N = run_arg_get_int( args, "N", 1000 ); + int M = run_arg_get_int( args, "M", N ); + int LDA = run_arg_get_int( args, "LDA", ( ( side == ChamLeft ) ? M : N ) ); + int LDB = run_arg_get_int( args, "LDB", M ); + int LDC = run_arg_get_int( args, "LDC", M ); + CHAMELEON_Complex64_t alpha = testing_zalea(); + CHAMELEON_Complex64_t beta = testing_zalea(); + int seedA = run_arg_get_int( args, "seedA", random() ); + int seedB = run_arg_get_int( args, "seedB", random() ); + int seedC = run_arg_get_int( args, "seedC", random() ); + double bump = testing_dalea(); + + /* Descriptors */ + int Am; + CHAMELEON_Complex64_t *A, *B, *C, *Cinit; + + bump = run_arg_get_double( args, "bump", bump ); + alpha = run_arg_get_complex64( args, "alpha", alpha ); + beta = run_arg_get_complex64( args, "beta", beta ); + + CHAMELEON_Set( CHAMELEON_TILE_SIZE, nb ); + + /* Calculate the dimensions according to the side */ + if ( side == ChamLeft ) { + Am = M; + } + else { + Am = N; + } + + /* Create the matrices */ + A = malloc( LDA*Am*sizeof(CHAMELEON_Complex64_t) ); + B = malloc( LDB*N*sizeof(CHAMELEON_Complex64_t) ); + C = malloc( LDC*N*sizeof(CHAMELEON_Complex64_t) ); + + /* Fills the matrix with random values */ + CHAMELEON_zplghe( bump, uplo, N, A, LDA, seedA ); + CHAMELEON_zplrnt( M, N, B, LDB, seedB ); + CHAMELEON_zplrnt( M, N, C, LDC, seedC ); + + /* Calculates the product */ + testing_start( &test_data ); + hres = CHAMELEON_zhemm( side, uplo, M, N, alpha, A, LDA, B, LDB, beta, C, LDC ); + test_data.hres = hres; + testing_stop( &test_data, flops_zhemm( side, M, N ) ); + + /* Checks the solution */ + if ( check ) { + Cinit = malloc( LDC*N*sizeof(CHAMELEON_Complex64_t) ); + CHAMELEON_zplrnt( M, N, Cinit, LDC, seedC ); + + // hres += check_zsymm( args, ChamHermitian, side, uplo, alpha, descA, descB, + // beta, descCinit, descC ); + + free( Cinit ); + } + + free( A ); + free( B ); + free( C ); + + return hres; +} + testing_t test_zhemm; const char *zhemm_params[] = { "mtxfmt", "nb", "side", "uplo", "m", "n", "lda", "ldb", "ldc", "alpha", "beta", "seedA", "seedB", "seedC", "bump", NULL }; @@ -132,7 +207,7 @@ testing_zhemm_init( void ) test_zhemm.output = zhemm_output; test_zhemm.outchk = zhemm_outchk; test_zhemm.fptr_desc = testing_zhemm_desc; - test_zhemm.fptr_std = NULL; + test_zhemm.fptr_std = testing_zhemm_std; test_zhemm.next = NULL; testing_register( &test_zhemm ); -- GitLab