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