Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
leaks --
[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   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     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 };
50
51
52 class Topo_Graph: public Topo {
53   private:
54     int nnodes_;
55     int nedges_;
56     int *index_;
57     int *edges_;
58   public:
59     Topo_Graph();
60     ~Topo_Graph();
61 };
62
63 class Topo_Dist_Graph: public Topo {
64   private:
65     int indegree_;
66     int *in_;
67     int *in_weights_;
68     int outdegree_;
69     int *out_;
70     int *out_weights_;
71     int is_weighted_;
72   public:
73     Topo_Dist_Graph();
74     ~Topo_Dist_Graph();
75 };
76
77 /*
78  * This is a utility function, no need to have anything in the lower layer for this at all
79  */
80 extern int Dims_create(int nnodes, int ndims, int dims[]);
81
82 }
83 }
84
85
86 #endif