Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
energy-pstate -> exec-dvfs
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 20 Feb 2020 11:37:54 +0000 (12:37 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 20 Feb 2020 11:37:54 +0000 (12:37 +0100)
MANIFEST.in
examples/c/CMakeLists.txt
examples/c/exec-dvfs/exec-dvfs.c [new file with mode: 0644]
examples/c/exec-dvfs/exec-dvfs.tesh [moved from teshsuite/msg/energy-pstate/energy-pstate.tesh with 90% similarity]
teshsuite/msg/CMakeLists.txt
teshsuite/msg/energy-pstate/energy-pstate.c [deleted file]

index e460543..341ecaa 100644 (file)
@@ -57,6 +57,8 @@ include examples/c/cloud-simple/cloud-simple.c
 include examples/c/cloud-simple/cloud-simple.tesh
 include examples/c/energy-exec/energy-exec.c
 include examples/c/energy-exec/energy-exec.tesh
+include examples/c/exec-dvfs/exec-dvfs.c
+include examples/c/exec-dvfs/exec-dvfs.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
@@ -644,8 +646,6 @@ include teshsuite/msg/cloud-migration/cloud-migration.c
 include teshsuite/msg/cloud-migration/cloud-migration.tesh
 include teshsuite/msg/cloud-two-tasks/cloud-two-tasks.c
 include teshsuite/msg/cloud-two-tasks/cloud-two-tasks.tesh
-include teshsuite/msg/energy-pstate/energy-pstate.c
-include teshsuite/msg/energy-pstate/energy-pstate.tesh
 include teshsuite/msg/energy-ptask/energy-ptask.c
 include teshsuite/msg/energy-ptask/energy-ptask.tesh
 include teshsuite/msg/get_sender/get_sender.c
index e04ef9e..226cb61 100644 (file)
@@ -6,6 +6,7 @@ foreach(x
         app-pingpong app-token-ring 
         async-waitall async-waitany
         cloud-capping cloud-simple
+        exec-dvfs
         energy-exec
         io-disk-raw
         plugin-hostload)
@@ -53,6 +54,7 @@ foreach(x
         app-chainsend app-pingpong app-token-ring
         async-waitall async-waitany
         cloud-capping cloud-simple
+        exec-dvfs
         energy-exec
         io-disk-raw
         plugin-hostload)
diff --git a/examples/c/exec-dvfs/exec-dvfs.c b/examples/c/exec-dvfs/exec-dvfs.c
new file mode 100644 (file)
index 0000000..0d14933
--- /dev/null
@@ -0,0 +1,77 @@
+/* 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 "xbt/asserts.h"
+#include "xbt/config.h"
+#include "xbt/log.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Pstate properties test");
+
+static void dvfs(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+  sg_host_t host = sg_host_self();
+
+  int nb = sg_host_get_nb_pstates(host);
+  XBT_INFO("Count of Processor states=%d", nb);
+
+  double current_peak = sg_host_speed(host);
+  XBT_INFO("Current power peak=%f", current_peak);
+
+  sg_actor_self_execute(100E6);
+
+  double task_time = simgrid_get_clock();
+  XBT_INFO("Task1 simulation time: %e", task_time);
+
+  // Change power peak
+  int new_pstate = 2;
+  xbt_assert(new_pstate < nb, "Cannot set the host %s at pstate %d because it only provides %d pstates.",
+             sg_host_get_name(host), new_pstate, nb);
+
+  double peak_at = sg_host_get_pstate_speed(host, new_pstate);
+  XBT_INFO("Changing power peak value to %f (at index %d)", peak_at, new_pstate);
+
+  sg_host_set_pstate(host, new_pstate);
+
+  current_peak = sg_host_speed(host);
+  XBT_INFO("Current power peak=%f", current_peak);
+
+  sg_actor_self_execute(100E6);
+
+  task_time = simgrid_get_clock() - task_time;
+  XBT_INFO("Task2 simulation time: %e", task_time);
+
+  // Verify the default pstate is set to 0
+  host    = sg_host_by_name("MyHost2");
+  int nb2 = sg_host_get_nb_pstates(host);
+  XBT_INFO("Count of Processor states=%d", nb2);
+
+  double current_peak2 = sg_host_speed(host);
+  XBT_INFO("Current power peak=%f", current_peak2);
+}
+
+int main(int argc, char* argv[])
+{
+  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 a1 = sg_actor_init("dvfs_test", sg_host_by_name("MyHost1"));
+  sg_actor_start(a1, dvfs, 0, NULL);
+
+  sg_actor_t a2 = sg_actor_init("dvfs_test", sg_host_by_name("MyHost2"));
+  sg_actor_start(a2, dvfs, 0, NULL);
+
+  simgrid_run();
+
+  XBT_INFO("Total simulation time: %e", simgrid_get_clock());
+
+  return 0;
+}
similarity index 90%
rename from teshsuite/msg/energy-pstate/energy-pstate.tesh
rename to examples/c/exec-dvfs/exec-dvfs.tesh
index 464869f..e778e14 100644 (file)
@@ -1,8 +1,6 @@
 #!/usr/bin/env tesh
 
-p Testing the DVFS-related functions
-
-$ ${bindir:=.}/energy-pstate ${platfdir}/energy_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ ${bindir:=.}/exec-dvfs-c ${platfdir}/energy_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:dvfs_test@MyHost1) Count of Processor states=3
 > [  0.000000] (1:dvfs_test@MyHost1) Current power peak=100000000.000000
 > [  0.000000] (2:dvfs_test@MyHost2) Count of Processor states=3
@@ -21,7 +19,7 @@ $ ${bindir:=.}/energy-pstate ${platfdir}/energy_platform.xml "--log=root.fmt:[%1
 > [  6.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
 > [  6.000000] (0:maestro@) Total simulation time: 6.000000e+00
 
-$ ${bindir:=.}/energy-pstate ${platfdir}/energy_cluster.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=host/model:ptask_L07
+$ ${bindir:=.}/exec-dvfs-c ${platfdir}/energy_cluster.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=host/model:ptask_L07
 > [  0.000000] (0:maestro@) Configuration change: Set 'host/model' to 'ptask_L07'
 > [  0.000000] (0:maestro@) Switching to the L07 model to handle parallel tasks.
 > [  0.000000] (1:dvfs_test@MyHost1) Count of Processor states=3
index 354fc07..f153e04 100644 (file)
@@ -3,7 +3,7 @@ foreach(x async-wait
           cloud-migration cloud-two-tasks
           get_sender host_on_off host_on_off_recv
           process-lifetime
-          energy-ptask energy-pstate platform-properties
+          energy-ptask platform-properties
           io-file io-file-remote
           task-priority
           trace_integration)
@@ -75,7 +75,6 @@ if(enable_msg)
     async-wait
     app-bittorrent
     cloud-migration cloud-two-tasks
-    energy-pstate
     host_on_off host_on_off_processes host_on_off_recv
     get_sender
     task_destroy_cancel task_listen_from task_progress 
diff --git a/teshsuite/msg/energy-pstate/energy-pstate.c b/teshsuite/msg/energy-pstate/energy-pstate.c
deleted file mode 100644 (file)
index 034d29f..0000000
+++ /dev/null
@@ -1,85 +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"
-
-/** @addtogroup MSG_examples
- *
- * - <b>energy-pstate/energy-pstate.c</b> Shows how a set of pstates can be defined for a host and how the current
- * pstate can be
- *     accessed/changed with @ref MSG_get_host_current_power_peak and @ref  MSG_set_host_pstate.
- *     Make sure to read the platform XML file for details on how to declare the CPU capacity for each pstate.
- */
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Pstate properties test");
-
-static int dvfs(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
-  double workload = 100E6;
-  msg_host_t host = MSG_host_self();
-
-  int nb = MSG_host_get_nb_pstates(host);
-  XBT_INFO("Count of Processor states=%d", nb);
-
-  double current_peak = MSG_host_get_speed(host);
-  XBT_INFO("Current power peak=%f", current_peak);
-
-  // Run a task
-  msg_task_t task1 = MSG_task_create("t1", workload, 0, NULL);
-  MSG_task_execute(task1);
-  MSG_task_destroy(task1);
-
-  double task_time = MSG_get_clock();
-  XBT_INFO("Task1 simulation time: %e", task_time);
-
-  // Change power peak
-  int new_pstate = 2;
-  xbt_assert(new_pstate < nb, "Cannot set the host %s at pstate %d because it only provides %d pstates.",
-             MSG_host_get_name(host), new_pstate, nb);
-
-  double peak_at = MSG_host_get_power_peak_at(host, new_pstate);
-  XBT_INFO("Changing power peak value to %f (at index %d)", peak_at, new_pstate);
-
-  MSG_host_set_pstate(host, new_pstate);
-
-  current_peak = MSG_host_get_speed(host);
-  XBT_INFO("Current power peak=%f", current_peak);
-
-  // Run a second task
-  task1 = MSG_task_create("t1", workload, 0, NULL);
-  MSG_task_execute(task1);
-  MSG_task_destroy(task1);
-
-  task_time = MSG_get_clock() - task_time;
-  XBT_INFO("Task2 simulation time: %e", task_time);
-
-  // Verify the default pstate is set to 0
-  host    = MSG_host_by_name("MyHost2");
-  int nb2 = MSG_host_get_nb_pstates(host);
-  XBT_INFO("Count of Processor states=%d", nb2);
-
-  double current_peak2 = MSG_host_get_speed(host);
-  XBT_INFO("Current power peak=%f", current_peak2);
-  return 0;
-}
-
-int main(int argc, char* argv[])
-{
-  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("dvfs_test", dvfs, NULL, MSG_get_host_by_name("MyHost1"));
-  MSG_process_create("dvfs_test", dvfs, NULL, MSG_get_host_by_name("MyHost2"));
-
-  msg_error_t res = MSG_main();
-
-  XBT_INFO("Total simulation time: %e", MSG_get_clock());
-
-  return res != MSG_OK;
-}