From a590ecca090266949a43274c55e075e3bed0b8a5 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Fri, 19 Jun 2009 21:15:23 +0200 Subject: [PATCH] commtechs bench: calculation init takes an arg --- .../src/calculation/calc_mat.c | 6 ++++-- communication_techniques/src/main.c | 15 ++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/communication_techniques/src/calculation/calc_mat.c b/communication_techniques/src/calculation/calc_mat.c index b551ade..149c7e5 100644 --- a/communication_techniques/src/calculation/calc_mat.c +++ b/communication_techniques/src/calculation/calc_mat.c @@ -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)); diff --git a/communication_techniques/src/main.c b/communication_techniques/src/main.c index 4e24fd2..614b112 100644 --- a/communication_techniques/src/main.c +++ b/communication_techniques/src/main.c @@ -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++) {