1 /* Copyright (c) 2007-2022. 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/plugins/file_system.h>
7 #include <simgrid/s4u.hpp>
10 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
12 int main(int argc, char* argv[])
14 simgrid::s4u::Engine e(&argc, argv);
15 sg_storage_file_system_init();
16 e.load_platform(argv[1]);
18 auto tremblay = e.host_by_name("Tremblay");
19 auto jupiter = e.host_by_name("Jupiter");
21 // Display the details on vetoed activities
22 simgrid::s4u::Activity::on_veto_cb([](const simgrid::s4u::Activity& a) {
23 XBT_INFO("Activity '%s' vetoed. Dependencies: %s; Ressources: %s", a.get_cname(),
24 (a.dependencies_solved() ? "solved" : "NOT solved"), (a.is_assigned() ? "assigned" : "NOT assigned"));
27 simgrid::s4u::Activity::on_completion_cb([](simgrid::s4u::Activity& activity) {
28 const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(&activity);
30 XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(),
31 exec->get_finish_time());
32 const auto* comm = dynamic_cast<simgrid::s4u::Comm*>(&activity);
34 XBT_INFO("Activity '%s' is complete", comm->get_cname());
37 // Create a small DAG: parent->transfert->child
38 simgrid::s4u::ExecPtr parent = simgrid::s4u::Exec::init();
39 simgrid::s4u::CommPtr transfert = simgrid::s4u::Comm::sendto_init();
40 simgrid::s4u::ExecPtr child = simgrid::s4u::Exec::init();
41 parent->add_successor(transfert);
42 transfert->add_successor(child);
44 // Set the parameters (the name is for logging purposes only)
45 // + parent and child end after 1 second
46 parent->set_name("parent")->set_flops_amount(tremblay->get_speed())->vetoable_start();
47 transfert->set_name("transfert")->set_payload_size(125e6)->vetoable_start();
48 child->set_name("child")->set_flops_amount(jupiter->get_speed())->vetoable_start();
50 // Schedule the different activities
51 parent->set_host(tremblay);
52 transfert->set_source(tremblay);
53 child->set_host(jupiter);
54 transfert->set_destination(jupiter);
58 XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());