Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #181 from bcamus/master
[simgrid.git] / src / smpi / smpi_topo.hpp
1 /* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SMPI_TOPO_HPP_INCLUDED
7 #define SMPI_TOPO_HPP_INCLUDED
8
9 #include "src/smpi/smpi_comm.hpp"
10 #include "src/smpi/smpi_status.hpp"
11
12 typedef enum MPIR_Topo_type {
13   MPI_GRAPH=1,
14   MPI_CART=2,
15   MPI_DIST_GRAPH=3,
16   MPI_INVALID_TOPO=-1
17 } MPIR_Topo_type;
18
19 typedef SMPI_Topology *MPI_Topology;
20
21 namespace simgrid{
22 namespace smpi{
23
24 class Topo {
25   public:
26     virtual ~Topo()=default;
27   protected:
28   MPI_Comm comm_;
29 };
30
31
32 class Topo_Cart: public Topo {
33   private:
34     int nnodes_ = 0;
35     int ndims_;
36     int *dims_;
37     int *periodic_;
38     int *position_;
39   public:
40     explicit Topo_Cart(int ndims);
41     ~Topo_Cart();
42     Topo_Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder, MPI_Comm *comm_cart);
43     Topo_Cart* sub(const int remain_dims[], MPI_Comm *newcomm) ;
44     int coords(int rank, int maxdims, int coords[]) ;
45     int get(int maxdims, int* dims, int* periods, int* coords);
46     int rank(int* coords, int* rank);
47     int shift(int direction, int disp, int *rank_source, int *rank_dest) ;
48     int dim_get(int *ndims);
49     static int Dims_create(int nnodes, int ndims, int dims[]);
50 };
51
52
53 class Topo_Graph: public Topo {
54   private:
55     int nnodes_;
56     int nedges_;
57     int *index_;
58     int *edges_;
59   public:
60     Topo_Graph();
61     ~Topo_Graph();
62 };
63
64 class Topo_Dist_Graph: public Topo {
65   private:
66     int indegree_;
67     int *in_;
68     int *in_weights_;
69     int outdegree_;
70     int *out_;
71     int *out_weights_;
72     int is_weighted_;
73   public:
74     Topo_Dist_Graph();
75     ~Topo_Dist_Graph();
76 };
77
78 }
79 }
80
81
82 #endif