Lab 1: Simpler deployments
--------------------------
-.. rst-class:: learning-goals
+.. rst-class:: compact-list
**Learning goals:**
Lab 2: Using the Whole Platform
-------------------------------
-.. rst-class:: learning-goals
+.. rst-class:: compact-list
**Learning goals:**
.. code-block:: cpp
- void my_actor(int param1, double param2, std::string param3) {
- ...
- }
- int main(int argc, char argv**) {
- ...
- simgrid::s4u::ActorPtr actor;
- actor = simgrid::s4u::Actor::create("name", simgrid::s4u::Host::by_name("the_host"),
- &my_actor, 42, 3.14, "thevalue");
- ...
- }
+ void my_actor(int param1, double param2, std::string param3) {
+ ...
+ }
+ int main(int argc, char argv**) {
+ ...
+ simgrid::s4u::ActorPtr actor;
+ actor = simgrid::s4u::Actor::create("name", simgrid::s4u::Host::by_name("the_host"),
+ &my_actor, 42, 3.14, "thevalue");
+ ...
+ }
.. group-tab:: Python
For that, the master needs to retrieve the list of hosts declared in
- the platform with :py:func:`simgrid.Engine.get_all_hosts`.
- Then, the master should start the worker actors with
- :py:func:`simgrid.Actor.create`.
+ the platform with :py:func:`simgrid.Engine.get_all_hosts`. Since this method is not static,
+ you may want to call it on the Engine instance, as in ``Engine.instance().get_all_hosts()``.
+ Then, the master should start the worker actors with :py:func:`simgrid.Actor.create`.
``Actor.create(name, host, func, params...)`` is a very flexible
function. Its third parameter is the function that the actor should
execute. This function can take any kind of parameter, provided that
- you pass similar parameters to ``Actor?create()``. For example, you
+ you pass similar parameters to ``Actor.create()``. For example, you
could have something like this:
- .. code-block:: cpp
+ .. code-block:: python
- def my_actor(param1, param2, param3):
- ...
- actor = simgrid.Actor.create("name", the_host, my_actor, 42, 3.14, "thevalue")
+ def my_actor(param1, param2, param3):
+ # your code comes here
+ actor = simgrid.Actor.create("name", the_host, my_actor, 42, 3.14, "thevalue")
Master-Workers Communication
use a mailbox name that is unique over the simulation even if there is
more than one master.
-One possibility for that is to use the actor ID (aid) of each worker
-as a mailbox name. The master can retrieve the aid of the newly
-created actor with ``get_pid()`` while the actor itself can
-retrieve its own aid with ``this_actor::get_pid()``.
-The retrieved value is an ``aid_t``, which is an alias for ``long``.
+.. tabs::
+
+ .. group-tab:: C++
+
+ One possibility for that is to use the actor ID (aid) of each worker
+ as a mailbox name. The master can retrieve the aid of the newly
+ created actor with :cpp:func:`simgrid::s4u::Actor::get_pid()` while the actor itself can
+ retrieve its own aid with :cpp:func:`simgrid::s4u::this_actor::get_pid()`.
+ The retrieved value is an :cpp:type:`aid_t`, which is an alias for ``long``.
+
+ .. group-tab:: Python
+
+ One possibility for that is to use the actor ID of each worker
+ as a mailbox name. The master can retrieve the aid of the newly
+ created actor with :py:func:`simgrid.Actor.pid` while the actor itself can
+ retrieve its own aid with :py:func:`simgrid.this_actor.get_pid()`.
Wrap up
.......
Lab 3: Fixed Experiment Duration
--------------------------------
-.. rst-class:: learning-goals
+.. rst-class:: compact-list
**Learning goals:**
You can still stop your workers with a specific task as previously,
or you may kill them forcefully with :cpp:func:`simgrid::s4u::Actor::kill` (C++)
-:py:func:`simgrid.Actor.kill` (C++).
+:py:func:`simgrid.Actor.kill` (Python).
Anyway, the new deployment `deployment3.xml` file should thus look
like this:
.................................
Not all messages are equally informative, so you probably want to
-change some of the *info* messages (C: :c:macro:`XBT_INFO`; Python: :py:func:`this_actor.info`)
-into *debug* messages`(C: c:macro:`XBT_DEBUG`; Python: :py:func:`this_actor.debug`) so that they are
+change some of the *info* messages (C: :c:macro:`XBT_INFO`; Python: :py:func:`simgrid.this_actor.info`)
+into *debug* messages`(C: :c:macro:`XBT_DEBUG`; Python: :py:func:`simgrid.this_actor.debug`) so that they are
hidden by default. For example, you may want to use an *info* message once
every 100 tasks and *debug* when sending all the other tasks. Or
you could show only the total number of tasks processed by
Lab 4: What-if analysis
-----------------------
-.. rst-class:: learning-goals
+.. rst-class:: compact-list
**Learning goals:**
Retrieve all links in the platform with :cpp:func:`simgrid::s4u::Engine::get_all_links()` (C++) or :py:func:`simgrid.Engine.get_all_links()` (python).
-Retrieve the list of links from one host to another with :cpp:func:`simgrid::s4u::Host::route_to` (C++) or :cpp:func:`simgrid.Host.route_to` (python).
+Retrieve the list of links from one host to another with :cpp:func:`simgrid::s4u::Host::route_to` (C++) or :py:func:`simgrid.Host.route_to` (python).
Modify the bandwidth of a given link with :cpp:func:`simgrid::s4u::Link::set_bandwidth` (C++) or :py:func:`simgrid.Link.set_bandwidth` (python).
You can even have the bandwidth automatically vary over time with :cpp:func:`simgrid::s4u::Link::set_bandwidth_profile` (C++) or :py:func:`simgrid.Link.set_bandwidth_profile` (python).
Lab 5: Competing Applications
-----------------------------
-.. rst-class:: learning-goals
+.. rst-class:: compact-list
**Learning goals:**
Instead of starting the execution in one function call only with
``this_actor::execute(cost)``, you need to
create the execution activity, set its tracing category, start it
-and wait for its completion, as follows:
+and wait for its completion, as follows.
.. tabs::
.. group-tab:: C++
+ Use :cpp:func:`simgrid::s4u::Exec::set_tracing_category` to change the category of an execution.
+
.. code-block:: cpp
simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(compute_cost);
.. group-tab:: Python
+ Use :py:func:`simgrid.Exec.set_tracing_category` to change the category of an execution.
+
.. code-block:: python
exec = simgrid:.this_actor.exec_init(compute_cost)