From: Martin Quinson Date: Sun, 9 Jul 2023 23:49:19 +0000 (+0200) Subject: Drop some redundant examples X-Git-Tag: v3.35~155 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e3d64fad1983e4f8c1b7e1a19a3e3ae02366e2bb Drop some redundant examples --- diff --git a/MANIFEST.in b/MANIFEST.in index 9914133f80..f4d801b2bf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -190,16 +190,12 @@ include examples/cpp/comm-ready/s4u-comm-ready.cpp include examples/cpp/comm-ready/s4u-comm-ready.tesh include examples/cpp/comm-suspend/s4u-comm-suspend.cpp include examples/cpp/comm-suspend/s4u-comm-suspend.tesh -include examples/cpp/comm-testany/s4u-comm-testany.cpp -include examples/cpp/comm-testany/s4u-comm-testany.tesh include examples/cpp/comm-throttling/s4u-comm-throttling.cpp include examples/cpp/comm-throttling/s4u-comm-throttling.tesh include examples/cpp/comm-wait/s4u-comm-wait.cpp include examples/cpp/comm-wait/s4u-comm-wait.tesh include examples/cpp/comm-waitall/s4u-comm-waitall.cpp include examples/cpp/comm-waitall/s4u-comm-waitall.tesh -include examples/cpp/comm-waitany/s4u-comm-waitany.cpp -include examples/cpp/comm-waitany/s4u-comm-waitany.tesh include examples/cpp/comm-waituntil/s4u-comm-waituntil.cpp include examples/cpp/comm-waituntil/s4u-comm-waituntil.tesh include examples/cpp/dag-comm/s4u-dag-comm.cpp @@ -291,8 +287,6 @@ include examples/cpp/exec-threads/s4u-exec-threads.cpp include examples/cpp/exec-threads/s4u-exec-threads.tesh include examples/cpp/exec-unassigned/s4u-exec-unassigned.cpp include examples/cpp/exec-unassigned/s4u-exec-unassigned.tesh -include examples/cpp/exec-waitany/s4u-exec-waitany.cpp -include examples/cpp/exec-waitany/s4u-exec-waitany.tesh include examples/cpp/exec-waitfor/s4u-exec-waitfor.cpp include examples/cpp/exec-waitfor/s4u-exec-waitfor.tesh include examples/cpp/io-async/s4u-io-async.cpp diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index 802f170d5b..1bada049a4 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -158,14 +158,14 @@ foreach (example activityset-testany activityset-waitany actor-lifetime actor-migrate actor-suspend actor-yield actor-stacksize app-bittorrent app-chainsend app-token-ring battery-degradation battery-simple battery-energy - comm-pingpong comm-ready comm-suspend comm-testany comm-wait comm-waitany comm-waitall comm-waituntil + comm-pingpong comm-ready comm-suspend comm-wait comm-waitall comm-waituntil comm-dependent comm-host2host comm-failure comm-throttling cloud-capping cloud-migration cloud-simple dag-comm dag-from-json-simple dag-from-dax-simple dag-from-dax dag-from-dot-simple dag-from-dot dag-failure dag-io dag-scheduling dag-simple dag-tuto dht-chord dht-kademlia energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi engine-filtering engine-run-partial - exec-async exec-basic exec-dvfs exec-remote exec-waitany exec-waitfor exec-dependent exec-unassigned + exec-async exec-basic exec-dvfs exec-remote exec-waitfor exec-dependent exec-unassigned exec-ptask-multicore exec-ptask-multicore-latency exec-cpu-nonlinear exec-cpu-factors exec-failure exec-threads maestro-set mc-bugged1 mc-bugged1-liveness mc-bugged2 mc-bugged2-liveness mc-centralized-mutex mc-electric-fence mc-failing-assert diff --git a/examples/cpp/comm-testany/s4u-comm-testany.cpp b/examples/cpp/comm-testany/s4u-comm-testany.cpp deleted file mode 100644 index f06cb1621b..0000000000 --- a/examples/cpp/comm-testany/s4u-comm-testany.cpp +++ /dev/null @@ -1,73 +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. */ - -#include "simgrid/s4u.hpp" -#include -#include -#include -namespace sg4 = simgrid::s4u; - -XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_testany, "Messages specific for this s4u example"); - -static void rank0() -{ - sg4::Mailbox* mbox = sg4::Mailbox::by_name("rank0"); - std::string* msg1; - std::string* msg2; - std::string* msg3; - - XBT_INFO("Post my asynchronous receives"); - auto comm1 = mbox->get_async(&msg1); - auto comm2 = mbox->get_async(&msg2); - auto comm3 = mbox->get_async(&msg3); - std::vector pending_comms = {comm1, comm2, comm3}; - - XBT_INFO("Send some data to rank-1"); - for (int i = 0; i < 3; i++) - sg4::Mailbox::by_name("rank1")->put(new int(i), 1); - - XBT_INFO("Test for completed comms"); - while (not pending_comms.empty()) { - ssize_t flag = sg4::Comm::test_any(pending_comms); - if (flag != -1) { - pending_comms.erase(pending_comms.begin() + flag); - XBT_INFO("Remove a pending comm."); - } else // nothing matches, wait for a little bit - sg4::this_actor::sleep_for(0.1); - } - XBT_INFO("Last comm is complete"); - delete msg1; - delete msg2; - delete msg3; -} - -static void rank1() -{ - sg4::Mailbox* rank0_mbox = sg4::Mailbox::by_name("rank0"); - sg4::Mailbox* rank1_mbox = sg4::Mailbox::by_name("rank1"); - - for (int i = 0; i < 3; i++) { - auto res = rank1_mbox->get_unique(); - XBT_INFO("Received %d", *res); - std::string msg_content = "Message " + std::to_string(i); - auto* payload = new std::string(msg_content); - XBT_INFO("Send '%s'", msg_content.c_str()); - rank0_mbox->put(payload, 1e6); - } -} - -int main(int argc, char* argv[]) -{ - sg4::Engine e(&argc, argv); - - e.load_platform(argv[1]); - - sg4::Actor::create("rank-0", e.host_by_name("Tremblay"), rank0); - sg4::Actor::create("rank-1", e.host_by_name("Fafard"), rank1); - - e.run(); - - return 0; -} diff --git a/examples/cpp/comm-testany/s4u-comm-testany.tesh b/examples/cpp/comm-testany/s4u-comm-testany.tesh deleted file mode 100644 index 0f19916447..0000000000 --- a/examples/cpp/comm-testany/s4u-comm-testany.tesh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env tesh - -$ ${bindir:=.}/s4u-comm-testany ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e[%8h]%e[%a]%e%m%n" -> [ 0.000000] [Tremblay] [rank-0] Post my asynchronous receives -> [ 0.000000] [Tremblay] [rank-0] Send some data to rank-1 -> [ 0.025708] [ Fafard] [rank-1] Received 0 -> [ 0.025708] [ Fafard] [rank-1] Send 'Message 0' -> [ 0.209813] [ Fafard] [rank-1] Received 1 -> [ 0.209813] [ Fafard] [rank-1] Send 'Message 1' -> [ 0.393918] [Tremblay] [rank-0] Test for completed comms -> [ 0.393918] [ Fafard] [rank-1] Received 2 -> [ 0.393918] [ Fafard] [rank-1] Send 'Message 2' -> [ 0.393918] [Tremblay] [rank-0] Remove a pending comm. -> [ 0.393918] [Tremblay] [rank-0] Remove a pending comm. -> [ 0.593918] [Tremblay] [rank-0] Remove a pending comm. -> [ 0.593918] [Tremblay] [rank-0] Last comm is complete diff --git a/examples/cpp/comm-waitany/s4u-comm-waitany.cpp b/examples/cpp/comm-waitany/s4u-comm-waitany.cpp deleted file mode 100644 index 429e22b121..0000000000 --- a/examples/cpp/comm-waitany/s4u-comm-waitany.cpp +++ /dev/null @@ -1,101 +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 use simgrid::s4u::this_actor::wait_any() to wait for the first occurring event. - * - * 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 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. - * - */ - -#include "simgrid/s4u.hpp" -#include -#include -#include -namespace sg4 = simgrid::s4u; - -XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_waitall, "Messages specific for this s4u example"); - -static void sender(unsigned int messages_count, unsigned int receivers_count, long msg_size) -{ - if (messages_count == 0 || receivers_count == 0) { - XBT_WARN("Sender has nothing to do. Bail out!"); - return; - } - /* Set in which we store all ongoing communications */ - sg4::ActivitySet pending_comms; - - /* Make a vector of the mailboxes to use */ - std::vector mboxes; - for (unsigned int i = 0; i < receivers_count; i++) - mboxes.push_back(sg4::Mailbox::by_name("receiver-" + std::to_string(i))); - - /* Start dispatching all messages to receivers, in a round robin fashion */ - for (unsigned int i = 0; i < messages_count; i++) { - std::string msg_content = "Message " + std::to_string(i); - // 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 it - auto* payload = new std::string(msg_content); - - XBT_INFO("Send '%s' to '%s'", msg_content.c_str(), mboxes[i % receivers_count]->get_cname()); - - /* Create a communication representing the ongoing communication, and store it in pending_comms */ - sg4::CommPtr comm = mboxes[i % receivers_count]->put_async(payload, msg_size); - pending_comms.push(comm); - } - - /* Start sending messages to let the workers know that they should stop */ - for (unsigned int i = 0; i < receivers_count; i++) { - XBT_INFO("Send 'finalize' to 'receiver-%u'", i); - sg4::CommPtr comm = mboxes[i]->put_async(new std::string("finalize"), 0); - pending_comms.push(comm); - } - XBT_INFO("Done dispatching all messages"); - - /* Now that all message exchanges were initiated, wait for their completion one by one. - * - * Activities are removed in order of termination. It differs from the order of creation, even if it's a bit difficult - * to see it here. - */ - while (not pending_comms.empty()) - pending_comms.wait_any(); - - XBT_INFO("Goodbye now!"); -} - -/* Receiver actor expects 1 argument: its ID */ -static void receiver(int id) -{ - sg4::Mailbox* mbox = sg4::Mailbox::by_name("receiver-" + std::to_string(id)); - XBT_INFO("Wait for my first message"); - for (bool cont = true; cont;) { - auto received = mbox->get_unique(); - XBT_INFO("I got a '%s'.", received->c_str()); - cont = (*received != "finalize"); // If it's a finalize message, we're done - // Receiving the message was all we were supposed to do - } -} - -int main(int argc, char* argv[]) -{ - sg4::Engine e(&argc, argv); - - e.load_platform(argv[1]); - - sg4::Actor::create("sender", e.host_by_name("Tremblay"), sender, 6, 2, 1e6); - sg4::Actor::create("receiver", e.host_by_name("Fafard"), receiver, 0); - sg4::Actor::create("receiver", e.host_by_name("Jupiter"), receiver, 1); - - e.run(); - - return 0; -} diff --git a/examples/cpp/comm-waitany/s4u-comm-waitany.tesh b/examples/cpp/comm-waitany/s4u-comm-waitany.tesh deleted file mode 100644 index f2480ad6cf..0000000000 --- a/examples/cpp/comm-waitany/s4u-comm-waitany.tesh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env tesh - -p Testing this_actor->wait_any() - -! output sort 19 -$ ${bindir:=.}/s4u-comm-waitany ${platfdir}/small_platform.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@Fafard) Wait for my first message -> [ 0.000000] (3:receiver@Jupiter) Wait for my first message -> [ 0.000000] (1:sender@Tremblay) Send 'Message 1' to 'receiver-1' -> [ 0.000000] (1:sender@Tremblay) Send 'Message 2' to 'receiver-0' -> [ 0.000000] (1:sender@Tremblay) Send 'Message 3' to 'receiver-1' -> [ 0.000000] (1:sender@Tremblay) Send 'Message 4' to 'receiver-0' -> [ 0.000000] (1:sender@Tremblay) Send 'Message 5' to 'receiver-1' -> [ 0.000000] (1:sender@Tremblay) Send 'finalize' to 'receiver-0' -> [ 0.000000] (1:sender@Tremblay) Send 'finalize' to 'receiver-1' -> [ 0.000000] (1:sender@Tremblay) Done dispatching all messages -> [ 0.158397] (2:receiver@Fafard) I got a 'Message 0'. -> [ 0.169155] (3:receiver@Jupiter) I got a 'Message 1'. -> [ 0.316794] (2:receiver@Fafard) I got a 'Message 2'. -> [ 0.338309] (3:receiver@Jupiter) I got a 'Message 3'. -> [ 0.475190] (2:receiver@Fafard) I got a 'Message 4'. -> [ 0.500898] (2:receiver@Fafard) I got a 'finalize'. -> [ 0.507464] (3:receiver@Jupiter) I got a 'Message 5'. -> [ 0.526478] (3:receiver@Jupiter) I got a 'finalize'. -> [ 0.526478] (1:sender@Tremblay) Goodbye now! diff --git a/examples/cpp/exec-waitany/s4u-exec-waitany.cpp b/examples/cpp/exec-waitany/s4u-exec-waitany.cpp deleted file mode 100644 index c30dd319a9..0000000000 --- a/examples/cpp/exec-waitany/s4u-exec-waitany.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (c) 2019-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. */ - -#include "simgrid/s4u.hpp" -#include -#include -#include - -XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_exec_waitany, "Messages specific for this s4u example"); -namespace sg4 = simgrid::s4u; - -static void worker(bool with_timeout) -{ - /* Vector in which we store all pending executions*/ - std::vector pending_executions; - - for (int i = 0; i < 3; i++) { - std::string name = "Exec-" + std::to_string(i); - double amount = (6 * (i % 2) + i + 1) * sg4::this_actor::get_host()->get_speed(); - - sg4::ExecPtr exec = sg4::this_actor::exec_init(amount)->set_name(name); - pending_executions.push_back(exec); - exec->start(); - - XBT_INFO("Activity %s has started for %.0f seconds", name.c_str(), - amount / sg4::this_actor::get_host()->get_speed()); - } - - /* Now that executions were initiated, wait for their completion, in order of termination. - * - * This loop waits for first terminating execution with wait_any() and remove it with erase(), until all execs are - * terminated. - */ - while (not pending_executions.empty()) { - ssize_t pos; - if (with_timeout) - pos = sg4::Exec::wait_any_for(pending_executions, 4); - else - pos = sg4::Exec::wait_any(pending_executions); - - if (pos < 0) { - XBT_INFO("Do not wait any longer for an activity"); - pending_executions.clear(); - } else { - XBT_INFO("Activity '%s' (at position %zd) is complete", pending_executions[pos]->get_cname(), pos); - pending_executions.erase(pending_executions.begin() + pos); - } - XBT_INFO("%zu activities remain pending", pending_executions.size()); - } -} - -int main(int argc, char* argv[]) -{ - sg4::Engine e(&argc, argv); - e.load_platform(argv[1]); - sg4::Actor::create("worker", e.host_by_name("Tremblay"), worker, false); - sg4::Actor::create("worker_timeout", e.host_by_name("Tremblay"), worker, true); - e.run(); - - return 0; -} diff --git a/examples/cpp/exec-waitany/s4u-exec-waitany.tesh b/examples/cpp/exec-waitany/s4u-exec-waitany.tesh deleted file mode 100644 index 072cab5269..0000000000 --- a/examples/cpp/exec-waitany/s4u-exec-waitany.tesh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env tesh - -! output sort 19 -$ ${bindir:=.}/s4u-exec-waitany ${platfdir}/multicore_machine.xml "--log=root.fmt:[%10.6r]%e[%14P]%e%m%n" -> [ 0.000000] [ worker] Activity Exec-0 has started for 1 seconds -> [ 0.000000] [worker_timeout] Activity Exec-0 has started for 1 seconds -> [ 0.000000] [ worker] Activity Exec-1 has started for 8 seconds -> [ 0.000000] [worker_timeout] Activity Exec-1 has started for 8 seconds -> [ 0.000000] [ worker] Activity Exec-2 has started for 3 seconds -> [ 0.000000] [worker_timeout] Activity Exec-2 has started for 3 seconds -> [ 1.000000] [worker_timeout] Activity 'Exec-0' (at position 0) is complete -> [ 1.000000] [worker_timeout] 2 activities remain pending -> [ 1.000000] [ worker] Activity 'Exec-0' (at position 0) is complete -> [ 1.000000] [ worker] 2 activities remain pending -> [ 3.000000] [worker_timeout] Activity 'Exec-2' (at position 1) is complete -> [ 3.000000] [worker_timeout] 1 activities remain pending -> [ 3.000000] [ worker] Activity 'Exec-2' (at position 1) is complete -> [ 3.000000] [ worker] 1 activities remain pending -> [ 7.000000] [worker_timeout] Do not wait any longer for an activity -> [ 7.000000] [worker_timeout] 0 activities remain pending -> [ 8.000000] [ worker] Activity 'Exec-1' (at position 0) is complete -> [ 8.000000] [ worker] 0 activities remain pending