Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove an example that is a dupplicate of another one
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 22 Jan 2023 23:03:53 +0000 (00:03 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 22 Jan 2023 23:05:49 +0000 (00:05 +0100)
MANIFEST.in
examples/README.rst
examples/python/CMakeLists.txt
examples/python/comm-waitfor/comm-waitfor.py [deleted file]
examples/python/comm-waitfor/comm-waitfor.tesh [deleted file]
examples/python/comm-waituntil/comm-waituntil.py

index fdc7ae4..46ccea4 100644 (file)
@@ -428,8 +428,6 @@ include examples/python/comm-waitallfor/comm-waitallfor.py
 include examples/python/comm-waitallfor/comm-waitallfor.tesh
 include examples/python/comm-waitany/comm-waitany.py
 include examples/python/comm-waitany/comm-waitany.tesh
-include examples/python/comm-waitfor/comm-waitfor.py
-include examples/python/comm-waitfor/comm-waitfor.tesh
 include examples/python/comm-waituntil/comm-waituntil.py
 include examples/python/comm-waituntil/comm-waituntil.tesh
 include examples/python/exec-async/exec-async.py
index 5da9c36..c7a55a2 100644 (file)
@@ -346,6 +346,8 @@ free to do something else during their completion.
 Waiting for communications with timeouts
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+There is two ways of declaring timeouts in SimGrid. ``waituntil`` let you specify the deadline until when you want to wait, while
+``waitfor`` expects the maximal wait duration.
 This example is very similar to the previous one, simply adding how to declare timeouts when waiting on asynchronous communication.
 
 .. tabs::
index 168af95..d2bb58a 100644 (file)
@@ -1,6 +1,6 @@
 foreach(example actor-create actor-daemon actor-join actor-kill actor-migrate actor-suspend actor-yield actor-lifetime
         app-masterworkers
-        comm-wait comm-waitall comm-waitallfor comm-waitany comm-waitfor comm-failure comm-host2host comm-pingpong
+        comm-wait comm-waitall comm-waitallfor comm-waitany comm-failure comm-host2host comm-pingpong
         comm-ready comm-suspend comm-testany comm-throttling comm-waitallfor comm-waituntil
         exec-async exec-basic exec-dvfs exec-remote exec-ptask
         platform-comm-serialize platform-profile platform-failures
diff --git a/examples/python/comm-waitfor/comm-waitfor.py b/examples/python/comm-waitfor/comm-waitfor.py
deleted file mode 100644 (file)
index 367392d..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright (c) 2010-2023. 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 block on the completion of a set of communications.
-
-As for the other asynchronous examples, the sender initiate all the messages it wants to send and
-pack the resulting simgrid.Comm objects in a list. All messages thus occur concurrently.
-
-The sender then loops until there is no ongoing communication. Using wait_any() ensures that the sender
-will notice events as soon as they occur even if it does not follow the order of the container.
-
-Here, finalize messages will terminate earlier because their size is 0, so they travel faster than the
-other messages of this application.  As expected, the trace shows that the finalize of worker 1 is
-processed before 'Message 5' that is sent to worker 0.
-"""
-
-import sys
-from simgrid import Actor, Comm, Engine, Host, Mailbox, this_actor
-
-
-FINALIZE_TAG = "finalize"
-
-
-def sender(receiver_id: str, messages_count: int, payload_size: int) -> None:
-    # List in which we store all ongoing communications
-    pending_comms = []
-    mbox = Mailbox.by_name(receiver_id)
-
-    # Asynchronously send `messages_count` message(s) to the receiver
-    for i in range(0, messages_count):
-        payload = "Message {:d}".format(i)
-        this_actor.info("Send '{:s}' to '{:s}'".format(payload, receiver_id))
-
-        # Create a communication representing the ongoing communication, and store it in pending_comms
-        comm = mbox.put_async(payload, payload_size)
-        pending_comms.append(comm)
-
-    # Send the final message to the receiver
-    payload = FINALIZE_TAG
-    final_payload_size = 0
-    final_comm = mbox.put_async(payload, final_payload_size)
-    pending_comms.append(final_comm)
-    this_actor.info("Send '{:s}' to '{:s}".format(payload, receiver_id))
-    this_actor.info("Done dispatching all messages")
-
-    this_actor.info("Waiting for all outstanding communications to complete")
-    while pending_comms:
-        current_comm: Comm = pending_comms[-1]
-        current_comm.wait_for(1.0)
-        pending_comms.pop()
-    this_actor.info("Goodbye now!")
-
-
-def receiver(identifier: str) -> None:
-    mbox: Mailbox = Mailbox.by_name(identifier)
-    this_actor.info("Wait for my first message")
-    while True:
-        received = mbox.get()
-        this_actor.info("I got a '{:s}'.".format(received))
-        if received == FINALIZE_TAG:
-            break
-    this_actor.info("Goodbye now!")
-
-
-def main():
-    e = Engine(sys.argv)
-
-    # Load the platform description
-    e.load_platform(sys.argv[1])
-
-    receiver_id = "receiver-0"
-    Actor.create("sender", Host.by_name("Tremblay"), sender, receiver_id, 3, int(5e7))
-    Actor.create("receiver", Host.by_name("Ruby"), receiver, receiver_id)
-
-    e.run()
-
-
-if __name__ == '__main__':
-    main()
diff --git a/examples/python/comm-waitfor/comm-waitfor.tesh b/examples/python/comm-waitfor/comm-waitfor.tesh
deleted file mode 100644 (file)
index b326fcb..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/env tesh
-
-p Testing Comm.wait_any()
-
-$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/comm-waitfor.py ${platfdir}/small_platform_fatpipe.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%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'
-> [  0.000000] (1:sender@Tremblay) Send 'Message 2' to 'receiver-0'
-> [  0.000000] (1:sender@Tremblay) Send 'finalize' to 'receiver-0
-> [  0.000000] (1:sender@Tremblay) Done dispatching all messages
-> [  0.000000] (1:sender@Tremblay) Waiting for all outstanding communications to complete
-> [  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] (2:receiver@Ruby) Goodbye now!
-> [  0.318326] (1:sender@Tremblay) Goodbye now!
index ef94412..0f2bdf8 100644 (file)
@@ -3,7 +3,7 @@
 # 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.
+""" This example demonstrates Comm.wait_for() and Comm.wait_until to set timeouts on waits.
 """
 
 from argparse import ArgumentParser
@@ -47,7 +47,7 @@ def sender(receiver_mailbox: Mailbox, messages_count: int, payload_size: int):
     # Now that all message exchanges were initiated, wait for their completion, in order of creation
     while pending_comms:
         comm = pending_comms[-1]
-        comm.wait_until(Engine.clock + 1)
+        comm.wait_until(Engine.clock + 1)  # same as: current_comm.wait_for(1.0)
         pending_comms.pop()  # remove it from the list
     this_actor.info("Goodbye now!")