Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove warnings.
authorTom Cornebize <tom.cornebize@ensimag.grenoble-inp.fr>
Tue, 11 Apr 2017 14:40:41 +0000 (16:40 +0200)
committerTom Cornebize <tom.cornebize@ensimag.grenoble-inp.fr>
Tue, 11 Apr 2017 14:40:41 +0000 (16:40 +0200)
src/smpi/smpi_global.cpp
src/smpi/smpi_shared.cpp
teshsuite/smpi/macro-partial-shared-communication/macro-partial-shared-communication.c
teshsuite/smpi/macro-partial-shared/macro-partial-shared.c

index f81d6fc..c29f0ca 100644 (file)
@@ -104,22 +104,22 @@ void smpi_comm_set_copy_data_callback(void (*callback) (smx_activity_t, void*, s
   smpi_comm_copy_data_callback = callback;
 }
 
   smpi_comm_copy_data_callback = callback;
 }
 
-void print(std::vector<std::pair<size_t, size_t>> vec) {
+static void print(std::vector<std::pair<size_t, size_t>> vec) {
     fprintf(stderr, "{");
     for(auto elt: vec) {
     fprintf(stderr, "{");
     for(auto elt: vec) {
-        fprintf(stderr, "(0x%x, 0x%x),", elt.first, elt.second);
+        fprintf(stderr, "(0x%lx, 0x%lx),", elt.first, elt.second);
     }
     }
-    stderr, fprintf(stderr, "}\n");
+    fprintf(stderr, "}\n");
 }
 }
-void memcpy_private(void *dest, const void *src, size_t n, std::vector<std::pair<size_t, size_t>> &private_blocks) {
+static void memcpy_private(void *dest, const void *src, size_t n, std::vector<std::pair<size_t, size_t>> &private_blocks) {
   for(auto block : private_blocks) {
     memcpy((uint8_t*)dest+block.first, (uint8_t*)src+block.first, block.second-block.first);
   }
 }
 
   for(auto block : private_blocks) {
     memcpy((uint8_t*)dest+block.first, (uint8_t*)src+block.first, block.second-block.first);
   }
 }
 
-void check_blocks(std::vector<std::pair<size_t, size_t>> &private_blocks, size_t buff_size) {
+static void check_blocks(std::vector<std::pair<size_t, size_t>> &private_blocks, size_t buff_size) {
   for(auto block : private_blocks) {
   for(auto block : private_blocks) {
-    xbt_assert(block.first >= 0 && block.second <= buff_size, "Oops, bug in shared malloc.");
+    xbt_assert(block.first <= block.second && block.second <= buff_size, "Oops, bug in shared malloc.");
   }
 }
 
   }
 }
 
@@ -131,7 +131,7 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b
   std::vector<std::pair<size_t, size_t>> src_private_blocks;
   std::vector<std::pair<size_t, size_t>> dst_private_blocks;
   XBT_DEBUG("Copy the data over");
   std::vector<std::pair<size_t, size_t>> src_private_blocks;
   std::vector<std::pair<size_t, size_t>> dst_private_blocks;
   XBT_DEBUG("Copy the data over");
-  if(src_shared=smpi_is_shared(buff, src_private_blocks, &src_offset)) {
+  if((src_shared=smpi_is_shared(buff, src_private_blocks, &src_offset))) {
     XBT_DEBUG("Sender %p is shared. Let's ignore it.", buff);
     src_private_blocks = shift_and_frame_private_blocks(src_private_blocks, src_offset, buff_size);
   }
     XBT_DEBUG("Sender %p is shared. Let's ignore it.", buff);
     src_private_blocks = shift_and_frame_private_blocks(src_private_blocks, src_offset, buff_size);
   }
@@ -139,7 +139,7 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b
     src_private_blocks.clear();
     src_private_blocks.push_back(std::make_pair(0, buff_size));
   }
     src_private_blocks.clear();
     src_private_blocks.push_back(std::make_pair(0, buff_size));
   }
-  if(dst_shared=smpi_is_shared((char*)comm->dst_buff, dst_private_blocks, &dst_offset)) {
+  if((dst_shared=smpi_is_shared((char*)comm->dst_buff, dst_private_blocks, &dst_offset))) {
     XBT_DEBUG("Receiver %p is shared. Let's ignore it.", (char*)comm->dst_buff);
     dst_private_blocks = shift_and_frame_private_blocks(dst_private_blocks, dst_offset, buff_size);
   }
     XBT_DEBUG("Receiver %p is shared. Let's ignore it.", (char*)comm->dst_buff);
     dst_private_blocks = shift_and_frame_private_blocks(dst_private_blocks, dst_offset, buff_size);
   }
index e6b8311..39a3369 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "private.h"
 #include "private.hpp"
 
 #include "private.h"
 #include "private.hpp"
+#include "smpi/smpi_shared_malloc.hpp"
 #include "xbt/dict.h"
 #include <errno.h>
 
 #include "xbt/dict.h"
 #include <errno.h>
 
@@ -169,7 +170,7 @@ static void* shm_map(int fd, size_t size, shared_data_key_type* data) {
   return mem;
 }
 
   return mem;
 }
 
-void *smpi_shared_malloc_local(size_t size, const char *file, int line)
+static void *smpi_shared_malloc_local(size_t size, const char *file, int line)
 {
   void* mem;
   smpi_source_location loc(file, line);
 {
   void* mem;
   smpi_source_location loc(file, line);
@@ -238,7 +239,6 @@ void *smpi_shared_malloc_global__(size_t size, const char *file, int line, size_
   for(int i_block = 0; i_block < nb_shared_blocks; i_block ++) {
     size_t start_offset = shared_block_offsets[2*i_block];
     size_t stop_offset = shared_block_offsets[2*i_block+1];
   for(int i_block = 0; i_block < nb_shared_blocks; i_block ++) {
     size_t start_offset = shared_block_offsets[2*i_block];
     size_t stop_offset = shared_block_offsets[2*i_block+1];
-    xbt_assert(0 <= start_offset,          "start_offset (%lu) should be greater than 0", start_offset);
     xbt_assert(start_offset < stop_offset, "start_offset (%lu) should be lower than stop offset (%lu)", start_offset, stop_offset);
     xbt_assert(stop_offset <= size,         "stop_offset (%lu) should be lower than size (%lu)", stop_offset, size);
     if(i_block < nb_shared_blocks-1)
     xbt_assert(start_offset < stop_offset, "start_offset (%lu) should be lower than stop offset (%lu)", start_offset, stop_offset);
     xbt_assert(stop_offset <= size,         "stop_offset (%lu) should be lower than size (%lu)", stop_offset, size);
     if(i_block < nb_shared_blocks-1)
@@ -314,7 +314,7 @@ void *smpi_shared_malloc_global__(size_t size, const char *file, int line, size_
  * Even indices are the start offsets (included), odd indices are the stop offsets (excluded).
  * For instance, if shared_block_offsets == {27, 42}, then the elements mem[27], mem[28], ..., mem[41] are shared. The others are not.
  */
  * Even indices are the start offsets (included), odd indices are the stop offsets (excluded).
  * For instance, if shared_block_offsets == {27, 42}, then the elements mem[27], mem[28], ..., mem[41] are shared. The others are not.
  */
-void *smpi_shared_malloc_global(size_t size, const char *file, int line, size_t *shared_block_offsets=NULL, int nb_shared_blocks=-1) {
+static void *smpi_shared_malloc_global(size_t size, const char *file, int line, size_t *shared_block_offsets=NULL, int nb_shared_blocks=-1) {
   size_t tmp_shared_block_offsets[2];
   if(nb_shared_blocks == -1) {
     nb_shared_blocks = 1;
   size_t tmp_shared_block_offsets[2];
   if(nb_shared_blocks == -1) {
     nb_shared_blocks = 1;
index 440a41e..afed268 100644 (file)
 #include <assert.h>
 
 // Set the elements between buf[start] and buf[stop-1] to (i+value)%256
 #include <assert.h>
 
 // Set the elements between buf[start] and buf[stop-1] to (i+value)%256
-void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
   for(size_t i = start; i < stop; i++) {
     buf[i] = (i+value)%256;
   }
 }
 
 // Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1].
   for(size_t i = start; i < stop; i++) {
     buf[i] = (i+value)%256;
   }
 }
 
 // Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1].
-int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static  int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
   size_t occ = 0;
   for(size_t i = start ; i < stop ; i++) {
     if(buf[i] == (i+value)%256) {
   size_t occ = 0;
   for(size_t i = start ; i < stop ; i++) {
     if(buf[i] == (i+value)%256) {
@@ -29,13 +29,13 @@ int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
 }
 
 // Return true iff the values from buf[start] to buf[stop-1] are all equal to (i+value)%256.
 }
 
 // Return true iff the values from buf[start] to buf[stop-1] are all equal to (i+value)%256.
-int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
   size_t occ = count_all(buf, start, stop, value);
   return occ == stop-start;
 }
 
 // Return true iff "enough" elements are equal to (i+value)%256 between buf[start] and buf[stop-1].
   size_t occ = count_all(buf, start, stop, value);
   return occ == stop-start;
 }
 
 // Return true iff "enough" elements are equal to (i+value)%256 between buf[start] and buf[stop-1].
-int check_enough(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int check_enough(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
   int page_size = 0x1000;
   size_t size = stop-start;
   if(size <= 2*page_size) // we are not sure to have a whole page that is shared
   int page_size = 0x1000;
   size_t size = stop-start;
   if(size <= 2*page_size) // we are not sure to have a whole page that is shared
index 18aafd8..305810e 100644 (file)
 #include <inttypes.h>
 
 // Set the elements between buf[start] and buf[stop-1] to (i+value)%256
 #include <inttypes.h>
 
 // Set the elements between buf[start] and buf[stop-1] to (i+value)%256
-void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
   for(size_t i = start; i < stop; i++) {
     buf[i] = (i+value)%256;
   }
 }
 
 // Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1].
   for(size_t i = start; i < stop; i++) {
     buf[i] = (i+value)%256;
   }
 }
 
 // Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1].
-int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
   size_t occ = 0;
   for(size_t i = start ; i < stop ; i++) {
     if(buf[i] == (i+value)%256) {
   size_t occ = 0;
   for(size_t i = start ; i < stop ; i++) {
     if(buf[i] == (i+value)%256) {
@@ -28,13 +28,13 @@ int count_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
 }
 
 // Return true iff the values from buf[start] to buf[stop-1] are all equal to (i+value)%256.
 }
 
 // Return true iff the values from buf[start] to buf[stop-1] are all equal to (i+value)%256.
-int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int check_all(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
   size_t occ = count_all(buf, start, stop, value);
   return occ == stop-start;
 }
 
 // Return true iff "enough" elements are equal to (i+value)%256 between buf[start] and buf[stop-1].
   size_t occ = count_all(buf, start, stop, value);
   return occ == stop-start;
 }
 
 // Return true iff "enough" elements are equal to (i+value)%256 between buf[start] and buf[stop-1].
-int check_enough(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
+static int check_enough(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
   int page_size = 0x1000;
   size_t size = stop-start;
   if(size <= 2*page_size) // we are not sure to have a whole page that is shared
   int page_size = 0x1000;
   size_t size = stop-start;
   if(size <= 2*page_size) // we are not sure to have a whole page that is shared