X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3b56ba0e1914362b1c7e6b7d84bf72e2fe88f3c2..e0f1a9dae032024c4f4043e29fa878fc2a6f7699:/examples/cpp/operation-variable-load/s4u-operation-variable-load.cpp diff --git a/examples/cpp/operation-variable-load/s4u-operation-variable-load.cpp b/examples/cpp/operation-variable-load/s4u-operation-variable-load.cpp index 3aa32fd948..a7d4553cf5 100644 --- a/examples/cpp/operation-variable-load/s4u-operation-variable-load.cpp +++ b/examples/cpp/operation-variable-load/s4u-operation-variable-load.cpp @@ -4,63 +4,63 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ /* This example demonstrates how to create a variable load for operations. - * + * * We consider the following graph: - * + * * comm -> exec - * + * * With a small load each comm operation is followed by an exec operation. * With a heavy load there is a burst of comm before the exec operation can even finish once. */ -#include "simgrid/s4u.hpp" #include "simgrid/plugins/operation.hpp" +#include "simgrid/s4u.hpp" XBT_LOG_NEW_DEFAULT_CATEGORY(operation_variable_load, "Messages specific for this s4u example"); static void variable_load(simgrid::plugins::OperationPtr op) { - XBT_INFO("--- Small load ---"); - for (int i=0; i < 3; i++) { - op->enqueue_execs(1); - simgrid::s4u::this_actor::sleep_for(100); - } - simgrid::s4u::this_actor::sleep_until(1000); - XBT_INFO("--- Heavy load ---"); - for (int i=0; i < 3; i++) { - op->enqueue_execs(1); - simgrid::s4u::this_actor::sleep_for(1); - } + XBT_INFO("--- Small load ---"); + for (int i = 0; i < 3; i++) { + op->enqueue_execs(1); + simgrid::s4u::this_actor::sleep_for(100); + } + simgrid::s4u::this_actor::sleep_until(1000); + XBT_INFO("--- Heavy load ---"); + for (int i = 0; i < 3; i++) { + op->enqueue_execs(1); + simgrid::s4u::this_actor::sleep_for(1); + } } int main(int argc, char* argv[]) { - simgrid::s4u::Engine e(&argc, argv); - e.load_platform(argv[1]); - simgrid::plugins::Operation::init(); + simgrid::s4u::Engine e(&argc, argv); + e.load_platform(argv[1]); + simgrid::plugins::Operation::init(); - // Retreive hosts - auto tremblay = e.host_by_name("Tremblay"); - auto jupiter = e.host_by_name("Jupiter"); + // Retreive hosts + auto tremblay = e.host_by_name("Tremblay"); + auto jupiter = e.host_by_name("Jupiter"); - // Create operations - auto comm = simgrid::plugins::CommOp::create("comm",1e7,tremblay,jupiter); - auto exec = simgrid::plugins::ExecOp::create("exec",1e9,jupiter); + // Create operations + auto comm = simgrid::plugins::CommOp::create("comm", 1e7, tremblay, jupiter); + auto exec = simgrid::plugins::ExecOp::create("exec", 1e9, jupiter); - // Create the graph by defining dependencies between operations - comm->add_successor(exec); + // Create the graph by defining dependencies between operations + comm->add_successor(exec); - // Add a function to be called when operations end for log purpose - std::vector ops{exec,comm}; - for (auto op: ops) - op->on_end([](simgrid::plugins::Operation* op) { - XBT_INFO("Operation %s finished (%d)",op->get_name().c_str(), op->get_count()); - }); + // Add a function to be called when operations end for log purpose + std::vector ops{exec, comm}; + for (auto op : ops) + op->on_end([](simgrid::plugins::Operation* op) { + XBT_INFO("Operation %s finished (%d)", op->get_name().c_str(), op->get_count()); + }); - // Create the actor that will inject load during the simulation - simgrid::s4u::Actor::create("input", tremblay, variable_load, comm); + // Create the actor that will inject load during the simulation + simgrid::s4u::Actor::create("input", tremblay, variable_load, comm); - // Start the simulation - e.run(); - return 0; + // Start the simulation + e.run(); + return 0; }