Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] A single statement should not have more than one resource allocation.
[simgrid.git] / src / smpi / mpi / smpi_topo.cpp
index 058b4bd..b79cefc 100644 (file)
@@ -19,6 +19,14 @@ static int getfactors(int num, int *nfators, int **factors);
 namespace simgrid{
 namespace smpi{
 
+void Topo::setComm(MPI_Comm comm)
+{
+  xbt_assert(not comm_);
+  comm_ = comm;
+  if (comm_)
+    comm_->topo_ = this;
+}
+
 /*******************************************************************************
  * Cartesian topologies
  ******************************************************************************/
@@ -72,7 +80,8 @@ Topo_Cart::Topo_Cart(MPI_Comm comm_old, int ndims, const int dims[], const int p
   } else {
     if(comm_cart != nullptr){
       if (rank == 0) {
-        *comm_cart = new  Comm(new  Group(MPI_COMM_SELF->group()), this);
+        MPI_Group group = new Group(MPI_COMM_SELF->group());
+        *comm_cart      = new Comm(group, this);
       } else {
         *comm_cart = MPI_COMM_NULL;
       }