Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Please sonar. Hopefully a lot.
[simgrid.git] / src / smpi / smpi_topo.hpp
1 /* Copyright (c) 2010-2015. 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_TOPO_HPP_INCLUDED
8 #define SMPI_TOPO_HPP_INCLUDED
9
10 #include "private.h"
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   protected:
26   MPI_Comm comm_;
27 };
28
29
30 class Topo_Cart: public Topo {
31   private:
32     int nnodes_ = 0;
33     int ndims_;
34     int *dims_;
35     int *periodic_;
36     int *position_;
37   public:
38     Topo_Cart(int ndims);
39     ~Topo_Cart();
40     Topo_Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder, MPI_Comm *comm_cart);
41     Topo_Cart* sub(const int remain_dims[], MPI_Comm *newcomm) ;
42     int coords(int rank, int maxdims, int coords[]) ;
43     int get(int maxdims, int* dims, int* periods, int* coords);
44     int rank(int* coords, int* rank);
45     int shift(int direction, int disp, int *rank_source, int *rank_dest) ;
46     int dim_get(int *ndims);
47 };
48
49
50 class Topo_Graph: public Topo {
51   private:
52     int nnodes_;
53     int nedges_;
54     int *index_;
55     int *edges_;
56   public:
57     Topo_Graph();
58     ~Topo_Graph();
59 };
60
61 class Topo_Dist_Graph: public Topo {
62   private:
63     int indegree_;
64     int *in_;
65     int *in_weights_;
66     int outdegree_;
67     int *out_;
68     int *out_weights_;
69     int is_weighted_;
70   public:
71     Topo_Dist_Graph();
72     ~Topo_Dist_Graph();
73 };
74
75 /*
76  * This is a utility function, no need to have anything in the lower layer for this at all
77  */
78 extern int Dims_create(int nnodes, int ndims, int dims[]);
79
80 }
81 }
82
83
84 #endif