X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a42065590d308653d71e5a49c8647c535b964a94..HEAD:/src/smpi/include/smpi_topo.hpp diff --git a/src/smpi/include/smpi_topo.hpp b/src/smpi/include/smpi_topo.hpp index c8f0caf3d1..e46d67e55a 100644 --- a/src/smpi/include/smpi_topo.hpp +++ b/src/smpi/include/smpi_topo.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -6,72 +6,54 @@ #ifndef SMPI_TOPO_HPP_INCLUDED #define SMPI_TOPO_HPP_INCLUDED -#include "smpi_comm.hpp" #include "smpi_status.hpp" +#include -typedef SMPI_Topology *MPI_Topology; +using MPI_Topology = std::shared_ptr; -namespace simgrid{ -namespace smpi{ +namespace simgrid::smpi { class Topo { - public: - virtual ~Topo()=default; - MPI_Comm getComm() const { return comm_; } - void setComm(MPI_Comm comm) { comm_ = comm; } - private: - MPI_Comm comm_; -}; + MPI_Comm comm_ = MPI_COMM_NULL; +public: + virtual ~Topo() = default; + MPI_Comm getComm() const { return comm_; } + void setComm(MPI_Comm comm); +}; class Topo_Cart: public Topo { - private: - int nnodes_ = 0; - int ndims_; - int *dims_; - int *periodic_; - int *position_; - public: - explicit Topo_Cart(int ndims); - ~Topo_Cart(); - Topo_Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder, MPI_Comm *comm_cart); - Topo_Cart* sub(const int remain_dims[], MPI_Comm *newcomm) ; - int coords(int rank, int maxdims, int coords[]) ; - int get(int maxdims, int* dims, int* periods, int* coords); - int rank(int* coords, int* rank); - int shift(int direction, int disp, int *rank_source, int *rank_dest) ; - int dim_get(int *ndims); - static int Dims_create(int nnodes, int ndims, int dims[]); + int nnodes_ = 0; + int ndims_; + std::vector dims_; + std::vector periodic_; + std::vector position_; + +public: + explicit Topo_Cart(int ndims); + Topo_Cart(MPI_Comm comm_old, int ndims, const int dims[], const int periods[], int reorder, MPI_Comm* comm_cart); + Topo_Cart* sub(const int remain_dims[], MPI_Comm* newcomm); + int coords(int rank, int maxdims, int coords[]); + int get(int maxdims, int* dims, int* periods, int* coords); + int rank(const int* coords, int* rank); + int shift(int direction, int disp, int* rank_source, int* rank_dest); + int dim_get(int* ndims) const; + static int Dims_create(int nnodes, int ndims, int dims[]); }; class Topo_Graph: public Topo { - private: - int nnodes_; - int nedges_; - int *index_; - int *edges_; - public: - Topo_Graph(); - ~Topo_Graph(); + std::vector index_; + std::vector edges_; }; class Topo_Dist_Graph: public Topo { - private: - int indegree_; - int *in_; - int *in_weights_; - int outdegree_; - int *out_; - int *out_weights_; - int is_weighted_; - public: - Topo_Dist_Graph(); - ~Topo_Dist_Graph(); + std::vector in_; + std::vector in_weights_; + std::vector out_; + std::vector out_weights_; }; -} -} - +} // namespace simgrid::smpi #endif