}
const std::string name_;
- int size_;
- std::vector<simgrid::s4u::ActorPtr> present_processes_;
+ unsigned int size_;
unsigned int finalized_ranks_ = 0;
MPI_Comm comm_world_;
};
if (code != nullptr) // When started with smpirun, we will not execute a function
simgrid::s4u::Engine::get_instance()->register_function(name, code);
- static bool already_called = false;
- if (not already_called) {
- already_called = true;
- for (auto const& host : simgrid::s4u::Engine::get_instance()->get_all_hosts())
- host->extension_set(new simgrid::smpi::Host(host));
- }
-
Instance instance(std::string(name), num_processes, MPI_COMM_NULL);
smpi_instances.insert(std::pair<std::string, Instance>(name, instance));
}
-void smpi_deployment_register_process(const std::string& instance_id, int rank, simgrid::s4u::ActorPtr actor)
+void smpi_deployment_register_process(const std::string& instance_id, int rank, simgrid::s4u::Actor* actor)
{
- Instance& instance = smpi_instances.at(instance_id);
-
- instance.present_processes_.push_back(actor);
+ const Instance& instance = smpi_instances.at(instance_id);
instance.comm_world_->group()->set_mapping(actor, rank);
}
void smpi_deployment_unregister_process(const std::string& instance_id)
{
Instance& instance = smpi_instances.at(instance_id);
-
instance.finalized_ranks_++;
- if (instance.finalized_ranks_ == instance.present_processes_.size()) {
- instance.present_processes_.clear();
+
+ if (instance.finalized_ranks_ == instance.size_) {
simgrid::smpi::Comm::destroy(instance.comm_world_);
smpi_instances.erase(instance_id);
}
MPI_Comm* smpi_deployment_comm_world(const std::string& instance_id)
{
- if (smpi_instances.empty()) { // no instance registered, we probably used smpirun.
+ if (smpi_instances
+ .empty()) { // no instance registered, we probably used smpirun. (FIXME: I guess this never happens for real)
return nullptr;
}
Instance& instance = smpi_instances.at(instance_id);
for (auto const& item : smpi_instances) {
XBT_CINFO(smpi, "Stalling SMPI instance: %s. Do all your MPI ranks call MPI_Finalize()?", item.first.c_str());
Instance instance = item.second;
- instance.present_processes_.clear();
simgrid::smpi::Comm::destroy(instance.comm_world_);
}
smpi_instances.clear();