-/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2022. 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. */
#include "mpi.h"
#include "simgrid/s4u.hpp"
-#include <stdio.h> /* snprintf */
+#include <array>
+#include <cstdio> /* snprintf */
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(smpi_masterworkers, "Messages specific for this example");
static void master(std::vector<std::string> args)
{
double compute_cost;
do {
- const double* msg = static_cast<double*>(mailbox->get());
- compute_cost = *msg;
- delete msg;
+ auto msg = mailbox->get_unique<double>();
+ compute_cost = *msg;
if (compute_cost > 0) /* If compute_cost is valid, execute a computation of that cost */
simgrid::s4u::this_actor::execute(compute_cost);
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
XBT_INFO("here for rank %d", rank);
- int test[1000] = {rank};
+ std::array<int, 1000> test{{rank}};
if (rank == 0)
- MPI_Send(&test, 1000, MPI_INT, 1, 1, MPI_COMM_WORLD);
+ MPI_Send(test.data(), 1000, MPI_INT, 1, 1, MPI_COMM_WORLD);
else
- MPI_Recv(&test, 1000, MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
+ MPI_Recv(test.data(), 1000, MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
XBT_INFO("After comm %d", rank);
MPI_Finalize();
xbt_assert(argc > 2,
"Usage: %s platform_file deployment_file\n"
- "\nexample: %s msg_platform.xml msg_deployment.xml\n",
+ "\nexample: %s platform.xml deployment.xml\n",
argv[0], argv[0]);
e.load_platform(argv[1]);
e.run();
- XBT_INFO("Simulation time %g", e.get_clock());
+ XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
SMPI_finalize();
return 0;