From bd5e118712d756ae393cf9c56b893eddfcd37f8a Mon Sep 17 00:00:00 2001 From: Tom Cornebize Date: Wed, 5 Apr 2017 09:46:44 +0200 Subject: [PATCH 1/1] Fix shared_malloc, add a macro for partial_sahred_malloc. --- include/smpi/smpi.h | 3 +++ src/smpi/smpi_shared.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 9148b84fbc..7f332247e5 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -875,6 +875,9 @@ XBT_PUBLIC(void) smpi_trace_set_call_location__(const char *file, int* line); XBT_PUBLIC(int) smpi_is_shared(void *buf); XBT_PUBLIC(void *) smpi_shared_malloc(size_t size, const char *file, int line); #define SMPI_SHARED_MALLOC(size) smpi_shared_malloc(size, __FILE__, __LINE__) +XBT_PUBLIC(void *) smpi_shared_malloc_global__(size_t size, const char *file, int line, int *shared_block_offsets, int nb_shared_blocks); +#define SMPI_PARTIAL_SHARED_MALLOC(size, shared_block_offsets, nb_shared_blocks)\ + smpi_shared_malloc_global__(size, __FILE__, __LINE__, shared_block_offsets, nb_shared_blocks) XBT_PUBLIC(void) smpi_shared_free(void *data); #define SMPI_SHARED_FREE(data) smpi_shared_free(data) diff --git a/src/smpi/smpi_shared.cpp b/src/smpi/smpi_shared.cpp index bed3941fec..7d7cced34c 100644 --- a/src/smpi/smpi_shared.cpp +++ b/src/smpi/smpi_shared.cpp @@ -236,7 +236,7 @@ void *smpi_shared_malloc_global__(size_t size, const char *file, int line, int * int start_offset = ALIGN_UP(shared_block_offsets[2*i_block], smpi_shared_malloc_blocksize); int stop_offset = ALIGN_DOWN(shared_block_offsets[2*i_block+1], smpi_shared_malloc_blocksize); unsigned int i; - for (i = start_offset; i < stop_offset / smpi_shared_malloc_blocksize; i++) { + for (i = start_offset / smpi_shared_malloc_blocksize; i < stop_offset / smpi_shared_malloc_blocksize; i++) { void* pos = (void*)((unsigned long)mem + i * smpi_shared_malloc_blocksize); void* res = mmap(pos, smpi_shared_malloc_blocksize, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED | MAP_POPULATE, smpi_shared_malloc_bogusfile, 0); -- 2.20.1