SimGrid (3.22) NOT RELEASED (Release Target: December 21. 2018, 22:23 UTC)
-Java:
- - Process termination which was broken at version 3.21 has been repaired.
- - Expose host load plugin: loadInit, getCurrentLoad, getComputedFlops, getAvgLoad
- - Hide the examples into examples/deprecated. New users should use Python.
+The Sneaky Release.
+
+Python:
+ - We are excited to introduce the SimGrid/S4U interface to your neighborhood
+ - Not complete yet: asynchronous activities (amongst others) are still missing
+ - Still ongoing: the interface may change a bit in the future (please
+ report any glitches), but it seems rather fast and reliable already.
+ - Forget about Java now (and soon about C++)
Core:
- Replace our own code to display a backtrace (that was forking addr2line)
- Bump cmake dependency to 3.5 (provided by Ubuntu 16.04).
- Stop setting random seed with srand() at initialization.
+XML
+ - In <host> and <peer>, 'availability_file' is now 'speed_file'.
+ XML file version remains 4.2 since old files are still compatible.
+
+Java:
+ - Process termination which was broken at version 3.21 has been repaired.
+ - Expose host load plugin: loadInit, getCurrentLoad, getComputedFlops, getAvgLoad
+ - Hide the examples into examples/deprecated. New users should use Python.
+
MSG:
- Drop MSG_process_create_from_stdfunc() from the API.
This C++ function was a pimple in the C API, made necessary at some
- Drop xbt_ex_display(), use simgrid::xbt::log_exception() instead.
- Drop cunit, use Catch2 instead.
-XML
- - In <host> and <peer>, availability_file is now speed_file.
- XML file version remains 4.2 since old files are still compatible.
-
-Internal:
+Kernel:
- Many cleanups in the kernel::activity namespace. This was long
overdue, and shall open the path to many future endeavors.
Fixed bugs:
- - #132: Java : a process can not shut down its own host
+ - #132: Java: a process can not shut down its own host
- #261: Document the parameters of parallel execution's constructor
- #300: [s4u] BarrierPtr is missing
- #314: SMPI args internal cleanup
\_/ \___|_| |___/_|\___/|_| |_| |____(_)_____|_____|
(not released)
+The Sneaky Release.
+
+ * Introducing the Python bindings (still partial)
+ * Doc: SMPI tutorial and platform description ported to RTD
+ * Further replace XBT by the std library.
+ * (+ the classical bug fixes and internal refactorings)
_ _____ ____ _
__ _____ _ __ ___(_) ___ _ __ |___ / |___ \/ |
\ \ / / _ \ '__/ __| |/ _ \| '_ \ |_ \ __) | |
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
+functions take a profile, that can be a fixed profile exhaustively
listing the events, or something else if you wish.
.. _howto_multicore:
> [ 1.000000] (7:worker@Fafard) Waiting a message on worker-2
> [ 1.000000] (1:master@Tremblay) Mmh. Something went wrong with 'worker-1'. Nevermind. Let's keep going!
> [ 1.000000] (1:master@Tremblay) Send a message to worker-2
-> [ 1.000000] (3:worker@Jupiter) Gloups. The cpu on which I'm running just turned off!. See you!
> [ 2.000000] (1:master@Tremblay) Mmh. Something went wrong with 'worker-2'. Nevermind. Let's keep going!
-> [ 2.000000] (7:worker@Fafard) Gloups. The cpu on which I'm running just turned off!. See you!
> [ 2.000000] (0:maestro@) Restart processes on host Jupiter
> [ 2.000000] (1:master@Tremblay) Send a message to worker-3
> [ 2.000000] (8:worker@Jupiter) Waiting a message on worker-1
> [ 1.000000] (7:worker@Fafard) Waiting a message on worker-2
> [ 1.000000] (1:master@Tremblay) Mmh. Something went wrong with 'worker-1'. Nevermind. Let's keep going!
> [ 1.000000] (1:master@Tremblay) Send a message to worker-2
-> [ 1.000000] (3:worker@Jupiter) Gloups. The cpu on which I'm running just turned off!. See you!
> [ 2.000000] (0:maestro@) Restart processes on host Jupiter
> [ 2.000000] (8:worker@Jupiter) Waiting a message on worker-1
> [ 2.000000] (1:master@Tremblay) Mmh. Something went wrong with 'worker-2'. Nevermind. Let's keep going!
> [ 2.000000] (1:master@Tremblay) Send a message to worker-3
-> [ 2.000000] (7:worker@Fafard) Gloups. The cpu on which I'm running just turned off!. See you!
> [ 2.010825] (2:worker@Tremblay) Execution complete.
> [ 2.010825] (2:worker@Tremblay) Waiting a message on worker-0
> [ 3.082474] (5:worker@Ginette) Start execution...
foreach(example actor-create actor-daemon actor-join actor-kill actor-migrate actor-suspend actor-yield # actor-lifetime
+ async-wait
exec-basic)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.tesh)
set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.py)
examples/python/actor-lifetime/actor-lifetime_d.xml
examples/python/actor-lifetime/actor-lifetime.py # example broken so far
examples/python/actor-lifetime/actor-lifetime.tesh
+ examples/python/async-wait/async-wait_d.xml
${tesh_files} PARENT_SCOPE)
set(examples_src ${examples_src} PARENT_SCOPE)
--- /dev/null
+# Copyright (c) 2010-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.
+
+import sys
+from simgrid import *
+
+# This example shows how to use simgrid::s4u::this_actor::wait() to wait for a given communication.
+#
+# As for the other asynchronous examples, the sender initiate all the messages it wants to send and
+# pack the resulting simgrid::s4u::CommPtr objects in a vector. All messages thus occurs concurrently.
+#
+# The sender then loops until there is no ongoing communication.
+
+class Sender:
+ def __init__(self, *args):
+ if len(args) != 3:
+ raise AssertionError(
+ "Actor sender requires 4 parameters, but got {:d}".format(len(args)))
+ self.messages_count = int(args[0]) # number of tasks
+ self.msg_size = int(args[1]) # communication cost (in bytes)
+ self.receivers_count = int(args[2]) # number of receivers
+
+ def __call__(self):
+ # List in which we store all ongoing communications
+ pending_comms = []
+
+ # Vector of the used mailboxes
+ mboxes = [Mailbox.by_name("receiver-{:d}".format(i)) for i in range(0, self.receivers_count)]
+
+ # Start dispatching all messages to receivers, in a round robin fashion
+ for i in range(0, self.messages_count):
+ content = "Message {:d}".format(i)
+ mbox = mboxes[i % self.receivers_count]
+
+ this_actor.info("Send '{:s}' to '{:s}'".format(content, str(mbox)))
+
+ # Create a communication representing the ongoing communication, and store it in pending_comms
+ comm = mbox.put_async(content, self.msg_size)
+ pending_comms.append(comm)
+
+ # Start sending messages to let the workers know that they should stop
+ for i in range(0, self.receivers_count):
+ mbox = mboxes[i]
+ this_actor.info("Send 'finalize' to '{:s}'".format(str(mbox)))
+ comm = mbox.put_async("finalize", 0)
+ pending_comms.append(comm)
+
+ this_actor.info("Done dispatching all messages")
+
+ # Now that all message exchanges were initiated, wait for their completion, in order of creation.
+ for comm in pending_comms:
+ comm.wait()
+ this_actor.info("Goodbye now!")
+
+class Receiver:
+ def __init__(self, *args):
+ if len(args) != 1: # Receiver actor expects 1 argument: its ID
+ raise AssertionError("Actor receiver requires 1 parameter, but got {:d}".format(len(args)))
+ self.mbox = Mailbox.by_name("receiver-{:s}".format(args[0]))
+
+ def __call__(self):
+ this_actor.info("Wait for my first message")
+ while True:
+ received = self.mbox.get()
+ this_actor.info("I got a '{:s}'.".format(received))
+ if received == "finalize":
+ break # If it's a finalize message, we're done.
+
+
+if __name__ == '__main__':
+ e = Engine(sys.argv)
+
+ e.load_platform(sys.argv[1]) # Load the platform description
+
+ # Register the classes representing the actors
+ e.register_actor("sender", Sender)
+ e.register_actor("receiver", Receiver)
+
+ e.load_deployment(sys.argv[2])
+
+ e.run()
--- /dev/null
+#!/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"
+> [ 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)'
+> [ 0.000000] (1:sender@Tremblay) Send 'Message 2' to 'Mailbox(receiver-0)'
+> [ 0.000000] (1:sender@Tremblay) Send 'finalize' to 'Mailbox(receiver-0)'
+> [ 0.000000] (1:sender@Tremblay) Done dispatching all messages
+> [ 0.105458] (2:receiver@Ruby) I got a 'Message 0'.
+> [ 0.210917] (2:receiver@Ruby) I got a 'Message 1'.
+> [ 0.316375] (2:receiver@Ruby) I got a 'Message 2'.
+> [ 0.318326] (2:receiver@Ruby) I got a 'finalize'.
+> [ 0.318326] (1:sender@Tremblay) Goodbye now!
\ No newline at end of file
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
+<platform version="4.1">
+ <!-- The master actor (with some arguments) -->
+ <actor host="Tremblay" function="sender">
+ <argument value="3"/> <!-- Number of tasks -->
+ <argument value="50000000"/> <!-- Computation size of tasks -->
+ <argument value="1"/> <!-- Number of receivers -->
+ </actor>
+ <!-- The receiver processes -->
+ <actor host="Ruby" function="receiver">
+ <argument value="0"/> <!-- id -->
+ </actor>
+</platform>
- **Basic asynchronous communications:**
Illustrates how to have non-blocking communications, that are
communications running in the background leaving the process free
- to do something else during their completion. The main functions
- involved are :cpp:func:`simgrid::s4u::Mailbox::put_async()` and
- :cpp:func:`simgrid::s4u::Comm::wait()`.
- |br| `examples/s4u/async-wait/s4u-async-wait.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/async-wait/s4u-async-wait.cpp>`_
+ to do something else during their completion.
+
+ - |cpp| `examples/s4u/async-wait/s4u-async-wait.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/async-wait/s4u-async-wait.cpp>`_
+ :cpp:func:`simgrid::s4u::Mailbox::put_async()` and :cpp:func:`simgrid::s4u::Comm::wait()`
+ - |py| `examples/python/async-wait/async-wait.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/async-wait/async-wait.py>`_
+ :py:func:`simgrid.Mailbox.put_async()` :py:func:`simgrid.Comm.wait()`
- **Waiting for all communications in a set:**
The :cpp:func:`simgrid::s4u::Comm::wait_all()` function is useful
matter which terminates first.
|br| `examples/s4u/async-waitany/s4u-async-waitany.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/async-waitany/s4u-async-waitany.cpp>`_
-.. todo:: add the `ready` example here
+.. todo:: review the `ready` and `waituntil` examples and add them here.
.. _s4u_ex_execution:
XBT_INFO("Send a message to %s", mailbox->get_cname());
mailbox->put(payload, comm_size, 10.0);
XBT_INFO("Send to %s completed", mailbox->get_cname());
- } catch (simgrid::HostFailureException& e) {
- XBT_INFO("Gloups. The cpu on which I'm running just turned off!. See you!");
- return -1;
} catch (simgrid::TimeoutError& e) {
delete payload;
XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox->get_cname());
> [ 1.000000] (7:worker@Fafard) Waiting a message on worker-2
> [ 1.000000] (1:master@Tremblay) Mmh. The communication with 'worker-1' failed. Nevermind. Let's keep going!
> [ 1.000000] (1:master@Tremblay) Send a message to worker-2
-> [ 1.000000] (3:worker@Jupiter) Gloups. The cpu on which I'm running just turned off!. See you!
> [ 2.000000] (1:master@Tremblay) Mmh. The communication with 'worker-2' failed. Nevermind. Let's keep going!
-> [ 2.000000] (7:worker@Fafard) Gloups. The cpu on which I'm running just turned off!. See you!
> [ 2.000000] (0:maestro@) Restart processes on host Jupiter
> [ 2.000000] (1:master@Tremblay) Send a message to worker-3
> [ 2.000000] (8:worker@Jupiter) Waiting a message on worker-1
> [ 1.000000] (7:worker@Fafard) Waiting a message on worker-2
> [ 1.000000] (1:master@Tremblay) Mmh. The communication with 'worker-1' failed. Nevermind. Let's keep going!
> [ 1.000000] (1:master@Tremblay) Send a message to worker-2
-> [ 1.000000] (3:worker@Jupiter) Gloups. The cpu on which I'm running just turned off!. See you!
> [ 2.000000] (0:maestro@) Restart processes on host Jupiter
> [ 2.000000] (8:worker@Jupiter) Waiting a message on worker-1
> [ 2.000000] (1:master@Tremblay) Mmh. The communication with 'worker-2' failed. Nevermind. Let's keep going!
> [ 2.000000] (1:master@Tremblay) Send a message to worker-3
-> [ 2.000000] (7:worker@Fafard) Gloups. The cpu on which I'm running just turned off!. See you!
> [ 2.010825] (2:worker@Tremblay) Execution complete.
> [ 2.010825] (2:worker@Tremblay) Waiting a message on worker-0
> [ 3.082474] (5:worker@Ginette) Start execution...
#include "src/kernel/context/Context.hpp"
#include <simgrid/Exception.hpp>
#include <simgrid/s4u/Actor.hpp>
+#include <simgrid/s4u/Comm.hpp>
#include <simgrid/s4u/Engine.hpp>
#include <simgrid/s4u/Host.hpp>
#include <simgrid/s4u/Mailbox.hpp>
/* Class Mailbox */
py::class_<simgrid::s4u::Mailbox, std::unique_ptr<Mailbox, py::nodelete>>(m, "Mailbox", "Mailbox, see :ref:`class s4u::Mailbox <API_s4u_Mailbox>`")
+ .def("__str__", [](Mailbox self) -> const std::string {
+ return std::string("Mailbox(")+self.get_cname()+")";
+ }, "Textual representation of the Mailbox`")
.def("by_name", &Mailbox::by_name, "Retrieve a Mailbox from its name, see :cpp:func:`simgrid::s4u::Mailbox::by_name()`")
.def_property_readonly("name", [](Mailbox* self) -> const std::string {
return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
data.inc_ref();
self.put(data.ptr(), size);
}, "Blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put(void*, uint64_t)`")
+ .def("put_async", [](Mailbox self, py::object data, int size) -> simgrid::s4u::CommPtr {
+ data.inc_ref();
+ return self.put_async(data.ptr(), size);
+ }, "Non-blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put_async(void*, uint64_t)`")
.def("get", [](Mailbox self) -> py::object {
py::object data = pybind11::reinterpret_steal<py::object>(pybind11::handle(static_cast<PyObject*>(self.get())));
data.dec_ref();
return data;
}, "Blocking data reception, see :cpp:func:`void* simgrid::s4u::Mailbox::get()`");
+ /* Class Comm */
+ py::class_<simgrid::s4u::Comm, simgrid::s4u::CommPtr>(m, "Comm", "Communication, see :ref:`class s4u::Comm <API_s4u_Comm>`")
+ .def("test", [](simgrid::s4u::CommPtr self) {
+ return self->test();
+ }, "Test whether the communication is terminated, see :cpp:func:`simgrid::s4u::Comm::test()`")
+ .def("wait", [](simgrid::s4u::CommPtr self) {
+ self->wait();
+ }, "Block until the completion of that communication, see :cpp:func:`simgrid::s4u::Comm::wait()`");
+
/* Class Actor */
py::class_<simgrid::s4u::Actor, ActorPtr>(m, "Actor",
"An actor is an independent stream of execution in your distributed "
if (not simcall->issuer->get_host()->is_on()) {
simcall->issuer->context_->iwannadie = true;
- simcall->issuer->exception_ =
- std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Host failed"));
} else {
switch (state_) {
XBT_DEBUG("Control returned to me: '%s'", get_cname());
if (context_->iwannadie) {
-
XBT_DEBUG("Actor %s@%s is dead", get_cname(), host_->get_cname());
// throw simgrid::kernel::context::ForcefulKillException(); Does not seem to properly kill the actor
context_->stop();
/** @brief Block the calling actor until the communication is finished, or until timeout
*
- * On timeout, an exception is thrown.
+ * On timeout, an exception is thrown and the communication is invalidated.
*
* @param timeout the amount of seconds to wait for the comm termination.
* Negative values denote infinite wait times. 0 as a timeout returns immediately. */
> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Turn Jupiter off
> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test 5 seems ok (number of Process: 2, it should be 2)
> [Tremblay:test_launcher:(1) 20.000000] [msg_test/INFO] Test done. See you!
-> [Jupiter:commRX:(2) 20.000000] [msg_test/INFO] Receive message: HOST_FAILURE
-> [Jupiter:commRX:(2) 20.000000] [msg_test/INFO] RX Done
> [Tremblay:commTX:(3) 40.000000] [msg_test/INFO] TX done
> [40.000000] [msg_test/INFO] Simulation time 40