}
static void print(std::vector<std::pair<size_t, size_t>> vec) {
- fprintf(stderr, "{");
- for(auto elt: vec) {
- fprintf(stderr, "(0x%lx, 0x%lx),", elt.first, elt.second);
+ std::fprintf(stderr, "{");
+ for (auto elt : vec) {
+ std::fprintf(stderr, "(0x%zx, 0x%zx),", elt.first, elt.second);
}
- fprintf(stderr, "}\n");
+ std::fprintf(stderr, "}\n");
}
-static 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, 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 smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t buff_size)
{
simgrid::kernel::activity::Comm *comm = dynamic_cast<simgrid::kernel::activity::Comm*>(synchro);
- int src_shared=0, dst_shared=0;
- size_t src_offset=0, dst_offset=0;
+ int src_shared = 0;
+ int dst_shared = 0;
+ size_t src_offset = 0;
+ size_t dst_offset = 0;
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");
smpi_switch_data_segment(
(static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->src_proc->data)->data))->index()));
tmpbuff = static_cast<void*>(xbt_malloc(buff_size));
- memcpy_private(tmpbuff, buff, buff_size, private_blocks);
+ memcpy_private(tmpbuff, buff, private_blocks);
}
if((smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) && ((char*)comm->dst_buff >= smpi_start_data_exe)
(static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->dst_proc->data)->data))->index()));
}
XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff,comm->dst_buff);
- memcpy_private(comm->dst_buff, tmpbuff, buff_size, private_blocks);
+ memcpy_private(comm->dst_buff, tmpbuff, private_blocks);
if (comm->detached) {
// if this is a detached send, the source buffer was duplicated by SMPI
}
static void smpi_init_options(){
-
+ //return if already called
+ if(smpi_cpu_threshold!=-1)
+ return;
simgrid::smpi::Colls::set_collectives();
simgrid::smpi::Colls::smpi_coll_cleanup_callback=nullptr;
smpi_cpu_threshold = xbt_cfg_get_double("smpi/cpu-threshold");
}
}
-static int execute_command(const char * const argv[])
-{
- pid_t pid;
- int status;
- if (posix_spawnp(&pid, argv[0], nullptr, nullptr, (char* const*) argv, environ) != 0)
- return 127;
- if (waitpid(pid, &status, 0) != pid)
- return 127;
- return status;
-}
-
typedef std::function<int(int argc, char *argv[])> smpi_entry_point_type;
typedef int (* smpi_c_entry_point_type)(int argc, char **argv);
typedef void (* smpi_fortran_entry_point_type)(void);
static std::size_t rank = 0;
+ smpi_init_options();
+
if (smpi_privatize_global_variables == SMPI_PRIVATIZE_DLOPEN) {
std::string executable_copy = executable;