abstract algorithms in the domains of Cloud, P2P, HPC, IoT, and similar
settings.
-Since v3.20 (June 2018), S4U is definitely the way to go for long-term
-projects. It is feature complete, but may still evolve slightly in the
+Since v3.20 (June 2018), S4U is the way to go for long-term
+projects. It is feature complete, but may still evolve slightly in
future releases. It can already be used to do everything that can be
done in SimGrid, but you may have to adapt your code in future
releases. When this happens, compiling your code will produce
:ref:`communication <API_s4u_Comm>`, :ref:`disk usage <API_s4u_Io>`,
and other |API_s4u_Activities|_, so that they get reflected within the
simulator. These activities take place on resources such as |API_s4u_Hosts|_,
-|API_s4u_Links|_ and |API_s4u_Disks|_. SimGrid predicts the time taken by each
+|API_s4u_Links|_, and |API_s4u_Disks|_. SimGrid predicts the time taken by each
activity and orchestrates the actors accordingly, waiting for the
completion of these activities.
When **communicating**, data is not directly sent to other actors but
-posted onto a |API_s4u_Mailbox|_ that serves as a rendez-vous point between
+posted onto a |API_s4u_Mailbox|_ that serves as a rendezvous point between
communicating actors. This means that you don't need to know who you
are talking to, you just put your communication `Put` request in a
mailbox, and it will be matched with a complementary `Get`
request. Alternatively, actors can interact through **classical
synchronization mechanisms** such as |API_s4u_Barrier|_, |API_s4u_Semaphore|_,
-|API_s4u_Mutex|_ and |API_s4u_ConditionVariable|_.
+|API_s4u_Mutex|_, and |API_s4u_ConditionVariable|_.
Each actor is located on a simulated |API_s4u_Host|_. Each host is located
-itself in a |API_s4u_NetZone|_, that knows the networking path between one
+in a |API_s4u_NetZone|_, that knows the networking path between one
resource to another. Each NetZone is included in another one, forming
a tree of NetZones which root zone contains the whole platform. The
actors can also be located on a |API_s4U_VirtualMachine|_ that may
- :ref:`class Engine <API_s4u_Engine>`
Simulation engine (singleton).
- :ref:`class Mailbox <API_s4u_Mailbox>`
- Communication rendez-vous, with which actors meet each other.
+ Communication rendezvous, with which actors meet each other.
- **Resources**
- :ref:`class Exec <API_s4u_Exec>`
Computation activity, started on Host and consuming CPU resources.
- :ref:`class Io <API_s4u_Io>`
- I/O activity, started on and consumming disks.
+ I/O activity, started on and consuming disks.
- **Synchronization Objects**: Classical IPC that actors can use
Once your asynchronous activity is started, you can test for its
completion using :cpp:func:`s4u::Activity::test() <simgrid::s4u::Activity::test>`.
-This function returns ``true`` if the activity completed already.
+This function returns ``true`` if the activity is completed already.
You can also use :cpp:func:`s4u::Activity::wait() <simgrid::s4u::Activity::wait>`
to block until the completion of the activity. To wait for at most a given amount of time,
use :cpp:func:`s4u::Activity::wait_for() <simgrid::s4u::Activity::wait_for>`.
What are Mailboxes?
===================
-|API_s4u_Mailboxes|_ are rendez-vous points for network communications,
+|API_s4u_Mailboxes|_ are rendezvous points for network communications,
similar to URLs on which you could post and retrieve data. Actually,
the mailboxes are not involved in the communication once it starts,
but only to find the contact with which you want to communicate.
They are similar to many common things: The phone number, which allows
-the caller to find the receiver. The twitter hashtag, which help
-senders and receivers to find each others. In TCP, the pair
+the caller to find the receiver. The Twitter hashtag, which helps
+senders and receivers to find each other. In TCP, the pair
``{host name, host port}`` to which you can connect to find your peer.
In HTTP, URLs through which the clients can connect to the servers.
In ZeroMQ, the queues are used to match senders and receivers.
for the corresponding :cpp:func:`Mailbox::get() <simgrid::s4u::Mailbox::get>`.
You can change this by :ref:`declaring a receiving actor <s4u_receiving_actor>`.
-A big difference with twitter hashtags is that SimGrid does not
+A big difference with Twitter hashtags is that SimGrid does not
offer easy support to broadcast a given message to many
-receivers. So that would be like a twitter tag where each message
+receivers. So that would be like a Twitter tag where each message
is consumed by the first receiver.
A big difference with the ZeroMQ queues is that you cannot filter
to each topic individually with a
:cpp:func:`get_async() <simgrid::s4u::Mailbox::get_async>` on each mailbox.
Then, use :cpp:func:`Comm::wait_any() <simgrid::s4u::Comm::wait_any>`
-to get the first message on any of the mailbox you are subscribed onto.
+to get the first message on any of the mailboxes you are subscribed to.
The mailboxes are not located on the network, and you can access
-them without any latency. The network delay are only related to the
+them without any latency. The network delays are only related to the
location of the sender and receiver once the match between them is
done on the mailbox. This is just like the phone number that you
can use locally, and the geographical distance only comes into play
=====================
You can retrieve any existing mailbox from its name (which is a
-unique string, just like a twitter tag). This results in a
-versatile mechanism that can be used to build many different
+unique string, just like a Twitter tag). This results in a
+versatile tool that can be used to build many different
situations.
To model classical socket communications, use "hostname:port" as
mailbox. This does not make it easy to build a perfectly realistic
model of the TCP sockets, but in most cases, this system is too
cumbersome for your simulations anyway. You probably want something
-simpler, that turns our to be easy to build with the mailboxes.
+simpler, that turns out to be easy to build with the mailboxes.
Many SimGrid examples use a sort of yellow page system where the
mailbox names are the name of the service (such as "worker",
-"master" or "reducer"). That way, you don't have to know where your
+"master", or "reducer"). That way, you don't have to know where your
peer is located to contact it. You don't even need its name. Its
function is enough for that. This also gives you some sort of load
balancing for free if more than one actor pulls from the mailbox:
Note that being permanent receivers of a mailbox prevents actors to be
garbage-collected. If your simulation creates many short-lived actors
-that marked as permanent receiver, you should call
+that are marked as permanent receiver, you should call
``mailbox->set_receiver(nullptr)`` by the end of the actors so that their
memory gets properly reclaimed. This call should be at the end of the
actor's function, not in an on_exit callback.
} // The mutex gets automatically freed because the only existing reference gets out of scope
-Note that Mailboxes, Hosts and Links are not handled thought smart
+Note that Mailboxes, Hosts, and Links are not handled through smart
pointers (yet?). This means that it is currently impossible to destroy a
mailbox or a link. You can still destroy a host (but probably
shouldn't), using :cpp:func:`simgrid::s4u::Host::destroy`.
---------------------
Simulate the execution of some code on this actor. You can either simulate
-parallel or sequential code, and you can either block upon the termination of
+parallel or sequential code and you can either block upon the termination of
the execution, or start an asynchronous activity.
.. tabs::
#include <simgrid/s4u/Mailbox.hpp>
- Note that there is no MailboxPtr type, and that you cannot use the RAII
+ Note that there is no MailboxPtr type and that you cannot use the RAII
idiom on mailboxes because they are internal objects to the simulation
engine. Once created, there is no way to destroy a mailbox before the end
of the simulation.
#include <simgrid/s4u/Disk.hpp>
- Note that there is no DiskPtr type, and that you cannot use the RAII
+ Note that there is no DiskPtr type and that you cannot use the RAII
idiom on disks because SimGrid does not allow (yet) to create nor
destroy resources once the simulation is started.
#include <simgrid/s4u/Link.hpp>
- Note that there is no LinkPtr type, and that you cannot use the RAII
+ Note that there is no LinkPtr type and that you cannot use the RAII
idiom on hosts because SimGrid does not allow (yet) to create nor
destroy resources once the simulation is started.
#include <simgrid/s4u/NetZone.hpp>
- Note that there is no NetZonePtr type, and that you cannot use the RAII
+ Note that there is no NetZonePtr type and that you cannot use the RAII
idiom on network zones because SimGrid does not allow (yet) to create nor
destroy resources once the simulation is started.
SimGrid comes with an extensive set of examples, documented on this
page. Most of them only demonstrate one single feature, with some
-larger examplars listed below.
+larger exemplars listed below.
The C++ examples can be found under examples/cpp while python examples
are in examples/python. Each such directory contains the source code (also listed
----------------------------
- **Creating actors:**
- Most actors are started from the deployment XML file, because this
+ Most actors are started from the deployment XML file because this
is a :ref:`better scientific habit <howto_science>`, but you can
also create them directly from your code.
The following file is used in both C++ and Python.
- **React to the end of actors:** You can attach callbacks to the end of
- actors. There is several ways of doing so, depending on whether you want to
+ actors. There are several ways of doing so, depending on whether you want to
attach your callback to a given actor and on how you define the end of a
- given actor. User code probably want to react to the termination of an actor
+ given actor. User code probably wants to react to the termination of an actor
while some plugins want to react to the destruction (memory collection) of
actors.
This file is not really interesting: the important matter is in the XML file.
- **Daemonize actors:**
- Some actors may be intended to simulate daemons that run in background. This example show how to transform a regular
+ Some actors may be intended to simulate daemons that run in the background.
+ This example shows how to transform a regular
actor into a daemon that will be automatically killed once the simulation is over.
.. tabs::
:cpp:func:`sg_actor_is_suspended()`.
- **Migrating Actors:**
- Actors can move or be moved from a host to another very easily. It amount to setting them on a new host.
+ Actors can move or be moved from a host to another very easily. It amounts to setting them on a new host.
.. tabs::
---------------------------
This section details how to run trace-driven simulations. It is very
-handy when you want to test an algorithm or protocol that only react
+handy when you want to test an algorithm or protocol that only reacts
to external events. For example, many P2P protocols react to user
requests, but do nothing if there is no such event.
- **Basic communications:**
This simple example just sends one message back and forth.
- The tesh file laying in the directory show how to start the simulator binary, highlighting how to pass options to
+ The tesh file laying in the directory shows how to start the simulator binary, highlighting how to pass options to
the simulators (as detailed in Section :ref:`options`).
.. tabs::
See also :cpp:func:`sg_mailbox_put_async()` and :cpp:func:`sg_comm__wait()`.
- - **Waiting communications with timeouts:**
+ - **Waiting for communications with timeouts:**
This example is very similar to the previous one, simply adding how to declare timeouts when waiting on asynchronous communication.
.. tabs::
- **Waiting for all communications in a set:**
The ``wait_all()`` function is useful when you want to block until
- all activities in a given set have completed.
+ all activities in a given set have been completed.
.. tabs::
- **Basic execution:**
The computations done in your program are not reported to the
- simulated world, unless you explicitly request the simulator to pause
+ simulated world unless you explicitly request the simulator to pause
the actor until a given amount of flops gets computed on its simulated
- host. Some executions can be given an higher priority so that they
+ host. Some executions can be given a higher priority so that they
get more resources.
.. tabs::
PDGEM and the other ScaLAPACK routines. Note that this only works
with the "ptask_L07" host model (``--cfg=host/model:ptask_L07``).
- This example demonstrates several kind of parallel tasks: regular
+ This example demonstrates several kinds of parallel tasks: regular
ones, communication-only (without computation), computation-only
(without communication), synchronization-only (neither
communication nor computation). It also shows how to reconfigure a
- task after its start, to change the amount of hosts it runs onto.
- This allows to simulate malleable tasks.
+ task after its start, to change the number of hosts it runs onto.
+ This allows simulating malleable tasks.
.. tabs::
See also :cpp:func:`simgrid::s4u::this_actor::parallel_execute()`.
- **Using Pstates on a host:**
- This example shows how define a set of pstates in the XML. The current pstate
+ This example shows how to define a set of pstates in the XML. The current pstate
of a host can then be accessed and changed from the program.
.. tabs::
This shows how to declare disks in XML.
The FileSystem plugin provides a more detailed view, with the
-classical operations over files: open, move, unlink, and of course
+classical operations over files: open, move, unlink, and of course,
read and write. The file and disk sizes are also dealt with and can
-result in short reads and short write, as in reality.
+result in short reads and short writes, as in reality.
- **File Management:**
This example illustrates the use of operations on files
.. example-tab:: examples/cpp/io-file-system/s4u-io-file-system.cpp
- **Remote I/O:**
- I/O operations on files can also be done in a remote fashion,
+ I/O operations on files can also be done remotely,
i.e. when the accessed disk is not mounted on the caller's host.
.. tabs::
.. showfile:: examples/platforms/prop.xml
:language: xml
- - **Retrieving the netzones matching a given criteria:**
+ - **Retrieving the netzones matching given criteria:**
Shows how to filter the cluster netzones.
.. tabs::
.. example-tab:: examples/cpp/routing-get-clusters/s4u-routing-get-clusters.cpp
- - **Retrieving the list of hosts matching a given criteria:**
- Shows how to filter the actors that match a given criteria.
+ - **Retrieving the list of hosts matching given criteria:**
+ Shows how to filter the actors that match given criteria.
.. tabs::
=================
- **Describing the energy profiles in the platform:**
- The first platform file contains the energy profile of each links and
- hosts for a wired network, which is necessary to get energy consumption
+ The first platform file contains the energy profile of each link and
+ host for a wired network, which is necessary to get energy consumption
predictions. The second platform file is the equivalent for a wireless
network. As usual, you should not trust our example, and you should
strive to double-check that your instantiation matches your target
.. example-tab:: examples/cpp/energy-wifi/s4u-energy-wifi.cpp
- **Modeling the shutdown and boot of hosts:**
- Simple example of model of model for the energy consumption during
+ Simple example of a model for the energy consumption during
the host boot and shutdown periods.
.. tabs::
=======================
Tracing can be activated by various configuration options which
-are illustrated in these example. See also the
+are illustrated in these examples. See also the
:ref:`full list of options related to tracing <tracing_tracing_options>`.
It is interesting to run the process-create example with the following
options to see the task executions:
- **Platform Tracing:**
- This program is a toy example just loading the platform, so that
+ This program is a toy example just loading the platform so that
you can play with the platform visualization. Recommended options:
``--cfg=tracing:yes --cfg=tracing/categorized:yes``
.. example-tab:: examples/cpp/trace-platform/s4u-trace-platform.cpp
- **Setting Categories**
- This example declares several tracing categories to that are used to
+ This example declares several tracing categories that are used to
classify its tasks. When the program is executed, the tracing mechanism
registers the resource utilization of hosts and links according to these
categories. Recommended options:
.. example-tab:: examples/cpp/trace-route-user-variables/s4u-trace-route-user-variables.cpp
========================
-Larger SimGrid Examplars
+Larger SimGrid Exemplars
========================
This section contains application examples that are somewhat larger
.. example-tab:: examples/c/app-token-ring/app-token-ring.c
- **Master Workers:**
- Another good old example, where one Master process has a bunch of task to dispatch to a set of several Worker
+ Another good old example, where one Master process has a bunch of tasks to dispatch to a set of several Worker
processes.
.. tabs::
-----------------
- **Cloud basics**
- This example starts some computations both on PMs and VMs, and
+ This example starts some computations both on PMs and VMs and
migrates some VMs around.
.. tabs::
Simulator. The most interesting is probably not the C++ files since
they are unchanged from the other simulations, but the associated files,
such as the platform file to see how to declare a platform to be used
- with the ns-3 bindings of SimGrid and the tesh file to see how to actually
+ with the ns-3 bindings of SimGrid and the tesh file to see how to
start a simulation in these settings.
.. tabs::
- **wifi links**
- This demonstrates how to declare a wifi link in your platform and
- how to use it in your simulation. The basics is to have a link
- which sharing policy is set to `WIFI`. Such links can have more
+ This demonstrates how to declare a wifi zone in your platform and
+ how to use it in your simulation. For that, you should have a link
+ whose sharing policy is set to `WIFI`. Such links can have more
than one bandwidth value (separated by commas), corresponding to
the several SNR level of your wifi link.
=======================
The model-checker can be used to exhaustively search for issues in the
-tested application. It must be activated at compile time, but this
-mode is rather experimental in SimGrid (as of v3.22). You should not
+tested application. It must be activated at compile-time, but this
+mode is rather experimental in SimGrid (as of v3.25). You should not
enable it unless you really want to formally verify your applications:
-SimGrid is slower and maybe less robust when MC is enabled.
+SimGrid is slower and may be less robust when MC is enabled.
- **Failing assert**
In this example, two actors send some data to a central server,
which asserts that the messages are always received in the same order.
- This is obviously wrong, and the model-checker correctly finds a
+ This is wrong, and the model-checker correctly finds a
counter-example to that assertion.
.. tabs::