X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/70d2f595faa35389d76189f75d8ac70ad0b01a36..5fd60ae4fdc2aaaff1bed6ac2978e8c7ed2077c4:/examples/s4u/plugin-link-cumload/s4u-plugin-link-cumload.cpp diff --git a/examples/s4u/plugin-link-cumload/s4u-plugin-link-cumload.cpp b/examples/s4u/plugin-link-cumload/s4u-plugin-link-cumload.cpp deleted file mode 100644 index 658add80ad..0000000000 --- a/examples/s4u/plugin-link-cumload/s4u-plugin-link-cumload.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved. */ - -/* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ - -#include "simgrid/s4u.hpp" -#include "simgrid/plugins/load.h" - -XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example"); - -static void sender(const std::string & mailbox, uint64_t msg_size) -{ - auto mbox = simgrid::s4u::Mailbox::by_name(mailbox); - mbox->put((void*)1, msg_size); -} - -static void receiver(const std::string & mailbox) -{ - auto mbox = simgrid::s4u::Mailbox::by_name(mailbox); - mbox->get(); -} - -static void run_transfer(simgrid::s4u::Host* src_host, simgrid::s4u::Host* dst_host, - const std::string & mailbox, uint64_t msg_size) -{ - XBT_INFO("Launching the transfer of %lu bytes", msg_size); - simgrid::s4u::Actor::create("sender", src_host, sender, mailbox, msg_size); - simgrid::s4u::Actor::create("receiver", dst_host, receiver, mailbox); -} - -static void execute_load_test() -{ - auto host0 = simgrid::s4u::Host::by_name("node-0.simgrid.org"); - auto host1 = simgrid::s4u::Host::by_name("node-1.simgrid.org"); - - simgrid::s4u::this_actor::sleep_for(1); - run_transfer(host0, host1, "1", 1000*1000*1000); - - simgrid::s4u::this_actor::sleep_for(10); - run_transfer(host0, host1, "2", 1000*1000*1000); - simgrid::s4u::this_actor::sleep_for(3); - run_transfer(host0, host1, "3", 1000*1000*1000); -} - -static void show_link_load(const std::string & link_name, const simgrid::s4u::Link* link) -{ - XBT_INFO("%s link load (cum, avg, min, max): (%g, %g, %g, %g)", link_name.c_str(), - sg_link_get_cum_load(link), - sg_link_get_avg_load(link), - sg_link_get_min_instantaneous_load(link), - sg_link_get_max_instantaneous_load(link) - ); -} - -static void monitor() -{ - auto link_backbone = simgrid::s4u::Link::by_name("cluster0_backbone"); - auto link_host0 = simgrid::s4u::Link::by_name("cluster0_link_0_UP"); - auto link_host1 = simgrid::s4u::Link::by_name("cluster0_link_1_DOWN"); - - XBT_INFO("Tracking desired links"); - sg_link_cumload_track(link_backbone); - sg_link_cumload_track(link_host0); - sg_link_cumload_track(link_host1); - - show_link_load("Backbone", link_backbone); - while (simgrid::s4u::Engine::get_clock() < 5) - { - simgrid::s4u::this_actor::sleep_for(1); - show_link_load("Backbone", link_backbone); - } - - XBT_INFO("Untracking the backbone link"); - sg_link_cumload_untrack(link_backbone); - - show_link_load("Host0_UP", link_host0); - show_link_load("Host1_UP", link_host1); - - XBT_INFO("Now resetting and probing host links each second."); - - while (simgrid::s4u::Engine::get_clock() < 29) - { - sg_link_cumload_reset(link_host0); - sg_link_cumload_reset(link_host1); - - simgrid::s4u::this_actor::sleep_for(1); - - show_link_load("Host0_UP", link_host0); - show_link_load("Host1_UP", link_host1); - } -} - -int main(int argc, char* argv[]) -{ - simgrid::s4u::Engine e(&argc, argv); - sg_link_cumload_plugin_init(); - - xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/energy_platform.xml\n", argv[0], argv[0]); - e.load_platform(argv[1]); - - simgrid::s4u::Actor::create("load_test", simgrid::s4u::Host::by_name("node-42.simgrid.org"), execute_load_test); - simgrid::s4u::Actor::create("monitor", simgrid::s4u::Host::by_name("node-51.simgrid.org"), monitor); - - e.run(); - - XBT_INFO("Total simulation time: %.2f", simgrid::s4u::Engine::get_clock()); - - return 0; -}