Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert plugin-hostload
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 19 Feb 2020 12:53:56 +0000 (13:53 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 19 Feb 2020 12:53:56 +0000 (13:53 +0100)
MANIFEST.in
examples/c/CMakeLists.txt
examples/c/plugin-hostload/plugin-hostload.c [new file with mode: 0644]
examples/c/plugin-hostload/plugin-hostload.tesh [new file with mode: 0644]
teshsuite/msg/CMakeLists.txt
teshsuite/msg/plugin-hostload/plugin-hostload.c [deleted file]
teshsuite/msg/plugin-hostload/plugin-hostload.tesh [deleted file]

index 5f49064..32a4b64 100644 (file)
@@ -51,6 +51,8 @@ include examples/c/energy-exec/energy-exec.c
 include examples/c/energy-exec/energy-exec.tesh
 include examples/c/io-disk-raw/io-disk-raw.c
 include examples/c/io-disk-raw/io-disk-raw.tesh
+include examples/c/plugin-hostload/plugin-hostload.c
+include examples/c/plugin-hostload/plugin-hostload.tesh
 include examples/deprecated/java/app/bittorrent/Common.java
 include examples/deprecated/java/app/bittorrent/Connection.java
 include examples/deprecated/java/app/bittorrent/Main.java
@@ -669,8 +671,6 @@ include teshsuite/msg/io-file/io-file.tesh
 include teshsuite/msg/platform-properties/platform-properties.c
 include teshsuite/msg/platform-properties/platform-properties.tesh
 include teshsuite/msg/platform-properties/platform-properties_d.xml
-include teshsuite/msg/plugin-hostload/plugin-hostload.c
-include teshsuite/msg/plugin-hostload/plugin-hostload.tesh
 include teshsuite/msg/process-lifetime/baseline_d.xml
 include teshsuite/msg/process-lifetime/kill_d.xml
 include teshsuite/msg/process-lifetime/process-lifetime.c
index f309904..97c3ad3 100644 (file)
@@ -4,7 +4,8 @@ foreach(x
         async-waitall async-waitany
         cloud-simple
         energy-exec
-        io-disk-raw)
+        io-disk-raw
+        plugin-hostload)
   add_executable       (${x}-c EXCLUDE_FROM_ALL ${x}/${x}.c)
   target_link_libraries(${x}-c simgrid)
   set_target_properties(${x}-c PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
@@ -30,7 +31,8 @@ foreach(x
         async-waitall async-waitany
         cloud-simple
         energy-exec
-        io-disk-raw)
+        io-disk-raw
+        plugin-hostload)
   ADD_TESH(c-${x} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
                   --setenv bindir=${CMAKE_BINARY_DIR}/examples/c/${x}
                   --cd ${CMAKE_HOME_DIRECTORY}/examples/c/${x}
diff --git a/examples/c/plugin-hostload/plugin-hostload.c b/examples/c/plugin-hostload/plugin-hostload.c
new file mode 100644 (file)
index 0000000..b698fbc
--- /dev/null
@@ -0,0 +1,111 @@
+/* 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/host.h"
+#include "simgrid/plugins/load.h"
+
+#include "xbt/asserts.h"
+#include "xbt/log.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(hostload_test, "Messages specific for this example");
+
+static void execute_load_test(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+  sg_host_t host = sg_host_by_name("MyHost1");
+
+  XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0) and current average "
+           "load: %.5f (should be 0)",
+           sg_host_speed(host), sg_host_get_computed_flops(host), sg_host_get_avg_load(host));
+
+  double start = simgrid_get_clock();
+  XBT_INFO("Sleep for 10 seconds");
+  sg_actor_sleep_for(10);
+
+  double speed = sg_host_speed(host);
+  XBT_INFO("Done sleeping %.2fs; peak speed: %.0E flop/s; number of flops computed so far: %.0E (nothing should have "
+           "changed)",
+           simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_computed_flops(host));
+
+  // Run a task
+  start = simgrid_get_clock();
+  XBT_INFO("Run a task of %.0E flops at current speed of %.0E flop/s", 200e6, sg_host_speed(host));
+  sg_actor_self_execute(200e6);
+
+  XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s (when I started the computation, "
+           "the speed was set to %.0E flop/s); number of flops computed so "
+           "far: %.2E, average load as reported by the HostLoad plugin: %.5f (should be %.5f)",
+           simgrid_get_clock() - start, sg_host_speed(host), speed, sg_host_get_computed_flops(host),
+           sg_host_get_avg_load(host),
+           200E6 / (10.5 * speed * sg_host_core_count(host) +
+                    (simgrid_get_clock() - start - 0.5) * sg_host_speed(host) * sg_host_core_count(host)));
+
+  // ========= Change power peak =========
+  int pstate = 1;
+  sg_host_set_pstate(host, pstate);
+  XBT_INFO(
+      "========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s, average load is %.5f)",
+      pstate, sg_host_get_pstate_speed(host, pstate), sg_host_speed(host), sg_host_get_avg_load(host));
+
+  // Run a second task
+  start = simgrid_get_clock();
+  XBT_INFO("Run a task of %.0E flops", 100e6);
+  sg_actor_self_execute(100e6);
+  XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
+           "far: %.2E",
+           simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_computed_flops(host));
+
+  start = simgrid_get_clock();
+  XBT_INFO("========= Requesting a reset of the computation and load counters");
+  sg_host_load_reset(host);
+  XBT_INFO("After reset: %.0E flops computed; load is %.5f", sg_host_get_computed_flops(host),
+           sg_host_get_avg_load(host));
+  XBT_INFO("Sleep for 4 seconds");
+  sg_actor_sleep_for(4);
+  XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
+           simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_computed_flops(host));
+
+  // =========== Turn the other host off ==========
+  XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed %.0f flops so far and has an "
+           "average load of %.5f.",
+           sg_host_get_computed_flops(sg_host_by_name("MyHost2")), sg_host_get_avg_load(sg_host_by_name("MyHost2")));
+  sg_host_turn_off(sg_host_by_name("MyHost2"));
+  start = simgrid_get_clock();
+  sg_actor_sleep_for(10);
+  XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
+           simgrid_get_clock() - start, sg_host_speed(host), sg_host_get_computed_flops(host));
+}
+
+static void change_speed(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+  sg_host_t host = sg_host_by_name("MyHost1");
+  sg_actor_sleep_for(10.5);
+  XBT_INFO("I slept until now, but now I'll change the speed of this host "
+           "while the other process is still computing! This should slow the computation down.");
+  sg_host_set_pstate(host, 2);
+}
+
+int main(int argc, char* argv[])
+{
+  sg_host_load_plugin_init();
+  simgrid_init(&argc, argv);
+
+  xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
+
+  simgrid_load_platform(argv[1]);
+  sg_actor_t actor = sg_actor_init("load_test", sg_host_by_name("MyHost1"));
+  sg_actor_start(actor, execute_load_test, 0, NULL);
+
+  sg_actor_t actor2 = sg_actor_init("change_speed", sg_host_by_name("MyHost1"));
+  sg_actor_start(actor2, change_speed, 0, NULL);
+
+  simgrid_run();
+
+  XBT_INFO("Total simulation time: %.2f", simgrid_get_clock());
+
+  return 0;
+}
diff --git a/examples/c/plugin-hostload/plugin-hostload.tesh b/examples/c/plugin-hostload/plugin-hostload.tesh
new file mode 100644 (file)
index 0000000..a55ce0d
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env tesh
+
+p This tests the HostLoad plugin (this allows the user to get the current load of a host and the computed flops)
+
+$ ${bindir:=.}/plugin-hostload-c ${platfdir}/energy_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (1:load_test@MyHost1) Initial peak speed: 1E+08 flop/s; number of flops computed so far: 0E+00 (should be 0) and current average load: 0.00000 (should be 0)
+> [  0.000000] (1:load_test@MyHost1) Sleep for 10 seconds
+> [ 10.000000] (1:load_test@MyHost1) Done sleeping 10.00s; peak speed: 1E+08 flop/s; number of flops computed so far: 0E+00 (nothing should have changed)
+> [ 10.000000] (1:load_test@MyHost1) Run a task of 2E+08 flops at current speed of 1E+08 flop/s
+> [ 10.500000] (2:change_speed@MyHost1) I slept until now, but now I'll change the speed of this host while the other process is still computing! This should slow the computation down.
+> [ 18.000000] (1:load_test@MyHost1) Done working on my task; this took 8.00s; current peak speed: 2E+07 flop/s (when I started the computation, the speed was set to 1E+08 flop/s); number of flops computed so far: 2.00E+08, average load as reported by the HostLoad plugin: 0.04167 (should be 0.04167)
+> [ 18.000000] (1:load_test@MyHost1) ========= Requesting pstate 1 (speed should be of 5E+07 flop/s and is of 5E+07 flop/s, average load is 0.04167)
+> [ 18.000000] (1:load_test@MyHost1) Run a task of 1E+08 flops
+> [ 20.000000] (1:load_test@MyHost1) Done working on my task; this took 2.00s; current peak speed: 5E+07 flop/s; number of flops computed so far: 3.00E+08
+> [ 20.000000] (1:load_test@MyHost1) ========= Requesting a reset of the computation and load counters
+> [ 20.000000] (1:load_test@MyHost1) After reset: 0E+00 flops computed; load is 0.00000
+> [ 20.000000] (1:load_test@MyHost1) Sleep for 4 seconds
+> [ 24.000000] (1:load_test@MyHost1) Done sleeping 4.00 s; peak speed: 5E+07 flop/s; number of flops computed so far: 0E+00
+> [ 24.000000] (1:load_test@MyHost1) Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed 0 flops so far and has an average load of 0.00000.
+> [ 34.000000] (1:load_test@MyHost1) Done sleeping 10.00 s; peak speed: 5E+07 flop/s; number of flops computed so far: 0E+00
+> [ 34.000000] (0:maestro@) Total simulation time: 34.00
index c7b3bad..4b4c944 100644 (file)
@@ -6,7 +6,6 @@ foreach(x async-wait
           energy-ptask energy-pstate platform-properties
           io-file io-file-remote
           task-priority
-          plugin-hostload
           trace_integration)
   if(enable_msg)
     add_executable       (${x} EXCLUDE_FROM_ALL ${x}/${x}.c)
@@ -98,7 +97,6 @@ if(enable_msg)
     io-file io-file-remote
     platform-properties
     task-priority
-    plugin-hostload
     trace_integration)
     
     ADD_TESH_FACTORIES(tesh-msg-${x} "raw" 
diff --git a/teshsuite/msg/plugin-hostload/plugin-hostload.c b/teshsuite/msg/plugin-hostload/plugin-hostload.c
deleted file mode 100644 (file)
index 1976cf0..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/* 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/msg.h"
-#include "simgrid/plugins/load.h"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-
-static int execute_load_test(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
-  msg_host_t host = MSG_host_by_name("MyHost1");
-
-  XBT_INFO("Initial peak speed: %.0E flop/s; number of flops computed so far: %.0E (should be 0)",
-           MSG_host_get_speed(host), sg_host_get_computed_flops(host));
-
-  double start = MSG_get_clock();
-  XBT_INFO("Sleep for 10 seconds");
-  MSG_process_sleep(10);
-
-  XBT_INFO("Done sleeping %.2fs; peak speed: %.0E flop/s; number of flops computed so far: %.0E (nothing should have "
-           "changed)",
-           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
-
-  // Run a task
-  start            = MSG_get_clock();
-  msg_task_t task1 = MSG_task_create("t1", 100E6, 0, NULL);
-  XBT_INFO("Run a task of %.0E flops", MSG_task_get_flops_amount(task1));
-  MSG_task_execute(task1);
-  MSG_task_destroy(task1);
-
-  XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
-           "far: %.0E",
-           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
-
-  // ========= Change power peak =========
-  int pstate = 2;
-  sg_host_set_pstate(host, pstate);
-  XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate,
-           MSG_host_get_power_peak_at(host, pstate), MSG_host_get_speed(host));
-
-  // Run a second task
-  start = MSG_get_clock();
-  task1 = MSG_task_create("t2", 100E6, 0, NULL);
-  XBT_INFO("Run a task of %.0E flops", MSG_task_get_flops_amount(task1));
-  MSG_task_execute(task1);
-  MSG_task_destroy(task1);
-  XBT_INFO("Done working on my task; this took %.2fs; current peak speed: %.0E flop/s; number of flops computed so "
-           "far: %.0E",
-           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
-
-  start = MSG_get_clock();
-  XBT_INFO("========= Requesting a reset of the computation counter");
-  sg_host_load_reset(host);
-  XBT_INFO("Sleep for 4 seconds");
-  MSG_process_sleep(4);
-  XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
-           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
-
-  // =========== Turn the other host off ==========
-  XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed %.0f flops so far.",
-           MSG_host_get_computed_flops(MSG_host_by_name("MyHost2")));
-  MSG_host_off(MSG_host_by_name("MyHost2"));
-  start = MSG_get_clock();
-  MSG_process_sleep(10);
-  XBT_INFO("Done sleeping %.2f s; peak speed: %.0E flop/s; number of flops computed so far: %.0E",
-           MSG_get_clock() - start, MSG_host_get_speed(host), sg_host_get_computed_flops(host));
-  return 0;
-}
-
-int main(int argc, char* argv[])
-{
-  sg_host_load_plugin_init();
-  MSG_init(&argc, argv);
-
-  xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
-
-  MSG_create_environment(argv[1]);
-  MSG_process_create("load_test", execute_load_test, NULL, MSG_get_host_by_name("MyHost1"));
-
-  msg_error_t res = MSG_main();
-
-  XBT_INFO("Total simulation time: %.2f", MSG_get_clock());
-
-  return res != MSG_OK;
-}
diff --git a/teshsuite/msg/plugin-hostload/plugin-hostload.tesh b/teshsuite/msg/plugin-hostload/plugin-hostload.tesh
deleted file mode 100644 (file)
index 1f8df83..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env tesh
-
-p This tests the HostLoad plugin (this allows the user to get the current load of a host and the computed flops)
-
-$ ${bindir:=.}/plugin-hostload ${platfdir}/energy_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [  0.000000] (1:load_test@MyHost1) Initial peak speed: 1E+08 flop/s; number of flops computed so far: 0E+00 (should be 0)
-> [  0.000000] (1:load_test@MyHost1) Sleep for 10 seconds
-> [ 10.000000] (1:load_test@MyHost1) Done sleeping 10.00s; peak speed: 1E+08 flop/s; number of flops computed so far: 0E+00 (nothing should have changed)
-> [ 10.000000] (1:load_test@MyHost1) Run a task of 1E+08 flops
-> [ 11.000000] (1:load_test@MyHost1) Done working on my task; this took 1.00s; current peak speed: 1E+08 flop/s; number of flops computed so far: 1E+08
-> [ 11.000000] (1:load_test@MyHost1) ========= Requesting pstate 2 (speed should be of 2E+07 flop/s and is of 2E+07 flop/s)
-> [ 11.000000] (1:load_test@MyHost1) Run a task of 1E+08 flops
-> [ 16.000000] (1:load_test@MyHost1) Done working on my task; this took 5.00s; current peak speed: 2E+07 flop/s; number of flops computed so far: 2E+08
-> [ 16.000000] (1:load_test@MyHost1) ========= Requesting a reset of the computation counter
-> [ 16.000000] (1:load_test@MyHost1) Sleep for 4 seconds
-> [ 20.000000] (1:load_test@MyHost1) Done sleeping 4.00 s; peak speed: 2E+07 flop/s; number of flops computed so far: 0E+00
-> [ 20.000000] (1:load_test@MyHost1) Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 computed 0 flops so far.
-> [ 30.000000] (1:load_test@MyHost1) Done sleeping 10.00 s; peak speed: 2E+07 flop/s; number of flops computed so far: 0E+00
-> [ 30.000000] (0:maestro@) Total simulation time: 30.00