Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add C version of exec-remote
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 5 Mar 2020 09:03:22 +0000 (10:03 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 5 Mar 2020 09:03:22 +0000 (10:03 +0100)
.gitignore
MANIFEST.in
examples/README.rst
examples/c/CMakeLists.txt
examples/c/exec-remote/exec-remote.c [new file with mode: 0644]
examples/c/exec-remote/exec-remote.tesh [new file with mode: 0644]

index fe6000b..eba7785 100644 (file)
@@ -138,7 +138,9 @@ examples/c/cloud-simple/cloud-simple-c
 examples/c/energy-exec/energy-exec-c
 examples/c/energy-exec-ptask/energy-exec-ptask-c
 examples/c/energy-vm/energy-vm-c
+examples/c/exec-basic/exec-basic-c
 examples/c/exec-dvfs/exec-dvfs-c
+examples/c/exec-remote/exec-remote-c
 examples/c/io-disk-raw/io-disk-raw-c
 examples/c/io-file-remote/io-file-remote-c
 examples/c/plugin-hostload/plugin-hostload-c
index a7b2fdc..3afdbb3 100644 (file)
@@ -76,6 +76,8 @@ include examples/c/exec-basic/exec-basic.c
 include examples/c/exec-basic/exec-basic.tesh
 include examples/c/exec-dvfs/exec-dvfs.c
 include examples/c/exec-dvfs/exec-dvfs.tesh
+include examples/c/exec-remote/exec-remote.c
+include examples/c/exec-remote/exec-remote.tesh
 include examples/c/io-disk-raw/io-disk-raw.c
 include examples/c/io-disk-raw/io-disk-raw.tesh
 include examples/c/io-file-remote/io-file-remote.c
index 3e6f6ce..538cc71 100644 (file)
@@ -391,6 +391,10 @@ Executions on the CPU
 
           See also :py:func:`simgrid.Exec.set_host()`.
 
+       .. example-tab:: examples/c/exec-remote/exec-remote.c
+
+          See also :cpp:func:`sg_exec_set_host()`.
+
   - **Parallel executions:**
     These objects are convenient abstractions of parallel
     computational kernels that span over several machines, such as a
index 1bd0755..48e8a61 100644 (file)
@@ -7,7 +7,7 @@ foreach(x
         app-pingpong app-token-ring 
         async-wait async-waitall async-waitany
         cloud-capping cloud-migration cloud-simple
-        exec-basic exec-dvfs
+        exec-basic exec-dvfs exec-remote
         energy-exec energy-exec-ptask energy-vm
         io-disk-raw io-file-remote
         plugin-hostload)
@@ -62,7 +62,7 @@ foreach(x
         app-chainsend app-pingpong app-token-ring
         async-wait async-waitall async-waitany
         cloud-capping cloud-migration cloud-simple
-        exec-basic exec-dvfs
+        exec-basic exec-dvfs exec-remote
         energy-exec energy-exec-ptask energy-vm
         io-disk-raw io-file-remote
         plugin-hostload)
diff --git a/examples/c/exec-remote/exec-remote.c b/examples/c/exec-remote/exec-remote.c
new file mode 100644 (file)
index 0000000..79cd017
--- /dev/null
@@ -0,0 +1,62 @@
+/* Copyright (c) 2007-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. */
+
+#include "simgrid/actor.h"
+#include "simgrid/engine.h"
+#include "simgrid/exec.h"
+#include "simgrid/host.h"
+
+#include "xbt/log.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(exec_remote, "Messages specific for this example");
+
+static void wizard(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+  const_sg_host_t fafard = sg_host_by_name("Fafard");
+  sg_host_t ginette      = sg_host_by_name("Ginette");
+  sg_host_t boivin       = sg_host_by_name("Boivin");
+
+  XBT_INFO("I'm a wizard! I can run a task on the Ginette host from the Fafard one! Look!");
+  sg_exec_t exec = sg_actor_exec_init(48.492e6);
+  sg_exec_set_host(exec, ginette);
+  sg_exec_start(exec);
+  XBT_INFO("It started. Running 48.492Mf takes exactly one second on Ginette (but not on Fafard).");
+
+  sg_actor_sleep_for(0.1);
+  XBT_INFO("Loads in flops/s: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", sg_host_load(boivin), sg_host_load(fafard),
+           sg_host_load(ginette));
+
+  sg_exec_wait(exec);
+
+  XBT_INFO("Done!");
+  XBT_INFO("And now, harder. Start a remote task on Ginette and move it to Boivin after 0.5 sec");
+  exec = sg_actor_exec_init(73293500);
+  sg_exec_set_host(exec, ginette);
+  sg_exec_start(exec);
+
+  sg_actor_sleep_for(0.5);
+  XBT_INFO("Loads before the move: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", sg_host_load(boivin), sg_host_load(fafard),
+           sg_host_load(ginette));
+
+  sg_exec_set_host(exec, boivin);
+
+  sg_actor_sleep_for(0.1);
+  XBT_INFO("Loads after the move: Boivin=%.0f; Fafard=%.0f; Ginette=%.0f", sg_host_load(boivin), sg_host_load(fafard),
+           sg_host_load(ginette));
+
+  sg_exec_wait(exec);
+  XBT_INFO("Done!");
+}
+
+int main(int argc, char* argv[])
+{
+  simgrid_init(&argc, argv);
+  simgrid_load_platform(argv[1]);
+  sg_actor_create("test", sg_host_by_name("Fafard"), wizard, 0, NULL);
+
+  simgrid_run();
+
+  return 0;
+}
diff --git a/examples/c/exec-remote/exec-remote.tesh b/examples/c/exec-remote/exec-remote.tesh
new file mode 100644 (file)
index 0000000..784c6c1
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/env tesh
+
+! output sort 19
+$ ${bindir:=.}/exec-remote-c ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (1:test@Fafard) I'm a wizard! I can run a task on the Ginette host from the Fafard one! Look!
+> [  0.000000] (1:test@Fafard) It started. Running 48.492Mf takes exactly one second on Ginette (but not on Fafard).
+> [  0.100000] (1:test@Fafard) Loads in flops/s: Boivin=0; Fafard=0; Ginette=48492000
+> [  1.000000] (1:test@Fafard) Done!
+> [  1.000000] (1:test@Fafard) And now, harder. Start a remote task on Ginette and move it to Boivin after 0.5 sec
+> [  1.500000] (1:test@Fafard) Loads before the move: Boivin=0; Fafard=0; Ginette=48492000
+> [  1.600000] (1:test@Fafard) Loads after the move: Boivin=98095000; Fafard=0; Ginette=0
+> [  2.000000] (1:test@Fafard) Done!