1 /* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/s4u.hpp"
9 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
11 /// Wait on the barrier then leave
12 static void worker(std::shared_ptr<simgrid::s4u::Barrier> barrier)
14 XBT_INFO("Waiting on the barrier");
20 /// Spawn process_count-1 workers and do a barrier with them
21 static void master(int process_count)
23 std::shared_ptr<simgrid::s4u::Barrier> barrier(new simgrid::s4u::Barrier(process_count));
25 XBT_INFO("Spawning %d workers", process_count-1);
26 for (int i = 0; i < process_count-1; i++)
28 simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Jupiter"), worker, barrier);
31 XBT_INFO("Waiting on the barrier");
37 int main(int argc, char **argv)
39 // Parameter: Number of processes in the barrier
40 xbt_assert(argc >= 2, "Usage: %s <process-count>\n", argv[0]);
41 int process_count = std::stoi(argv[1]);
42 xbt_assert(process_count > 0, "<process-count> must be greater than 0");
44 simgrid::s4u::Engine e(&argc, argv);
45 e.load_platform("../../platforms/two_hosts.xml");
46 simgrid::s4u::Actor::create("master", simgrid::s4u::Host::by_name("Tremblay"), master, process_count);