Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / smpi / include / smpi_topo.hpp
index be11c32..24efab5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2021. 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. */
@@ -8,67 +8,52 @@
 
 #include "smpi_comm.hpp"
 #include "smpi_status.hpp"
+#include <memory>
 
-typedef SMPI_Topology *MPI_Topology;
+using MPI_Topology = std::shared_ptr<SMPI_Topology>;
 
 namespace simgrid{
 namespace smpi{
 
 class Topo {
-  MPI_Comm comm_;
+  MPI_Comm comm_ = MPI_COMM_NULL;
 
 public:
   virtual ~Topo() = default;
   MPI_Comm getComm() const { return comm_; }
-  void setComm(MPI_Comm comm) { comm_ = comm; }
+  void setComm(MPI_Comm comm);
 };
 
 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(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(int* coords, int* rank);
+  int rank(const int* coords, int* rank);
   int shift(int direction, int disp, int* rank_source, int* rank_dest);
-  int dim_get(int* ndims);
+  int dim_get(int* ndims) const;
   static int Dims_create(int nnodes, int ndims, int dims[]);
 };
 
 
 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_;
 };
 
 }