X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8914cdf67bb2cdd7b64e6eeef5b06c29b24c3c96..d77b02b38c73cf34e18a45339d3c3cf8cd23c72b:/src/smpi/internals/smpi_global.cpp diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 0e46a5291d..84f00e4418 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -57,6 +57,7 @@ std::unordered_map location2speedup; static std::map process_data; int process_count = 0; +static int smpi_exit_status = 0; int smpi_universe_size = 0; extern double smpi_total_benched_time; xbt_os_timer_t global_timer; @@ -418,7 +419,8 @@ static int smpi_run_entry_point(smpi_entry_point_type entry_point, std::vectorset_return_value(res); + if (smpi_exit_status == 0) + smpi_exit_status = res; } return 0; } @@ -491,7 +493,8 @@ int smpi_main(const char* executable, int argc, char *argv[]) + "_" + std::to_string(rank++) + ".so"; int fdin = open(executable_copy.c_str(), O_RDONLY); - xbt_assert(fdin >= 0, "Cannot read from %s", executable_copy.c_str()); + xbt_assert(fdin >= 0, "Cannot read from %s. Please make sure that the file exists and is executable.", + executable_copy.c_str()); int fdout = open(target_executable.c_str(), O_CREAT | O_RDWR, S_IRWXU); xbt_assert(fdout >= 0, "Cannot write into %s", target_executable.c_str()); @@ -543,7 +546,7 @@ int smpi_main(const char* executable, int argc, char *argv[]) else { // Load the dynamic library and resolve the entry point: - void* handle = dlopen(executable, RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND); + void* handle = dlopen(executable, RTLD_LAZY | RTLD_LOCAL); if (handle == nullptr) xbt_die("dlopen failed for %s: %s (errno: %d -- %s)", executable, dlerror(), errno, strerror(errno)); smpi_entry_point_type entry_point = smpi_resolve_function(handle); @@ -563,7 +566,7 @@ int smpi_main(const char* executable, int argc, char *argv[]) SMPI_init(); SIMIX_launch_application(argv[2]); SMPI_app_instance_register(smpi_default_instance_name, nullptr, - SIMIX_process_count()); // This call has a side effect on process_count... + process_data.size()); // This call has a side effect on process_count... MPI_COMM_WORLD = *smpi_deployment_comm_world(smpi_default_instance_name); smpi_universe_size = process_count; @@ -591,30 +594,25 @@ int smpi_main(const char* executable, int argc, char *argv[]) "You may want to use sampling functions or trace replay to reduce this."); } } - int ret = 0; - for (auto& pair : process_data) { - auto& smpi_process = pair.second; - if (smpi_process->return_value() != 0) { - ret = smpi_process->return_value(); // return first non 0 value - break; - } - } smpi_global_destroy(); TRACE_end(); - return ret; + return smpi_exit_status; } // Called either directly from the user code, or from the code called by smpirun void SMPI_init(){ simgrid::s4u::Actor::onCreation.connect([](simgrid::s4u::ActorPtr actor) { - process_data.insert({actor, new simgrid::smpi::Process(actor, nullptr)}); + if (not actor->isDaemon()) { + process_data.insert({actor, new simgrid::smpi::Process(actor, nullptr)}); + } }); simgrid::s4u::Actor::onDestruction.connect([](simgrid::s4u::ActorPtr actor) { - if (process_data.find(actor) != process_data.end()) { - delete process_data.at(actor); - process_data.erase(actor); + auto it = process_data.find(actor); + if (it != process_data.end()) { + delete it->second; + process_data.erase(it); } });