From 22c97ab418c682ad2c81dfc51e8d78a2533f8df2 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Wed, 2 Mar 2011 12:20:47 +0100 Subject: [PATCH] [commtech] Make BUF_SIZE definition be per tech Don't define BUF_SIZE globally anymore, but per communication technique --- communication_techniques/include/batch_queue_comm.h | 4 ++++ communication_techniques/include/commtech.h | 1 - communication_techniques/include/csq_common_comm.h | 4 ++++ communication_techniques/include/fast_forward_comm.h | 4 ++++ communication_techniques/include/lamport_comm.h | 4 ++++ communication_techniques/include/mcringbuffer_comm.h | 2 +- communication_techniques/include/shared_mem_opt_comm.h | 2 +- communication_techniques/src/communication/mcringbuffer.c | 2 +- 8 files changed, 19 insertions(+), 4 deletions(-) diff --git a/communication_techniques/include/batch_queue_comm.h b/communication_techniques/include/batch_queue_comm.h index 340dba8..9d552d2 100644 --- a/communication_techniques/include/batch_queue_comm.h +++ b/communication_techniques/include/batch_queue_comm.h @@ -4,6 +4,10 @@ /* Non standard include */ #include +#ifndef BUF_SIZE +#define BUF_SIZE (32 * CACHE_LINE_SIZE) +#endif + /* This is not an error, we need this two-macro system */ #define toString(x) doStringification(x) #define doStringification(x) #x diff --git a/communication_techniques/include/commtech.h b/communication_techniques/include/commtech.h index cf6b080..944ecb2 100644 --- a/communication_techniques/include/commtech.h +++ b/communication_techniques/include/commtech.h @@ -2,7 +2,6 @@ #define _COMMTECH_H_ 1 #define CACHE_LINE_SIZE 64 -#define BUF_SIZE CACHE_LINE_SIZE #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect((x), 0) diff --git a/communication_techniques/include/csq_common_comm.h b/communication_techniques/include/csq_common_comm.h index 3d6a64f..7a43bd8 100644 --- a/communication_techniques/include/csq_common_comm.h +++ b/communication_techniques/include/csq_common_comm.h @@ -4,6 +4,10 @@ /* Non standard include */ #include +#ifndef BUF_SIZE +#define BUF_SIZE CACHE_LINE_SIZE +#endif + #ifndef SLOTS #define SLOTS 64 /* Value used in the article, section V.A */ #endif diff --git a/communication_techniques/include/fast_forward_comm.h b/communication_techniques/include/fast_forward_comm.h index cd5095a..004a537 100644 --- a/communication_techniques/include/fast_forward_comm.h +++ b/communication_techniques/include/fast_forward_comm.h @@ -8,6 +8,10 @@ #define SHARED_SPACE_SIZE (16 * BUF_SIZE) #define SHARED_SPACE_VOIDPTR (SHARED_SPACE_SIZE / sizeof(void *)) +#ifndef BUF_SIZE +#define BUF_SIZE CACHE_LINE_SIZE +#endif + #define DANGER (2 * BUF_SIZE / sizeof(void *)) #define GOOD (6 * BUF_SIZE / sizeof(void *)) #define ADJUST_FREQ 64 diff --git a/communication_techniques/include/lamport_comm.h b/communication_techniques/include/lamport_comm.h index 7fdc277..c9a09b5 100644 --- a/communication_techniques/include/lamport_comm.h +++ b/communication_techniques/include/lamport_comm.h @@ -4,6 +4,10 @@ /* Non standard include */ #include +#ifndef BUF_SIZE +#define BUF_SIZE CACHE_LINE_SIZE +#endif + #define SHARED_SPACE_SIZE (2 * BUF_SIZE) #define SHARED_SPACE_VOIDPTR (SHARED_SPACE_SIZE / sizeof(void *)) diff --git a/communication_techniques/include/mcringbuffer_comm.h b/communication_techniques/include/mcringbuffer_comm.h index 70cd60e..3eee817 100644 --- a/communication_techniques/include/mcringbuffer_comm.h +++ b/communication_techniques/include/mcringbuffer_comm.h @@ -4,7 +4,7 @@ /* Non standard include */ #include -#define SHARED_SPACE_SIZE (2 * BUF_SIZE) +#define SHARED_SPACE_SIZE (250 * CACHE_LINE_SIZE) // Check with batchSize #define SHARED_SPACE_VOIDPTR (SHARED_SPACE_SIZE / sizeof(void *)) struct control diff --git a/communication_techniques/include/shared_mem_opt_comm.h b/communication_techniques/include/shared_mem_opt_comm.h index ac10518..eef3e53 100644 --- a/communication_techniques/include/shared_mem_opt_comm.h +++ b/communication_techniques/include/shared_mem_opt_comm.h @@ -4,7 +4,7 @@ /* Non standard include */ #include -#define SHARED_SPACE_SIZE (2 * BUF_SIZE) +#define SHARED_SPACE_SIZE (2 * CACHE_LINE_SIZE) #define SHARED_SPACE_VOIDPTR (SHARED_SPACE_SIZE / sizeof(void *)) struct comm diff --git a/communication_techniques/src/communication/mcringbuffer.c b/communication_techniques/src/communication/mcringbuffer.c index 1ad3771..028148c 100644 --- a/communication_techniques/src/communication/mcringbuffer.c +++ b/communication_techniques/src/communication/mcringbuffer.c @@ -9,7 +9,7 @@ __thread struct comm *comm; -const int batchSize = BUF_SIZE / sizeof(void *); +const int batchSize = 50; // Check with SHARED_SPACE_SIZE int init_library(void) {