Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
replace old and counter-intuitive simdag-throttling example by modern comm-throttling
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 21 Dec 2021 10:00:44 +0000 (11:00 +0100)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 21 Dec 2021 10:00:44 +0000 (11:00 +0100)
MANIFEST.in
examples/cpp/CMakeLists.txt
examples/cpp/comm-throttling/s4u-comm-throttling.cpp [new file with mode: 0644]
examples/cpp/comm-throttling/s4u-comm-throttling.tesh [new file with mode: 0644]
examples/deprecated/simdag/CMakeLists.txt
examples/deprecated/simdag/throttling/sd_throttling.c [deleted file]
examples/deprecated/simdag/throttling/sd_throttling.tesh [deleted file]

index 76442aa..eec4b35 100644 (file)
@@ -188,6 +188,8 @@ include examples/cpp/comm-serialize/s4u-comm-serialize.tesh
 include examples/cpp/comm-suspend/s4u-comm-suspend.cpp
 include examples/cpp/comm-suspend/s4u-comm-suspend.tesh
 include examples/cpp/comm-suspend/s4u-comm-suspend_d.xml
+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-wait/s4u-comm-wait_d.xml
@@ -503,8 +505,6 @@ include examples/deprecated/simdag/scheduling/sd_scheduling.c
 include examples/deprecated/simdag/scheduling/sd_scheduling.tesh
 include examples/deprecated/simdag/test/sd_test.cpp
 include examples/deprecated/simdag/test/sd_test.tesh
-include examples/deprecated/simdag/throttling/sd_throttling.c
-include examples/deprecated/simdag/throttling/sd_throttling.tesh
 include examples/deprecated/simdag/typed_tasks/sd_typed_tasks.c
 include examples/deprecated/simdag/typed_tasks/sd_typed_tasks.tesh
 include examples/python/actor-create/actor-create.py
index af65846..07c5b57 100644 (file)
@@ -64,7 +64,7 @@ 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-token-ring
                  comm-pingpong comm-ready comm-serialize comm-suspend comm-wait comm-waitany comm-waitall comm-waituntil
-                 comm-dependent comm-host2host comm-failure
+                 comm-dependent comm-host2host comm-failure comm-throttling
                  cloud-capping cloud-migration cloud-simple
                  dag-failure dag-simple
                  dht-chord dht-kademlia
diff --git a/examples/cpp/comm-throttling/s4u-comm-throttling.cpp b/examples/cpp/comm-throttling/s4u-comm-throttling.cpp
new file mode 100644 (file)
index 0000000..4a5069a
--- /dev/null
@@ -0,0 +1,56 @@
+/* Copyright (c) 2007-2021. 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>
+namespace sg4 = simgrid::s4u;
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_throttling, "Messages specific for this s4u example");
+
+static void sender(sg4::Mailbox* mailbox)
+{
+  XBT_INFO("Send at full bandwidth");
+
+  /* - First send a 2.5e8 Bytes payload at full bandwidth (1.25e8 Bps) */
+  auto* payload = new double(sg4::Engine::get_clock());
+  mailbox->put(payload, 2.5e8);
+
+  XBT_INFO("Throttle the bandwidth at the Comm level");
+  /* - ... then send it again but throttle the Comm */
+  payload = new double(sg4::Engine::get_clock());
+  /* get a handler on the comm first */
+  sg4::CommPtr comm = mailbox->put_init(payload, 2.5e8);
+
+  /* let throttle the communication. It amounts to set the rate of the comm to half the nominal bandwidth of the link,
+   * i.e., 1.25e8 / 2. This second communication will thus take approximately twice as long as the first one*/
+  comm->set_rate(1.25e8 / 2)->wait();
+}
+
+static void receiver(sg4::Mailbox* mailbox)
+{
+  /* - Receive the first payload sent at full bandwidth */
+  auto sender_time          = mailbox->get_unique<double>();
+  double communication_time = sg4::Engine::get_clock() - *sender_time;
+  XBT_INFO("Payload received (full bandwidth) in %f seconds", communication_time);
+
+  /*  - ... Then receive the second payload sent with a throttled Comm */
+  sender_time        = mailbox->get_unique<double>();
+  communication_time = sg4::Engine::get_clock() - *sender_time;
+  XBT_INFO("Payload received (throttled) in %f seconds", communication_time);
+}
+
+int main(int argc, char* argv[])
+{
+  sg4::Engine e(&argc, argv);
+  e.load_platform(argv[1]);
+
+  sg4::Mailbox* mbox = e.mailbox_by_name_or_create("Mailbox");
+
+  sg4::Actor::create("sender", e.host_by_name("node-0.simgrid.org"), sender, mbox);
+  sg4::Actor::create("receiver", e.host_by_name("node-1.simgrid.org"), receiver, mbox);
+
+  e.run();
+
+  return 0;
+}
diff --git a/examples/cpp/comm-throttling/s4u-comm-throttling.tesh b/examples/cpp/comm-throttling/s4u-comm-throttling.tesh
new file mode 100644 (file)
index 0000000..e1db63a
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-comm-throttling ${platfdir}/cluster_backbone.xml "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
+> [  0.000000] (1:sender@node-0.simgrid.org) Send at full bandwidth
+> [  2.069662] (1:sender@node-0.simgrid.org) Throttle the bandwidth at the Comm level
+> [  2.069662] (2:receiver@node-1.simgrid.org) Payload received (full bandwidth) in 2.069662 seconds
+> [  6.077468] (2:receiver@node-1.simgrid.org) Payload received (throttled) in 4.007806 seconds
index 59c59a6..6676fec 100644 (file)
@@ -1,4 +1,4 @@
-foreach(x daxload typed_tasks throttling scheduling)
+foreach(x daxload typed_tasks scheduling)
   add_executable       (sd_${x}  EXCLUDE_FROM_ALL  ${x}/sd_${x}.c)
   target_link_libraries(sd_${x}     simgrid)
   set_target_properties(sd_${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
@@ -39,7 +39,7 @@ set(txt_files    ${txt_files}     ${CMAKE_CURRENT_SOURCE_DIR}/dag-dotload/dag_wi
                                   ${CMAKE_CURRENT_SOURCE_DIR}/schedule-dotload/dag_with_good_schedule.dot
                                   ${CMAKE_CURRENT_SOURCE_DIR}/scheduling/expected_output.jed               PARENT_SCOPE)
 
-foreach(x daxload typed_tasks throttling scheduling test)
+foreach(x daxload typed_tasks scheduling test)
   ADD_TESH(simdag-${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/simdag --cd ${CMAKE_BINARY_DIR}/examples/deprecated/simdag ${CMAKE_HOME_DIRECTORY}/examples/deprecated/simdag/${x}/sd_${x}.tesh)
 endforeach()
 
diff --git a/examples/deprecated/simdag/throttling/sd_throttling.c b/examples/deprecated/simdag/throttling/sd_throttling.c
deleted file mode 100644 (file)
index 2acf571..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Copyright (c) 2006-2021. 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/simdag.h"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(sd_comm_throttling, "Logging specific to this SimDag example");
-
-int main(int argc, char **argv)
-{
-  unsigned int ctr;
-  SD_task_t task;
-  xbt_dynar_t changed_tasks = xbt_dynar_new(sizeof(SD_task_t), NULL);
-
-  SD_init(&argc, argv);
-  xbt_assert(argc > 1, "Usage: %s platform_file\n\nExample: %s two_clusters.xml", argv[0], argv[0]);
-
-  SD_create_environment(argv[1]);
-
-  sg_host_t *hosts = sg_host_list();
-
-  /* creation of some typed tasks and their dependencies */
-  /* chain of five tasks, three compute tasks with two data transfers in between */
-  SD_task_t taskA = SD_task_create_comp_seq("Task A", NULL, 5e9);
-  SD_task_t taskB = SD_task_create_comm_e2e("Task B", NULL, 1e7);
-  SD_task_t taskC = SD_task_create_comp_seq("Task C", NULL, 5e9);
-  SD_task_t taskD = SD_task_create_comm_e2e("Task D", NULL, 1e7);
-  SD_task_t taskE = SD_task_create_comp_seq("Task E", NULL, 5e9);
-
-  SD_task_dependency_add(taskA, taskB);
-  SD_task_dependency_add(taskB, taskC);
-  SD_task_dependency_add(taskC, taskD);
-  SD_task_dependency_add(taskD, taskE);
-
-  /* Add watchpoints on completion of compute tasks */
-  SD_task_watch(taskA, SD_DONE);
-  SD_task_watch(taskC, SD_DONE);
-  SD_task_watch(taskE, SD_DONE);
-
-  /* Auto-schedule the compute tasks on three different workstations */
-  /* Data transfer tasks taskB and taskD are automagically scheduled */
-  SD_task_schedulel(taskA, 1, hosts[0]);
-  SD_task_schedulel(taskC, 1, hosts[1]);
-  SD_task_schedulel(taskE, 1, hosts[0]);
-
-  SD_simulate_with_update(-1.0, changed_tasks);
-  while (!xbt_dynar_is_empty(changed_tasks)) {
-    XBT_INFO("Simulation stopped after %.4f seconds", simgrid_get_clock());
-    xbt_dynar_foreach(changed_tasks, ctr, task) {
-      XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task),
-               SD_task_get_finish_time(task));
-    }
-    xbt_dynar_reset(changed_tasks);
-
-    /* let throttle the communication for taskD if its parent is SD_DONE */
-    /* the bandwidth is 1.25e8, the data size is 1e7, and we want to throttle the bandwidth by a factor 2.
-     * The rate is then 1.25e8/(2*1e7)=6.25
-     * Changing the rate is possible before the task execution starts (in SD_RUNNING state).
-     */
-    if (SD_task_get_state(taskC) == SD_DONE && SD_task_get_state(taskD) < SD_RUNNING)
-      SD_task_set_rate(taskD, 6.25);
-    SD_simulate_with_update(-1.0, changed_tasks);
-  }
-
-  xbt_dynar_free(&changed_tasks);
-
-  XBT_DEBUG("Destroying tasks...");
-  SD_task_destroy(taskA);
-  SD_task_destroy(taskB);
-  SD_task_destroy(taskC);
-  SD_task_destroy(taskD);
-  SD_task_destroy(taskE);
-
-  XBT_DEBUG("Tasks destroyed. Exiting SimDag...");
-  xbt_free(hosts);
-  return 0;
-}
diff --git a/examples/deprecated/simdag/throttling/sd_throttling.tesh b/examples/deprecated/simdag/throttling/sd_throttling.tesh
deleted file mode 100644 (file)
index a389778..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env tesh
-p Modify the rate of communication tasks even when they are auto-scheduled
-
-# We need to sort this out because the order changes with the sanitizers (at least)
-! output sort
-
-$ ./throttling/sd_throttling ${srcdir:=.}/../../platforms/cluster_backbone.xml
-> [0.000000] [xbt_cfg/INFO] Switching to the L07 model to handle parallel tasks.
-> [5.000000] [sd_comm_throttling/INFO] Simulation stopped after 5.0000 seconds
-> [5.000000] [sd_comm_throttling/INFO] Task 'Task A' start time: 0.000000, finish time: 5.000000
-> [10.080600] [sd_comm_throttling/INFO] Simulation stopped after 10.0806 seconds
-> [10.080600] [sd_comm_throttling/INFO] Task 'Task B' start time: 5.000000, finish time: 5.080600
-> [10.080600] [sd_comm_throttling/INFO] Task 'Task C' start time: 5.080600, finish time: 10.080600
-> [15.241200] [sd_comm_throttling/INFO] Simulation stopped after 15.2412 seconds
-> [15.241200] [sd_comm_throttling/INFO] Task 'Task D' start time: 10.080600, finish time: 10.241200
-> [15.241200] [sd_comm_throttling/INFO] Task 'Task E' start time: 10.241200, finish time: 15.241200