- char* instance_id = (*argv)[1];
- comm_world_ = smpi_deployment_comm_world(instance_id);
- msg_bar_t bar = smpi_deployment_finalization_barrier(instance_id);
- if (bar!=nullptr) // don't overwrite the default one
- finalization_barrier_ = bar;
- instance_id_ = instance_id;
- index_ = index;
-
- static_cast<simgrid::msg::ActorExt*>(SIMIX_process_self()->userdata)->data = this;
-
- if (*argc > 3) {
- memmove(&(*argv)[0], &(*argv)[2], sizeof(char *) * (*argc - 2));
- (*argv)[(*argc) - 1] = nullptr;
- (*argv)[(*argc) - 2] = nullptr;
- }
- (*argc)-=2;
- argc_ = argc;
- argv_ = argv;
- // set the process attached to the mailbox
- mailbox_small_->setReceiver(simgrid::s4u::Actor::self());
- process_ = SIMIX_process_self();
- XBT_DEBUG("<%d> New process in the game: %p", index_, SIMIX_process_self());
+ if (comm_self_ != MPI_COMM_NULL)
+ simgrid::smpi::Comm::destroy(comm_self_);
+ if (comm_intra_ != MPI_COMM_NULL)
+ simgrid::smpi::Comm::destroy(comm_intra_);
+ xbt_os_timer_free(timer_);
+ xbt_mutex_destroy(mailboxes_mutex_);
+}
+
+void Process::set_data(int* argc, char*** argv)
+{
+ instance_id_ = std::string((*argv)[1]);
+ comm_world_ = smpi_deployment_comm_world(instance_id_);
+ msg_bar_t barrier = smpi_deployment_finalization_barrier(instance_id_);
+ if (barrier != nullptr) // don't overwrite the current one if the instance has none
+ finalization_barrier_ = barrier;
+
+ process_ = simgrid::s4u::Actor::self();
+ static_cast<simgrid::msg::ActorExt*>(process_->get_impl()->userdata)->data = this;
+
+ if (*argc > 3) {
+ memmove(&(*argv)[0], &(*argv)[2], sizeof(char*) * (*argc - 2));
+ (*argv)[(*argc) - 1] = nullptr;
+ (*argv)[(*argc) - 2] = nullptr;
+ }
+ (*argc) -= 2;
+ argc_ = argc;
+ argv_ = argv;
+ // set the process attached to the mailbox
+ mailbox_small_->setReceiver(process_);
+ XBT_DEBUG("<%ld> SMPI process has been initialized: %p", process_->get_pid(), process_.get());