Gilles Carry wrote:
> Dimension (128) of statistics arrays must be a multiple of number of cpu.
> This is a hassle as you have to recompile every time your arch changes
> or if you want to disable cpus.
> Failing to do so causes segfault when requiring statistics if
> 128 modulo nr_cpus != 0 .
> 

OK, nice to get iterations configurable.  A few comments below.

> This patch adds option -i to specify how many iterations are wanted
> (still defaulting to 128).
> It rounds down iterations to the nearest multiple of online cpus.

Hrm, in my opinion, as a user I would expect the test to run AT LEAST as 
many iterations as I specify.  This is how timers and timeouts works as 
well (at least this long, but no less).  I think I'd prefer a rounding 
up.  Would any other users of the test care to offer up an opinion?

Some mostly formatting issues below

> ---
>  testcases/realtime/func/matrix_mult/matrix_mult.c |   33 ++++++++++++++------
>  1 files changed, 23 insertions(+), 10 deletions(-)
> 
> diff --git a/testcases/realtime/func/matrix_mult/matrix_mult.c 
> b/testcases/realtime/func/matrix_mult/matrix_mult.c
> index 0a3904d..18c3e47 100644
> --- a/testcases/realtime/func/matrix_mult/matrix_mult.c
> +++ b/testcases/realtime/func/matrix_mult/matrix_mult.c
> @@ -51,7 +51,7 @@
>                                       /* (and therefore SMP performance goes 
> up) */
>  #define PASS_CRITERIA        0.75            /* Avg concurrent time * pass 
> criteria < avg seq time - */
>                                       /* for every addition of a cpu */
> -#define ITERATIONS   128             /* HAS to be a multiple of 'numcpus' */
> +#define ITERATIONS   128
>  #define HIST_BUCKETS 100
> 
>  #define THREAD_WAIT  1
> @@ -68,6 +68,7 @@ static int *mult_index;
>  static int *tids;
>  static int *flags;
>  static int online_cpu_id = -1;
> +static int iterations = ITERATIONS;
> 
>  stats_container_t sdat, cdat, *curdat;
>  stats_container_t shist, chist;
> @@ -85,6 +86,7 @@ void usage(void)
>       printf("matrix_mult specific options:\n");
>       printf("  -j            enable jvmsim\n");
>       printf("  -l#           #: number of multiplications per iteration 
> (load)\n");
> +     printf("  -i#           #: number of iterations\n");

This help text needs to document the multiple of numonlinecpus 
adjustments that may be made.

>  }
> 
>  int parse_args(int c, char *v)
> @@ -94,6 +96,9 @@ int parse_args(int c, char *v)
>       case 'j':
>               run_jvmsim = 1;
>               break;
> +     case 'i':
> +             iterations = atoi(v);
> +             break;
>       case 'l':
>               ops = atoi(v);
>               break;
> @@ -236,9 +241,9 @@ void main_thread(void)
>       float savg, cavg;
>       int cpuid;
> 
> -     if (    stats_container_init(&sdat, ITERATIONS) ||
> +     if (    stats_container_init(&sdat, iterations) ||
>               stats_container_init(&shist, HIST_BUCKETS) ||
> -             stats_container_init(&cdat, ITERATIONS/numcpus) ||
> +             stats_container_init(&cdat, iterations/numcpus) ||
>               stats_container_init(&chist, HIST_BUCKETS)
>       )
>       {
> @@ -279,12 +284,12 @@ void main_thread(void)
>       curdat = &sdat;
>       printf("\nRunning sequential operations\n");
>       start = rt_gettime();
> -     for (i = 0; i < ITERATIONS; i++)
> +     for (i = 0; i < iterations; i++)
>               matrix_mult_record(MATRIX_SIZE, i);
>       end = rt_gettime();
>       delta = (long)((end - start)/NS_PER_US);
> 
> -     savg = delta/ITERATIONS; /* don't use the stats record, use the total 
> time recorded */
> +     savg = delta/iterations; /* don't use the stats record, use the total 
> time recorded */
>       smin = stats_min(&sdat);
>       smax = stats_max(&sdat);
> 
> @@ -317,9 +322,9 @@ void main_thread(void)
> 
>       /* run matrix mult operation concurrently */
>       curdat = &cdat;
> -     printf("\nRunning concurrent operations (%dx)\n", ITERATIONS);
> +     printf("\nRunning concurrent operations (%dx)\n", iterations);
>       start = rt_gettime();
> -     for (i = 0; i < ITERATIONS; i++)
> +     for (i = 0; i < iterations; i++)
>               concurrent_ops();
>       end = rt_gettime();
>       delta = (long)((end - start)/NS_PER_US);
> @@ -334,7 +339,7 @@ void main_thread(void)
>               pthread_mutex_unlock(&t->mutex);
>       }
> 
> -     cavg = delta/ITERATIONS; /* don't use the stats record, use the total 
> time recorded */
> +     cavg = delta/iterations; /* don't use the stats record, use the total 
> time recorded */
>       cmin = stats_min(&cdat);
>       cmax = stats_max(&cdat);
> 
> @@ -373,15 +378,23 @@ int main(int argc, char *argv[])
>  {
>       setup();
>       pass_criteria = PASS_CRITERIA;
> -     rt_init("jl:h", parse_args, argc, argv);
> +     rt_init("jl:i:h", parse_args, argc, argv);
>       numcpus = sysconf(_SC_NPROCESSORS_ONLN);
>       /* the minimum avg concurrent multiplier to pass */
>       criteria = pass_criteria * numcpus;
> 
> +     /* Line below rounds down iterations to a multiple
> +      * of numcpus.
> +      * Without this, having iterations not a mutiple
> +      * of numcpus causes stats to segfault (overflow
> +      * stats array).
> +      */

This comment block should be reformatted so the lines are as close to 80 
chars as possible.

> +     iterations = (int) (iterations / numcpus) * numcpus;
> +
>       printf("\n---------------------------------------\n");
>       printf("Matrix Multiplication (SMP Performance)\n");
>       printf("---------------------------------------\n\n");
> -     printf("Running %d iterations\n", ITERATIONS);
> +     printf("Running %d iterations\n", iterations);
>       printf("Matrix Dimensions: %dx%d\n", MATRIX_SIZE, MATRIX_SIZE);
>       printf("Calculations per iteration: %d\n", ops);
>       printf("Number of CPUs: %u\n", numcpus);


-- 
Darren Hart
IBM Linux Technology Center
Real-Time Linux Team


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to