Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into energy-pstate
authorZitagcc <toufik.boubehziz@inria.fr>
Tue, 28 Nov 2017 11:03:03 +0000 (12:03 +0100)
committerGitHub <noreply@github.com>
Tue, 28 Nov 2017 11:03:03 +0000 (12:03 +0100)
examples/msg/README.doc
examples/s4u/CMakeLists.txt
examples/s4u/README.doc
examples/s4u/energy-pstate/s4u-energy-pstate.cpp [new file with mode: 0644]
examples/s4u/energy-pstate/s4u-energy-pstate.tesh [new file with mode: 0644]

index 42597dd..eb2d0c5 100644 (file)
@@ -89,6 +89,12 @@ shipped in the archive:
     You can specify a start time and a kill time in the deployment
     file. See all *_d.xml files in this directory.
 
+  - <b>Using Pstates on a host</b>
+    @ref examples/msg/energy-pstate/energy-pstate.c\n
+    Show how define a set of pstates 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.
+    See also the platform XML file for have a details on how to declare the CPU capacity for each pstate.
+
 @section msg_ex_tracing Tracing and visualization features
 
 Tracing can be activated by various configuration options which
@@ -129,8 +135,8 @@ options to see the task executions:
     displayed as arrows in a Gantt-chart visualization. Recommanded
     options to that extend:
     @verbatim -cfg=tracing:yes --cfg=tracing/msg/process:yes
-    @endverbatim     
-
+    @endverbatim 
+    
 TODO: These tracing examples should be integrated in the examples to
 not duplicate the C files. A full command line to see the result in
 the right tool (vite/FrameSoc) should be given along with some
index 38866d4..2cd0fba 100644 (file)
@@ -1,6 +1,6 @@
 foreach (example actions-comm actions-storage 
                  actor-create actor-daemon actor-execute actor-kill actor-lifetime actor-migration actor-suspend actor-priority actor-yield
-                 app-masterworker app-pingpong app-token-ring
+                 app-masterworker app-pingpong app-token-ring energy-pstate
                 async-wait async-waitany async-waitall
                 energy-link
                 plugin-hostload io mutex)
@@ -33,6 +33,8 @@ endforeach()
 set(examples_src  ${examples_src}                                                                          PARENT_SCOPE)
 set(tesh_files    ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent.tesh
                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord.tesh
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/energy-pstate/s4u-energy-pstate.tesh
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/actor-priority/s4u-actor-priority.tesh
                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime.tesh
                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-priority/s4u-actor-priority.tesh
                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-yield/s4u-actor-yield.tesh
@@ -63,7 +65,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-lifetime actor-migration actor-suspend actor-priority actor-yield
-                app-bittorrent app-masterworker app-pingpong app-token-ring 
+                app-bittorrent app-masterworker app-pingpong app-token-ring energy-pstate
                async-wait async-waitall async-waitany
                dht-chord 
                energy-link
index 6c88294..42cf0f8 100644 (file)
@@ -101,6 +101,12 @@ documentation, but it should remain readable directly.
     @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.
 
+  - <b>Using Pstates on a host</b>
+    @ref examples/s4u/energy-pstate/s4u-energy-pstate.c\n
+    Show how define a set of pstates for a host and how the current
+    pstate can be accessed/changed with @ref getPstateSpeed and @ref  sg_host_set_pstate.
+    See also the platform XML file for have a details on how to declare the CPU capacity for each pstate.
+
   - <b>Yielding to other actor</b>.
     @ref examples/s4u/actor-yield/s4u-actor-yield.c\n
     The simgrid::s4u::this_actor::yield() function interrupts the
diff --git a/examples/s4u/energy-pstate/s4u-energy-pstate.cpp b/examples/s4u/energy-pstate/s4u-energy-pstate.cpp
new file mode 100644 (file)
index 0000000..6f82f4e
--- /dev/null
@@ -0,0 +1,67 @@
+/* Copyright (c) 2007-2010, 2013-2015. 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"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Pstate properties test");
+
+static int dvfs(std::vector<std::string> args)
+{
+  double workload = 100E6;
+  sg_host_t host = simgrid::s4u::this_actor::getHost();
+
+  int nb = sg_host_get_nb_pstates(host);
+  XBT_INFO("Count of Processor states=%d", nb);
+
+  XBT_INFO("Current power peak=%f", host->getSpeed());
+
+  // Run a task
+  simgrid::s4u::this_actor::execute(workload);
+
+  double task_time = simgrid::s4u::Engine::getClock();
+  XBT_INFO("Task1 simulation time: %e", task_time);
+
+  // Change power peak
+  int new_pstate = 2;
+
+  XBT_INFO("Changing power peak value to %f (at index %d)", host->getPstateSpeed(new_pstate), new_pstate);
+
+  sg_host_set_pstate(host, new_pstate);
+
+  XBT_INFO("Current power peak=%f", host->getSpeed());
+
+  // Run a second task
+  simgrid::s4u::this_actor::execute(workload);
+
+  task_time = simgrid::s4u::Engine::getClock() - task_time;
+  XBT_INFO("Task2 simulation time: %e", task_time);
+
+  // Verify the default pstate is set to 0
+  host = simgrid::s4u::Host::by_name_or_null("MyHost2");
+  XBT_INFO("Count of Processor states=%d", sg_host_get_nb_pstates(host));
+
+  XBT_INFO("Current power peak=%f", host->getSpeed());
+  return 0;
+}
+
+int main(int argc, char *argv[])
+{
+  simgrid::s4u::Engine e(&argc, argv);
+  std::vector<std::string> args;
+
+  xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
+
+   e.loadPlatform(argv[1]); /* - Load the platform description */
+
+   simgrid::s4u::Actor::createActor("dvfs_test", simgrid::s4u::Host::by_name("MyHost1"), dvfs, args);
+   simgrid::s4u::Actor::createActor("dvfs_test", simgrid::s4u::Host::by_name("MyHost2"), dvfs, args);
+
+   e.run();
+
+  XBT_INFO("Total simulation time: %e", e.getClock());
+
+  return 0;
+}
diff --git a/examples/s4u/energy-pstate/s4u-energy-pstate.tesh b/examples/s4u/energy-pstate/s4u-energy-pstate.tesh
new file mode 100644 (file)
index 0000000..6a2e593
--- /dev/null
@@ -0,0 +1,41 @@
+#! ./tesh
+
+p Testing the DVFS-related functions
+
+$ ${bindir:=.}/s4u-energy-pstate$EXEEXT ${srcdir:=.}/../platforms/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
+> [  0.000000] (2:dvfs_test@MyHost2) Current power peak=100000000.000000
+> [  1.000000] (1:dvfs_test@MyHost1) Task1 simulation time: 1.000000e+00
+> [  1.000000] (2:dvfs_test@MyHost2) Task1 simulation time: 1.000000e+00
+> [  1.000000] (1:dvfs_test@MyHost1) Changing power peak value to 20000000.000000 (at index 2)
+> [  1.000000] (2:dvfs_test@MyHost2) Changing power peak value to 20000000.000000 (at index 2)
+> [  1.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
+> [  1.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [  6.000000] (1:dvfs_test@MyHost1) Task2 simulation time: 5.000000e+00
+> [  6.000000] (1:dvfs_test@MyHost1) Count of Processor states=3
+> [  6.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
+> [  6.000000] (2:dvfs_test@MyHost2) Task2 simulation time: 5.000000e+00
+> [  6.000000] (2:dvfs_test@MyHost2) Count of Processor states=3
+> [  6.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [  6.000000] (0:maestro@) Total simulation time: 6.000000e+00
+
+$ ${bindir:=.}/s4u-energy-pstate$EXEEXT ${srcdir:=.}/../platforms/energy_cluster.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
+> [  0.000000] (2:dvfs_test@MyHost2) Current power peak=100000000.000000
+> [  1.000000] (1:dvfs_test@MyHost1) Task1 simulation time: 1.000000e+00
+> [  1.000000] (2:dvfs_test@MyHost2) Task1 simulation time: 1.000000e+00
+> [  1.000000] (1:dvfs_test@MyHost1) Changing power peak value to 20000000.000000 (at index 2)
+> [  1.000000] (2:dvfs_test@MyHost2) Changing power peak value to 20000000.000000 (at index 2)
+> [  1.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
+> [  1.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [  6.000000] (1:dvfs_test@MyHost1) Task2 simulation time: 5.000000e+00
+> [  6.000000] (1:dvfs_test@MyHost1) Count of Processor states=3
+> [  6.000000] (1:dvfs_test@MyHost1) Current power peak=20000000.000000
+> [  6.000000] (2:dvfs_test@MyHost2) Task2 simulation time: 5.000000e+00
+> [  6.000000] (2:dvfs_test@MyHost2) Count of Processor states=3
+> [  6.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+> [  6.000000] (0:maestro@) Total simulation time: 6.000000e+00