diff --git a/testing/chameleon_ztesting.c b/testing/chameleon_ztesting.c index e2baddbcd8e31fd6390c7e565616f54e1c5b9488..759122fe3edb0ec8373b58efe6cdc65669ea68f0 100644 --- a/testing/chameleon_ztesting.c +++ b/testing/chameleon_ztesting.c @@ -25,6 +25,8 @@ */ #include "testings.h" +testing_options_t options; + /** * @brief Defines all the parameters of the testings * @@ -138,11 +140,8 @@ parameter_t parameters[] = { int main (int argc, char **argv) { - int ncores, ngpus, human, generic, check, i, niter; - int trace, nowarmup, profile, forcegpu, api; + int i; int rc, info = 0; - int run_id = 0; - char *func_name; char *input_file; run_list_t *runlist; testing_t * test; @@ -155,20 +154,10 @@ int main (int argc, char **argv) { parameters_read_file( input_file ); free(input_file); } - ncores = parameters_getvalue_int( "threads" ); - ngpus = parameters_getvalue_int( "gpus" ); - check = parameters_getvalue_int( "check" ); - human = parameters_getvalue_int( "human" ); - generic = parameters_getvalue_int( "generic" ); - func_name = parameters_getvalue_str( "op" ); - niter = parameters_getvalue_int( "niter" ); - trace = parameters_getvalue_int( "trace" ); - nowarmup = parameters_getvalue_int( "nowarmup" ); - profile = parameters_getvalue_int( "profile" ); - forcegpu = parameters_getvalue_int( "forcegpu" ); - api = parameters_getvalue_int( "api" ); - - rc = CHAMELEON_Init( ncores, ngpus ); + + testing_options_init( &options ); + + rc = CHAMELEON_Init( options.threads, options.gpus ); if ( rc != CHAMELEON_SUCCESS ) { fprintf( stderr, "CHAMELEON_Init failed and returned %d.\n", rc ); info = 1; @@ -176,19 +165,19 @@ int main (int argc, char **argv) { } /* Set ncores to the right value */ - if ( ncores == -1 ) { + if ( options.threads == -1 ) { parameter_t *param; param = parameters_get( 't' ); param->value.ival = CHAMELEON_GetThreadNbr(); + options.threads = param->value.ival; } /* Binds the right function to be called and builds the parameters combinations */ - test = testing_gettest( argv[0], func_name ); - free(func_name); - test_fct_t fptr = (api == 0) ? test->fptr_desc : test->fptr_std; + test = testing_gettest( argv[0], options.op ); + test_fct_t fptr = (options.api == 0) ? test->fptr_desc : test->fptr_std; if ( fptr == NULL ) { fprintf( stderr, "The %s API is not available for function %s\n", - (api == 0) ? "descriptor" : "standard", func_name ); + (options.api == 0) ? "descriptor" : "standard", options.op ); info = 1; goto end; } @@ -197,12 +186,12 @@ int main (int argc, char **argv) { runlist = run_list_generate( test->params ); /* Executes the tests */ - run_print_header( test, check, human ); + run_print_header( test, options.check, options.human ); run = runlist->head; /* Force all possible kernels on GPU */ - if ( forcegpu ) { - if ( ngpus == 0 ) { + if ( options.forcegpu ) { + if ( options.gpus == 0 ) { fprintf( stderr, "--forcegpu can't be enable without GPU (-g 0).\n" " Please specify a larger number of GPU or disable this option\n" ); @@ -213,37 +202,41 @@ int main (int argc, char **argv) { } /* Warmup */ - if ( !nowarmup ) { + if ( !options.nowarmup ) { run_arg_list_t copy = run_arg_list_copy( &(run->args) ); - fptr( ©, check ); + + /* Run the warmup test as -1 */ + options.run_id--; + fptr( ©, options.check ); run_arg_list_destroy( © ); + options.run_id++; } /* Start kernel statistics */ - if ( profile ) { + if ( options.profile ) { CHAMELEON_Enable( CHAMELEON_KERNELPROFILE_MODE ); } /* Start tracing */ - if ( trace ) { + if ( options.trace ) { CHAMELEON_Enable( CHAMELEON_PROFILING_MODE ); } - if ( generic ) { + if ( options.generic ) { CHAMELEON_Enable( CHAMELEON_GENERIC ); } /* Perform all runs */ while ( run != NULL ) { - for(i=0; i<niter; i++) { + for(i=0; i<options.niter; i++) { run_arg_list_t copy = run_arg_list_copy( &(run->args) ); - rc = fptr( ©, check ); + rc = fptr( ©, options.check ); /* If rc < 0, we skipped the test */ if ( rc >= 0 ) { run_arg_add_int( ©, "RETURN", rc ); - run_print_line( test, ©, check, human, run_id ); - run_id++; + run_print_line( test, ©, options.check, options.human, options.run_id ); + options.run_id++; info += rc; } run_arg_list_destroy( © ); @@ -256,19 +249,20 @@ int main (int argc, char **argv) { } /* Stop tracing */ - if ( trace ) { + if ( options.trace ) { CHAMELEON_Disable( CHAMELEON_PROFILING_MODE ); } /* Stop kernel statistics and display results */ - if ( profile ) { + if ( options.profile ) { CHAMELEON_Disable( CHAMELEON_KERNELPROFILE_MODE ); RUNTIME_kernelprofile_display(); } free( runlist ); end: - ;/* OpenMP end */ + /* OpenMP end */ + free( options.op ); CHAMELEON_Finalize(); parameters_destroy(); diff --git a/testing/testings.c b/testing/testings.c index 09e1d91bee09adbffd045816fa46538b94ff4bb0..cdcadb74d4186f70b22df73d5d92e126874f7215 100644 --- a/testing/testings.c +++ b/testing/testings.c @@ -17,6 +17,8 @@ */ #include "testings.h" +extern testing_options_t options; + /** * @brief List of all the testings available. */ @@ -77,12 +79,47 @@ testing_gettest( const char *prog_name, return test; } +/** + * @brief Initialize the option structure to avoid looking for the parameters at + * each iteration + */ +void +testing_options_init( testing_options_t *options ) +{ + options->human = parameters_getvalue_int( "human" ); + options->niter = parameters_getvalue_int( "niter" ); + options->nowarmup = parameters_getvalue_int( "nowarmup" ); +#if !defined(CHAMELEON_TESTINGS_VENDOR) + options->api = parameters_getvalue_int( "api" ); + options->async = parameters_getvalue_int( "async" ); + options->check = parameters_getvalue_int( "check" ); + options->forcegpu = parameters_getvalue_int( "forcegpu" ); + options->generic = parameters_getvalue_int( "generic" ); + options->gpus = parameters_getvalue_int( "gpus" ); + options->mtxfmt = parameters_getvalue_int( "mtxfmt" ); + options->P = parameters_getvalue_int( "P" ); + options->profile = parameters_getvalue_int( "profile" ); + options->splitsub = parameters_getvalue_int( "splitsub" ); + options->threads = parameters_getvalue_int( "threads" ); + options->trace = parameters_getvalue_int( "trace" ); +#endif + + options->file = parameters_getvalue_str( "file" ); + options->op = parameters_getvalue_str( "op" ); + + options->run_id = 0; +} + /** * @brief Starts the measure for the testing. */ void testing_start( testdata_t *tdata ) { + tdata->sequence = NULL; + tdata->request.status = 0; + tdata->request.schedopt = NULL; + #if defined(CHAMELEON_TESTINGS_VENDOR) /* * If we test the vendor functions, we want to use all the threads of the @@ -93,21 +130,21 @@ testing_start( testdata_t *tdata ) #else int splitsub = parameters_getvalue_int( "splitsub" ); int async = parameters_getvalue_int( "async" ) || splitsub; -#endif - - tdata->sequence = NULL; - tdata->request.status = 0; - tdata->request.schedopt = NULL; -#if !defined(CHAMELEON_TESTINGS_VENDOR) #if defined(CHAMELEON_USE_MPI) CHAMELEON_Distributed_start(); #endif - + /* + * Create the sequence for the asynchronous calls + */ if ( async ) { CHAMELEON_Sequence_Create( &(tdata->sequence) ); } + /* + * Pause the task execution if we want to time separately the task + * submission from the task execution + */ if ( splitsub ) { CHAMELEON_Pause(); } diff --git a/testing/testings.h b/testing/testings.h index 2832223f4edeac53eba444a13c5e8249fc4592ed..5326b192250ccce54602a854cab040ad21619820 100644 --- a/testing/testings.h +++ b/testing/testings.h @@ -239,8 +239,6 @@ void parameters_destroy( ); run_list_t *run_list_generate( const char **params ); void run_list_destroy( run_list_elt_t *run ); -void testing_register( testing_t *test ); - /** * @brief Define the data associated to a single run of a testing */ @@ -254,12 +252,39 @@ typedef struct testdata_ { cham_fixdbl_t texec; /**< The execution time of test */ cham_fixdbl_t tsub; /**< The task submission tome of the test */ RUNTIME_sequence_t *sequence; /**< The sequence to run the test if splitsub */ - RUNTIME_request_t request; /**< The request to run the test if splitsub */ + RUNTIME_request_t request; /**< The request to run the test if splitsub */ } testdata_t; +/** + * @brief Structure to store the read parameters for a quicker access + */ +typedef struct testing_options_ { + /* Static parameters */ + int api; + int async; + int check; + int forcegpu; + int generic; + int gpus; + int human; + int mtxfmt; + int niter; + int nowarmup; + int P; + int profile; + int splitsub; + int threads; + int trace; + char *file; + char *op; + /* Additionnal information to exchange between the main and the testings */ + int run_id; +} testing_options_t; + void testing_register( testing_t *test ); testing_t *testing_gettest( const char *prog_name, const char *func_name ); void testing_start( testdata_t *tdata ); void testing_stop( testdata_t *tdata, cham_fixdbl_t flops ); +void testing_options_init( testing_options_t *options ); #endif /* _testings_h_ */ diff --git a/testing/vendor_ztesting.c b/testing/vendor_ztesting.c index f959ad3ced59fbd0040a3d531a3578c46066cd8f..9acfe313c065ca16f852478647c4515b9f5f119b 100644 --- a/testing/vendor_ztesting.c +++ b/testing/vendor_ztesting.c @@ -19,6 +19,8 @@ */ #include "testings.h" +testing_options_t options; + /** * @brief Defines all the parameters of the testings * @@ -96,11 +98,8 @@ parameter_t parameters[] = { int main (int argc, char **argv) { - int ncores, human, i, niter; - int nowarmup; - int rc, info, check = 0; - int run_id = 0; - char *func_name; + int i; + int rc, info = 0; char *input_file; run_list_t *runlist; testing_t * test; @@ -113,13 +112,10 @@ int main (int argc, char **argv) { parameters_read_file( input_file ); free(input_file); } - ncores = parameters_getvalue_int( "threads" ); - human = parameters_getvalue_int( "human" ); - func_name = parameters_getvalue_str( "op" ); - niter = parameters_getvalue_int( "niter" ); - nowarmup = parameters_getvalue_int( "nowarmup" ); - rc = CHAMELEON_Init( ncores, 0 ); + testing_options_init( &options ); + + rc = CHAMELEON_Init( options.threads, 0 ); if ( rc != CHAMELEON_SUCCESS ) { fprintf( stderr, "CHAMELEON_Init failed and returned %d.\n", rc ); info = 1; @@ -127,18 +123,18 @@ int main (int argc, char **argv) { } /* Set ncores to the right value */ - if ( ncores == -1 ) { + if ( options.threads == -1 ) { parameter_t *param; param = parameters_get( 't' ); param->value.ival = CHAMELEON_GetThreadNbr(); + options.threads = param->value.ival; } /* Binds the right function to be called and builds the parameters combinations */ - test = testing_gettest( argv[0], func_name ); - free(func_name); + test = testing_gettest( argv[0], options.op ); test_fct_t fptr = test->fptr_std; if ( fptr == NULL ) { - fprintf( stderr, "The vendor API is not available for function %s\n", func_name ); + fprintf( stderr, "The vendor API is not available for function %s\n", options.op ); info = 1; goto end; } @@ -147,27 +143,31 @@ int main (int argc, char **argv) { runlist = run_list_generate( test->params ); /* Executes the tests */ - run_print_header( test, check, human ); + run_print_header( test, options.check, options.human ); run = runlist->head; /* Warmup */ - if ( !nowarmup ) { + if ( !options.nowarmup ) { run_arg_list_t copy = run_arg_list_copy( &(run->args) ); - fptr( ©, check ); + + /* Run the warmup test as -1 */ + options.run_id--; + fptr( ©, options.check ); run_arg_list_destroy( © ); + options.run_id++; } /* Perform all runs */ while ( run != NULL ) { - for(i=0; i<niter; i++) { + for(i=0; i<options.niter; i++) { run_arg_list_t copy = run_arg_list_copy( &(run->args) ); - rc = fptr( ©, check ); + rc = fptr( ©, options.check ); /* If rc < 0, we skipped the test */ if ( rc >= 0 ) { run_arg_add_int( ©, "RETURN", rc ); - run_print_line( test, ©, check, human, run_id ); - run_id++; + run_print_line( test, ©, options.check, options.human, options.run_id ); + options.run_id++; info += rc; } run_arg_list_destroy( © ); @@ -182,7 +182,8 @@ int main (int argc, char **argv) { free( runlist ); end: - ;/* OpenMP end */ + /* OpenMP end */ + free( options.op ); CHAMELEON_Finalize(); parameters_destroy();