Logo AND Algorithmique Numérique Distribuée

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