Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #218 from Takishipp/MSG2S4U
[simgrid.git] / src / smpi / mpi / smpi_group.cpp
index bce418b..a3b3446 100644 (file)
@@ -39,7 +39,7 @@ Group::Group(MPI_Group origin)
       rank_to_index_map_[i] = origin->rank_to_index_map_[i];
     }
 
-    for (auto elm : origin->index_to_rank_map_) {
+    for (auto const& elm : origin->index_to_rank_map_) {
       index_to_rank_map_.insert({elm.first, elm.second});
     }
   }
@@ -73,11 +73,8 @@ int Group::rank(int index)
 {
   if (this == MPI_GROUP_EMPTY)
     return MPI_UNDEFINED;
-  try {
-    return index_to_rank_map_.at(index);
-  } catch (std::out_of_range& unfound) {
-    return MPI_UNDEFINED;
-  }
+  auto rank = index_to_rank_map_.find(index);
+  return rank == index_to_rank_map_.end() ? MPI_UNDEFINED : rank->second;
 }
 
 void Group::ref()
@@ -130,10 +127,8 @@ int Group::incl(int n, int* ranks, MPI_Group* newgroup)
     *newgroup = MPI_GROUP_EMPTY;
   } else if (n == size_) {
     *newgroup = this;
-    if(this!= MPI_COMM_WORLD->group()
-              && this != MPI_COMM_SELF->group()
-              && this != MPI_GROUP_EMPTY)
-    this->ref();
+    if (this != MPI_COMM_WORLD->group() && this != MPI_COMM_SELF->group() && this != MPI_GROUP_EMPTY)
+      this->ref();
   } else {
     *newgroup = new Group(n);
     for (i = 0; i < n; i++) {
@@ -355,7 +350,7 @@ MPI_Group Group::f2c(int id) {
     return MPI_GROUP_EMPTY;
   } else if(F2C::f2c_lookup() != nullptr && id >= 0) {
     char key[KEY_SIZE];
-    return static_cast<MPI_Group>(xbt_dict_get_or_null(F2C::f2c_lookup(), get_key(key, id)));
+    return static_cast<MPI_Group>(F2C::f2c_lookup()->at(get_key(key, id)));
   } else {
     return static_cast<MPI_Group>(MPI_GROUP_NULL);
   }