From 92b5807a50d37d792c86af8b7309b73056586c41 Mon Sep 17 00:00:00 2001 From: degomme Date: Wed, 8 Mar 2017 14:30:55 +0100 Subject: [PATCH] Rename specific topology classes, to ease comprehension. --- include/smpi/forward.hpp | 14 +++++++------- src/smpi/smpi_pmpi.cpp | 16 ++++++++-------- src/smpi/smpi_topo.cpp | 24 ++++++++++++------------ src/smpi/smpi_topo.hpp | 22 +++++++++++----------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/include/smpi/forward.hpp b/include/smpi/forward.hpp index 0586826f62..67e39d708a 100644 --- a/include/smpi/forward.hpp +++ b/include/smpi/forward.hpp @@ -18,11 +18,11 @@ class Group; class Op; class Request; class Topo; +class Topo_Cart; +class Topo_Graph; +class Topo_Dist_Graph; class Win; -//TODO : rename these -class Cart; -class Graph; -class Dist_Graph; + } @@ -33,10 +33,10 @@ typedef simgrid::smpi::Group SMPI_Group; typedef simgrid::smpi::Op SMPI_Op; typedef simgrid::smpi::Request SMPI_Request; typedef simgrid::smpi::Topo SMPI_Topology; +typedef simgrid::smpi::Topo_Cart SMPI_Cart_topology; +typedef simgrid::smpi::Topo_Dist_Graph SMPI_Dist_Graph_topology; +typedef simgrid::smpi::Topo_Graph SMPI_Graph_topology; typedef simgrid::smpi::Win SMPI_Win; -typedef simgrid::smpi::Graph SMPI_Graph_topology; -typedef simgrid::smpi::Cart SMPI_Cart_topology; -typedef simgrid::smpi::Dist_Graph SMPI_Dist_Graph_topology; #else diff --git a/src/smpi/smpi_pmpi.cpp b/src/smpi/smpi_pmpi.cpp index 449032c689..e87079d3aa 100644 --- a/src/smpi/smpi_pmpi.cpp +++ b/src/smpi/smpi_pmpi.cpp @@ -2303,7 +2303,7 @@ int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periodic, int } else if (ndims < 0 || (ndims > 0 && (dims == nullptr || periodic == nullptr)) || comm_cart == nullptr) { return MPI_ERR_ARG; } else{ - new Cart(comm_old, ndims, dims, periodic, reorder, comm_cart); + new Topo_Cart(comm_old, ndims, dims, periodic, reorder, comm_cart); return MPI_SUCCESS; } } @@ -2315,7 +2315,7 @@ int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) { if (coords == nullptr) { return MPI_ERR_ARG; } - Cart* topo = static_cast(comm->topo()); + MPIR_Cart_Topology topo = static_cast(comm->topo()); if (topo==nullptr) { return MPI_ERR_ARG; } @@ -2329,7 +2329,7 @@ int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* d if (source == nullptr || dest == nullptr || direction < 0 ) { return MPI_ERR_ARG; } - Cart* topo = static_cast(comm->topo()); + MPIR_Cart_Topology topo = static_cast(comm->topo()); if (topo==nullptr) { return MPI_ERR_ARG; } @@ -2349,7 +2349,7 @@ int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) { if(coords == nullptr) { return MPI_ERR_ARG; } - Cart* topo = static_cast(comm->topo()); + MPIR_Cart_Topology topo = static_cast(comm->topo()); if (topo==nullptr) { return MPI_ERR_ARG; } @@ -2363,7 +2363,7 @@ int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coor if(maxdims <= 0 || dims == nullptr || periods == nullptr || coords == nullptr) { return MPI_ERR_ARG; } - Cart* topo = static_cast(comm->topo()); + MPIR_Cart_Topology topo = static_cast(comm->topo()); if (topo==nullptr) { return MPI_ERR_ARG; } @@ -2377,7 +2377,7 @@ int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) { if (ndims == nullptr) { return MPI_ERR_ARG; } - Cart* topo = static_cast(comm->topo()); + MPIR_Cart_Topology topo = static_cast(comm->topo()); if (topo==nullptr) { return MPI_ERR_ARG; } @@ -2401,11 +2401,11 @@ int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) { if (comm_new == nullptr) { return MPI_ERR_ARG; } - Cart* topo = static_cast(comm->topo()); + MPIR_Cart_Topology topo = static_cast(comm->topo()); if (topo==nullptr) { return MPI_ERR_ARG; } - Cart* cart = topo->sub(remain_dims, comm_new); + MPIR_Cart_Topology cart = topo->sub(remain_dims, comm_new); if(cart==nullptr) return MPI_ERR_ARG; return MPI_SUCCESS; diff --git a/src/smpi/smpi_topo.cpp b/src/smpi/smpi_topo.cpp index ca89d50c43..49a36a2bff 100644 --- a/src/smpi/smpi_topo.cpp +++ b/src/smpi/smpi_topo.cpp @@ -19,13 +19,13 @@ namespace simgrid{ namespace smpi{ -Graph::~Graph() +Topo_Graph::~Topo_Graph() { delete[] index_; delete[] edges_; } -Dist_Graph::~Dist_Graph() +Topo_Dist_Graph::~Topo_Dist_Graph() { delete[] in_; delete[] in_weights_; @@ -36,14 +36,14 @@ Dist_Graph::~Dist_Graph() /******************************************************************************* * Cartesian topologies ******************************************************************************/ -Cart::~Cart() +Topo_Cart::~Topo_Cart() { delete[] dims_; delete[] periodic_; delete[] position_; } -Cart::Cart(int ndims) +Topo_Cart::Topo_Cart(int ndims) { nnodes_ = 0; ndims_ = ndims; @@ -54,7 +54,7 @@ Cart::Cart(int ndims) /* reorder is ignored, don't know what would be the consequences of a dumb reordering but neither do I see the point of * reordering*/ -Cart::Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder, MPI_Comm *comm_cart) : Cart(ndims) { +Topo_Cart::Topo_Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder, MPI_Comm *comm_cart) : Topo_Cart(ndims) { MPI_Group newGroup; MPI_Group oldGroup; int nranks; @@ -100,7 +100,7 @@ Cart::Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder, comm_=*comm_cart; } -Cart* Cart::sub(const int remain_dims[], MPI_Comm *newcomm) { +Topo_Cart* Topo_Cart::sub(const int remain_dims[], MPI_Comm *newcomm) { int oldNDims = ndims_; int j = 0; int *newDims = nullptr; @@ -128,10 +128,10 @@ Cart* Cart::sub(const int remain_dims[], MPI_Comm *newcomm) { } } } - return new Cart(comm_, newNDims, newDims, newPeriodic, 0, newcomm); + return new Topo_Cart(comm_, newNDims, newDims, newPeriodic, 0, newcomm); } -int Cart::coords(int rank, int maxdims, int coords[]) { +int Topo_Cart::coords(int rank, int maxdims, int coords[]) { int nnodes = nnodes_; for (int i = 0; i< ndims_; i++ ) { nnodes = nnodes /dims_[i]; @@ -141,7 +141,7 @@ int Cart::coords(int rank, int maxdims, int coords[]) { return MPI_SUCCESS; } -int Cart::get(int maxdims, int* dims, int* periods, int* coords) { +int Topo_Cart::get(int maxdims, int* dims, int* periods, int* coords) { int ndims=ndims_ < maxdims ?ndims_ : maxdims; for(int i = 0 ; i < ndims ; i++) { dims[i] =dims_[i]; @@ -151,7 +151,7 @@ int Cart::get(int maxdims, int* dims, int* periods, int* coords) { return MPI_SUCCESS; } -int Cart::rank(int* coords, int* rank) { +int Topo_Cart::rank(int* coords, int* rank) { int ndims =ndims_; int coord; *rank = 0; @@ -188,7 +188,7 @@ int Cart::rank(int* coords, int* rank) { return MPI_SUCCESS; } -int Cart::shift(int direction, int disp, int *rank_source, int *rank_dest) { +int Topo_Cart::shift(int direction, int disp, int *rank_source, int *rank_dest) { int position[ndims_]; @@ -229,7 +229,7 @@ int Cart::shift(int direction, int disp, int *rank_source, int *rank_dest) { return MPI_SUCCESS; } -int Cart::dim_get(int *ndims) { +int Topo_Cart::dim_get(int *ndims) { *ndims =ndims_; return MPI_SUCCESS; } diff --git a/src/smpi/smpi_topo.hpp b/src/smpi/smpi_topo.hpp index a7a5b552bc..7444794d11 100644 --- a/src/smpi/smpi_topo.hpp +++ b/src/smpi/smpi_topo.hpp @@ -19,7 +19,7 @@ class Topo { }; -class Cart: public Topo { +class Topo_Cart: public Topo { private: int nnodes_; int ndims_; @@ -27,10 +27,10 @@ class Cart: public Topo { int *periodic_; int *position_; public: - Cart(int ndims); - ~Cart(); - Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder, MPI_Comm *comm_cart); - Cart* sub(const int remain_dims[], MPI_Comm *newcomm) ; + 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); @@ -39,18 +39,18 @@ class Cart: public Topo { }; -class Graph: public Topo { +class Topo_Graph: public Topo { private: int nnodes_; int nedges_; int *index_; int *edges_; public: - Graph(); - ~Graph(); + Topo_Graph(); + ~Topo_Graph(); }; -class Dist_Graph: public Topo { +class Topo_Dist_Graph: public Topo { private: int indegree_; int *in_; @@ -60,8 +60,8 @@ class Dist_Graph: public Topo { int *out_weights_; int is_weighted_; public: - Dist_Graph(); - ~Dist_Graph(); + Topo_Dist_Graph(); + ~Topo_Dist_Graph(); }; /* -- 2.20.1