Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / smpi / include / smpi_topo.hpp
1 /* Copyright (c) 2010-2022. 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 "smpi_comm.hpp"
10 #include "smpi_status.hpp"
11 #include <memory>
12
13 using MPI_Topology = std::shared_ptr<SMPI_Topology>;
14
15 namespace simgrid{
16 namespace smpi{
17
18 class Topo {
19   MPI_Comm comm_ = MPI_COMM_NULL;
20
21 public:
22   virtual ~Topo() = default;
23   MPI_Comm getComm() const { return comm_; }
24   void setComm(MPI_Comm comm);
25 };
26
27 class Topo_Cart: public Topo {
28   int nnodes_ = 0;
29   int ndims_;
30   std::vector<int> dims_;
31   std::vector<int> periodic_;
32   std::vector<int> position_;
33
34 public:
35   explicit Topo_Cart(int ndims);
36   Topo_Cart(MPI_Comm comm_old, int ndims, const int dims[], const int periods[], int reorder, MPI_Comm* comm_cart);
37   Topo_Cart* sub(const int remain_dims[], MPI_Comm* newcomm);
38   int coords(int rank, int maxdims, int coords[]);
39   int get(int maxdims, int* dims, int* periods, int* coords);
40   int rank(const int* coords, int* rank);
41   int shift(int direction, int disp, int* rank_source, int* rank_dest);
42   int dim_get(int* ndims) const;
43   static int Dims_create(int nnodes, int ndims, int dims[]);
44 };
45
46
47 class Topo_Graph: public Topo {
48   std::vector<int> index_;
49   std::vector<int> edges_;
50 };
51
52 class Topo_Dist_Graph: public Topo {
53   std::vector<int> in_;
54   std::vector<int> in_weights_;
55   std::vector<int> out_;
56   std::vector<int> out_weights_;
57 };
58
59 }
60 }
61
62
63 #endif