Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SMPI] Move a map in smpi::Group from array to std::vector
[simgrid.git] / src / smpi / include / smpi_group.hpp
1 /* Copyright (c) 2010, 2013-2017. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SMPI_GROUP_HPP_INCLUDED
8 #define SMPI_GROUP_HPP_INCLUDED
9
10 #include "smpi_f2c.hpp"
11 #include <smpi/smpi.h>
12
13 namespace simgrid{
14 namespace smpi{
15
16 class Group : public F2C{
17   private:
18     int size_;
19     /* This is actually a map from int to int. We could use
20      * std::map here, but looking up a value there costs O(log(n)).
21      * For a vector, this costs O(1). We hence go with the vector.
22      */
23     std::vector<int> rank_to_index_map_;
24     std::unordered_map<int, int> index_to_rank_map_;
25     int refcount_;
26   public:
27     explicit Group();
28     explicit Group(int size);
29     explicit Group(Group* origin);
30     ~Group();
31
32     void set_mapping(int index, int rank);
33     int index(int rank);
34     int rank(int index);
35     void ref();
36     static void unref(MPI_Group group);
37     int size();
38     int compare(MPI_Group group2);
39     int incl(int n, int* ranks, MPI_Group* newgroup);
40     int excl(int n, int *ranks, MPI_Group * newgroup);
41     int group_union(MPI_Group group2, MPI_Group* newgroup);
42     int intersection(MPI_Group group2, MPI_Group* newgroup);
43     int difference(MPI_Group group2, MPI_Group* newgroup);
44     int range_incl(int n, int ranges[][3], MPI_Group * newgroup);
45     int range_excl(int n, int ranges[][3], MPI_Group * newgroup);
46
47     static Group* f2c(int id);
48
49 };
50 }
51 }
52
53 #endif