Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use std::vector instead of plain arrays in smpi_topo.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 18 Apr 2019 20:35:24 +0000 (22:35 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 18 Apr 2019 20:38:25 +0000 (22:38 +0200)
src/smpi/include/smpi_topo.hpp
src/smpi/mpi/smpi_topo.cpp

index be11c32..c65b401 100644 (file)
@@ -26,15 +26,12 @@ public:
 class Topo_Cart: public Topo {
   int nnodes_ = 0;
   int ndims_;
-  int* dims_;
-  int* periodic_;
-  int* position_;
+  std::vector<int> dims_;
+  std::vector<int> periodic_;
+  std::vector<int> position_;
 
 public:
   explicit Topo_Cart(int ndims);
-  Topo_Cart(const Topo_Cart&) = delete;
-  Topo_Cart& operator=(const Topo_Cart&) = delete;
-  ~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[]);
@@ -47,28 +44,15 @@ public:
 
 
 class Topo_Graph: public Topo {
-  int nnodes_;
-  int* index_;
-  int* edges_;
-
-public:
-  Topo_Graph();
-  Topo_Graph(const Topo_Graph&) = delete;
-  Topo_Graph& operator=(const Topo_Graph&) = delete;
-  ~Topo_Graph();
+  std::vector<int> index_;
+  std::vector<int> edges_;
 };
 
 class Topo_Dist_Graph: public Topo {
-  int* in_;
-  int* in_weights_;
-  int* out_;
-  int* out_weights_;
-
-public:
-  Topo_Dist_Graph();
-  Topo_Dist_Graph(const Topo_Dist_Graph&) = delete;
-  Topo_Dist_Graph& operator=(const Topo_Dist_Graph&) = delete;
-  ~Topo_Dist_Graph();
+  std::vector<int> in_;
+  std::vector<int> in_weights_;
+  std::vector<int> out_;
+  std::vector<int> out_weights_;
 };
 
 }
index 8af2975..82bfd74 100644 (file)
@@ -19,35 +19,12 @@ static int getfactors(int num, int *nfators, int **factors);
 namespace simgrid{
 namespace smpi{
 
-Topo_Graph::~Topo_Graph()
-{
-  delete[] index_;
-  delete[] edges_;
-}
-
-Topo_Dist_Graph::~Topo_Dist_Graph()
-{
-  delete[] in_;
-  delete[] in_weights_;
-  delete[] out_;
-  delete[] out_weights_;
-}
-
 /*******************************************************************************
  * Cartesian topologies
  ******************************************************************************/
-Topo_Cart::~Topo_Cart()
-{
-  delete[] dims_;
-  delete[] periodic_;
-  delete[] position_;
-}
 
-Topo_Cart::Topo_Cart(int ndims) : ndims_(ndims)
+Topo_Cart::Topo_Cart(int ndims) : ndims_(ndims), dims_(ndims), periodic_(ndims), position_(ndims)
 {
-  dims_ = new int[ndims];
-  periodic_ = new int[ndims];
-  position_ = new 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