.. _howto_churn:
-Modeling Churn in P2P
-*********************
+Modeling Churn (e.g. in P2P)
+****************************
One of the biggest challenges in P2P settings is to cope with the
churn, meaning that resources keep appearing and disappearing. In
the churn is high, you can also attach a **state profile** to the host
directly.
-This is not possible from S4U yet (TODO), and you should use the
-``state_file`` attribute of :ref:`pf_tag_host`, :ref:`pf_tag_cluster`
-or :ref:`pf_tag_link`.
-
-Every lines (but the last) of such files describe timed events with
-the form "date value". Example:
+This can be done through the XML file, using the ``state_file``
+attribute of :ref:`pf_tag_host`, :ref:`pf_tag_cluster` or
+:ref:`pf_tag_link`. Every lines (but the last) of such files describe
+timed events with the form "date value". Example:
.. code-block:: python
If your trace does not contain a LOOPAFTER line, then your profile is
only executed once and not repetitively.
+Another possibility is to use the
+:cpp:func:`simgrid::s4u::Host::set_state_profile()` or
+:cpp:func:`simgrid::s4u::Link::set_state_profile()` functions. These
+functions take a profile, that can be an fixed profile exhaustively
+listing the events, or something else if you wish.
+
.. _howto_multicore:
Modeling Multicore Machines
<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
<platform version="4.1">
<zone id="AS0" routing="Full">
- <host id="Faulty Host" speed="1Gf" state_file="trace/faulty_host.trace"/>
+ <host id="Faulty Host" speed="1Gf" state_file="profiles/faulty_host.profile"/>
<host id="Safe Host" speed="500Mf"/>
</zone>
</platform>
--- /dev/null
+0 0.5
+2 1.0
+4 0.7
+6 0.1
+8 4
+LOOPAFTER 10
\ No newline at end of file
--- /dev/null
+2 2000000
+4 3000000
+LOOPAFTER 6
--- /dev/null
+1 0.003
+3 0.015
+LOOPAFTER 6
<link id="l155" bandwidth="125MBps" latency="100us"/>
<link id="l156" bandwidth="125MBps" latency="100us"/>
<link id="l157" bandwidth="125MBps" latency="100us"/>
- <link id="l159" bandwidth="125MBps" latency="100us" bandwidth_file="trace/linkBandwidth7.bw"/>
+ <link id="l159" bandwidth="125MBps" latency="100us" bandwidth_file="profiles/linkBandwidth7.bw"/>
<link id="l160" bandwidth="125MBps" latency="100us"/>
<link id="l161" bandwidth="125MBps" latency="100us"/>
<link id="l162" bandwidth="125MBps" latency="100us"/>
<platform version="4.1">
<zone id="AS0" routing="Full">
<host id="Tremblay" speed="25Mf"/>
- <host id="Jupiter" speed="25Mf" state_file="trace/jupiter_state.trace"/>
- <host id="Fafard" speed="25Mf" state_file="trace/fafard_state.trace" />
- <host id="Ginette" speed="25Mf" state_file="trace/ginette_state.trace"/>
- <host id="Bourassa" speed="25Mf" state_file="trace/bourassa_state.trace"/>
+ <host id="Jupiter" speed="25Mf" state_file="profiles/jupiter_state.profile"/>
+ <host id="Fafard" speed="25Mf" state_file="profiles/fafard_state.profile" />
+ <host id="Ginette" speed="25Mf" state_file="profiles/ginette_state.profile"/>
+ <host id="Bourassa" speed="25Mf" state_file="profiles/bourassa_state.profile"/>
<link id="1" bandwidth="1MBps" latency="0"/>
<link id="2" bandwidth="1MBps" latency="0"/>
- <link id="3" bandwidth="1MBps" latency="0" state_file="trace/link3_state.trace" />
- <link id="4" bandwidth="1MBps" latency="0" state_file="trace/link4_state.trace" />
+ <link id="3" bandwidth="1MBps" latency="0" state_file="profiles/link3_state.profile" />
+ <link id="4" bandwidth="1MBps" latency="0" state_file="profiles/link4_state.profile" />
<link id="5" bandwidth="1MBps" latency="0"/>
<link id="6" bandwidth="1MBps" latency="0"/>
<link id="7" bandwidth="1MBps" latency="0"/>
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
+<platform version="4.1">
+ <zone id="AS0" routing="Full">
+ <host id="Tremblay" speed="25Mf"/>
+ <host id="Jupiter" speed="25Mf" availability_file="profiles/jupiter_speed.profile" />
+ <host id="Fafard" speed="25Mf"/>
+ <host id="Ginette" speed="25Mf"/>
+ <host id="Bourassa" speed="25Mf"/>
+
+ <link id="1" bandwidth="1MBps" latency="10ms" bandwidth_file="profiles/link1_bandwidth.profile" latency_file="profiles/link1_latency.profile" />
+ <link id="2" bandwidth="1MBps" latency="10ms"/>
+ <link id="3" bandwidth="1MBps" latency="10ms"/>
+ <link id="4" bandwidth="1MBps" latency="10ms"/>
+ <link id="5" bandwidth="1MBps" latency="10ms"/>
+ <link id="6" bandwidth="1MBps" latency="10ms"/>
+ <link id="7" bandwidth="1MBps" latency="10ms"/>
+ <link id="8" bandwidth="1MBps" latency="10ms"/>
+ <link id="9" bandwidth="1MBps" latency="10ms"/>
+ <link id="10" bandwidth="1MBps" latency="10ms"/>
+ <link id="loopback_FATPIPE" bandwidth="10MBps" latency="0" sharing_policy="FATPIPE"/>
+ <link id="loopback" bandwidth="100MBps" latency="0"/>
+
+ <route src="Tremblay" dst="Tremblay">
+ <link_ctn id="loopback"/>
+ </route>
+ <route src="Jupiter" dst="Jupiter">
+ <link_ctn id="loopback"/>
+ </route>
+ <route src="Fafard" dst="Fafard">
+ <link_ctn id="loopback"/>
+ </route>
+ <route src="Ginette" dst="Ginette">
+ <link_ctn id="loopback"/>
+ </route>
+ <route src="Bourassa" dst="Bourassa">
+ <link_ctn id="loopback"/>
+ </route>
+ <route src="Tremblay" dst="Jupiter">
+ <link_ctn id="1"/>
+ </route>
+ <route src="Tremblay" dst="Fafard">
+ <link_ctn id="2"/>
+ </route>
+ <route src="Tremblay" dst="Ginette">
+ <link_ctn id="3"/>
+ </route>
+ <route src="Tremblay" dst="Bourassa">
+ <link_ctn id="4"/>
+ </route>
+ <route src="Jupiter" dst="Fafard">
+ <link_ctn id="5"/>
+ </route>
+ <route src="Jupiter" dst="Ginette">
+ <link_ctn id="6"/>
+ </route>
+ <route src="Jupiter" dst="Bourassa">
+ <link_ctn id="7"/>
+ </route>
+ <route src="Fafard" dst="Ginette">
+ <link_ctn id="8"/>
+ </route>
+ <route src="Fafard" dst="Bourassa">
+ <link_ctn id="9"/>
+ </route>
+ <route src="Ginette" dst="Bourassa">
+ <link_ctn id="10"/>
+ </route>
+ </zone>
+</platform>
+++ /dev/null
-0 0.5
-2 1.0
\ No newline at end of file
+++ /dev/null
-2 62500000
-4 31250000
-LOOPAFTER 6
<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
<platform version="4.1">
<zone id="AS0" routing="Full">
- <host id="Cpu A" speed="10f" availability_file="trace/trace_A.txt" state_file="trace/trace_A_failure.txt"/>
- <host id="Cpu B" speed="10f" availability_file="trace/trace_B.txt"/>
+ <host id="Cpu A" speed="10f" availability_file="profiles/trace_A.txt" state_file="profiles/trace_A_failure.txt"/>
+ <host id="Cpu B" speed="10f" availability_file="profiles/trace_B.txt"/>
<link id="LinkA" bandwidth="10MBps" latency="200ms"/>
<route src="Cpu A" dst="Cpu B">
<link_ctn id="LinkA"/>
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)
|br| `examples/s4u/platform-properties/s4u-platform-properties_d.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/platform-properties/s4u-platform-properties_d.xml>`_
|br| `examples/platforms/prop.xml <https://framagit.org/simgrid/simgrid/tree/master/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 <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/small_platform_with_failure.xml>`_
+ |br| The state profiles in `examples/platforms/profiles <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/profiles>`_
+
+ - **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 <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/small_platform_profile.xml>`_
+ |br| The speed, bandwidth and latency profiles in `examples/platforms/profiles <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/profiles>`_
+
=================
Energy Simulation
=================
/* 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. */
+/* This example shows how to work with the state profile of an host or a link,
+ * specifying when the resource must be turned on or off.
+ *
+ * To set such a profile, the first way is to use a file in the XML, while the second is to use the programmatic
+ * interface. Once this profile is in place, the resource will automatically be turned on and off.
+ *
+ * The actors running on an host that is turned off will receive a simgrid::HostFailureException. Since we specified
+ * on_failure="RESTART" for each actors in the XML file, they will be automatically restarted when the host starts
+ * again.
+ *
+ * Communications using failed links will .. fail.
+ */
+
#include "simgrid/s4u.hpp"
#include "xbt/str.h"
} catch (xbt_ex& e) {
if (e.category != network_error)
xbt_die("Unexpected behavior");
- XBT_INFO("Mmh. Something went wrong with '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
+ XBT_INFO("Mmh. The communication with '%s' failed. Nevermind. Let's keep going!", mailbox->get_cname());
delete payload;
}
}
--- /dev/null
+/* 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;
+}
--- /dev/null
+#!/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)
void set_property(std::string key, std::string value);
std::unordered_map<std::string, std::string>* get_properties();
+ void set_state_profile(kernel::profile::Profile* p);
+ void set_speed_profile(kernel::profile::Profile* p);
+
#ifndef DOXYGEN
/** @deprecated See Host::get_properties() */
XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_properties()") std::map<std::string, std::string>* getProperties()
bool is_used();
void turn_on();
+ bool is_on();
void turn_off();
+ bool is_off();
void* get_data(); /** Should be used only from the C interface. Prefer extensions in C++ */
void set_data(void* d);
}
#endif
- /** Setup the profile file with states events (ON or OFF). The profile must contain boolean values. */
+ /** Setup the profile with states events (ON or OFF). The profile must contain boolean values. */
void set_state_profile(kernel::profile::Profile* profile);
- /** Setup the profile file with bandwidth events (peak speed changes due to external load).
+ /** Setup the profile with bandwidth events (peak speed changes due to external load).
* The profile must contain percentages (value between 0 and 1). */
void set_bandwidth_profile(kernel::profile::Profile* profile);
/** Setup the profile file with latency events (peak latency changes due to external load).
{
simgrid::simix::simcall([this, key, value] { this->pimpl_->set_property(key, value); });
}
+/** Specify a profile turning the host on and off according to a exhaustive list or a stochastic law.
+ * The profile must contain boolean values. */
+void Host::set_state_profile(kernel::profile::Profile* p)
+{
+ return simgrid::simix::simcall([this, p] { pimpl_cpu->set_state_profile(p); });
+}
+/** Specify a profile modeling the external load according to a exhaustive list or a stochastic law.
+ *
+ * Each event of the profile represent a peak speed change that is due to external load. The values are given as a rate
+ * of the initial value. This means that the actual value is obtained by multiplying the initial value (the peek speed
+ * at this pstate level) by the rate coming from the profile.
+ */
+void Host::set_speed_profile(kernel::profile::Profile* p)
+{
+ return simgrid::simix::simcall([this, p] { pimpl_cpu->set_speed_profile(p); });
+}
/** @brief Get the peak processor speed (in flops/s), at the specified pstate */
double Host::get_pstate_speed(int pstate_index) const
return simgrid::simix::simcall([this, pstate_index] { return this->pimpl_cpu->get_pstate_peak_speed(pstate_index); });
}
-/** @brief Get the peak computing speed in flops/s at the current pstate, taking the external load into account.
+/** @brief Get the peak computing speed in flops/s at the current pstate, NOT taking the external load into account.
*
* The amount of flops per second available for computing depends on several things:
* - The current pstate determines the maximal peak computing speed (use @ref get_pstate_speed() to retrieve the
* computing speed you would get at another pstate)
- * - If you declared an external load, then this reduces the available computing speed
- * (see @ref simgrid::surf::Cpu::set_speed_trace())
+ * - If you declared an external load (with @ref simgrid::surf::Cpu::set_speed_profile()), you must multiply the
+ * result of get_speed() by get_available_speed() to retrieve what a new computation would get.
*
* The remaining speed is then shared between the executions located on this host.
* You can retrieve the amount of tasks currently running on this host with @ref get_load().
}
/** @brief Get the available speed ratio, between 0 and 1.
*
- * This accounts for external load (see @ref simgrid::surf::Cpu::set_speed_trace()).
+ * This accounts for external load (see @ref simgrid::surf::Cpu::set_speed_profile()).
*/
double Host::get_available_speed() const
{
simgrid::simix::simcall([this]() { this->pimpl_->turn_off(); });
}
+bool Link::is_on()
+{
+ return this->pimpl_->is_on();
+}
+bool Link::is_off()
+{
+ return this->pimpl_->is_off();
+}
+
void* Link::get_data()
{
return this->pimpl_->get_data();
examples/platforms/optorsim/transform_optorsim_platform.pl
examples/platforms/config.xml
examples/platforms/config_tracing.xml
- examples/platforms/trace/bourassa_state.trace
- examples/platforms/trace/fafard_state.trace
- examples/platforms/trace/faulty_host.trace
- 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/link3_state.trace
- examples/platforms/trace/link4_state.trace
- examples/platforms/trace/linkBandwidth7.bw
- examples/platforms/trace/trace_A_failure.txt
- examples/platforms/trace/trace_A.txt
- examples/platforms/trace/trace_B.txt
+ examples/platforms/profiles/bourassa_state.profile
+ examples/platforms/profiles/fafard_state.profile
+ examples/platforms/profiles/faulty_host.profile
+ examples/platforms/profiles/ginette_state.profile
+ examples/platforms/profiles/jupiter_speed.profile
+ examples/platforms/profiles/jupiter_state.profile
+ examples/platforms/profiles/link1_bandwidth.profile
+ examples/platforms/profiles/link1_latency.profile
+ examples/platforms/profiles/link3_state.profile
+ examples/platforms/profiles/link4_state.profile
+ examples/platforms/profiles/linkBandwidth7.bw
+ examples/platforms/profiles/trace_A_failure.txt
+ examples/platforms/profiles/trace_A.txt
+ examples/platforms/profiles/trace_B.txt
examples/platforms/data_center.xml
examples/platforms/dogbone.xml
examples/platforms/energy_platform.xml
examples/platforms/small_platform.xml
examples/platforms/small_platform.lua
examples/platforms/small_platform_constant.xml
+ examples/platforms/small_platform_failures.xml
examples/platforms/small_platform_fatpipe.xml
examples/platforms/small_platform_one_link_routes.xml
- examples/platforms/small_platform_with_failures.xml
+ examples/platforms/small_platform_profile.xml
examples/platforms/small_platform_with_routers.xml
examples/platforms/syscoord/generate_peer_platform.pl
examples/platforms/syscoord/median_harvard.syscoord