From 6b9777cb9bdd646ce87e5fc57315146d23fa628f Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Thu, 25 Jun 2009 14:01:18 +0200 Subject: [PATCH] Align shared_mem and initial jikes buffer --- communication_techniques/src/communication/jikes_barrier.c | 3 +-- communication_techniques/src/communication/shared_mem.c | 3 +-- communication_techniques/src/communication/shared_mem_opt.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/communication_techniques/src/communication/jikes_barrier.c b/communication_techniques/src/communication/jikes_barrier.c index 0676975..4c0c45a 100644 --- a/communication_techniques/src/communication/jikes_barrier.c +++ b/communication_techniques/src/communication/jikes_barrier.c @@ -38,8 +38,7 @@ int init_thread_comm(struct thread_comm *comm) { void **new_buffer; - new_buffer = (void **) malloc(BUFFER_SIZE); - if (new_buffer == NULL) + if (posix_memalign((void *) &new_buffer, CACHE_LINE_SIZE, BUFFER_SIZE)) { fprintf(stderr, "Failed to allocate a new buffer for the thread\n"); return -1; diff --git a/communication_techniques/src/communication/shared_mem.c b/communication_techniques/src/communication/shared_mem.c index e96c5f9..0ca39d1 100644 --- a/communication_techniques/src/communication/shared_mem.c +++ b/communication_techniques/src/communication/shared_mem.c @@ -15,8 +15,7 @@ __thread volatile int prod_idx = 0; int init_thread_comm(struct thread_comm *comm) { - shared_space = (volatile void **) malloc(SHARED_SPACE_SIZE); - if (shared_space == NULL) + if (posix_memalign((void *) &shared_space, CACHE_LINE_SIZE, SHARED_SPACE_SIZE)) { fprintf(stderr, "Unable to allocate space for shared mem communication\n"); return -1; diff --git a/communication_techniques/src/communication/shared_mem_opt.c b/communication_techniques/src/communication/shared_mem_opt.c index df726c7..64e58ad 100644 --- a/communication_techniques/src/communication/shared_mem_opt.c +++ b/communication_techniques/src/communication/shared_mem_opt.c @@ -15,8 +15,7 @@ __thread volatile int prod_idx = 0; int init_thread_comm(struct thread_comm *comm) { - shared_space = (volatile void **) malloc(SHARED_SPACE_SIZE); - if (shared_space == NULL) + if (posix_memalign((void *) &shared_space, CACHE_LINE_SIZE, SHARED_SPACE_SIZE)) { fprintf(stderr, "Unable to allocate space for shared mem communication\n"); return -1;