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, "(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);
}
}
-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) {
- 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.");
}
}
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);
}
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);
}
#include "private.h"
#include "private.hpp"
+#include "smpi/smpi_shared_malloc.hpp"
#include "xbt/dict.h"
#include <errno.h>
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);
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)
* 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;
#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].
-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) {
}
// 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].
-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
#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].
-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) {
}
// 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].
-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