From 716d24e108b1b69a9241edfe8ccf0e52be8ad945 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 8 Feb 2019 11:55:17 +0100 Subject: [PATCH] add an example of speed profile in the platform --- examples/platforms/small_platform_profile.xml | 70 +++++++++++++++++++ examples/platforms/trace/jupiter_speed.trace | 6 +- examples/platforms/trace/link1_avail.trace | 3 - .../platforms/trace/link1_bandwidth.trace | 3 + examples/platforms/trace/link1_latency.trace | 3 + examples/s4u/CMakeLists.txt | 3 +- examples/s4u/README.rst | 13 ++++ .../platform-profile/s4u-platform-profile.cpp | 45 ++++++++++++ .../s4u-platform-profile.tesh | 13 ++++ tools/cmake/DefinePackages.cmake | 4 +- 10 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 examples/platforms/small_platform_profile.xml delete mode 100644 examples/platforms/trace/link1_avail.trace create mode 100644 examples/platforms/trace/link1_bandwidth.trace create mode 100644 examples/platforms/trace/link1_latency.trace create mode 100644 examples/s4u/platform-profile/s4u-platform-profile.cpp create mode 100644 examples/s4u/platform-profile/s4u-platform-profile.tesh diff --git a/examples/platforms/small_platform_profile.xml b/examples/platforms/small_platform_profile.xml new file mode 100644 index 0000000000..efabd6f40c --- /dev/null +++ b/examples/platforms/small_platform_profile.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/platforms/trace/jupiter_speed.trace b/examples/platforms/trace/jupiter_speed.trace index 33719c8887..4b0a723d05 100644 --- a/examples/platforms/trace/jupiter_speed.trace +++ b/examples/platforms/trace/jupiter_speed.trace @@ -1,2 +1,6 @@ 0 0.5 -2 1.0 \ No newline at end of file +2 1.0 +4 0.7 +6 0.1 +8 4 +LOOPAFTER 10 \ No newline at end of file diff --git a/examples/platforms/trace/link1_avail.trace b/examples/platforms/trace/link1_avail.trace deleted file mode 100644 index fd47a867c8..0000000000 --- a/examples/platforms/trace/link1_avail.trace +++ /dev/null @@ -1,3 +0,0 @@ -2 62500000 -4 31250000 -LOOPAFTER 6 diff --git a/examples/platforms/trace/link1_bandwidth.trace b/examples/platforms/trace/link1_bandwidth.trace new file mode 100644 index 0000000000..46b3c52477 --- /dev/null +++ b/examples/platforms/trace/link1_bandwidth.trace @@ -0,0 +1,3 @@ +2 2000000 +4 3000000 +LOOPAFTER 6 diff --git a/examples/platforms/trace/link1_latency.trace b/examples/platforms/trace/link1_latency.trace new file mode 100644 index 0000000000..c56791bd1e --- /dev/null +++ b/examples/platforms/trace/link1_latency.trace @@ -0,0 +1,3 @@ +1 0.003 +3 0.015 +LOOPAFTER 6 diff --git a/examples/s4u/CMakeLists.txt b/examples/s4u/CMakeLists.txt index 6b476fa341..ec13f74c66 100644 --- a/examples/s4u/CMakeLists.txt +++ b/examples/s4u/CMakeLists.txt @@ -11,7 +11,8 @@ foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill engine-filtering exec-async exec-basic exec-dvfs exec-monitor exec-ptask exec-remote io-async io-file-system io-file-remote io-storage-raw - platform-failures platform-properties plugin-hostload + platform-failures platform-profile platform-properties + plugin-hostload replay-comm replay-storage routing-get-clusters synchro-barrier synchro-mutex synchro-semaphore) diff --git a/examples/s4u/README.rst b/examples/s4u/README.rst index a01e332eb4..e8378dc52a 100644 --- a/examples/s4u/README.rst +++ b/examples/s4u/README.rst @@ -281,6 +281,19 @@ Interacting with the Platform |br| `examples/s4u/platform-properties/s4u-platform-properties_d.xml `_ |br| `examples/platforms/prop.xml `_ + - **Specifying state profiles:** shows how to specify when the + resources must be turned off and on again, and how to react to such + failures in your code. + + |br| `examples/platforms/small_platform_with_failure.xml `_ + |br| The state profiles in `examples/platforms/trace `_ + + - **Specifying speed profiles:** shows how to specify an external + load to resources, variating their peak speed over time. + + |br| `examples/platforms/small_platform_profile.xml `_ + |br| The speed, bandwidth and latency profiles in `examples/platforms/trace `_ + ================= Energy Simulation ================= diff --git a/examples/s4u/platform-profile/s4u-platform-profile.cpp b/examples/s4u/platform-profile/s4u-platform-profile.cpp new file mode 100644 index 0000000000..0da24ff4ad --- /dev/null +++ b/examples/s4u/platform-profile/s4u-platform-profile.cpp @@ -0,0 +1,45 @@ +/* Copyright (c) 2017-2019. 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" + +/* This example demonstrates how to attach a profile to an host or a link, + * to specify external changes to the resource speed. The first way to do + * so is to use a file in the XML, while the second is to use the programmatic interface. + */ + +XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_platform_profile, "Messages specific for this s4u example"); + +/* Main function of the Yielder process */ +static void watcher() +{ + simgrid::s4u::Host* jupiter = simgrid::s4u::Host::by_name("Jupiter"); + simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard"); + simgrid::s4u::Link* link1 = simgrid::s4u::Link::by_name("1"); + simgrid::s4u::Link* link2 = simgrid::s4u::Link::by_name("2"); + + for (int i = 0; i < 10; i++) { + XBT_INFO("Fafard: %.0fGflops, Jupiter: % 3.0fGflops, Link1: (%.2fMB/s %.0fms), Link2: (%.2fMB/s %.0fms)", + fafard->get_speed() * fafard->get_available_speed() / 1000000, + jupiter->get_speed() * jupiter->get_available_speed() / 1000000, link1->get_bandwidth() / 1000, + link1->get_latency() * 1000, link2->get_bandwidth() / 1000, link2->get_latency() * 1000); + simgrid::s4u::this_actor::sleep_for(1); + } +}; + +int main(int argc, char* argv[]) +{ + simgrid::s4u::Engine e(&argc, argv); + + xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s platform.xml deployment.xml\n", argv[0], argv[0]); + + e.load_platform(argv[1]); + + simgrid::s4u::Actor::create("watcher", simgrid::s4u::Host::by_name("Tremblay"), watcher); + + e.run(); /* - Run the simulation */ + + return 0; +} diff --git a/examples/s4u/platform-profile/s4u-platform-profile.tesh b/examples/s4u/platform-profile/s4u-platform-profile.tesh new file mode 100644 index 0000000000..11b0d003aa --- /dev/null +++ b/examples/s4u/platform-profile/s4u-platform-profile.tesh @@ -0,0 +1,13 @@ +#!/usr/bin/env tesh + +$ $SG_TEST_EXENV ${bindir:=.}/s4u-platform-profile ${platfdir}/small_platform_profile.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (1:watcher@Tremblay) Fafard: 25Gflops, Jupiter: 12Gflops, Link1: (1000.00MB/s 10ms), Link2: (1000.00MB/s 10ms) +> [ 1.000000] (1:watcher@Tremblay) Fafard: 25Gflops, Jupiter: 12Gflops, Link1: (1000.00MB/s 3ms), Link2: (1000.00MB/s 10ms) +> [ 2.000000] (1:watcher@Tremblay) Fafard: 25Gflops, Jupiter: 25Gflops, Link1: (2000.00MB/s 3ms), Link2: (1000.00MB/s 10ms) +> [ 3.000000] (1:watcher@Tremblay) Fafard: 25Gflops, Jupiter: 25Gflops, Link1: (2000.00MB/s 15ms), Link2: (1000.00MB/s 10ms) +> [ 4.000000] (1:watcher@Tremblay) Fafard: 25Gflops, Jupiter: 18Gflops, Link1: (3000.00MB/s 15ms), Link2: (1000.00MB/s 10ms) +> [ 5.000000] (1:watcher@Tremblay) Fafard: 25Gflops, Jupiter: 18Gflops, Link1: (3000.00MB/s 15ms), Link2: (1000.00MB/s 10ms) +> [ 6.000000] (1:watcher@Tremblay) Fafard: 25Gflops, Jupiter: 2Gflops, Link1: (3000.00MB/s 15ms), Link2: (1000.00MB/s 10ms) +> [ 7.000000] (1:watcher@Tremblay) Fafard: 25Gflops, Jupiter: 2Gflops, Link1: (3000.00MB/s 15ms), Link2: (1000.00MB/s 10ms) +> [ 8.000000] (1:watcher@Tremblay) Fafard: 25Gflops, Jupiter: 100Gflops, Link1: (3000.00MB/s 15ms), Link2: (1000.00MB/s 10ms) +> [ 9.000000] (1:watcher@Tremblay) Fafard: 25Gflops, Jupiter: 100Gflops, Link1: (3000.00MB/s 15ms), Link2: (1000.00MB/s 10ms) diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index c6b9e8f281..2e41255573 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -1115,7 +1115,8 @@ set(PLATFORMS_EXAMPLES examples/platforms/trace/ginette_state.trace examples/platforms/trace/jupiter_speed.trace examples/platforms/trace/jupiter_state.trace - examples/platforms/trace/link1_avail.trace + examples/platforms/trace/link1_bandwidth.trace + examples/platforms/trace/link1_latency.trace examples/platforms/trace/link3_state.trace examples/platforms/trace/link4_state.trace examples/platforms/trace/linkBandwidth7.bw @@ -1147,6 +1148,7 @@ set(PLATFORMS_EXAMPLES examples/platforms/small_platform_constant.xml examples/platforms/small_platform_fatpipe.xml examples/platforms/small_platform_one_link_routes.xml + examples/platforms/small_platform_profile.xml examples/platforms/small_platform_with_failures.xml examples/platforms/small_platform_with_routers.xml examples/platforms/syscoord/generate_peer_platform.pl -- 2.20.1