Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
jedule: obey our coding standards
[simgrid.git] / src / smpi / include / smpi_group.hpp
1 /* Copyright (c) 2010-2018. 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 #include <map>
13 #include <vector>
14
15 namespace simgrid{
16 namespace smpi{
17
18 class Group : public F2C{
19   private:
20     int size_;
21     /* This is actually a map from int to int. We could use
22      * std::map here, but looking up a value there costs O(log(n)).
23      * For a vector, this costs O(1). We hence go with the vector.
24      */
25     std::vector<simgrid::s4u::ActorPtr> rank_to_actor_map_;
26     std::map<simgrid::s4u::ActorPtr, int> actor_to_rank_map_;
27     std::vector<int> rank_to_index_map_;
28     std::vector<int> index_to_rank_map_;
29
30     int refcount_;
31   public:
32     explicit Group();
33     explicit Group(int size);
34     explicit Group(Group* origin);
35
36     void set_mapping(simgrid::s4u::ActorPtr actor, int rank);
37     int rank(int index);
38     simgrid::s4u::ActorPtr actor(int rank);
39     int rank(const simgrid::s4u::ActorPtr process);
40     void ref();
41     static void unref(MPI_Group group);
42     int size();
43     int compare(MPI_Group group2);
44     int incl(int n, int* ranks, MPI_Group* newgroup);
45     int excl(int n, int *ranks, MPI_Group * newgroup);
46     int group_union(MPI_Group group2, MPI_Group* newgroup);
47     int intersection(MPI_Group group2, MPI_Group* newgroup);
48     int difference(MPI_Group group2, MPI_Group* newgroup);
49     int range_incl(int n, int ranges[][3], MPI_Group * newgroup);
50     int range_excl(int n, int ranges[][3], MPI_Group * newgroup);
51
52     static Group* f2c(int id);
53
54 };
55 }
56 }
57
58 #endif