Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cut the backtrace displayed from sthread to the sthread_create to hide useless cruft
[simgrid.git] / examples / cpp / dag-from-dax / s4u-dag-from-dax.cpp
index 54c27ce6aaeb4f9d097b91af507cdceb37b2ec11..9c62ac8d503e36d23b4eca4f2c360bfd32ccb8de 100644 (file)
@@ -1,7 +1,6 @@
 /* simple test trying to load a DAX file.                                   */
 
-/* Copyright (c) 2009-2021. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2009-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 <string.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(dag_from_dax, "Logging specific to this example");
+namespace sg4 = simgrid::s4u;
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
   e.load_platform(argv[1]);
 
-  std::vector<simgrid::s4u::ActivityPtr> dag = simgrid::s4u::create_DAG_from_DAX(argv[2]);
+  std::vector<sg4::ActivityPtr> dag = sg4::create_DAG_from_DAX(argv[2]);
 
   if (dag.empty()) {
     XBT_ERROR("A problem occurred during DAX parsing (cycle or syntax). Do not continue this test");
@@ -29,7 +29,7 @@ int main(int argc, char** argv)
   for (const auto& a : dag) {
     std::string type = "an Exec";
     std::string task = "flops to execute";
-    if (dynamic_cast<simgrid::s4u::Comm*>(a.get()) != nullptr) {
+    if (dynamic_cast<sg4::Comm*>(a.get()) != nullptr) {
       type = "a Comm";
       task = "bytes to transfer";
     }
@@ -43,18 +43,16 @@ int main(int argc, char** argv)
   auto count = e.get_host_count();
   int cursor = 0;
   // Schedule end first
-  static_cast<simgrid::s4u::Exec*>(dag.back().get())->set_host(hosts[0]);
+  static_cast<sg4::Exec*>(dag.back().get())->set_host(hosts[0]);
 
   for (const auto& a : dag) {
-    auto* exec = dynamic_cast<simgrid::s4u::Exec*>(a.get());
-    if (exec != nullptr && exec->get_name() != "end") {
+    if (auto* exec = dynamic_cast<sg4::Exec*>(a.get()); exec != nullptr && exec->get_name() != "end") {
       exec->set_host(hosts[cursor % count]);
       cursor++;
     }
-    auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get());
-    if (comm != nullptr) {
-      auto pred = dynamic_cast<simgrid::s4u::Exec*>((*comm->get_dependencies().begin()).get());
-      auto succ = dynamic_cast<simgrid::s4u::Exec*>(comm->get_successors().front().get());
+    if (auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
+      const auto* pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
+      const auto* succ = dynamic_cast<sg4::Exec*>(comm->get_successors().front().get());
       comm->set_source(pred->get_host())->set_destination(succ->get_host());
     }
   }
@@ -64,13 +62,11 @@ int main(int argc, char** argv)
 
   XBT_INFO("-------------- Summary of executed schedule ------------------");
   for (const auto& a : dag) {
-    const auto* exec = dynamic_cast<simgrid::s4u::Exec*>(a.get());
-    if (exec != nullptr) {
+    if (const auto* exec = dynamic_cast<sg4::Exec*>(a.get())) {
       XBT_INFO("[%f->%f] '%s' executed on %s", exec->get_start_time(), exec->get_finish_time(), exec->get_cname(),
                exec->get_host()->get_cname());
     }
-    const auto* comm = dynamic_cast<simgrid::s4u::Comm*>(a.get());
-    if (comm != nullptr) {
+    if (const auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
       XBT_INFO("[%f->%f] '%s' transferred from %s to %s", comm->get_start_time(), comm->get_finish_time(),
                comm->get_cname(), comm->get_source()->get_cname(), comm->get_destination()->get_cname());
     }