Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move tests on dependencies to a better place
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 21 Dec 2021 10:38:41 +0000 (11:38 +0100)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Tue, 21 Dec 2021 10:38:41 +0000 (11:38 +0100)
MANIFEST.in
examples/deprecated/simdag/test/sd_test.cpp
include/simgrid/s4u/Activity.hpp
teshsuite/s4u/CMakeLists.txt
teshsuite/s4u/dependencies/dependencies.cpp [new file with mode: 0644]
teshsuite/s4u/dependencies/dependencies.tesh [new file with mode: 0644]

index eec4b35..7c1a0f5 100644 (file)
@@ -756,6 +756,8 @@ include teshsuite/s4u/comm-get-sender/comm-get-sender.tesh
 include teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp
 include teshsuite/s4u/concurrent_rw/concurrent_rw.cpp
 include teshsuite/s4u/concurrent_rw/concurrent_rw.tesh
+include teshsuite/s4u/dependencies/dependencies.cpp
+include teshsuite/s4u/dependencies/dependencies.tesh
 include teshsuite/s4u/evaluate-get-route-time/evaluate-get-route-time.cpp
 include teshsuite/s4u/evaluate-parse-time/evaluate-parse-time.cpp
 include teshsuite/s4u/host-multicore-speed-file/host-multicore-speed-file.cpp
index a766648..db9ea3d 100644 (file)
@@ -66,36 +66,6 @@ int main(int argc, char **argv)
   SD_task_dependency_add(taskD, taskC);
   SD_task_dependency_add(taskB, taskC);
 
-  try {
-    SD_task_dependency_add(taskA, taskA); /* shouldn't work and must raise an exception */
-    xbt_die("Hey, I can add a dependency between Task A and Task A!");
-  } catch (const std::invalid_argument& e) {
-    XBT_DEBUG("Caught invalid_argument: %s", e.what());
-  }
-
-  try {
-    SD_task_dependency_add(taskB, taskA); /* shouldn't work and must raise an exception */
-    xbt_die("Oh oh, I can add an already existing dependency!");
-  } catch (const std::invalid_argument& e) {
-    XBT_DEBUG("Caught invalid_argument: %s", e.what());
-  }
-
-  try {
-    SD_task_dependency_remove(taskA, taskC);    /* shouldn't work and must raise an exception */
-    xbt_die("Dude, I can remove an unknown dependency!");
-  } catch (const std::invalid_argument& e) {
-    XBT_DEBUG("Caught invalid_argument: %s", e.what());
-  }
-
-  try {
-    SD_task_dependency_remove(taskC, taskC);    /* shouldn't work and must raise an exception */
-    xbt_die("Wow, I can remove a dependency between Task C and itself!");
-  } catch (const std::invalid_argument& e) {
-    XBT_DEBUG("Caught invalid_argument: %s", e.what());
-  }
-
-  /* if everything is ok, no exception is forwarded or rethrown by main() */
-
   /* watch points */
   SD_task_watch(taskD, SD_DONE);
   SD_task_watch(taskB, SD_DONE);
index b7d3594..d64f99a 100644 (file)
@@ -78,7 +78,7 @@ protected:
   void remove_successor(ActivityPtr a)
   {
     if(this == a)
-      throw std::invalid_argument("Cannot ask to remove its from successors");
+      throw std::invalid_argument("Cannot ask to remove itself from successors list");
 
     auto p = std::find_if(successors_.begin(), successors_.end(), [a](ActivityPtr const& i){ return i.get() == a.get(); });
     if (p != successors_.end()){
index 2468678..15e28f6 100644 (file)
@@ -3,6 +3,7 @@ foreach(x actor actor-autorestart actor-suspend
         comm-get-sender comm-pt2pt wait-all-for wait-any-for
         cloud-interrupt-migration cloud-two-execs
         concurrent_rw
+        dependencies
         host-on-off host-on-off-actors host-on-off-recv host-multicore-speed-file io-set-bw
         basic-link-test basic-parsing-test evaluate-get-route-time evaluate-parse-time is-router
         storage_client_server listen_async pid
@@ -26,10 +27,9 @@ set_property(TARGET activity-lifecycle APPEND PROPERTY INCLUDE_DIRECTORIES "${IN
 
 ## Add the tests.
 ## Some need to be run with all factories, some don't need tesh to run
-foreach(x actor actor-autorestart actor-suspend
-        activity-lifecycle comm-get-sender wait-all-for wait-any-for
-        cloud-interrupt-migration cloud-two-execs concurrent_rw io-set-bw
-       vm-live-migration vm-suicide)
+foreach(x actor actor-autorestart actor-suspend activity-lifecycle comm-get-sender wait-all-for wait-any-for
+        cloud-interrupt-migration cloud-two-execs concurrent_rw dependencies io-set-bw
+           vm-live-migration vm-suicide)
   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
   ADD_TESH_FACTORIES(tesh-s4u-${x} "*" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x}/${x}.tesh)
 endforeach()
diff --git a/teshsuite/s4u/dependencies/dependencies.cpp b/teshsuite/s4u/dependencies/dependencies.cpp
new file mode 100644 (file)
index 0000000..697c512
--- /dev/null
@@ -0,0 +1,75 @@
+/* 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/s4u.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(dependencies, "Logging specific to this test");
+
+int main(int argc, char** argv)
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  xbt_assert(argc > 1, "Usage: %s platform_file\n\nExample: %s two_clusters.xml", argv[0], argv[0]);
+  e.load_platform(argv[1]);
+
+  simgrid::s4u::Exec::on_completion.connect([](simgrid::s4u::Exec const& exec) {
+    XBT_INFO("Exec '%s' start time: %f, finish time: %f", exec.get_cname(), exec.get_start_time(),
+             exec.get_finish_time());
+  });
+
+  /* creation of the activities and their dependencies */
+  simgrid::s4u::ExecPtr A = simgrid::s4u::Exec::init()->set_name("A")->vetoable_start();
+  simgrid::s4u::ExecPtr B = simgrid::s4u::Exec::init()->set_name("B")->vetoable_start();
+  simgrid::s4u::ExecPtr C = simgrid::s4u::Exec::init()->set_name("C")->vetoable_start();
+  simgrid::s4u::ExecPtr D = simgrid::s4u::Exec::init()->set_name("D")->vetoable_start();
+
+  B->add_successor(A);
+  C->add_successor(A);
+  D->add_successor(B);
+  D->add_successor(C);
+  B->add_successor(C);
+
+  try {
+    A->add_successor(A);
+    ; /* shouldn't work and must raise an exception */
+    xbt_die("Hey, I can add a dependency between A and A!");
+  } catch (const std::invalid_argument& e) {
+    XBT_INFO("Caught attempt to self-dependency creation: %s", e.what());
+  }
+
+  try {
+    B->add_successor(A); /* shouldn't work and must raise an exception */
+    xbt_die("Oh oh, I can add an already existing dependency!");
+  } catch (const std::invalid_argument& e) {
+    XBT_INFO("Caught attempt to add an already existing dependency: %s", e.what());
+  }
+
+  try {
+    A->remove_successor(C); /* shouldn't work and must raise an exception */
+    xbt_die("Dude, I can remove an unknown dependency!");
+  } catch (const std::invalid_argument& e) {
+    XBT_INFO("Caught attempt to remove an unknown dependency: %s", e.what());
+  }
+
+  try {
+    C->remove_successor(C); /* shouldn't work and must raise an exception */
+    xbt_die("Wow, I can remove a dependency between Task C and itself!");
+  } catch (const std::invalid_argument& e) {
+    XBT_INFO("Caught attempt to remove a self-dependency: %s", e.what());
+  }
+
+  /* scheduling parameters */
+  const auto hosts                           = e.get_all_hosts();
+  std::vector<simgrid::s4u::Host*> host_list = {hosts[2], hosts[4]};
+  std::vector<double> flops_amounts          = {2000000, 1000000};
+  std::vector<double> bytes_amounts          = {0, 2000000, 3000000, 0};
+
+  A->set_flops_amounts(flops_amounts)->set_bytes_amounts(bytes_amounts)->set_hosts(host_list);
+  B->set_flops_amounts(flops_amounts)->set_bytes_amounts(bytes_amounts)->set_hosts(host_list);
+  C->set_flops_amounts(flops_amounts)->set_bytes_amounts(bytes_amounts)->set_hosts(host_list);
+  D->set_flops_amounts(flops_amounts)->set_bytes_amounts(bytes_amounts)->set_hosts(host_list);
+
+  e.run();
+  return 0;
+}
diff --git a/teshsuite/s4u/dependencies/dependencies.tesh b/teshsuite/s4u/dependencies/dependencies.tesh
new file mode 100644 (file)
index 0000000..f5c9842
--- /dev/null
@@ -0,0 +1,13 @@
+#!/usr/bin/env tesh
+
+$ ./dependencies ${platfdir}/small_platform.xml --cfg=host/model:ptask_L07
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'host/model' to 'ptask_L07'
+> [0.000000] [xbt_cfg/INFO] Switching to the L07 model to handle parallel tasks.
+> [0.000000] [dependencies/INFO] Caught attempt to self-dependency creation: Cannot be its own successor
+> [0.000000] [dependencies/INFO] Caught attempt to add an already existing dependency: Dependency already exists
+> [0.000000] [dependencies/INFO] Caught attempt to remove an unknown dependency: Dependency does not exist. Can not be removed.
+> [0.000000] [dependencies/INFO] Caught attempt to remove a self-dependency: Cannot ask to remove itself from successors list
+> [2.004027] [dependencies/INFO] Exec 'D' start time: 0.000000, finish time: 2.004027
+> [4.008055] [dependencies/INFO] Exec 'B' start time: 2.004027, finish time: 4.008055
+> [6.012082] [dependencies/INFO] Exec 'C' start time: 4.008055, finish time: 6.012082
+> [8.016109] [dependencies/INFO] Exec 'A' start time: 6.012082, finish time: 8.016109