Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'actor-startkilltime' of https://github.com/Takishipp/simgrid into Takis...
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 15 Oct 2017 19:36:23 +0000 (21:36 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 15 Oct 2017 19:36:23 +0000 (21:36 +0200)
examples/s4u/CMakeLists.txt
examples/s4u/README.doc
examples/s4u/actor-startkilltime/s4u-actor-baseline_d.xml [new file with mode: 0644]
examples/s4u/actor-startkilltime/s4u-actor-kill_d.xml [new file with mode: 0644]
examples/s4u/actor-startkilltime/s4u-actor-start_d.xml [new file with mode: 0644]
examples/s4u/actor-startkilltime/s4u-actor-start_kill_d.xml [new file with mode: 0644]
examples/s4u/actor-startkilltime/s4u-actor-startkilltime.cpp [new file with mode: 0644]
examples/s4u/actor-startkilltime/s4u-actor-startkilltime.tesh [new file with mode: 0644]

index 542c454..4d14919 100644 (file)
@@ -1,7 +1,7 @@
 foreach (example actions-comm actions-storage 
                  actor-create actor-daemon actor-execute actor-kill actor-migration actor-suspend 
                  app-masterworker app-pingpong app-token-ring
-                async-wait async-waitany async-waitall
+                async-wait async-waitany async-waitall actor-startkilltime 
                 plugin-hostload io mutex)
   add_executable       (s4u-${example}  ${example}/s4u-${example}.cpp)
   target_link_libraries(s4u-${example}  simgrid)
@@ -35,7 +35,8 @@ set(tesh_files    ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u
                                   ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait.tesh
                                   ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u-async-waitany.tesh
                                   ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/s4u-async-waitall.tesh
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/actor-execute/s4u-actor-execute.tesh         PARENT_SCOPE)
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/actor-execute/s4u-actor-execute.tesh       
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/actor-startkilltime/s4u-actor-startkilltime.tesh         PARENT_SCOPE)
 set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm-split_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/actions-storage/s4u-actions-storage_d.xml
@@ -45,7 +46,11 @@ set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-a
                                   ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u-async-waitany_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/s4u-async-waitall_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait_d.xml
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml                PARENT_SCOPE)
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/actor-startkilltime/s4u-actor-baseline_d.xml
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/actor-startkilltime/s4u-actor-kill_d.xml
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/actor-startkilltime/s4u-actor-start_d.xml
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/actor-startkilltime/s4u-actor-star_kill_d.xml                PARENT_SCOPE)
 set(txt_files     ${txt_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm-split-p0.txt
                                   ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm-split-p1.txt
                                   ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm.txt
@@ -55,7 +60,7 @@ set(txt_files     ${txt_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-a
 foreach(example actions-comm actions-storage 
                 actor-create actor-daemon actor-execute actor-kill actor-migration actor-suspend
                 app-bittorrent app-masterworker app-pingpong app-token-ring 
-               async-wait async-waitall async-waitany
+               async-wait async-waitall async-waitany actor-startkilltime
                dht-chord plugin-hostload io mutex)
   ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example} s4u-${example}.tesh)
 endforeach()
index c3df307..58bcb14 100644 (file)
@@ -86,6 +86,11 @@ documentation, but it should remain readable directly.
     @ref examples/s4u/actor-kill/s4u-actor-kill.cpp \n
     Actors can forcefully stop other actors with the @ref kill method.
 
+  - <b>Controling the actor life cycle</b>.
+    @ref examples/s4u/actor-startkilltime/s4u-actor-startkilltime.cpp \n
+    You can specify a start time and a kill time in the deployment
+    file. See all *_d.xml files in this directory.    
+
   - <b>Migrating Actors</b>.
     @ref examples/s4u/actor-migration/s4u-actor-migration.cpp \n
     Actors can move or be moved from a host to another with the @ref migrate method.
diff --git a/examples/s4u/actor-startkilltime/s4u-actor-baseline_d.xml b/examples/s4u/actor-startkilltime/s4u-actor-baseline_d.xml
new file mode 100644 (file)
index 0000000..e24cced
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
+<platform version="4.1">
+  <!-- Just sleeps for 10 seconds and quits -->
+  <actor host="node-0.acme.org" function="sleeper">  
+    <argument value="10"/>
+  </actor>
+</platform>
diff --git a/examples/s4u/actor-startkilltime/s4u-actor-kill_d.xml b/examples/s4u/actor-startkilltime/s4u-actor-kill_d.xml
new file mode 100644 (file)
index 0000000..6d7d312
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
+<platform version="4.1">
+  <actor host="node-1.acme.org" function="sleeper" kill_time="6">
+    <argument value="10"/>
+  </actor>
+  <actor host="node-2.acme.org" function="sleeper" kill_time="6">
+    <argument value="6"/>
+  </actor>
+  <actor host="node-3.acme.org" function="sleeper" kill_time="10"> 
+    <argument value="6"/>
+  </actor>
+</platform>
diff --git a/examples/s4u/actor-startkilltime/s4u-actor-start_d.xml b/examples/s4u/actor-startkilltime/s4u-actor-start_d.xml
new file mode 100644 (file)
index 0000000..3d6934b
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
+<platform version="4.1">
+  <actor host="node-0.acme.org" function="sleeper" start_time="0">
+    <argument value="10"/>
+  </actor>
+  <actor host="node-1.acme.org" function="sleeper" start_time="1">
+    <argument value="10"/>
+  </actor>
+  <actor host="node-2.acme.org" function="sleeper" start_time="2">
+    <argument value="10"/>
+  </actor>
+  <actor host="node-3.acme.org" function="sleeper" start_time="3">
+    <argument value="10"/>
+  </actor>
+  <actor host="node-4.acme.org" function="sleeper" start_time="4">
+    <argument value="10"/>
+  </actor>
+  <actor host="node-5.acme.org" function="sleeper" start_time="5">
+    <argument value="10"/>
+  </actor>
+</platform>
diff --git a/examples/s4u/actor-startkilltime/s4u-actor-start_kill_d.xml b/examples/s4u/actor-startkilltime/s4u-actor-start_kill_d.xml
new file mode 100644 (file)
index 0000000..7292ca2
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
+<platform version="4.1">
+  <actor host="node-0.acme.org" function="sleeper" start_time="0" kill_time="5">
+    <argument value="10"/>
+  </actor>
+  <actor host="node-1.acme.org" function="sleeper" start_time="1" kill_time="6">
+    <argument value="10"/>
+  </actor>
+  <actor host="node-2.acme.org" function="sleeper" start_time="2" kill_time="7">
+    <argument value="4" />
+  </actor>
+  <actor host="node-3.acme.org" function="sleeper" start_time="3" kill_time="8">
+    <argument value="4" />
+  </actor>
+  <actor host="node-4.acme.org" function="sleeper" start_time="4" kill_time="9">
+    <argument value="5" />
+  </actor>
+  <actor host="node-5.acme.org" function="sleeper" start_time="5" kill_time="10">
+    <argument value="5"/>
+  </actor>
+</platform>
diff --git a/examples/s4u/actor-startkilltime/s4u-actor-startkilltime.cpp b/examples/s4u/actor-startkilltime/s4u-actor-startkilltime.cpp
new file mode 100644 (file)
index 0000000..f8ba252
--- /dev/null
@@ -0,0 +1,51 @@
+/* Copyright (c) 2007-2016. 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 <cstdlib>
+ #include <iostream>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
+/* Executed on process termination*/
+static int my_onexit(void* ignored1, void *ignored2) {
+  XBT_INFO("Exiting now (done sleeping or got killed)."); /* - Just display an informative message (see tesh file) */
+  return 0;
+}
+
+/* Just sleep until termination */
+class sleeper {
+
+public:
+  explicit sleeper(std::vector<std::string> args)
+{
+  XBT_INFO("Hello! I go to sleep.");
+  simcall_process_on_exit(SIMIX_process_self(), my_onexit, NULL);
+
+  simgrid::s4u::this_actor::sleep_for(std::stoi(args[1]));
+
+}
+void operator()()
+{
+  XBT_INFO("Done sleeping.");
+}
+};
+
+int main(int argc, char *argv[])
+{
+  simgrid::s4u::Engine e(&argc, argv);
+
+  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
+             "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
+
+  e.loadPlatform(argv[1]);            /* - Load the platform description */
+  e.registerFunction<sleeper>("sleeper");
+  e.loadDeployment(argv[2]);   /* - Deploy the sleeper processes with explicit start/kill times */
+
+  e.run();                           /* - Run the simulation */
+
+  XBT_INFO("Simulation time %g", SIMIX_get_clock());
+  return 0;
+}
diff --git a/examples/s4u/actor-startkilltime/s4u-actor-startkilltime.tesh b/examples/s4u/actor-startkilltime/s4u-actor-startkilltime.tesh
new file mode 100644 (file)
index 0000000..f8e7b5c
--- /dev/null
@@ -0,0 +1,63 @@
+#! ./tesh
+
+p Test0 actor without time
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-startkilltime ${srcdir:=.}/cluster.xml ${srcdir:=.}/../s4u/actor-startkilltime/s4u-actor-baseline_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (1:sleeper@node-0.acme.org) Hello! I go to sleep.
+> [ 10.000000] (1:sleeper@node-0.acme.org) Done sleeping.
+> [ 10.000000] (1:sleeper@node-0.acme.org) Exiting now (done sleeping or got killed).
+> [ 10.000000] (0:maestro@) Simulation time 10
+
+p Test1 actor with start time
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-startkilltime ${srcdir:=.}/cluster.xml ${srcdir:=.}/../s4u/actor-startkilltime/s4u-actor-start_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (1:sleeper@node-0.acme.org) Hello! I go to sleep.
+> [  1.000000] (2:sleeper@node-1.acme.org) Hello! I go to sleep.
+> [  2.000000] (3:sleeper@node-2.acme.org) Hello! I go to sleep.
+> [  3.000000] (4:sleeper@node-3.acme.org) Hello! I go to sleep.
+> [  4.000000] (5:sleeper@node-4.acme.org) Hello! I go to sleep.
+> [  5.000000] (6:sleeper@node-5.acme.org) Hello! I go to sleep.
+> [ 10.000000] (1:sleeper@node-0.acme.org) Done sleeping.
+> [ 10.000000] (1:sleeper@node-0.acme.org) Exiting now (done sleeping or got killed).
+> [ 11.000000] (2:sleeper@node-1.acme.org) Done sleeping.
+> [ 11.000000] (2:sleeper@node-1.acme.org) Exiting now (done sleeping or got killed).
+> [ 12.000000] (3:sleeper@node-2.acme.org) Done sleeping.
+> [ 12.000000] (3:sleeper@node-2.acme.org) Exiting now (done sleeping or got killed).
+> [ 13.000000] (4:sleeper@node-3.acme.org) Done sleeping.
+> [ 13.000000] (4:sleeper@node-3.acme.org) Exiting now (done sleeping or got killed).
+> [ 14.000000] (5:sleeper@node-4.acme.org) Done sleeping.
+> [ 14.000000] (5:sleeper@node-4.acme.org) Exiting now (done sleeping or got killed).
+> [ 15.000000] (6:sleeper@node-5.acme.org) Done sleeping.
+> [ 15.000000] (6:sleeper@node-5.acme.org) Exiting now (done sleeping or got killed).
+> [ 15.000000] (0:maestro@) Simulation time 15
+
+p Test1 actor with kill time
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-startkilltime ${srcdir:=.}/cluster.xml ${srcdir:=.}/../s4u/actor-startkilltime/s4u-actor-kill_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (1:sleeper@node-1.acme.org) Hello! I go to sleep.
+> [  0.000000] (2:sleeper@node-2.acme.org) Hello! I go to sleep.
+> [  0.000000] (3:sleeper@node-3.acme.org) Hello! I go to sleep.
+> [  6.000000] (1:sleeper@node-1.acme.org) Exiting now (done sleeping or got killed).
+> [  6.000000] (2:sleeper@node-2.acme.org) Exiting now (done sleeping or got killed).
+> [  6.000000] (3:sleeper@node-3.acme.org) Done sleeping.
+> [  6.000000] (3:sleeper@node-3.acme.org) Exiting now (done sleeping or got killed).
+> [  6.000000] (0:maestro@) Simulation time 6
+
+p Test2 actor with start and kill times
+
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-actor-startkilltime ${srcdir:=.}/cluster.xml ${srcdir:=.}/../s4u/actor-startkilltime/s4u-actor-start_kill_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (1:sleeper@node-0.acme.org) Hello! I go to sleep.
+> [  1.000000] (2:sleeper@node-1.acme.org) Hello! I go to sleep.
+> [  2.000000] (3:sleeper@node-2.acme.org) Hello! I go to sleep.
+> [  3.000000] (4:sleeper@node-3.acme.org) Hello! I go to sleep.
+> [  4.000000] (5:sleeper@node-4.acme.org) Hello! I go to sleep.
+> [  5.000000] (1:sleeper@node-0.acme.org) Exiting now (done sleeping or got killed).
+> [  5.000000] (6:sleeper@node-5.acme.org) Hello! I go to sleep.
+> [  6.000000] (2:sleeper@node-1.acme.org) Exiting now (done sleeping or got killed).
+> [  6.000000] (3:sleeper@node-2.acme.org) Done sleeping.
+> [  6.000000] (3:sleeper@node-2.acme.org) Exiting now (done sleeping or got killed).
+> [  7.000000] (4:sleeper@node-3.acme.org) Done sleeping.
+> [  7.000000] (4:sleeper@node-3.acme.org) Exiting now (done sleeping or got killed).
+> [  9.000000] (5:sleeper@node-4.acme.org) Exiting now (done sleeping or got killed).
+> [ 10.000000] (6:sleeper@node-5.acme.org) Exiting now (done sleeping or got killed).
+> [ 10.000000] (0:maestro@) Simulation time 10