+MPI_Comm Comm::find_intra_comm(int * leader){
+ //get the indices of all processes sharing the same simix host
+ auto& process_list = sg_host_self()->pimpl_->process_list_;
+ int intra_comm_size = 0;
+ int min_index = INT_MAX; // the minimum index will be the leader
+ for (auto& actor : process_list) {
+ int index = actor.get_pid();
+ if (this->group()->rank(actor.iface()) != MPI_UNDEFINED) { // Is this process in the current group?
+ intra_comm_size++;
+ if (index < min_index)
+ min_index = index;
+ }
+ }
+ XBT_DEBUG("number of processes deployed on my node : %d", intra_comm_size);
+ MPI_Group group_intra = new Group(intra_comm_size);
+ int i = 0;
+ for (auto& actor : process_list) {
+ if (this->group()->rank(actor.iface()) != MPI_UNDEFINED) {
+ group_intra->set_mapping(actor.iface(), i);
+ i++;
+ }
+ }
+ *leader=min_index;
+ return new Comm(group_intra, nullptr, 1);
+}
+