diff --git a/testing/chameleon_ztesting.c b/testing/chameleon_ztesting.c index 9d70612cb80e409320c5d441589145f897b30c58..4d8317ed37f1939ab2135059616ce766071ae12d 100644 --- a/testing/chameleon_ztesting.c +++ b/testing/chameleon_ztesting.c @@ -11,7 +11,7 @@ * * @brief Chameleon CHAMELEON_Complex64_t auxiliary testings routines * - * @version 1.2.0 + * @version 1.3.0 * @author Mathieu Faverge * @author Cedric Castagnede * @author Lucas Barros de Assis @@ -21,7 +21,8 @@ * @author Philippe Swartvagher * @author Lucas Nesi * @author Matthieu Kuhn - * @date 2023-01-05 + * @author Lionel Eyraud-Dubois + * @date 2023-07-05 * @precisions normal z -> c d s * */ @@ -57,11 +58,12 @@ parameter_t parameters[] = { #endif { NULL, "Machine parameters", 0, PARAM_OPTION, 0, 0, 0, {0}, NULL, NULL, NULL }, - { "threads", "Number of CPU workers per node", 't', PARAM_OPTION | PARAM_OUTPUT, 1, 7, TestValInt, {-1}, NULL, pread_int, sprint_int }, + { "threads", "Number of CPU workers per node", 't', PARAM_OPTION | PARAM_OUTPUT, 1, 7, TestValInt, {-1}, NULL, pread_int, sprint_int }, #if !defined(CHAMELEON_TESTINGS_VENDOR) - { "gpus", "Number of GPU workers per node", 'g', PARAM_OPTION | PARAM_OUTPUT, 1, 4, TestValInt, { 0}, NULL, pread_int, sprint_int }, - { "P", "Rows (P) in the PxQ process grid", 'P', PARAM_OPTION | PARAM_OUTPUT, 1, 2, TestValInt, { 1}, NULL, pread_int, sprint_int }, - { "Q", "Columns (Q) in the PxQ process grid", 'Q', PARAM_OUTPUT, 1, 2, TestValInt, { 1}, NULL, pread_int, sprint_int }, + { "gpus", "Number of GPU workers per node", 'g', PARAM_OPTION | PARAM_OUTPUT, 1, 4, TestValInt, { 0}, NULL, pread_int, sprint_int }, + { "P", "Rows (P) in the PxQ process grid", 'P', PARAM_OPTION | PARAM_OUTPUT, 1, 2, TestValInt, { 1}, NULL, pread_int, sprint_int }, + { "Q", "Columns (Q) in the PxQ process grid", 'Q', PARAM_OUTPUT, 1, 2, TestValInt, { 1}, NULL, pread_int, sprint_int }, + { "custom", "Name of custom distribution file", -61, PARAM_OPTION, 1, 1, TestString, { 0}, NULL, pread_string, sprint_string }, #endif { NULL, "Main input parameters", 0, PARAM_OPTION, 0, 0, 0, {0}, NULL, NULL, NULL }, diff --git a/testing/parameters.c b/testing/parameters.c index f8b936946e77cc610b90adbb88fc34fdc76bc25a..745f1c15648ecd3ca2bc6921e994407399724585 100644 --- a/testing/parameters.c +++ b/testing/parameters.c @@ -8,11 +8,12 @@ * * @brief Chameleon auxiliary routines for testing structures * - * @version 1.2.0 + * @version 1.3.0 * @author Lucas Barros de Assis * @author Mathieu Faverge * @author Alycia Lisito - * @date 2022-02-22 + * @author Lionel Eyraud-Dubois + * @date 2023-07-05 * */ #include "testings.h" @@ -465,6 +466,87 @@ parameters_compute_q( int p ) param->value.ival = np / p; return param->value.ival; } + +/** + ******************************************************************************** + * + * @brief Helper function to generate the testing descriptors with the right + * data distrbution. + * + ******************************************************************************* + * + * @param[in] filename + * The name of the input file. + * + ******************************************************************************* + */ +int +parameters_desc_create( const char *id, CHAM_desc_t **descptr, cham_flttype_t dtyp, + int mb, int nb, int lm, int ln, int m, int n ) +{ + custom_dist_t *custom_args = NULL; + const char *custom = parameters_getvalue_str( "custom" ); + intptr_t mtxfmt = parameters_getvalue_int( "mtxfmt" ); + int rc; + + mtxfmt = -mtxfmt; /* Inverse sign to get the defined values */ + + if ( !custom ) { + int P = parameters_getvalue_int( "P" ); + int Q = parameters_compute_q( P ); + rc = CHAMELEON_Desc_Create( + descptr, (void*)mtxfmt, dtyp, mb, nb, mb * nb, lm, ln, 0, 0, m, n, P, Q ); + (*descptr)->name = id; + return rc; + } + + if ( ((void*)mtxfmt) == CHAMELEON_MAT_ALLOC_GLOBAL ) { + fprintf( stderr, "In parameters_desc_create, cannot use custom distributions with global matrix allocation (Use --mtxfmt=1)\n" ); + return CHAMELEON_ERR_ILLEGAL_VALUE; + } + + rc = chameleon_getrankof_custom_init( &custom_args, custom ); + if ( rc != CHAMELEON_SUCCESS ) { + return rc; + } + + rc = CHAMELEON_Desc_Create_User( + descptr, (void*)mtxfmt, dtyp, mb, nb, mb * nb, lm, ln, 0, 0, m, n, CHAMELEON_Comm_size(), 1, + NULL, NULL, chameleon_getrankof_custom, custom_args ); + (*descptr)->name = id; + return rc; +} + +/** + ******************************************************************************* + * + * @brief Helper function to destroy the testing descriptors. + * + ******************************************************************************* + * + * @param[inout] descptr + * The descriptor to destroy. On exit the descriptor can no longer be used. + * + ******************************************************************************* + */ +int +parameters_desc_destroy(CHAM_desc_t **descptr) +{ + CHAM_desc_t *desc; + if ( descptr == NULL ) { + return CHAMELEON_ERR_ILLEGAL_VALUE; + } + desc = *descptr; + if ( desc == NULL ) { + return CHAMELEON_ERR_ILLEGAL_VALUE; + } + if ( desc->get_rankof_init_arg ) { + if ( desc->get_rankof_init == chameleon_getrankof_custom ) { + chameleon_getrankof_custom_destroy( (custom_dist_t**)&(desc->get_rankof_init_arg) ); + } + } + return CHAMELEON_Desc_Destroy( descptr ); +} #endif void diff --git a/testing/testings.h b/testing/testings.h index 14383a1938fdc7e147d2a3bb6e4e0284460d1daf..abd70ab22cbe3a850986de53bfbcef99fd1eabd1 100644 --- a/testing/testings.h +++ b/testing/testings.h @@ -8,12 +8,13 @@ * * @brief Chameleon auxiliary routines for testing structures * - * @version 1.2.0 + * @version 1.3.0 * @author Lucas Barros de Assis * @author Mathieu Faverge * @author Alycia Lisito * @author Florent Pruvost - * @date 2023-01-05 + * @author Lionel Eyraud-Dubois + * @date 2023-07-05 * */ #ifndef _testings_h_ @@ -242,6 +243,10 @@ void parameters_destroy( ); run_list_t *run_list_generate( const char **params ); void run_list_destroy( run_list_elt_t *run ); +int parameters_desc_create( const char *id, CHAM_desc_t **descptr, cham_flttype_t dtyp, + int mb, int nb, int lm, int ln, int m, int n ); +int parameters_desc_destroy( CHAM_desc_t **descptr ); + /** * @brief Define the data associated to a single run of a testing */