-/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
refcount_ = 1; /* refcount_: start > 0 so that this group never gets freed */
}
-Group::Group(int n) : size_(n), rank_to_actor_map_(size_, nullptr)
+Group::Group(int n) : size_(n), rank_to_actor_map_(size_, nullptr), index_to_rank_map_(size_, MPI_UNDEFINED)
{
refcount_ = 1;
}
if (origin != MPI_GROUP_NULL && origin != MPI_GROUP_EMPTY) {
size_ = origin->size();
refcount_ = 1;
+ // FIXME: cheinrich: There is no such thing as an index any more; the two maps should be removed
+ index_to_rank_map_ = origin->index_to_rank_map_;
rank_to_actor_map_ = origin->rank_to_actor_map_;
actor_to_rank_map_ = origin->actor_to_rank_map_;
}
{
if (0 <= rank && rank < size_) {
int index = actor->get_pid();
+ if (index != MPI_UNDEFINED) {
+ if ((unsigned)index >= index_to_rank_map_.size())
+ index_to_rank_map_.resize(index + 1, MPI_UNDEFINED);
+ index_to_rank_map_[index] = rank;
+ }
rank_to_actor_map_[rank] = actor;
if (actor != nullptr) {
}
}
+int Group::rank(int index)
+{
+ int rank;
+ if (0 <= index && (unsigned)index < index_to_rank_map_.size())
+ rank = index_to_rank_map_[index];
+ else
+ rank = MPI_UNDEFINED;
+
+ return rank;
+}
+
simgrid::s4u::ActorPtr Group::actor(int rank) {
if (0 <= rank && rank < size_)
return rank_to_actor_map_[rank];