1 /* Copyright (c) 2006-2023. 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. */
6 #include "simgrid/s4u.hpp"
8 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
9 namespace sg4 = simgrid::s4u;
11 /// Wait on the barrier then leave
12 static void worker(sg4::BarrierPtr barrier)
14 XBT_INFO("Waiting on the barrier");
20 /// Spawn actor_count-1 workers and do a barrier with them
21 static void master(int actor_count)
23 sg4::BarrierPtr barrier = sg4::Barrier::create(actor_count);
25 XBT_INFO("Spawning %d workers", actor_count - 1);
26 for (int i = 0; i < actor_count - 1; i++) {
27 sg4::Actor::create("worker", sg4::Host::by_name("Jupiter"), worker, barrier);
30 XBT_INFO("Waiting on the barrier");
36 int main(int argc, char **argv)
38 sg4::Engine e(&argc, argv);
40 // Parameter: Number of actores in the barrier
41 xbt_assert(argc >= 2, "Usage: %s <actor-count>\n", argv[0]);
42 int actor_count = std::stoi(argv[1]);
43 xbt_assert(actor_count > 0, "<actor-count> must be greater than 0");
45 e.load_platform(argc > 2 ? argv[2] : "../../platforms/two_hosts.xml");
46 sg4::Actor::create("master", e.host_by_name("Tremblay"), master, actor_count);