namespace smpi{
class Group : public F2C{
- /* This is actually a map from int to s4u::Actor*. We could use std::map here, but looking up a value there costs
+ /* This is actually a map from int to aid_t. We could use std::map here, but looking up a value there costs
* O(log(n)). For a vector, this costs O(1). We hence go with the vector.
*/
- std::map<s4u::Actor*, int> actor_to_rank_map_;
std::vector<aid_t> rank_to_pid_map_;
std::vector<int> pid_to_rank_map_;
int rank(aid_t pid) const;
aid_t actor_pid(int rank) const;
std::string name() const override {return std::string("MPI_Group");}
- int rank(s4u::Actor* process) const;
void ref();
static void unref(MPI_Group group);
int size() const { return static_cast<int>(rank_to_pid_map_.size()); }
Group::Group(const Group* origin)
{
if (origin != MPI_GROUP_NULL && origin != MPI_GROUP_EMPTY) {
- // FIXME: cheinrich: There is no such thing as an index any more; the two maps should be removed
- rank_to_pid_map_ = origin->rank_to_pid_map_;
- pid_to_rank_map_ = origin->pid_to_rank_map_;
- actor_to_rank_map_ = origin->actor_to_rank_map_;
+ rank_to_pid_map_ = origin->rank_to_pid_map_;
+ pid_to_rank_map_ = origin->pid_to_rank_map_;
}
}
if (0 <= rank && rank < size()) {
if (static_cast<size_t>(pid) >= pid_to_rank_map_.size())
pid_to_rank_map_.resize(pid + 1, MPI_UNDEFINED);
- rank_to_pid_map_[rank] = pid;
- pid_to_rank_map_[pid] = rank;
- s4u::Actor* actor = s4u::Actor::by_pid(pid).get();
- actor_to_rank_map_.insert({actor, rank});
+ rank_to_pid_map_[rank] = pid;
+ pid_to_rank_map_[pid] = rank;
}
}
return (0 <= rank && rank < size()) ? rank_to_pid_map_[rank] : -1;
}
-int Group::rank(s4u::Actor* actor) const
-{
- auto iterator = actor_to_rank_map_.find(actor);
- //I'm not in the communicator ... but maybe my parent is ?
- if (iterator == actor_to_rank_map_.end())
- iterator = actor_to_rank_map_.find(s4u::Actor::by_pid(actor->get_ppid()).get());
- int res = (iterator == actor_to_rank_map_.end()) ? MPI_UNDEFINED : (*iterator).second;
- int rank2 = rank(actor->get_pid());
- xbt_assert(res == rank2, "res = %d, rank2 = %d", res, rank2);
- return res;
-}
-
void Group::ref()
{
refcount_++;