X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d26f5e7bdc81826a1d2089ef8af36e9377e8fa6f..377d2091c1e0f30ef48fb068f672ae624ad59d0f:/src/smpi/smpi_global.cpp diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index 6f09f53221..ff2da6f47d 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -3,40 +3,27 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include -#include -#include -#include -#include -#include - #include "mc/mc.h" -#include "private.h" -#include "private.hpp" #include "simgrid/s4u/Mailbox.hpp" -#include "smpi/smpi_shared_malloc.hpp" -#include "simgrid/sg_config.h" -#include "src/kernel/activity/SynchroComm.hpp" -#include "src/mc/mc_record.h" -#include "src/mc/mc_replay.h" +#include "simgrid/s4u/Host.hpp" #include "src/msg/msg_private.h" #include "src/simix/smx_private.h" #include "src/surf/surf_interface.hpp" #include "src/smpi/SmpiHost.hpp" -#include "surf/surf.h" -#include "xbt/replay.hpp" -#include +#include "xbt/config.hpp" +#include "src/smpi/private.h" +#include "smpi/smpi_shared_malloc.hpp" +#include "src/smpi/smpi_coll.hpp" +#include "src/smpi/smpi_comm.hpp" +#include "src/smpi/smpi_group.hpp" +#include "src/smpi/smpi_info.hpp" +#include "src/smpi/smpi_process.hpp" +#include +#include +#include #include /* DBL_MAX */ #include -#include -#include -#include -#include -#include -#include -#include -#include #if HAVE_SENDFILE #include @@ -54,9 +41,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_kernel, smpi, "Logging specific to SMPI (ke #define RTLD_DEEPBIND 0 #endif -/* Mac OSX does not have any header file providing that definition so we have to duplicate it here. Bummers. */ -extern char** environ; /* we use it in posix_spawnp below */ - #if HAVE_PAPI #include "papi.h" const char* papi_default_config_name = "default"; @@ -86,8 +70,6 @@ static simgrid::config::Flag smpi_init_sleep( void (*smpi_comm_copy_data_callback) (smx_activity_t, void*, size_t) = &smpi_comm_copy_buffer_callback; - - int smpi_process_count() { return process_count; @@ -95,7 +77,10 @@ int smpi_process_count() simgrid::smpi::Process* smpi_process() { - simgrid::MsgActorExt* msgExt = static_cast(SIMIX_process_self()->data); + smx_actor_t me = SIMIX_process_self(); + if (me == nullptr) // This happens sometimes (eg, when linking against NS3 because it pulls openMPI...) + return nullptr; + simgrid::MsgActorExt* msgExt = static_cast(me->data); return static_cast(msgExt->data); } @@ -116,6 +101,14 @@ int smpi_process_index(){ return smpi_process()->index(); } +void * smpi_process_get_user_data(){ + return smpi_process()->get_user_data(); +} + +void smpi_process_set_user_data(void *data){ + return smpi_process()->set_user_data(data); +} + int smpi_global_size() { @@ -187,7 +180,8 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !"); smpi_switch_data_segment( - (static_cast((static_cast(comm->src_proc->data)->data))->index())); + static_cast((static_cast(comm->src_proc->data)->data)) + ->index()); tmpbuff = static_cast(xbt_malloc(buff_size)); memcpy_private(tmpbuff, buff, private_blocks); } @@ -196,7 +190,8 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b && ((char*)comm->dst_buff < smpi_start_data_exe + smpi_size_data_exe )){ XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment"); smpi_switch_data_segment( - (static_cast((static_cast(comm->dst_proc->data)->data))->index())); + static_cast((static_cast(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, private_blocks); @@ -465,6 +460,13 @@ static void smpi_init_options(){ else xbt_die("Invalid value for smpi/privatization: '%s'", smpi_privatize_option); +#if defined(__FreeBSD__) + if (smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) { + XBT_INFO("Mixing mmap privatization is broken on FreeBSD, switching to dlopen privatization instead."); + smpi_privatize_global_variables = SMPI_PRIVATIZE_DLOPEN; + } +#endif + if (smpi_cpu_threshold < 0) smpi_cpu_threshold = DBL_MAX; @@ -487,10 +489,11 @@ typedef void (*smpi_fortran_entry_point_type)(); static int smpi_run_entry_point(smpi_entry_point_type entry_point, std::vector args) { + char noarg[] = {'\0'}; const int argc = args.size(); std::unique_ptr argv(new char*[argc + 1]); for (int i = 0; i != argc; ++i) - argv[i] = args[i].empty() ? const_cast(""): &args[i].front(); + argv[i] = args[i].empty() ? noarg : &args[i].front(); argv[argc] = nullptr; int res = entry_point(argc, argv.get()); @@ -575,10 +578,10 @@ int smpi_main(const char* executable, int argc, char *argv[]) #if HAVE_SENDFILE ssize_t sent_size = sendfile(fdout, fdin, NULL, fdin_size); xbt_assert(sent_size == fdin_size, - "Error while copying %s: only %zd bytes copied instead of %zd (errno: %d -- %s)", + "Error while copying %s: only %zd bytes copied instead of %ld (errno: %d -- %s)", target_executable.c_str(), sent_size, fdin_size, errno, strerror(errno)); #else - XBT_WARN("Copy %d bytes into %s", static_cast(fdin_size), target_executable.c_str()); + XBT_VERB("Copy %d bytes into %s", static_cast(fdin_size), target_executable.c_str()); const int bufsize = 1024 * 1024 * 4; char buf[bufsize]; while (int got = read(fdin, buf, bufsize)) { @@ -603,7 +606,8 @@ int smpi_main(const char* executable, int argc, char *argv[]) // Load the copy and resolve the entry point: void* handle = dlopen(target_executable.c_str(), RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND); - unlink(target_executable.c_str()); + if (xbt_cfg_get_boolean("smpi/keep-temps") == false) + unlink(target_executable.c_str()); if (handle == nullptr) xbt_die("dlopen failed: %s (errno: %d -- %s)", dlerror(), errno, strerror(errno)); smpi_entry_point_type entry_point = smpi_resolve_function(handle); @@ -663,8 +667,8 @@ int smpi_main(const char* executable, int argc, char *argv[]) } } int count = smpi_process_count(); - int i, ret=0; - for (i = 0; i < count; i++) { + int ret = 0; + for (int i = 0; i < count; i++) { if(process_data[i]->return_value()!=0){ ret=process_data[i]->return_value();//return first non 0 value break;