Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix the execution of the bittorrent example
[simgrid.git] / examples / smpi / smpi_s4u_masterslave / masterslave_mailbox_smpi.cpp
index 1e583ce..a786889 100644 (file)
@@ -56,13 +56,12 @@ static void worker(std::vector<std::string> args)
 
     if (compute_cost > 0) /* If compute_cost is valid, execute a computation of that cost */
       simgrid::s4u::this_actor::execute(compute_cost);
-
   } while (compute_cost > 0); /* Stop when receiving an invalid compute_cost */
 
   XBT_INFO("Exiting now.");
 }
 
-static int master_mpi(int argc, char* argv[])
+static void master_mpi(int argc, char* argv[])
 {
   MPI_Init(&argc, &argv);
 
@@ -79,10 +78,9 @@ static int master_mpi(int argc, char* argv[])
   MPI_Finalize();
 
   XBT_INFO("After finalize %d %d", rank, test[0]);
-  return 0;
 }
 
-static int alltoall_mpi(int argc, char* argv[])
+static void alltoall_mpi(int argc, char* argv[])
 {
   MPI_Init(&argc, &argv);
 
@@ -91,15 +89,12 @@ static int alltoall_mpi(int argc, char* argv[])
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   MPI_Comm_size(MPI_COMM_WORLD, &size);
   XBT_INFO("alltoall for rank %d", rank);
-  int* out = new int[1000 * size];
-  int* in  = new int[1000 * size];
-  MPI_Alltoall(out, 1000, MPI_INT, in, 1000, MPI_INT, MPI_COMM_WORLD);
+  std::vector<int> out(1000 * size);
+  std::vector<int> in(1000 * size);
+  MPI_Alltoall(out.data(), 1000, MPI_INT, in.data(), 1000, MPI_INT, MPI_COMM_WORLD);
 
   XBT_INFO("after alltoall %d", rank);
-  delete[] out;
-  delete[] in;
   MPI_Finalize();
-  return 0;
 }
 
 int main(int argc, char* argv[])