commtechs bench: calculation init takes an arg

This commit is contained in:
Thomas Preud'homme 2009-06-19 21:15:23 +02:00 committed by Thomas Preud'homme
parent f4b3904541
commit a590ecca09
2 changed files with 14 additions and 7 deletions

View File

@ -7,12 +7,14 @@
static int *mat, *vect;
static int li;
static int n = 16, m = 16; /* Size of the matrice: n lines, m columns */
static int n, m; /* Size of the matrice: n lines, m columns */
void init_calc(void)
void init_calc(int size)
{
int i;
n = size;
m = size;
srand(42);
mat = (int *) malloc(n * m * sizeof(int));
vect = (int *) malloc(m * sizeof(int));

View File

@ -19,11 +19,12 @@
#define toString(x) doStringification(x)
#define doStringification(x) #x
#define INIT_CALC_ARG 16
static long nb_bufs_sent = 0;
long nb_prod = 0;
static void (*init_calc)(void) = NULL;
static void (*init_calc)(int) = NULL;
static void *(*do_calc)(void) = NULL;
static void (*end_calc)(void) = NULL;
static int shared = 0;
@ -49,7 +50,7 @@ void usage(char *argv[])
printf("%s\n", options);
}
void do_nothing(void)
void do_noinit(int unused)
{
}
@ -60,6 +61,10 @@ void *do_nocalc(void)
return &an_int;
}
void do_noend(void)
{
}
int analyse_options(int argc, char *argv[])
{
int opt;
@ -162,9 +167,9 @@ int analyse_options(int argc, char *argv[])
}
if (do_calc == NULL)
{
init_calc = do_nothing;
init_calc = do_noinit;
do_calc = do_nocalc;
end_calc = do_nothing;
end_calc = do_noend;
}
return 0;
}
@ -202,7 +207,7 @@ void *producer(void *unused)
return NULL;
}
}
init_calc();
init_calc(INIT_CALC_ARG);
if (initialize_papi() != -1)
{
for(i = 0; i < nb_bufs_sent; i++) {