Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
update the comments of that file
[simgrid.git] / src / smpi / smpi_topo.c
index 7429959fa27cad3984ff441d80962c791ebd0115..fdc5f7709d321fc3bca38e3837df026d520e6510 100644 (file)
@@ -53,10 +53,11 @@ int smpi_mpi_cart_create(MPI_Comm comm_old, int ndims, int dims[],
 
   rank = smpi_comm_rank(comm_old);
 
-  // TODO : add somewhere : if topo != NULL, free...
-  topo = smpi_topo_create(ndims);
   newSize = 1;
   if(ndims != 0) {
+    topo = smpi_topo_create(ndims);
     for (i = 0 ; i < ndims ; i++) {
       newSize *= dims[i];
     }
@@ -91,6 +92,7 @@ int smpi_mpi_cart_create(MPI_Comm comm_old, int ndims, int dims[],
   }
   else {
     if (rank == 0) {
+      topo = smpi_topo_create(ndims);
       *comm_cart = smpi_comm_new(smpi_comm_group(MPI_COMM_SELF), topo);
     }
     else {
@@ -451,7 +453,6 @@ getfactors(int num, int *nfactors, int **factors) {
         (*factors)[i++] = 2;
     }
     /* determine all occurences of uneven prime numbers up to sqrt(num) */
-    d = 3;
     for(d = 3; (num > 1) && (d < sqrtnum); d += 2) {
         while((num % d) == 0) {
             num /= d;