Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix shared_malloc, add a macro for partial_sahred_malloc.
authorTom Cornebize <tom.cornebize@ensimag.grenoble-inp.fr>
Wed, 5 Apr 2017 07:46:44 +0000 (09:46 +0200)
committerTom Cornebize <tom.cornebize@ensimag.grenoble-inp.fr>
Wed, 5 Apr 2017 07:46:44 +0000 (09:46 +0200)
include/smpi/smpi.h
src/smpi/smpi_shared.cpp

index 9148b84..7f33224 100644 (file)
@@ -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)
index bed3941..7d7cced 100644 (file)
@@ -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);