X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3b75c63566a0ec524832a4caa7ca320a5212a4cd..4d9809aa64447811ca65a1242d4f9e07972c6472:/src/smpi/internals/smpi_actor.cpp?ds=sidebyside diff --git a/src/smpi/internals/smpi_actor.cpp b/src/smpi/internals/smpi_actor.cpp index c358275cd4..1e43e29712 100644 --- a/src/smpi/internals/smpi_actor.cpp +++ b/src/smpi/internals/smpi_actor.cpp @@ -61,20 +61,14 @@ ActorExt::~ActorExt() xbt_mutex_destroy(mailboxes_mutex_); } -void ActorExt::set_data(int* argc, char*** argv) +void ActorExt::set_data(const char* instance_id) { - instance_id_ = std::string((*argv)[1]); + instance_id_ = std::string(instance_id); comm_world_ = smpi_deployment_comm_world(instance_id_); simgrid::s4u::Barrier* barrier = smpi_deployment_finalization_barrier(instance_id_); if (barrier != nullptr) // don't overwrite the current one if the instance has none finalization_barrier_ = barrier; - if (*argc > 3) { - memmove(&(*argv)[0], &(*argv)[2], sizeof(char*) * (*argc - 2)); - (*argv)[(*argc) - 1] = nullptr; - (*argv)[(*argc) - 2] = nullptr; - } - (*argc) -= 2; // set the process attached to the mailbox mailbox_small_->set_receiver(actor_); XBT_DEBUG("<%ld> SMPI process has been initialized: %p", actor_->get_pid(), actor_.get()); @@ -233,42 +227,36 @@ int ActorExt::sampling() return sampling_; } -void ActorExt::init(int* argc, char*** argv) +void ActorExt::init() { - if (smpi_process_count() == 0) { xbt_die("SimGrid was not initialized properly before entering MPI_Init. Aborting, please check compilation process " "and use smpirun\n"); } - if (argc != nullptr && argv != nullptr) { - simgrid::s4u::ActorPtr proc = simgrid::s4u::Actor::self(); - proc->get_impl()->context_->set_cleanup(&SIMIX_process_cleanup); - // cheinrich: I'm not sure what the impact of the SMPI_switch_data_segment on this call is. I moved - // this up here so that I can set the privatized region before the switch. - ActorExt* process = smpi_process_remote(proc); - //if we are in MPI_Init and argc handling has already been done. - if (process->initialized()) - return; - - process->state_ = SmpiProcessState::INITIALIZING; - - char* instance_id = (*argv)[1]; - try { - int rank = std::stoi(std::string((*argv)[2])); - smpi_deployment_register_process(instance_id, rank, proc); - } catch (std::invalid_argument& ia) { - throw std::invalid_argument(std::string("Invalid rank: ") + (*argv)[2]); - } - if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) { - /* Now using the segment index of this process */ - process->set_privatized_region(smpi_init_global_memory_segment_process()); - /* Done at the process's creation */ - SMPI_switch_data_segment(proc); - } + simgrid::s4u::ActorPtr proc = simgrid::s4u::Actor::self(); + proc->get_impl()->context_->set_cleanup(&SIMIX_process_cleanup); + // cheinrich: I'm not sure what the impact of the SMPI_switch_data_segment on this call is. I moved + // this up here so that I can set the privatized region before the switch. + ActorExt* process = smpi_process_remote(proc); + // if we are in MPI_Init and argc handling has already been done. + if (process->initialized()) + return; + + if (smpi_privatize_global_variables == SmpiPrivStrategies::MMAP) { + /* Now using the segment index of this process */ + process->set_privatized_region(smpi_init_global_memory_segment_process()); + /* Done at the process's creation */ + SMPI_switch_data_segment(proc); + } + + const char* instance_id = simgrid::s4u::Actor::self()->get_property("instance_id"); + const int rank = xbt_str_parse_int(simgrid::s4u::Actor::self()->get_property("rank"), "Cannot parse rank"); + + process->state_ = SmpiProcessState::INITIALIZING; + smpi_deployment_register_process(instance_id, rank, proc); - process->set_data(argc, argv); - } + process->set_data(instance_id); } int ActorExt::get_optind()