src/dest, and communicator information). This may change simulation times
for very small message sizes, but should be more realistic.
+Documentation:
+ - New examples: wifi networks, and communication suspend
+
S4U:
- the on_exit() of each actor is also executed when the simulation deadlocks.
+ - New functions: s4u::Activity:: suspend(), resume() and is_suspended()
+ An example is provided for s4u::Comm but it should work with Exec and Io.
SMPI:
- Update proxy apps coverage of new ECP apps: 60+ apps now tested nightly on
- FG!24: Documentation and fix for xbt/random
- FG!35: Add a modeling hint for parallel links in doc
- FG!36: [xbt/random] Read/Write the state of the RNG
+ - FG#54: How to suspend a comm?
- GF#18137: Allow different stack sizes?
- GH#128: Parallelization of simulation with --cfg=contexts/nthreads
- GH#139: Allow pthread creation in SMPI
- GH#336: Packet-level simulation using SMPI?
- GH!337: Fix link_energy plugin for wifi platforms
- GH!339: Add Mailbox set_receiver method to python binding
+ - GH!344: Cast hugepages macros parameters to int64
----------------------------------------------------------------------------
include examples/c/app-pingpong/app-pingpong_d.xml
include examples/c/app-token-ring/app-token-ring.c
include examples/c/app-token-ring/app-token-ring.tesh
-include examples/c/async-wait/async-wait.c
-include examples/c/async-wait/async-wait.tesh
-include examples/c/async-wait/async-wait2_d.xml
-include examples/c/async-wait/async-wait3_d.xml
-include examples/c/async-wait/async-wait4_d.xml
-include examples/c/async-wait/async-wait_d.xml
-include examples/c/async-waitall/async-waitall.c
-include examples/c/async-waitall/async-waitall.tesh
-include examples/c/async-waitall/async-waitall_d.xml
-include examples/c/async-waitany/async-waitany.c
-include examples/c/async-waitany/async-waitany.tesh
-include examples/c/async-waitany/async-waitany_d.xml
include examples/c/cloud-capping/cloud-capping.c
include examples/c/cloud-capping/cloud-capping.tesh
include examples/c/cloud-masterworker/cloud-masterworker.c
include examples/c/cloud-migration/cloud-migration.tesh
include examples/c/cloud-simple/cloud-simple.c
include examples/c/cloud-simple/cloud-simple.tesh
+include examples/c/comm-wait/comm-wait.c
+include examples/c/comm-wait/comm-wait.tesh
+include examples/c/comm-wait/comm-wait2_d.xml
+include examples/c/comm-wait/comm-wait3_d.xml
+include examples/c/comm-wait/comm-wait4_d.xml
+include examples/c/comm-wait/comm-wait_d.xml
+include examples/c/comm-waitall/comm-waitall.c
+include examples/c/comm-waitall/comm-waitall.tesh
+include examples/c/comm-waitall/comm-waitall_d.xml
+include examples/c/comm-waitany/comm-waitany.c
+include examples/c/comm-waitany/comm-waitany.tesh
+include examples/c/comm-waitany/comm-waitany_d.xml
include examples/c/dht-kademlia/answer.c
include examples/c/dht-kademlia/answer.h
include examples/c/dht-kademlia/common.h
include examples/python/actor-suspend/actor-suspend.tesh
include examples/python/actor-yield/actor-yield.py
include examples/python/actor-yield/actor-yield.tesh
-include examples/python/async-wait/async-wait.py
-include examples/python/async-wait/async-wait.tesh
-include examples/python/async-waitall/async-waitall.py
-include examples/python/async-waitall/async-waitall.tesh
-include examples/python/async-waitany/async-waitany.py
-include examples/python/async-waitany/async-waitany.tesh
+include examples/python/comm-wait/comm-wait.py
+include examples/python/comm-wait/comm-wait.tesh
+include examples/python/comm-waitall/comm-waitall.py
+include examples/python/comm-waitall/comm-waitall.tesh
+include examples/python/comm-waitany/comm-waitany.py
+include examples/python/comm-waitany/comm-waitany.tesh
include examples/python/exec-async/exec-async.py
include examples/python/exec-async/exec-async.tesh
include examples/python/exec-basic/exec-basic.py
include examples/s4u/app-pingpong/simix-breakpoint.tesh
include examples/s4u/app-token-ring/s4u-app-token-ring.cpp
include examples/s4u/app-token-ring/s4u-app-token-ring.tesh
-include examples/s4u/async-ready/s4u-async-ready.cpp
-include examples/s4u/async-ready/s4u-async-ready.tesh
-include examples/s4u/async-ready/s4u-async-ready_d.xml
-include examples/s4u/async-wait/s4u-async-wait.cpp
-include examples/s4u/async-wait/s4u-async-wait.tesh
-include examples/s4u/async-wait/s4u-async-wait_d.xml
-include examples/s4u/async-waitall/s4u-async-waitall.cpp
-include examples/s4u/async-waitall/s4u-async-waitall.tesh
-include examples/s4u/async-waitall/s4u-async-waitall_d.xml
-include examples/s4u/async-waitany/s4u-async-waitany.cpp
-include examples/s4u/async-waitany/s4u-async-waitany.tesh
-include examples/s4u/async-waitany/s4u-async-waitany_d.xml
-include examples/s4u/async-waituntil/s4u-async-waituntil.cpp
-include examples/s4u/async-waituntil/s4u-async-waituntil.tesh
-include examples/s4u/async-waituntil/s4u-async-waituntil_d.xml
include examples/s4u/cloud-capping/s4u-cloud-capping.cpp
include examples/s4u/cloud-capping/s4u-cloud-capping.tesh
include examples/s4u/cloud-migration/s4u-cloud-migration.cpp
include examples/s4u/cloud-simple/s4u-cloud-simple.tesh
include examples/s4u/comm-dependent/s4u-comm-dependent.cpp
include examples/s4u/comm-dependent/s4u-comm-dependent.tesh
+include examples/s4u/comm-ready/s4u-comm-ready.cpp
+include examples/s4u/comm-ready/s4u-comm-ready.tesh
+include examples/s4u/comm-ready/s4u-comm-ready_d.xml
+include examples/s4u/comm-suspend/s4u-comm-suspend.cpp
+include examples/s4u/comm-suspend/s4u-comm-suspend.tesh
+include examples/s4u/comm-suspend/s4u-comm-suspend_d.xml
+include examples/s4u/comm-wait/s4u-comm-wait.cpp
+include examples/s4u/comm-wait/s4u-comm-wait.tesh
+include examples/s4u/comm-wait/s4u-comm-wait_d.xml
+include examples/s4u/comm-waitall/s4u-comm-waitall.cpp
+include examples/s4u/comm-waitall/s4u-comm-waitall.tesh
+include examples/s4u/comm-waitall/s4u-comm-waitall_d.xml
+include examples/s4u/comm-waitany/s4u-comm-waitany.cpp
+include examples/s4u/comm-waitany/s4u-comm-waitany.tesh
+include examples/s4u/comm-waitany/s4u-comm-waitany_d.xml
+include examples/s4u/comm-waituntil/s4u-comm-waituntil.cpp
+include examples/s4u/comm-waituntil/s4u-comm-waituntil.tesh
+include examples/s4u/comm-waituntil/s4u-comm-waituntil_d.xml
include examples/s4u/dht-chord/s4u-dht-chord-node.cpp
include examples/s4u/dht-chord/s4u-dht-chord.cpp
include examples/s4u/dht-chord/s4u-dht-chord.hpp
include examples/s4u/network-ns3/onelink_d.xml
include examples/s4u/network-ns3/s4u-network-ns3.cpp
include examples/s4u/network-ns3/s4u-network-ns3.tesh
+include examples/s4u/network-wifi/s4u-network-wifi.cpp
+include examples/s4u/network-wifi/s4u-network-wifi.tesh
include examples/s4u/platform-failures/s4u-platform-failures.cpp
include examples/s4u/platform-failures/s4u-platform-failures.tesh
include examples/s4u/platform-failures/s4u-platform-failures_d.xml
include examples/platforms/two_peers.xml
include examples/platforms/vivaldi.xml
include examples/platforms/wifi.xml
-include examples/platforms/wifi_decay_2STA.xml
include examples/python/CMakeLists.txt
include examples/python/actor-create/actor-create_d.xml
include examples/python/actor-lifetime/actor-lifetime_d.xml
-include examples/python/async-wait/async-wait_d.xml
-include examples/python/async-waitall/async-waitall_d.xml
-include examples/python/async-waitany/async-waitany_d.xml
+include examples/python/comm-wait/comm-wait_d.xml
+include examples/python/comm-waitall/comm-waitall_d.xml
+include examples/python/comm-waitany/comm-waitany_d.xml
include examples/s4u/CMakeLists.txt
include examples/smpi/CMakeLists.txt
include examples/smpi/NAS/CMakeLists.txt
.. autodoxymethod:: simgrid::s4u::Link::set_latency_profile(kernel::profile::Profile *profile)
.. autodoxymethod:: simgrid::s4u::Link::set_state_profile(kernel::profile::Profile *profile)
+WIFI links
+----------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Link::set_host_wifi_rate(s4u::Host* host, int level)
+
Signals
-------
.. autodoxymethod:: simgrid::s4u::Activity::wait_until(double time_limit)
.. autodoxymethod:: simgrid::s4u::Activity::vetoable_start()
+Suspending and resuming an activity
+-----------------------------------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. autodoxymethod:: simgrid::s4u::Activity::suspend
+ .. autodoxymethod:: simgrid::s4u::Activity::resume
+ .. autodoxymethod:: simgrid::s4u::Activity::is_suspended
+
.. _API_s4u_Comm:
=============
recent version of both SimGrid and ns-3. While the Debian package of SimGrid
don't have the ns-3 bindings activated, you can still use the packaged version
of ns-3 by grabbing the ``libns3-dev ns3`` packages. Alternatively, you can
-install ns-3 from scratch as follows:
-
-.. code-block:: shell
-
- # Download the source
- wget http://www.nsnam.org/release/ns-allinone-3.29.tar.bz2
- tar -xf ns-allinone-3.29.tar.bz2
- cd ns-allinone-3.29/ns-3.29/
- # Configure, build and install
- ./waf configure --prefix="/opt/ns3" # or give another path if you prefer
- ./waf
- ./waf install
-
-For more information, please refer to the ns-3 documentation
-(`official website <http://www.nsnam.org>`_).
+install ns-3 from scratch (see the `ns-3 documentation <http://www.nsnam.org>`_).
Enabling ns-3 in SimGrid
========================
SimGrid must be recompiled with the ``enable_ns3`` option activated in cmake.
-Optionally, use ``NS3_HINT`` to hint cmake about where to find ns-3.
+Optionally, use ``NS3_HINT`` to tell cmake where ns3 is installed on
+your disk.
.. code-block:: shell
Any route longer than one will be ignored when using ns-3. They are
harmless, but you still need to connect your hosts using one-hop routes.
The best solution is to add routers to split your route. Here is an
-example of invalid platform:
+example of an invalid platform:
.. code-block:: shell
<platform>
- <host id="alice" speed="1Gf" />
- <host id="bob" speed="1Gf" />
+ <zone id="zone0" routing="Full">
+ <host id="alice" speed="1Gf" />
+ <host id="bob" speed="1Gf" />
- <link id="l1" bw="1Mbps" />
- <link id="l2" bw="1Mbps" />
-
- <route src="alice" dst="bob">
- <link_ctn id="l1"/> <!-- !!!! INVALID WITH ns-3 !!!! -->
- <link_ctn id="l2"/> <!-- !!!! length=2 IS TOO MUCH !!!! -->
- </route>
+ <link id="l1" bw="1Mbps" />
+ <link id="l2" bw="1Mbps" />
+
+ <route src="alice" dst="bob">
+ <link_ctn id="l1"/> <!-- !!!! INVALID WITH ns-3 !!!! -->
+ <link_ctn id="l2"/> <!-- !!!! length=2 IS TOO MUCH !!!! -->
+ </route>
+ </zone>
</platform>
This can be reformulated as follows to make it usable with the ns-3 binding.
.. code-block:: shell
<platform>
- <host id="alice" speed="1Gf" />
- <host id="bob" speed="1Gf" />
+ <zone id="zone0" routing="Full">
+ <host id="alice" speed="1Gf" />
+ <host id="bob" speed="1Gf" />
- <router id="r1" /> <!-- routers are compute-less hosts -->
+ <router id="r1" /> <!-- routers are compute-less hosts -->
- <link id="l1" bw="1Mbps" />
- <link id="l2" bw="1Mbps" />
+ <link id="l1" bw="1Mbps" />
+ <link id="l2" bw="1Mbps" />
- <route src="alice" dst="r1">
- <link_ctn id="l1"/>
- </route>
+ <route src="alice" dst="r1">
+ <link_ctn id="l1"/>
+ </route>
- <route src="r1" dst="bob">
- <link_ctn id="l2"/>
- </route>
+ <route src="r1" dst="bob">
+ <link_ctn id="l2"/>
+ </route>
+ </zone>
</platform>
Once your platform is OK, just change the :ref:`network/model
Many other files from the ``examples/platform directory`` are usable with the
ns-3 model, such as `examples/platforms/dogbone.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/dogbone.xml>`_.
-Check the file `examples/deprecated/msg/network-ns3/network-ns3.tesh <https://framagit.org/simgrid/simgrid/tree/master/examples/deprecated/msg/network-ns3/network-ns3.tesh>`_
+Check the file `examples/s4u/network-ns3/network-ns3.tesh <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/network-ns3/network-ns3.tesh>`_
to see which ones are used in our regression tests.
Limitations
Our goal is to keep the ns-3 plugin of SimGrid as easy (and hopefully readable)
as possible. If the current state does not fit your needs, you should modify
this plugin, and/or create your own plugin from the existing one. If you come up
-with interesting improvements, please contribute them back
+with interesting improvements, please contribute them back.
Troubleshooting
===============
.. tabs::
- .. example-tab:: examples/s4u/async-wait/s4u-async-wait.cpp
+ .. example-tab:: examples/s4u/comm-wait/s4u-comm-wait.cpp
See also :cpp:func:`simgrid::s4u::Mailbox::put_async()` and :cpp:func:`simgrid::s4u::Comm::wait()`.
- .. example-tab:: examples/python/async-wait/async-wait.py
+ .. example-tab:: examples/python/comm-wait/comm-wait.py
See also :py:func:`simgrid.Mailbox.put_async()` and :py:func:`simgrid.Comm.wait()`.
- .. example-tab:: examples/c/async-wait/async-wait.c
+ .. example-tab:: examples/c/comm-wait/comm-wait.c
See also :cpp:func:`sg_mailbox_put_async()` and :cpp:func:`sg_comm__wait()`.
+ - **Suspending communications:**
+ The ``suspend()`` and ``resume()`` functions allow to block the
+ progression of a given communication for a while and then unblock it.
+ ``is_suspended()`` can be used to retrieve whether the activity is
+ currently blocked or not.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/comm-suspend/s4u-comm-suspend.cpp
+
+ See also :cpp:func:`simgrid::s4u::Activity::suspend()`
+ :cpp:func:`simgrid::s4u::Activity::resume()` and
+ :cpp:func:`simgrid::s4u::Activity::is_suspended()`.
+
+
- **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.
.. tabs::
- .. example-tab:: examples/s4u/async-waitall/s4u-async-waitall.cpp
+ .. example-tab:: examples/s4u/comm-waitall/s4u-comm-waitall.cpp
See also :cpp:func:`simgrid::s4u::Comm::wait_all()`.
- .. example-tab:: examples/python/async-waitall/async-waitall.py
+ .. example-tab:: examples/python/comm-waitall/comm-waitall.py
See also :py:func:`simgrid.Comm.wait_all()`.
- .. example-tab:: examples/c/async-waitall/async-waitall.c
+ .. example-tab:: examples/c/comm-waitall/comm-waitall.c
See also :cpp:func:`sg_comm_wait_all()`.
.. tabs::
- .. example-tab:: examples/s4u/async-waitany/s4u-async-waitany.cpp
+ .. example-tab:: examples/s4u/comm-waitany/s4u-comm-waitany.cpp
See also :cpp:func:`simgrid::s4u::Comm::wait_any()`.
- .. example-tab:: examples/python/async-waitany/async-waitany.py
+ .. example-tab:: examples/python/comm-waitany/comm-waitany.py
See also :py:func:`simgrid.Comm.wait_any()`.
- .. example-tab:: examples/c/async-waitany/async-waitany.c
+ .. example-tab:: examples/c/comm-waitany/comm-waitany.c
See also :cpp:func:`sg_comm_wait_any`.
.. showfile:: examples/platforms/small_platform_one_link_routes.xml
:language: xml
+
+ - **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
+ than one bandwidth value (separated by commas), corresponding to
+ the several SNR level of your wifi link.
+
+ In this case, SimGrid automatically switches to validated
+ performance models of wifi networks, where the time is shared
+ between users instead of the bandwidth for wired links (the
+ corresponding publication is currently being written).
+
+ If your wifi link provides more than one SNR level, you can switch
+ the level of a given host using
+ :cpp:func:`simgrid::s4u::Link::set_host_wifi_rate`. By default,
+ the first level is used.
+
+ .. tabs::
+
+ .. example-tab:: examples/s4u/network-wifi/s4u-network-wifi.cpp
+
+ .. group-tab:: XML
+
+ **Platform files:**
+
+ .. showfile:: examples/platforms/wifi.xml
+ :language: xml
=======================
Model-Checking Examples
actor-create actor-daemon actor-exiting actor-join actor-kill actor-lifetime actor-migrate actor-stacksize
actor-suspend actor-yield
app-masterworker app-pingpong app-token-ring
- async-wait async-waitall async-waitany
+ comm-wait comm-waitall comm-waitany
cloud-capping cloud-masterworker cloud-migration cloud-simple
dht-pastry
exec-async exec-basic exec-dvfs exec-remote exec-waitany
${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-multicore_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-vivaldi_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-pingpong/app-pingpong_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait2_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait3_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait4_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/async-waitall_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/async-waitany_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-wait/comm-wait_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-wait/comm-wait2_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-wait/comm-wait3_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-wait/comm-wait4_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitall/comm-waitall_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitany/comm-waitany_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/dht-kademlia_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/dht-pastry/dht-pastry_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/io-file-remote_d.xml
actor-create actor-daemon actor-exiting actor-join actor-kill actor-lifetime actor-migrate actor-stacksize
actor-suspend actor-yield
app-bittorrent app-chainsend app-masterworker app-pingpong app-token-ring
- async-wait async-waitall async-waitany
+ comm-wait comm-waitall comm-waitany
cloud-capping cloud-masterworker cloud-migration cloud-simple
dht-kademlia dht-pastry
exec-async exec-basic exec-dvfs exec-remote exec-waitany
#include <stdio.h>
-XBT_LOG_NEW_DEFAULT_CATEGORY(async_wait, "Messages specific for this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(comm_wait, "Messages specific for this example");
/* Main function of the Sender actor */
static void sender(int argc, char* argv[])
p Test1 sg_comm_test() with Sleep_sender > Sleep_receiver
-$ ${bindir:=.}/c-async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/c-comm-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/comm-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.100000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.100000
> [ 1.000000] (2:receiver@Ruby) Wait for my first message
p Test2 sg_comm_test() with Sleep_sender < Sleep_receiver
-$ ${bindir:=.}/c-async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait2_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/c-comm-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/comm-wait2_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 1.000000 , sleep_test_time : 0.100000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 5.000000 , sleep_test_time : 0.100000
> [ 1.000000] (1:sender@Tremblay) Send 'Message 0' to 'receiver'
p Test1 sg_comm_wait() with Sleep_sender > Sleep_receiver
-$ ${bindir:=.}/c-async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait3_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/c-comm-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/comm-wait3_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.000000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.000000
> [ 1.000000] (2:receiver@Ruby) Wait for my first message
p Test2 sg_comm_wait() with Sleep_sender < Sleep_receiver
-$ ${bindir:=.}/c-async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait4_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/c-comm-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/comm-wait4_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 1.000000 , sleep_test_time : 0.000000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 5.000000 , sleep_test_time : 0.000000
> [ 1.000000] (1:sender@Tremblay) Send 'Message 0' to 'receiver'
#include <stdio.h> /* snprintf */
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_async_waitall, "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(comm_waitall, "Messages specific for this msg example");
static void sender(int argc, char* argv[])
{
#!/usr/bin/env tesh
! output sort 19
-$ ${bindir:=.}/c-async-waitall ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-waitall_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/c-comm-waitall ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/comm-waitall_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) Send 'Message 0' to 'receiver-0'
> [ 0.000000] (2:receiver@Ruby) Wait for my first message
> [ 0.000000] (3:receiver@Perl) Wait for my first message
#include <stdio.h> /* snprintf */
-XBT_LOG_NEW_DEFAULT_CATEGORY(async_waitany, "Messages specific for this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(comm_waitany, "Messages specific for this example");
static void sender(int argc, char* argv[])
{
#!/usr/bin/env tesh
! output sort 19
-$ ${bindir:=.}/c-async-waitany ${platfdir:=.}/small_platform.xml ${srcdir:=.}/async-waitany_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/c-comm-waitany ${platfdir:=.}/small_platform.xml ${srcdir:=.}/comm-waitany_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) Send 'Message 0' to 'receiver-0'
> [ 0.000000] (1:sender@Tremblay) Send 'Message 1' to 'receiver-1'
> [ 0.000000] (1:sender@Tremblay) Send 'Message 2' to 'receiver-0'
<zone id="WIFI zone" routing="Cluster">
<!-- First declare the Access Point (ie, the wifi media) -->
- <link id="AP1" sharing_policy="WIFI" bandwidth="54Mbps" latency="0ms" />
+ <link id="AP1" sharing_policy="WIFI" bandwidth="54Mbps,36Mbps,24Mbps" latency="0ms" />
<!-- Two stations in the wifi zone -->
<host id="Station 1" speed="100.0Mf,50.0Mf,20.0Mf" />
+++ /dev/null
-<?xml version='1.0'?>
-
-<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
-<platform version="4.1">
- <zone id="world" routing="Full">
-
- <zone id="WIFI zone" routing="Cluster">
- <!-- First declare the Access Point (ie, the wifi media) -->
- <link id="AP1" sharing_policy="WIFI" bandwidth="54Mbps" latency="0ms" />
-
- <!-- Two stations in the wifi zone -->
- <host id="Station 1" speed="100.0Mf,50.0Mf,20.0Mf" />
- <host id="Station 2" speed="100.0Mf,50.0Mf,20.0Mf" />
-
- <!-- Specify that stations use the WIFI link for every communication (incoming or outgoing) -->
- <host_link id="Station 1" up="AP1" down="AP1"/>
- <host_link id="Station 2" up="AP1" down="AP1"/>
-
- <router id="WIFI router"/>
- </zone>
-
-
- <!-- NODE1 AS -->
- <zone id="Wired zone" routing="Full">
- <host id="NODE1" speed="100.0Mf,50.0Mf,20.0Mf" />
- </zone>
-
-
- <!-- AS Routing -->
- <link id="Collector" sharing_policy="SHARED" bandwidth="100Mbps" latency="0ms" />
- <zoneRoute src="WIFI zone" dst="Wired zone" gw_src="WIFI router" gw_dst="NODE1">
- <link_ctn id="Collector" />
- </zoneRoute>
-
- </zone>
-</platform>
foreach(example actor-create actor-daemon actor-join actor-kill actor-migrate actor-suspend actor-yield actor-lifetime
- async-wait async-waitall async-waitany
+ comm-wait comm-waitall comm-waitany
exec-async exec-basic exec-dvfs exec-remote)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.tesh)
set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.py)
set(examples_src ${examples_src} PARENT_SCOPE)
set(tesh_files ${tesh_files} examples/python/actor-create/actor-create_d.xml
examples/python/actor-lifetime/actor-lifetime_d.xml
- examples/python/async-wait/async-wait_d.xml
- examples/python/async-waitall/async-waitall_d.xml
- examples/python/async-waitany/async-waitany_d.xml PARENT_SCOPE)
+ examples/python/comm-wait/comm-wait_d.xml
+ examples/python/comm-waitall/comm-waitall_d.xml
+ examples/python/comm-waitany/comm-waitany_d.xml PARENT_SCOPE)
#!/usr/bin/env tesh
-$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/async-wait.py ${platfdir}/small_platform_fatpipe.xml async-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/comm-wait.py ${platfdir}/small_platform_fatpipe.xml comm-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) Send 'Message 0' to 'Mailbox(receiver-0)'
> [ 0.000000] (2:receiver@Ruby) Wait for my first message
> [ 0.000000] (1:sender@Tremblay) Send 'Message 1' to 'Mailbox(receiver-0)'
#!/usr/bin/env tesh
-$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/async-waitall.py ${platfdir}/small_platform_fatpipe.xml async-waitall_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/comm-waitall.py ${platfdir}/small_platform_fatpipe.xml comm-waitall_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) Send 'Message 0' to 'Mailbox(receiver-0)'
> [ 0.000000] (2:receiver@Ruby) Wait for my first message
> [ 0.000000] (3:receiver@Perl) Wait for my first message
p Testing Comm.wait_any()
! output sort 19
-$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/async-waitany.py ${platfdir}/small_platform.xml async-waitany_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/comm-waitany.py ${platfdir}/small_platform.xml comm-waitany_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) Send 'Message 0' to 'Mailbox(receiver-0)'
> [ 0.000000] (2:receiver@Fafard) Wait for my first message
> [ 0.000000] (3:receiver@Jupiter) Wait for my first message
foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill
actor-lifetime actor-migrate actor-suspend actor-yield actor-stacksize
app-bittorrent app-chainsend app-pingpong app-token-ring
- async-ready async-wait async-waitany async-waitall async-waituntil
+ comm-ready comm-suspend comm-wait comm-waitany comm-waitall comm-waituntil
comm-dependent
cloud-capping cloud-migration cloud-simple
dht-chord dht-kademlia
exec-async exec-basic exec-dvfs exec-ptask exec-remote exec-waitany exec-waitfor exec-dependent
maestro-set
mc-bugged1 mc-bugged1-liveness mc-bugged2 mc-electric-fence mc-failing-assert
+ network-wifi
io-async io-file-system io-file-remote io-disk-raw io-dependent
platform-failures platform-profile platform-properties
plugin-hostload
${CMAKE_CURRENT_SOURCE_DIR}/actor-yield/s4u-actor-yield_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u-async-waitany_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/s4u-async-waitall_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-ready/s4u-async-ready_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/async-waituntil/s4u-async-waituntil_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-suspend/s4u-comm-suspend_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-wait/s4u-comm-wait_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitany/s4u-comm-waitany_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-waitall/s4u-comm-waitall_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-ready/s4u-comm-ready_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/comm-waituntil/s4u-comm-waituntil_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/s4u-dht-kademlia_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/energy-boot/platform_boot.xml
double msg_size = std::stol(argv[3]); /* - message size in bytes */
long peers_count = std::stod(argv[4]); /* - number of peers */
- /* Set myself as the persistent receiver of my mailbox so that messages start flowing to me as soon as they are put into it */
+ /* Set myself as the persistent receiver of my mailbox so that messages start flowing to me as soon as they are put
+ * into it */
simgrid::s4u::Mailbox* my_mbox = simgrid::s4u::Mailbox::by_name(std::string("peer-") + std::to_string(my_id));
my_mbox->set_receiver(simgrid::s4u::Actor::self());
for (int i = 0; i < messages_count; i++) {
for (int peer_id = 0; peer_id < peers_count; peer_id++) {
if (peer_id != my_id) {
- std::string mboxName = std::string("peer-") + std::to_string(peer_id);
- simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
- std::string msgName = std::string("Message ") + std::to_string(i) + std::string(" from peer ") + std::to_string(my_id);
- std::string* payload = new std::string(msgName); // copy the data we send:
+ std::string mboxName = std::string("peer-") + std::to_string(peer_id);
+ simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
+ std::string msgName =
+ std::string("Message ") + std::to_string(i) + std::string(" from peer ") + std::to_string(my_id);
+ std::string* payload = new std::string(msgName); // copy the data we send:
// 'msgName' is not a stable storage location
XBT_INFO("Send '%s' to '%s'", msgName.c_str(), mboxName.c_str());
/* Create a communication representing the ongoing communication */
/* Start sending messages to let peers know that they should stop */
for (int peer_id = 0; peer_id < peers_count; peer_id++) {
if (peer_id != my_id) {
- std::string mboxName = std::string("peer-") + std::to_string(peer_id);
- simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
- std::string* payload = new std::string("finalize"); // Make a copy of the data we will send
+ std::string mboxName = std::string("peer-") + std::to_string(peer_id);
+ simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
+ std::string* payload = new std::string("finalize"); // Make a copy of the data we will send
pending_comms.push_back(mbox->put_async(payload, msg_size));
XBT_INFO("Send 'finalize' to 'peer-%d'", peer_id);
}
}
XBT_INFO("Done dispatching all messages");
- /* Retrieve all the messages other peers have been sending to me until I receive all the corresponding "Finalize" messages */
+ /* Retrieve all the messages other peers have been sending to me until I receive all the corresponding "Finalize"
+ * messages */
int pending_finalize_messages = peers_count - 1;
while (pending_finalize_messages > 0) {
if (my_mbox->ready()) {
- double start = simgrid::s4u::Engine::get_clock();
+ double start = simgrid::s4u::Engine::get_clock();
const std::string* received = static_cast<std::string*>(my_mbox->get());
- double waiting_time = simgrid::s4u::Engine::get_clock() - start;
- xbt_assert(waiting_time == 0, "Expecting the waiting time to be 0 because the communication was supposedly ready, but got %f instead", waiting_time);
+ double waiting_time = simgrid::s4u::Engine::get_clock() - start;
+ xbt_assert(
+ waiting_time == 0,
+ "Expecting the waiting time to be 0 because the communication was supposedly ready, but got %f instead",
+ waiting_time);
XBT_INFO("I got a '%s'.", received->c_str());
if (*received == "finalize") {
pending_finalize_messages--;
XBT_INFO("Goodbye now!");
}
-
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
p Test1 Peer sending and receiving
-$ ${bindir:=.}/s4u-async-ready ${platfdir}/small_platform_fatpipe.xml s4u-async-ready_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/s4u-comm-ready ${platfdir}/small_platform_fatpipe.xml s4u-comm-ready_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:peer@Tremblay) Send 'Message 0 from peer 0' to 'peer-1'
> [ 0.000000] (2:peer@Ruby) Send 'Message 0 from peer 1' to 'peer-0'
> [ 0.000000] (1:peer@Tremblay) Send 'Message 0 from peer 0' to 'peer-2'
--- /dev/null
+/* Copyright (c) 2010-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. */
+
+/* This example shows how to suspend and resume an asynchronous communication. */
+
+#include "simgrid/s4u.hpp"
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_wait, "Messages specific for this s4u example");
+
+static void sender(int argc, char**)
+{
+ xbt_assert(argc == 1, "Expecting no parameter from the XML deployment file but got %d", argc - 1);
+
+ simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name("receiver");
+
+ // Copy the data we send: the 'msg_content' variable is not a stable storage location.
+ // It will be destroyed when this actor leaves the loop, ie before the receiver gets the data
+ std::string* payload = new std::string("Sent message");
+
+ /* Create a communication representing the ongoing communication and then */
+ simgrid::s4u::CommPtr comm = mbox->put_init(payload, 13194230);
+ XBT_INFO("Suspend the communication before it starts (remaining: %.0f bytes) and wait a second.",
+ comm->get_remaining());
+ simgrid::s4u::this_actor::sleep_for(1);
+ XBT_INFO("Now, start the communication (remaining: %.0f bytes) and wait another second.", comm->get_remaining());
+ comm->start();
+ simgrid::s4u::this_actor::sleep_for(1);
+
+ XBT_INFO("There is still %.0f bytes to transfer in this communication. Suspend it for one second.",
+ comm->get_remaining());
+ comm->suspend();
+ XBT_INFO("Now there is %.0f bytes to transfer. Resume it and wait for its completion.", comm->get_remaining());
+ comm->resume();
+ comm->wait();
+ XBT_INFO("There is %f bytes to transfer after the communication completion.", comm->get_remaining());
+ XBT_INFO("Suspending a completed activity is a no-op.");
+ comm->suspend();
+}
+
+static void receiver(int, char**)
+{
+ simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name("receiver");
+
+ XBT_INFO("Wait for the message.");
+ void* payload = mbox->get();
+
+ const std::string* received = static_cast<std::string*>(payload);
+ XBT_INFO("I got '%s'.", received->c_str());
+
+ delete received;
+}
+
+int main(int argc, char* argv[])
+{
+ xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
+
+ simgrid::s4u::Engine e(&argc, argv);
+ e.register_function("sender", &sender);
+ e.register_function("receiver", &receiver);
+
+ e.load_platform(argv[1]);
+ e.load_deployment(argv[2]);
+ e.run();
+
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-comm-suspend ${platfdir}/small_platform.xml s4u-comm-suspend_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:sender@Tremblay) Suspend the communication before it starts (remaining: 13194230 bytes) and wait a second.
+> [ 0.000000] (2:receiver@Jupiter) Wait for the message.
+> [ 1.000000] (1:sender@Tremblay) Now, start the communication (remaining: 13194230 bytes) and wait another second.
+> [ 2.000000] (1:sender@Tremblay) There is still 6660438 bytes to transfer in this communication. Suspend it for one second.
+> [ 2.000000] (1:sender@Tremblay) Now there is 6660438 bytes to transfer. Resume it and wait for its completion.
+> [ 3.000000] (2:receiver@Jupiter) I got 'Sent message'.
+> [ 3.000000] (1:sender@Tremblay) There is 0.000000 bytes to transfer after the communication completion.
+> [ 3.000000] (1:sender@Tremblay) Suspending a completed activity is a no-op.
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
+<platform version="4.1">
+ <actor host="Tremblay" function="sender" />
+ <actor host="Jupiter" function="receiver" />
+</platform>
#include <iostream>
#include <string>
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_async_wait, "Messages specific for this s4u example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_wait, "Messages specific for this s4u example");
static void sender(int argc, char** argv)
{
}
}
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
p Test1 Sleep_sender > Sleep_receiver
-$ ${bindir:=.}/s4u-async-wait ${platfdir}/small_platform_fatpipe.xml s4u-async-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/s4u-comm-wait ${platfdir}/small_platform_fatpipe.xml s4u-comm-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.000000
> [ 0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.100000
> [ 1.000000] (2:receiver@Ruby) Wait for my first message
}
};
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
#!/usr/bin/env tesh
-$ ${bindir:=.}/s4u-async-waitall ${platfdir}/small_platform_fatpipe.xml s4u-async-waitall_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/s4u-comm-waitall ${platfdir}/small_platform_fatpipe.xml s4u-comm-waitall_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) Send 'Message 0' to 'receiver-0'
> [ 0.000000] (2:receiver@Ruby) Wait for my first message
> [ 0.000000] (3:receiver@Perl) Wait for my first message
#include <iostream>
#include <string>
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_async_waitall, "Messages specific for this s4u example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_waitall, "Messages specific for this s4u example");
class Sender {
long messages_count; /* - number of messages */
}
};
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n", argv[0]);
p Testing this_actor->wait_any()
! output sort 19
-$ ${bindir:=.}/s4u-async-waitany ${platfdir}/small_platform.xml s4u-async-waitany_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/s4u-comm-waitany ${platfdir}/small_platform.xml s4u-comm-waitany_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) Send 'Message 0' to 'receiver-0'
> [ 0.000000] (2:receiver@Fafard) Wait for my first message
> [ 0.000000] (3:receiver@Jupiter) Wait for my first message
/* This example shows how to use simgrid::s4u::Activity::wait_until() and
* simgrid::s4u::Activity::wait_for() on a given communication.
*
- * It is very similar to the async-wait example, but the sender initially
+ * It is very similar to the comm-wait example, but the sender initially
* does some waits that are too short before doing an infinite wait.
*/
#include <iostream>
#include <string>
-XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_async_waituntil, "Messages specific for this s4u example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_waituntil, "Messages specific for this s4u example");
static void sender(int argc, char** argv)
{
/* Start dispatching all messages to receivers, in a round robin fashion */
for (int i = 0; i < messages_count; i++) {
- std::string mboxName = std::string("receiver-") + std::to_string(i % receivers_count);
- simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
- std::string msgName = std::string("Message ") + std::to_string(i);
- std::string* payload = new std::string(msgName); // copy the data we send:
+ std::string mboxName = std::string("receiver-") + std::to_string(i % receivers_count);
+ simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
+ std::string msgName = std::string("Message ") + std::to_string(i);
+ std::string* payload = new std::string(msgName); // copy the data we send:
// 'msgName' is not a stable storage location
XBT_INFO("Send '%s' to '%s'", msgName.c_str(), mboxName.c_str());
/* Start sending messages to let the workers know that they should stop */
for (int i = 0; i < receivers_count; i++) {
- std::string mboxName = std::string("receiver-") + std::to_string(i % receivers_count);
- simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
- std::string* payload = new std::string("finalize"); // Make a copy of the data we will send
+ std::string mboxName = std::string("receiver-") + std::to_string(i % receivers_count);
+ simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
+ std::string* payload = new std::string("finalize"); // Make a copy of the data we will send
simgrid::s4u::CommPtr comm = mbox->put_async(payload, 0);
pending_comms.push_back(comm);
p Test1 Sleep_sender > Sleep_receiver
-$ ${bindir:=.}/s4u-async-waituntil ${platfdir}/small_platform_fatpipe.xml s4u-async-waituntil_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/s4u-comm-waituntil ${platfdir}/small_platform_fatpipe.xml s4u-comm-waituntil_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sender@Tremblay) Send 'Message 0' to 'receiver-0'
> [ 0.000000] (2:receiver@Ruby) Wait for my first message
> [ 0.000000] (1:sender@Tremblay) Send 'Message 1' to 'receiver-0'
--- /dev/null
+/* Copyright (c) 2017-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"
+
+/* This example demonstrates how to use wifi links in SimGrid. Most of the interesting things happen in the
+ * corresponding XML file.
+ */
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_network_wifi, "Messages specific for this s4u example");
+
+static void sender(simgrid::s4u::Mailbox* mailbox, int data_size)
+{
+ XBT_INFO("Send a message to the other station.");
+ static char message[] = "message";
+ mailbox->put(message, data_size);
+ XBT_INFO("Done.");
+}
+static void receiver(simgrid::s4u::Mailbox* mailbox)
+{
+ XBT_INFO("Wait for a message.");
+ mailbox->get();
+ XBT_INFO("Done.");
+}
+
+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]);
+
+ auto mailbox = simgrid::s4u::Mailbox::by_name("mailbox");
+ auto station1 = simgrid::s4u::Host::by_name("Station 1");
+ auto station2 = simgrid::s4u::Host::by_name("Station 2");
+ simgrid::s4u::Actor::create("sender", station1, sender, mailbox, 1e7);
+ simgrid::s4u::Actor::create("receiver", station2, receiver, mailbox);
+
+ auto ap = simgrid::s4u::Link::by_name("AP1");
+ ap->set_host_wifi_rate(station1, 1); // The host "Station 1" uses the second level of bandwidths on that AP
+ ap->set_host_wifi_rate(station2, 0); // This is perfectly useless as level 0 is used by default
+
+ e.run();
+
+ return 0;
+}
--- /dev/null
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-network-wifi ${platfdir}/wifi.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (1:sender@Station 1) Send a message to the other station.
+> [ 0.000000] (2:receiver@Station 2) Wait for a message.
+> [ 3.888889] (1:sender@Station 1) Done.
+> [ 3.888889] (2:receiver@Station 2) Done.
XBT_PUBLIC xbt_dict_t sg_actor_get_properties(const_sg_actor_t actor);
XBT_PUBLIC void sg_actor_suspend(sg_actor_t actor);
XBT_PUBLIC void sg_actor_resume(sg_actor_t actor);
-XBT_PUBLIC int sg_actor_is_suspended(sg_actor_t actor);
+XBT_PUBLIC int sg_actor_is_suspended(const_sg_actor_t actor);
XBT_PUBLIC sg_actor_t sg_actor_restart(sg_actor_t actor);
XBT_PUBLIC void sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart);
XBT_PUBLIC void sg_actor_daemonize(sg_actor_t actor);
XBT_PUBLIC void MSG_process_suspend(msg_process_t process);
XBT_PUBLIC void MSG_process_resume(msg_process_t process);
-XBT_PUBLIC int MSG_process_is_suspended(msg_process_t process);
+XBT_PUBLIC int MSG_process_is_suspended(const_sg_actor_t process);
XBT_PUBLIC void MSG_process_restart(msg_process_t process);
/** @brief Sets the "auto-restart" flag of the process.
*
XBT_PUBLIC const char* sg_file_get_name(const_sg_file_t fd);
XBT_PUBLIC sg_size_t sg_file_get_size(const_sg_file_t fd);
-XBT_PUBLIC void sg_file_dump(sg_file_t fd);
+XBT_PUBLIC void sg_file_dump(const_sg_file_t fd);
XBT_PUBLIC void* sg_file_get_data(const_sg_file_t fd);
XBT_PUBLIC void sg_file_set_data(sg_file_t fd, void* data);
XBT_PUBLIC void sg_file_seek(sg_file_t fd, sg_offset_t offset, int origin);
* This function is optional: you can call wait() even if you didn't call start()
*/
virtual Activity* start() = 0;
- /** Blocks until the activity is terminated */
+ /** Blocks the current actor until the activity is terminated */
virtual Activity* wait() = 0;
- /** Blocks until the activity is terminated, or until the timeout is elapsed
+ /** Blocks the current actor until the activity is terminated, or until the timeout is elapsed\n
* Raises: timeout exception.*/
virtual Activity* wait_for(double timeout) = 0;
- /** Blocks until the activity is terminated, or until the time limit is reached
+ /** Blocks the current actor until the activity is terminated, or until the time limit is reached\n
* Raises: timeout exception. */
void wait_until(double time_limit);
/** Tests whether the given activity is terminated yet. */
virtual bool test();
+ /** Blocks the progression of this activity until it gets resumed */
+ virtual Activity* suspend();
+ /** Unblock the progression of this activity if it was suspended previously */
+ virtual Activity* resume();
+ /** Whether or not the progression of this activity is blocked */
+ bool is_suspended() { return suspended_; }
+
virtual const char* get_cname() const = 0;
virtual const std::string& get_name() const = 0;
kernel::activity::ActivityImplPtr pimpl_ = nullptr;
Activity::State state_ = Activity::State::INITED;
double remains_ = 0;
+ bool suspended_ = false;
std::vector<ActivityPtr> successors_;
std::set<ActivityPtr> dependencies_;
std::atomic_int_fast32_t refcount_{0};
/** Sets the time at which that actor should be killed */
void set_kill_time(double time);
/** Retrieves the time at which that actor will be killed (or -1 if not set) */
- double get_kill_time();
+ double get_kill_time() const;
/** @brief Moves the actor to another host
*
/** @brief Describes how the link is shared between flows */
SharingPolicy get_sharing_policy() const;
- /** @brief Returns the current load (in flops per second) */
+ /** @brief Set the level of communication speed of the given host on this wifi link.
+ *
+ * The bandwidth of a wifi link for a given host depends on its SNR (signal to noise ratio),
+ * which ultimately depends on the distance between the host and the station and the material between them.
+ *
+ * This is modeled in SimGrid by providing several bandwidths to wifi links, one per SNR level (just provide
+ * comma-separated values in the XML file). By default, the first level in the list is used, but you can use the
+ * current function to specify that a given host uses another level of bandwidth. This can be used to take the
+ * location of hosts into account, or even to model mobility in your SimGrid simulation.
+ *
+ * Note that this function asserts that the link is actually a wifi link */
+ void set_host_wifi_rate(s4u::Host* host, int level);
+
+ /** @brief Returns the current load (in bytes per second) */
double get_usage() const;
/** @brief Check if the Link is used (at least one flow uses the link) */
}
}
-void AppSide::main_loop()
+void AppSide::main_loop() const
{
while (true) {
simgrid::mc::wait_for_requests();
public:
Channel const& get_channel() const { return channel_; }
Channel& get_channel() { return channel_; }
- XBT_ATTRIB_NORETURN void main_loop();
+ XBT_ATTRIB_NORETURN void main_loop() const;
void report_assertion_failure() const;
void ignore_memory(void* addr, std::size_t size) const;
void ignore_heap(void* addr, std::size_t size) const;
{
sg_actor_resume(actor);
}
-int MSG_process_is_suspended(sg_actor_t actor)
+int MSG_process_is_suspended(const_sg_actor_t actor)
{
return sg_actor_is_suspended(actor);
}
double computed_flops_lookup();
double get_intensity() const { return dp_intensity_; }
void set_intensity(double intensity) { dp_intensity_ = intensity; }
- double get_working_set_memory() const { return working_set_memory_; }
+ sg_size_t get_working_set_memory() const { return working_set_memory_; }
void set_working_set_memory(sg_size_t size) { working_set_memory_ = size; }
void set_migration_speed(double speed) { mig_speed_ = speed; }
double get_migration_speed() const { return mig_speed_; }
return fd->size();
}
-void sg_file_dump(sg_file_t fd)
+void sg_file_dump(const_sg_file_t fd)
{
fd->dump();
}
return false;
}
+Activity* Activity::suspend()
+{
+ if (suspended_)
+ return this; // Already suspended
+ suspended_ = true;
+
+ if (state_ == State::STARTED)
+ pimpl_->suspend();
+
+ return this;
+}
+
+Activity* Activity::resume()
+{
+ if (not suspended_)
+ return this; // nothing to restore when it's not suspended
+
+ if (state_ == State::STARTED)
+ pimpl_->resume();
+
+ return this;
+}
+
double Activity::get_remaining() const
{
- return remains_;
+ if (state_ == State::INITED || state_ == State::STARTING)
+ return remains_;
+ else
+ return pimpl_->get_remaining();
}
Activity* Activity::set_remaining(double remains)
}
/** @brief Get the kill time of an actor(or 0 if unset). */
-double Actor::get_kill_time()
+double Actor::get_kill_time() const
{
return pimpl_->get_kill_time();
}
*
* This checks whether an actor is suspended or not by inspecting the task on which it was waiting for the completion.
*/
-int sg_actor_is_suspended(sg_actor_t actor)
+int sg_actor_is_suspended(const_sg_actor_t actor)
{
return actor->is_suspended();
}
} else {
xbt_die("Cannot start a communication before specifying whether we are the sender or the receiver");
}
+
+ if (suspended_)
+ pimpl_->suspend();
+
state_ = State::STARTED;
return this;
}
.set_flops_amount(flops_amounts_.front())
.start();
});
+
+ if (suspended_)
+ pimpl_->suspend();
+
state_ = State::STARTED;
on_start(*Actor::self(), *this);
return this;
.start();
}
});
+
+ if (suspended_)
+ pimpl_->suspend();
+
state_ = State::STARTED;
return this;
}
#include "simgrid/simix.hpp"
#include "src/kernel/lmm/maxmin.hpp"
#include "src/surf/network_interface.hpp"
+#include "src/surf/network_wifi.hpp"
#include "xbt/log.h"
namespace simgrid {
return this->pimpl_->get_sharing_policy();
}
+void Link::set_host_wifi_rate(s4u::Host* host, int level)
+{
+ xbt_assert(pimpl_->get_sharing_policy() == Link::SharingPolicy::WIFI, "Link %s does not seem to be a wifi link.",
+ get_cname());
+ auto* wlink = dynamic_cast<kernel::resource::NetworkWifiLink*>(pimpl_);
+ xbt_assert(wlink != nullptr, "Cannot convert link %s into a wifi link.", get_cname());
+ wlink->set_host_rate(host, level);
+}
+
double Link::get_usage() const
{
return this->pimpl_->get_constraint()->get_usage();
}
// Align functions, from http://stackoverflow.com/questions/4840410/how-to-align-a-pointer-in-c
-#define ALIGN_UP(n, align) (((n) + (align)-1) & -(align))
-#define ALIGN_DOWN(n, align) ((n) & -(align))
+#define ALIGN_UP(n, align) ((((int64_t)n) + ((int64_t)align)-1) & -((int64_t)align))
+#define ALIGN_DOWN(n, align) (((int64_t)n) & -((int64_t)align))
constexpr unsigned PAGE_SIZE = 0x1000;
constexpr unsigned HUGE_PAGE_SIZE = 1U << 21;
"to allow big allocations.\n",
size >> 20);
if(use_huge_page)
- mem = (void*)ALIGN_UP((int64_t)allocated_ptr, HUGE_PAGE_SIZE);
+ mem = (void*)ALIGN_UP(allocated_ptr, HUGE_PAGE_SIZE);
else
mem = allocated_ptr;
if(i_block < nb_shared_blocks-1)
xbt_assert(stop_offset < shared_block_offsets[2*i_block+2],
"stop_offset (%zu) should be lower than its successor start offset (%zu)", stop_offset, shared_block_offsets[2*i_block+2]);
- size_t start_block_offset = ALIGN_UP((int64_t)start_offset, smpi_shared_malloc_blocksize);
- size_t stop_block_offset = ALIGN_DOWN((int64_t)stop_offset, smpi_shared_malloc_blocksize);
+ size_t start_block_offset = ALIGN_UP(start_offset, smpi_shared_malloc_blocksize);
+ size_t stop_block_offset = ALIGN_DOWN(stop_offset, smpi_shared_malloc_blocksize);
for (size_t offset = start_block_offset; offset < stop_block_offset; offset += smpi_shared_malloc_blocksize) {
XBT_DEBUG("\t\tglobal shared allocation, mmap block offset %zx", offset);
void* pos = (void*)((unsigned long)mem + offset);
"and that the directory you are passing is mounted correctly (mount /path/to/huge -t hugetlbfs -o rw,mode=0777).",
strerror(errno));
}
- size_t low_page_start_offset = ALIGN_UP((int64_t)start_offset, PAGE_SIZE);
- size_t low_page_stop_offset = (int64_t)start_block_offset < ALIGN_DOWN((int64_t)stop_offset, PAGE_SIZE) ? start_block_offset : ALIGN_DOWN((int64_t)stop_offset, (int64_t)PAGE_SIZE);
+ size_t low_page_start_offset = ALIGN_UP(start_offset, PAGE_SIZE);
+ size_t low_page_stop_offset = (int64_t)start_block_offset < ALIGN_DOWN(stop_offset, PAGE_SIZE) ? start_block_offset : ALIGN_DOWN(stop_offset, PAGE_SIZE);
if(low_page_start_offset < low_page_stop_offset) {
XBT_DEBUG("\t\tglobal shared allocation, mmap block start");
void* pos = (void*)((unsigned long)mem + low_page_start_offset);
}
if(low_page_stop_offset <= stop_block_offset) {
XBT_DEBUG("\t\tglobal shared allocation, mmap block stop");
- size_t high_page_stop_offset = stop_offset == size ? size : ALIGN_DOWN((int64_t)stop_offset, PAGE_SIZE);
+ size_t high_page_stop_offset = stop_offset == size ? size : ALIGN_DOWN(stop_offset, PAGE_SIZE);
if(high_page_stop_offset > stop_block_offset) {
void* pos = (void*)((unsigned long)mem + stop_block_offset);
const void* res = mmap(pos, high_page_stop_offset - stop_block_offset, PROT_READ | PROT_WRITE,
return -1;
int rate_id = host_rates_it->second;
- xbt_assert(rate_id >= 0 && rate_id < (int)bandwidths_.size(), "Host '%s' has an invalid rate '%d' on wifi link '%s'",
- host->get_name().c_str(), rate_id, this->get_cname());
+ xbt_assert(rate_id >= 0,
+ "Negative host wifi rate levels are invalid but host '%s' uses %d as a rate level on link '%s'",
+ host->get_cname(), rate_id, this->get_cname());
+ xbt_assert(rate_id < (int)bandwidths_.size(),
+ "Link '%s' only has %zu wifi rate levels, so the provided level %d is invalid for host '%s'.",
+ this->get_cname(), bandwidths_.size(), rate_id, host->get_cname());
Metric rate = use_decay_model_ ? decay_bandwidths_[rate_id] : bandwidths_[rate_id];
return rate.peak * rate.scale;
int xbt_automaton_propositional_symbols_compare_value(const_xbt_dynar_t s1, const_xbt_dynar_t s2)
{
- unsigned int nb_elem = xbt_dynar_length(s1);
+ unsigned long nb_elem = xbt_dynar_length(s1);
- for (unsigned int cursor = 0; cursor < nb_elem; cursor++) {
+ for (unsigned long cursor = 0; cursor < nb_elem; cursor++) {
const int* iptr1 = xbt_dynar_get_ptr(s1, cursor);
const int* iptr2 = xbt_dynar_get_ptr(s2, cursor);
if(*iptr1 != *iptr2)
{
// Update heapinfo about the heapinfo pages (!):
xbt_assert((uintptr_t) mdp->heapinfo % BLOCKSIZE == 0);
- int block = BLOCK(mdp->heapinfo);
+ size_t block = BLOCK(mdp->heapinfo);
size_t nblocks = mdp->heapsize * sizeof(malloc_info) / BLOCKSIZE;
// Mark them as free:
for (size_t j=0; j!=nblocks; ++j) {
result = mmalloc(mdp, BLOCKSIZE); // does not return NULL
block = BLOCK(result);
- mdp->heapinfo[block].type = log;
+ mdp->heapinfo[block].type = (int)log;
/* Link all fragments but the first as free, and add the block to the swag of blocks containing free frags */
size_t i;
for (i = 1; i < (size_t) (BLOCKSIZE >> log); ++i) {
/* Full blocks -> Full blocks; see if we can hold it in place. */
blocks = BLOCKIFY(size);
if (blocks < mdp->heapinfo[block].busy_block.size) {
- int it;
+ size_t it;
/* The new size is smaller; return excess memory to the free list. */
for (it= block+blocks; it< mdp->heapinfo[block].busy_block.size ; it++){
mdp->heapinfo[it].type = MMALLOC_TYPE_UNFRAGMENTED; // FIXME that should be useless, type should already be 0 here
/* The new size is the same kind of fragment. */
result = ptr;
- int frag_nb = RESIDUAL(result, BLOCKSIZE) >> type;
+ uintptr_t frag_nb = RESIDUAL(result, BLOCKSIZE) >> type;
mdp->heapinfo[block].busy_frag.frag_size[frag_nb] = requested_size;
mdp->heapinfo[block].busy_frag.ignore[frag_nb] = 0;
return (double) (time(NULL));
#endif /* HAVE_GETTIMEOFDAY? */
- return tv.tv_sec + tv.tv_usec / 1000000.0;
+ return (double)tv.tv_sec + (double)tv.tv_usec / 1e6;
}
void xbt_os_sleep(double sec)
#elif HAVE_NANOSLEEP
struct timespec ts;
- ts.tv_sec = sec;
- ts.tv_nsec = (sec - floor(sec)) * 1e9;
+ ts.tv_sec = (time_t)sec;
+ ts.tv_nsec = (long)((sec - floor(sec)) * 1e9);
nanosleep (&ts, NULL);
#else /* don't have nanosleep. Use select to sleep less than one second */
struct timeval timeout;
- timeout.tv_sec = (unsigned long) (sec);
- timeout.tv_usec = (sec - floor(sec)) * 1000000;
+ timeout.tv_sec = (long)sec;
+ timeout.tv_usec = (long)(sec - floor(sec)) * 1e6);
select(0, NULL, NULL, NULL, &timeout);
#endif
std::vector<double> bandwidths;
std::vector<std::string> tokens;
- boost::split(tokens, string, boost::is_any_of(";"));
+ boost::split(tokens, string, boost::is_any_of(";,"));
for (auto token : tokens) {
bandwidths.push_back(surf_parse_get_value_with_unit(
filename, lineno, token.c_str(), units, entity_kind, name,
SD_task_t task;
sg_host_t *hosts = sg_host_list();
- int totalHosts = sg_host_count();
+ size_t totalHosts = sg_host_count();
qsort((void *) hosts, totalHosts, sizeof(sg_host_t), name_compare_hosts);
xbt_dynar_foreach(dax, cursor, task) {
xbt_dynar_free_container(&route);
}
if (!strcmp(argv[2], "FULL_LINK")) {
- int list_size = sg_host_count();
- for (int i = 0; i < list_size; i++) {
+ size_t list_size = sg_host_count();
+ for (size_t i = 0; i < list_size; i++) {
const_sg_host_t h1 = hosts[i];
const char *name1 = sg_host_get_name(h1);
- for (int j = 0; j < list_size; j++) {
+ for (size_t j = 0; j < list_size; j++) {
const_sg_host_t h2 = hosts[j];
const char *name2 = sg_host_get_name(h2);
fprintf(stderr, "Route between %s and %s\n", name1, name2);
int main(int argc, char ** argv)
{
- size_t M = 8*1024;
- size_t N = 32*1024;
+ const int M = 8 * 1024;
+ const int N = 32 * 1024;
MPI_Init(&argc, &argv);
// Set the elements between buf[start] and buf[stop-1] to (i+value)%256
static void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
for(size_t i = start; i < stop; i++) {
- buf[i] = (i+value)%256;
+ buf[i] = (uint8_t)((i + value) % 256);
}
}
// Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1].
-static int count_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+static size_t count_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
{
size_t occ = 0;
for(size_t i = start ; i < stop ; i++) {
for(int i = 0; i < nb_blocks-1; i++) {
size_t start = shared_blocks[2*i+1];
size_t stop = shared_blocks[2*i+2];
- set(buf, start, stop, rank);
+ set(buf, start, stop, (uint8_t)rank);
}
}
// Then, even processes send their buffer to their successor
if(rank%2 == 0) {
- MPI_Send(buf, mem_size, MPI_UINT8_T, rank+1, 0, MPI_COMM_WORLD);
+ MPI_Send(buf, (int)mem_size, MPI_UINT8_T, rank + 1, 0, MPI_COMM_WORLD);
}
else {
- MPI_Recv(buf, mem_size, MPI_UINT8_T, rank-1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ MPI_Recv(buf, (int)mem_size, MPI_UINT8_T, rank - 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
for(int i = 0; i < nb_blocks-1; i++) {
size_t start = shared_blocks[2*i+1];
size_t stop = shared_blocks[2*i+2];
- int comm = check_all(buf, start, stop, rank-1);
+ int comm = check_all(buf, start, stop, (uint8_t)(rank - 1));
printf("[%d] The result of the (normal) communication check for block (0x%zx, 0x%zx) is: %d\n", rank, start, stop, comm);
}
memset(buf, rank, mem_size);
// Then, even processes send a sub-part of their buffer their successor
// Note that the last block should not be copied entirely
if(rank%2 == 0) {
- MPI_Send(buf+0x10000, mem_size-0xa00000, MPI_UINT8_T, rank+1, 0, MPI_COMM_WORLD);
+ MPI_Send(buf + 0x10000, (int)(mem_size - 0xa00000), MPI_UINT8_T, rank + 1, 0, MPI_COMM_WORLD);
}
else {
- MPI_Recv(buf+0x10000, mem_size-0xa00000, MPI_UINT8_T, rank-1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ MPI_Recv(buf + 0x10000, (int)(mem_size - 0xa00000), MPI_UINT8_T, rank - 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
for(int i = 0; i < nb_blocks-1; i++) {
size_t start = shared_blocks[2*i+1];
size_t stop = shared_blocks[2*i+2];
- int comm = check_all(buf, start, stop, rank-1);
+ int comm = check_all(buf, start, stop, (uint8_t)(rank - 1));
printf("[%d] The result of the (shifted) communication check for block (0x%zx, 0x%zx) is: %d\n", rank, start, stop, comm);
}
}
// Set the elements between buf[start] and buf[stop-1] to (i+value)%256
static void set(uint8_t *buf, size_t start, size_t stop, uint8_t value) {
for(size_t i = start; i < stop; i++) {
- buf[i] = (i+value)%256;
+ buf[i] = (uint8_t)((i + value) % 256);
}
}
// Return the number of times that an element is equal to (i+value)%256 between buf[start] and buf[stop-1].
-static int count_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
+static size_t count_all(const uint8_t* buf, size_t start, size_t stop, uint8_t value)
{
size_t occ = 0;
for(size_t i = start ; i < stop ; i++) {
#include "xbt/config.hpp"
#include "xbt/log.h"
-#include "src/surf/network_wifi.hpp"
+#include "src/surf/network_interface.hpp"
XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[usage] wifi_usage <platform-file>");
simgrid::s4u::this_actor::get_host()->get_cname(), dest, end_time - start_time);
});
simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name(dest), [mailbox]() { mailbox->get(); });
- auto* l = (simgrid::kernel::resource::NetworkWifiLink*)simgrid::s4u::Link::by_name("AP1")->get_impl();
- l->set_host_rate(simgrid::s4u::Host::by_name(src), 0);
- l->set_host_rate(simgrid::s4u::Host::by_name(dest), 0);
+ auto* ap1 = simgrid::s4u::Link::by_name("AP1");
+ ap1->set_host_wifi_rate(simgrid::s4u::Host::by_name(src), 0);
+ ap1->set_host_wifi_rate(simgrid::s4u::Host::by_name(dest), 0);
simgrid::s4u::this_actor::sleep_for(10);
XBT_INFO("\n");
}
examples/platforms/two_hosts_platform_with_availability_included.xml
examples/platforms/two_peers.xml
examples/platforms/vivaldi.xml
- examples/platforms/wifi_decay_2STA.xml
examples/platforms/wifi.xml
)