1 /* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SMPI_TOPO_HPP_INCLUDED
7 #define SMPI_TOPO_HPP_INCLUDED
9 #include "smpi_comm.hpp"
10 #include "smpi_status.hpp"
12 typedef SMPI_Topology *MPI_Topology;
21 virtual ~Topo() = default;
22 MPI_Comm getComm() const { return comm_; }
23 void setComm(MPI_Comm comm) { comm_ = comm; }
26 class Topo_Cart: public Topo {
29 std::vector<int> dims_;
30 std::vector<int> periodic_;
31 std::vector<int> position_;
34 explicit Topo_Cart(int ndims);
35 Topo_Cart(MPI_Comm comm_old, int ndims, const int dims[], const int periods[], int reorder, MPI_Comm* comm_cart);
36 Topo_Cart* sub(const int remain_dims[], MPI_Comm* newcomm);
37 int coords(int rank, int maxdims, int coords[]);
38 int get(int maxdims, int* dims, int* periods, int* coords);
39 int rank(const int* coords, int* rank);
40 int shift(int direction, int disp, int* rank_source, int* rank_dest);
41 int dim_get(int* ndims);
42 static int Dims_create(int nnodes, int ndims, int dims[]);
46 class Topo_Graph: public Topo {
47 std::vector<int> index_;
48 std::vector<int> edges_;
51 class Topo_Dist_Graph: public Topo {
53 std::vector<int> in_weights_;
54 std::vector<int> out_;
55 std::vector<int> out_weights_;