Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add new exemple of dag with comm
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Wed, 22 Dec 2021 12:32:06 +0000 (13:32 +0100)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Wed, 22 Dec 2021 12:33:18 +0000 (13:33 +0100)
MANIFEST.in
examples/cpp/CMakeLists.txt
examples/cpp/dag-comm/s4u-dag-comm.cpp [new file with mode: 0644]
examples/cpp/dag-comm/s4u-dag-comm.tesh [new file with mode: 0644]

index fdf64cd..52a85f1 100644 (file)
@@ -202,6 +202,8 @@ include examples/cpp/comm-waitany/s4u-comm-waitany_d.xml
 include examples/cpp/comm-waituntil/s4u-comm-waituntil.cpp
 include examples/cpp/comm-waituntil/s4u-comm-waituntil.tesh
 include examples/cpp/comm-waituntil/s4u-comm-waituntil_d.xml
+include examples/cpp/dag-comm/s4u-dag-comm.cpp
+include examples/cpp/dag-comm/s4u-dag-comm.tesh
 include examples/cpp/dag-failure/s4u-dag-failure.cpp
 include examples/cpp/dag-failure/s4u-dag-failure.tesh
 include examples/cpp/dag-io/s4u-dag-io.cpp
index 4e11a9c..4b19e36 100644 (file)
@@ -66,7 +66,7 @@ foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill
                  comm-pingpong comm-ready comm-serialize comm-suspend comm-wait comm-waitany comm-waitall comm-waituntil
                  comm-dependent comm-host2host comm-failure comm-throttling
                  cloud-capping cloud-migration cloud-simple
-                 dag-failure dag-io dag-simple
+                 dag-comm dag-failure dag-io dag-simple
                  dht-chord dht-kademlia
                  energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi
                  engine-filtering engine-run-partial
diff --git a/examples/cpp/dag-comm/s4u-dag-comm.cpp b/examples/cpp/dag-comm/s4u-dag-comm.cpp
new file mode 100644 (file)
index 0000000..80b8282
--- /dev/null
@@ -0,0 +1,60 @@
+/* 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/plugins/file_system.h>
+#include <simgrid/s4u.hpp>
+#include <vector>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+
+int main(int argc, char* argv[])
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  sg_storage_file_system_init();
+  e.load_platform(argv[1]);
+
+  auto tremblay = e.host_by_name("Tremblay");
+  auto jupiter  = e.host_by_name("Jupiter");
+
+  // Display the details on vetoed activities
+  simgrid::s4u::Activity::on_veto.connect([](simgrid::s4u::Activity& a) {
+    XBT_INFO("Activity '%s' vetoed. Dependencies: %s; Ressources: %s", a.get_cname(),
+             (a.dependencies_solved() ? "solved" : "NOT solved"), (a.is_assigned() ? "assigned" : "NOT assigned"));
+  });
+
+  simgrid::s4u::Activity::on_completion.connect([](simgrid::s4u::Activity& activity) {
+    auto* exec = dynamic_cast<simgrid::s4u::Exec*>(&activity);
+    if (exec != nullptr)
+      XBT_INFO("Activity '%s' is complete (start time: %f, finish time: %f)", exec->get_cname(), exec->get_start_time(),
+               exec->get_finish_time());
+    auto* comm = dynamic_cast<simgrid::s4u::Comm*>(&activity);
+    if (comm != nullptr)
+      XBT_INFO("Activity '%s' is complete", comm->get_cname());
+  });
+
+  // Create a small DAG: parent->transfert->child
+  simgrid::s4u::ExecPtr parent    = simgrid::s4u::Exec::init();
+  simgrid::s4u::CommPtr transfert = simgrid::s4u::Comm::sendto_init(tremblay, jupiter);
+  simgrid::s4u::ExecPtr child     = simgrid::s4u::Exec::init();
+  parent->add_successor(transfert);
+  transfert->add_successor(child);
+
+  // Set the parameters (the name is for logging purposes only)
+  // + parent and child end after 1 second
+  parent->set_name("parent")->set_flops_amount(tremblay->get_speed());
+  transfert->set_name("transfert")->set_payload_size(125e6);
+  child->set_name("child")->set_flops_amount(jupiter->get_speed());
+
+  // Schedule and try to start the different activities
+  parent->set_host(tremblay)->vetoable_start();
+  transfert->vetoable_start();
+  child->set_host(jupiter)->vetoable_start();
+
+  e.run();
+
+  XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
+
+  return 0;
+}
diff --git a/examples/cpp/dag-comm/s4u-dag-comm.tesh b/examples/cpp/dag-comm/s4u-dag-comm.tesh
new file mode 100644 (file)
index 0000000..70ddce3
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/s4u-dag-comm ${platfdir}/two_hosts.xml --log=s4u_activity.t:verbose "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n"
+> [  0.000000] (0:maestro@) 'parent' is assigned to a resource and all dependencies are solved. Let's start
+> [  0.000000] (0:maestro@) Activity 'transfert' vetoed. Dependencies: NOT solved; Ressources: assigned
+> [  0.000000] (0:maestro@) Activity 'child' vetoed. Dependencies: NOT solved; Ressources: assigned
+> [  1.000000] (0:maestro@) Remove a dependency from 'parent' on 'transfert'
+> [  1.000000] (0:maestro@) 'transfert' is assigned to a resource and all dependencies are solved. Let's start
+> [  1.000000] (0:maestro@) Activity 'parent' is complete (start time: 0.000000, finish time: 1.000000)
+> [  2.083775] (0:maestro@) Remove a dependency from 'transfert' on 'child'
+> [  2.083775] (0:maestro@) 'child' is assigned to a resource and all dependencies are solved. Let's start
+> [  2.083775] (0:maestro@) Activity 'transfert' is complete
+> [  3.083775] (0:maestro@) Activity 'child' is complete (start time: 2.083775, finish time: 3.083775)
+> [  3.083775] (0:maestro@) Simulation time 3.08378