1 /* Copyright (c) 2007-2022. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/s4u.hpp"
9 XBT_LOG_NEW_DEFAULT_CATEGORY(incomplete, "Incomplete DAG test");
11 /* Dag ncomplete simulation Test
13 * - Create a bunch of activities
14 * - schedule only a subset of them (init, A and D)
15 * - run the simulation
16 * - Verify that we detect which activities are blocked and show their state.
17 * The scheduled activity A sends 1GB. Simulation time should be
18 * 1e9/1.25e8 + 1e-4 = 8.0001 seconds
19 * Activity D is scheduled but depends on unscheduled activity C.
21 int main(int argc, char** argv)
23 simgrid::s4u::Engine e(&argc, argv);
24 e.load_platform(argv[1]);
26 auto host = e.host_by_name("cpu0");
27 /* creation of the tasks and their dependencies */
28 simgrid::s4u::ExecPtr Init = simgrid::s4u::Exec::init()->set_name("Init")->set_flops_amount(0)->vetoable_start();
29 simgrid::s4u::CommPtr A = simgrid::s4u::Comm::sendto_init()->set_name("A")->set_payload_size(1e9)->vetoable_start();
30 simgrid::s4u::CommPtr B = simgrid::s4u::Comm::sendto_init()->set_name("B")->vetoable_start();
31 simgrid::s4u::ExecPtr C = simgrid::s4u::Exec::init()->set_name("C")->vetoable_start();
32 simgrid::s4u::CommPtr D = simgrid::s4u::Comm::sendto_init()->set_name("D")->set_payload_size(1e9)->vetoable_start();
33 std::vector<simgrid::s4u::ActivityPtr> activities = {Init, A, B, C, D};
35 Init->add_successor(A);
36 Init->add_successor(B);
40 A->set_source(host)->set_destination(host);
41 D->set_source(host)->set_destination(host);
43 /* let's launch the simulation! */
47 for (auto a : activities) {
48 if (a->get_state() == simgrid::s4u::Activity::State::STARTING) {
50 XBT_INFO("Activity '%s' blocked: Dependencies: %s; Ressources: %s", a->get_cname(),
51 (a->dependencies_solved() ? "solved" : "NOT solved"), (a->is_assigned() ? "assigned" : "NOT assigned"));
54 XBT_INFO("Simulation is finished but %d tasks are still not done", count);