Logo AND Algorithmique Numérique Distribuée

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