X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f15e92e5de94e0d84b2084de6e1648ce64dadbed..3efa482f86d7828379214dedabbcd76c145103d5:/examples/smpi/smpi_s4u_masterslave/masterslave_mailbox_smpi.cpp diff --git a/examples/smpi/smpi_s4u_masterslave/masterslave_mailbox_smpi.cpp b/examples/smpi/smpi_s4u_masterslave/masterslave_mailbox_smpi.cpp index 1e583cee66..6ed9f330e9 100644 --- a/examples/smpi/smpi_s4u_masterslave/masterslave_mailbox_smpi.cpp +++ b/examples/smpi/smpi_s4u_masterslave/masterslave_mailbox_smpi.cpp @@ -14,9 +14,9 @@ static void master(std::vector args) { xbt_assert(args.size() > 4, "The master function expects at least 3 arguments"); - long tasks_count = std::stol(args[1]); - double compute_cost = std::stod(args[2]); - double communication_cost = std::stod(args[3]); + long tasks_count = std::stol(args[1]); + double compute_cost = std::stod(args[2]); + long communication_cost = std::stol(args[3]); std::vector workers; for (unsigned int i = 4; i < args.size(); i++) workers.push_back(simgrid::s4u::Mailbox::by_name(args[i])); @@ -56,13 +56,12 @@ static void worker(std::vector 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 out(1000 * size); + std::vector 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[])