From 7d7ad0c46a38dd6fbbca2365a651b48c70581d8a Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Fri, 28 Jan 2011 04:56:44 +0100 Subject: [PATCH] [commtech] Make WORDS_PER_BUF indep of BUF_SIZE. The number of data sent must be independent of the buffer size chosen by each algorithm. --- communication_techniques/src/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/communication_techniques/src/main.c b/communication_techniques/src/main.c index b6bea0e..8da250a 100644 --- a/communication_techniques/src/main.c +++ b/communication_techniques/src/main.c @@ -21,7 +21,7 @@ #define MAX_BLOCK_ENTRIES (page_size / sizeof(void *)) #define toString(x) doStringification(x) #define doStringification(x) #x -#define WORDS_PER_BUF (BUF_SIZE / sizeof(uintptr_t)) +#define WORDS_PER_LINE (CACHE_LINE_SIZE / sizeof(uintptr_t)) static long nb_bufs_sent = 0; @@ -233,7 +233,7 @@ int analyse_options(int argc, char *argv[]) do_calc = do_nocalc; end_calc = do_noend; } - printf("buf size: %lu\n", WORDS_PER_BUF); + printf("buf size: %lu\n", WORDS_PER_LINE); return 0; } @@ -281,7 +281,7 @@ void *producer(void *channel) } for(i = 0; i < nb_bufs_sent; i++) { //printf("[%p] Send %d new CACHE_LINE\n", (void *) pthread_self(), BUF_SIZE / CACHE_LINE_SIZE); - for(j = 0; j < WORDS_PER_BUF; j++) + for(j = 0; j < WORDS_PER_LINE; j++) send(do_calc()); } if (end_calc()) @@ -333,7 +333,7 @@ void *consumer(void *channel) long long total_data_received = 0; void *data_buf[MAX_BLOCK_ENTRIES]; - while (total_data_received < nb_bufs_sent * WORDS_PER_BUF) + while (total_data_received < nb_bufs_sent * WORDS_PER_LINE) { int i; ssize_t nb_data_received; @@ -351,7 +351,7 @@ void *consumer(void *channel) for(i = 0; i < nb_bufs_sent; i++) { //printf("[%p] About to receive %d new cache line%s\n", (void *) pthread_self(), BUF_SIZE / CACHE_LINE_SIZE, (BUF_SIZE / CACHE_LINE_SIZE > 1) ? "s" : ""); - for(j = 0; j < WORDS_PER_BUF; j++) + for(j = 0; j < WORDS_PER_LINE; j++) on_message(recv_one_data()); } }