Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add C version of actor-stacksize example
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 6 Mar 2020 08:50:18 +0000 (09:50 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 6 Mar 2020 08:50:18 +0000 (09:50 +0100)
MANIFEST.in
examples/c/CMakeLists.txt
examples/c/actor-stacksize/actor-stacksize.c [new file with mode: 0644]
examples/c/actor-stacksize/actor-stacksize.tesh [new file with mode: 0644]

index 1263862..48b0ebc 100644 (file)
@@ -32,6 +32,8 @@ include examples/c/actor-lifetime/actor-lifetime.tesh
 include examples/c/actor-lifetime/actor-lifetime_d.xml
 include examples/c/actor-migrate/actor-migrate.c
 include examples/c/actor-migrate/actor-migrate.tesh
+include examples/c/actor-stacksize/actor-stacksize.c
+include examples/c/actor-stacksize/actor-stacksize.tesh
 include examples/c/actor-suspend/actor-suspend.c
 include examples/c/actor-suspend/actor-suspend.tesh
 include examples/c/actor-yield/actor-yield.c
index 48e8a61..173b87c 100644 (file)
@@ -2,8 +2,8 @@
 ######################################################################
 
 foreach(x
-        actor-create actor-daemon actor-exiting actor-join actor-kill actor-lifetime actor-migrate actor-suspend 
-        actor-yield
+        actor-create actor-daemon actor-exiting actor-join actor-kill actor-lifetime actor-migrate actor-stacksize
+        actor-suspend actor-yield
         app-pingpong app-token-ring 
         async-wait async-waitall async-waitany
         cloud-capping cloud-migration cloud-simple
@@ -57,8 +57,8 @@ set(xml_files     ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/actor-cr
                                PARENT_SCOPE)
 
 foreach(x
-        actor-create actor-daemon actor-exiting actor-join actor-kill actor-lifetime actor-migrate actor-suspend 
-        actor-yield
+        actor-create actor-daemon actor-exiting actor-join actor-kill actor-lifetime actor-migrate actor-stacksize
+        actor-suspend actor-yield
         app-chainsend app-pingpong app-token-ring
         async-wait async-waitall async-waitany
         cloud-capping cloud-migration cloud-simple
diff --git a/examples/c/actor-stacksize/actor-stacksize.c b/examples/c/actor-stacksize/actor-stacksize.c
new file mode 100644 (file)
index 0000000..8155733
--- /dev/null
@@ -0,0 +1,51 @@
+/* Copyright (c) 2010-2020. 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. */
+
+/* This code tests that we can change the stack-size between the actors creation. */
+
+#include "simgrid/actor.h"
+#include "simgrid/engine.h"
+#include "simgrid/host.h"
+
+#include "xbt/config.h"
+#include "xbt/log.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(actor_stacksize, "Messages specific for this example");
+
+static void actor(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+  XBT_INFO("Hello");
+}
+
+int main(int argc, char* argv[])
+{
+  simgrid_init(&argc, argv);
+  simgrid_load_platform(argv[1]);
+
+  // If you don't specify anything, you get the default size (8Mb) or the one passed on the command line
+  sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
+
+  // You can use sg_cfg_set_int(key, value) to pass a size that will be parsed. That value will be used for any
+  // subsequent actors
+  sg_cfg_set_int("contexts/stack-size", 16384);
+  sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
+  sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
+
+  sg_cfg_set_int("contexts/stack-size", 32 * 1024);
+  sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
+  sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
+
+  // Or you can use set_stacksize() before starting the actor to modify only this one
+  sg_actor_t a = sg_actor_init("actor", sg_host_by_name("Tremblay"));
+  sg_actor_set_stacksize(a, 64 * 1024);
+  sg_actor_start(a, actor, 0, NULL);
+
+  sg_actor_create("actor", sg_host_by_name("Tremblay"), actor, 0, NULL);
+
+  simgrid_run();
+  XBT_INFO("Simulation time %g", simgrid_get_clock());
+
+  return 0;
+}
diff --git a/examples/c/actor-stacksize/actor-stacksize.tesh b/examples/c/actor-stacksize/actor-stacksize.tesh
new file mode 100644 (file)
index 0000000..c56a0dc
--- /dev/null
@@ -0,0 +1,22 @@
+
+! ignore .*Using Boost contexts. Welcome to the 21th century.
+! ignore .*Activating SYSV context factory
+! ignore .*Using raw contexts. Because the glibc is just not good enough for us.
+
+$ ${bindir:=.}/actor-stacksize-c --log=simix_context.thresh:verbose --log=no_loc ${platfdir}/small_platform.xml
+> [::(0) 0.000000] [simix_context/VERBOSE] Creating a context of stack 8Mb
+> [0.000000] [simix_context/VERBOSE] Creating a context of stack 8Mb
+> [0.000000] [simix_context/VERBOSE] Creating a context of stack 16Mb
+> [0.000000] [simix_context/VERBOSE] Creating a context of stack 16Mb
+> [0.000000] [simix_context/VERBOSE] Creating a context of stack 32Mb
+> [0.000000] [simix_context/VERBOSE] Creating a context of stack 32Mb
+> [0.000000] [simix_context/VERBOSE] Creating a context of stack 64Mb
+> [0.000000] [simix_context/VERBOSE] Creating a context of stack 32Mb
+> [Tremblay:actor:(1) 0.000000] [actor_stacksize/INFO] Hello
+> [Tremblay:actor:(2) 0.000000] [actor_stacksize/INFO] Hello
+> [Tremblay:actor:(3) 0.000000] [actor_stacksize/INFO] Hello
+> [Tremblay:actor:(4) 0.000000] [actor_stacksize/INFO] Hello
+> [Tremblay:actor:(5) 0.000000] [actor_stacksize/INFO] Hello
+> [Tremblay:actor:(6) 0.000000] [actor_stacksize/INFO] Hello
+> [Tremblay:actor:(7) 0.000000] [actor_stacksize/INFO] Hello
+> [0.000000] [actor_stacksize/INFO] Simulation time 0