Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[tests] Add energy-exec-ptask test
authorclement-dell <clement.mommessin@inria.fr>
Wed, 14 Aug 2019 08:29:15 +0000 (10:29 +0200)
committerMillian Poquet <millian.poquet@inria.fr>
Thu, 5 Sep 2019 15:09:42 +0000 (17:09 +0200)
examples/s4u/CMakeLists.txt
examples/s4u/energy-exec-ptask/s4u-energy-exec-ptask.cpp [new file with mode: 0644]
examples/s4u/energy-exec-ptask/s4u-energy-exec-ptask.tesh [new file with mode: 0644]

index e6d1930..e8d52f6 100644 (file)
@@ -7,7 +7,7 @@ foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill
                  app-chainsend app-pingpong app-token-ring
                  async-ready async-wait async-waitany async-waitall async-waituntil
                  cloud-capping cloud-migration cloud-simple
-                 energy-exec energy-boot energy-link energy-vm
+                 energy-exec energy-boot energy-link energy-vm energy-exec-ptask
                  engine-filtering
                  exec-async exec-basic exec-dvfs exec-ptask exec-remote exec-waitany
                  io-async io-file-system io-file-remote io-storage-raw
diff --git a/examples/s4u/energy-exec-ptask/s4u-energy-exec-ptask.cpp b/examples/s4u/energy-exec-ptask/s4u-energy-exec-ptask.cpp
new file mode 100644 (file)
index 0000000..aa2c214
--- /dev/null
@@ -0,0 +1,148 @@
+/* Copyright (c) 2007-2019. 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"
+#include "simgrid/plugins/energy.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+
+static void runner()
+{
+  simgrid::s4u::Host* host1 = simgrid::s4u::Host::by_name("MyHost1");
+  simgrid::s4u::Host* host2 = simgrid::s4u::Host::by_name("MyHost2");
+  std::vector<simgrid::s4u::Host*> hosts{host1, host2};
+
+  double old_energy_host1 = sg_host_get_consumed_energy(host1);
+  double old_energy_host2 = sg_host_get_consumed_energy(host2);
+
+  XBT_INFO("[%s] Energetic profile: %s", host1->get_cname(), host1->get_property("watt_per_state"));
+  XBT_INFO("[%s] Initial peak speed=%.0E flop/s; Total energy dissipated =%.0E J", host1->get_cname(), host1->get_speed(),
+           old_energy_host1);
+  XBT_INFO("[%s] Energetic profile: %s", host2->get_cname(), host2->get_property("watt_per_state"));
+  XBT_INFO("[%s] Initial peak speed=%.0E flop/s; Total energy dissipated =%.0E J", host2->get_cname(), host2->get_speed(),
+           old_energy_host2);
+
+  double start = simgrid::s4u::Engine::get_clock();
+  XBT_INFO("Sleep for 10 seconds");
+  simgrid::s4u::this_actor::sleep_for(10);
+
+  double new_energy_host1 = sg_host_get_consumed_energy(host1);
+  double new_energy_host2 = sg_host_get_consumed_energy(host2);
+  XBT_INFO("Done sleeping (duration: %.2f s).\n"
+           "[%s] Current peak speed=%.0E; Energy dissipated during this step=%.2f J; Total energy dissipated=%.2f J\n"
+           "[%s] Current peak speed=%.0E; Energy dissipated during this step=%.2f J; Total energy dissipated=%.2f J\n",
+           simgrid::s4u::Engine::get_clock() - start,
+           host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1),
+           host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
+
+  old_energy_host1 = new_energy_host1;
+  old_energy_host2 = new_energy_host2;
+
+
+  // ========= Execute something =========
+  start             = simgrid::s4u::Engine::get_clock();
+  double flopAmount = 1E9;
+  std::vector<double> cpu_amounts{flopAmount, flopAmount};
+  std::vector<double> com_amounts{0, 0, 0, 0};
+  XBT_INFO("Run a task of %.0E flops on two hosts", flopAmount);
+  simgrid::s4u::this_actor::parallel_execute(hosts, cpu_amounts, com_amounts);
+
+  new_energy_host1 = sg_host_get_consumed_energy(host1);
+  new_energy_host2 = sg_host_get_consumed_energy(host2);
+  XBT_INFO("Task done (duration: %.2f s).\n"
+           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
+           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n",
+           simgrid::s4u::Engine::get_clock() - start,
+           host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1),
+           host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
+
+  old_energy_host1 = new_energy_host1;
+  old_energy_host2 = new_energy_host2;
+
+
+  // ========= Change power peak =========
+  int pstate = 2;
+  host1->set_pstate(pstate);
+  host2->set_pstate(pstate);
+  XBT_INFO("========= Requesting pstate %d for both hosts (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate,
+           host1->get_pstate_speed(pstate), host1->get_speed());
+
+
+  // ========= Run another ptask =========
+  start             = simgrid::s4u::Engine::get_clock();
+  std::vector<double> cpu_amounts2{flopAmount, flopAmount};
+  std::vector<double> com_amounts2{0, 0, 0, 0};
+  XBT_INFO("Run a task of %.0E flops on %s and %.0E flops on %s.", flopAmount, host1->get_cname(), flopAmount, host2->get_cname());
+  simgrid::s4u::this_actor::parallel_execute(hosts, cpu_amounts2, com_amounts2);
+
+  new_energy_host1 = sg_host_get_consumed_energy(host1);
+  new_energy_host2 = sg_host_get_consumed_energy(host2);
+  XBT_INFO("Task done (duration: %.2f s).\n"
+           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
+           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n",
+           simgrid::s4u::Engine::get_clock() - start,
+           host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1),
+           host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
+
+  old_energy_host1 = new_energy_host1;
+  old_energy_host2 = new_energy_host2;
+
+
+  // ========= A new ptask with computation and communication =========
+  start             = simgrid::s4u::Engine::get_clock();
+  double comAmount = 1E7;
+  std::vector<double> cpu_amounts3{flopAmount, flopAmount};
+  std::vector<double> com_amounts3{0, comAmount, comAmount, 0};
+  XBT_INFO("Run a task with computation and communication on two hosts.");
+  simgrid::s4u::this_actor::parallel_execute(hosts, cpu_amounts3, com_amounts3);
+
+  new_energy_host1 = sg_host_get_consumed_energy(host1);
+  new_energy_host2 = sg_host_get_consumed_energy(host2);
+  XBT_INFO("Task done (duration: %.2f s).\n"
+           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
+           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n",
+           simgrid::s4u::Engine::get_clock() - start,
+           host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1),
+           host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
+
+  old_energy_host1 = new_energy_host1;
+  old_energy_host2 = new_energy_host2;
+
+
+  // ========= A new ptask with communication only =========
+  start             = simgrid::s4u::Engine::get_clock();
+  std::vector<double> cpu_amounts4{0, 0};
+  std::vector<double> com_amounts4{0, comAmount, comAmount, 0};
+  XBT_INFO("Run a task with only communication on two hosts.");
+  simgrid::s4u::this_actor::parallel_execute(hosts, cpu_amounts4, com_amounts4);
+
+  new_energy_host1 = sg_host_get_consumed_energy(host1);
+  new_energy_host2 = sg_host_get_consumed_energy(host2);
+  XBT_INFO("Task done (duration: %.2f s).\n"
+           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n"
+           "[%s] Current peak speed=%.0E flop/s; Energy dissipated during this step=%.2f J; Total energy dissipated=%.0f J\n",
+           simgrid::s4u::Engine::get_clock() - start,
+           host1->get_cname(), host1->get_speed(), (new_energy_host1 - old_energy_host1), sg_host_get_consumed_energy(host1),
+           host2->get_cname(), host2->get_speed(), (new_energy_host2 - old_energy_host2), sg_host_get_consumed_energy(host2));
+
+  XBT_INFO("Now is time to quit!");
+}
+
+int main(int argc, char* argv[])
+{
+  sg_host_energy_plugin_init();
+  simgrid::s4u::Engine e(&argc, argv);
+  e.set_config("host/model:ptask_L07");
+  //xbt_log_control_set("surf_energy.thresh:debug");
+
+  xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/energy_platform.xml\n", argv[0], argv[0]);
+
+  e.load_platform(argv[1]);
+  simgrid::s4u::Actor::create("energy_ptask_test", simgrid::s4u::Host::by_name("MyHost1"), runner);
+
+  e.run();
+  XBT_INFO("End of simulation.");
+  return 0;
+}
diff --git a/examples/s4u/energy-exec-ptask/s4u-energy-exec-ptask.tesh b/examples/s4u/energy-exec-ptask/s4u-energy-exec-ptask.tesh
new file mode 100644 (file)
index 0000000..376b3e8
--- /dev/null
@@ -0,0 +1,83 @@
+#!/usr/bin/env tesh
+
+p Testing the mechanism for computing host energy consumption
+
+$ ${bindir:=.}/s4u-energy-exec-ptask ${platfdir}/energy_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  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:energy_ptask_test@MyHost1) [MyHost1] Energetic profile: 100.0:93.33333333333333:200.0, 93.0:90.0:170.0, 90.0:90.0:150.0
+> [  0.000000] (1:energy_ptask_test@MyHost1) [MyHost1] Initial peak speed=1E+08 flop/s; Total energy dissipated =0E+00 J
+> [  0.000000] (1:energy_ptask_test@MyHost1) [MyHost2] Energetic profile: 100.0:200.0:200.0, 93.0:170.0:170.0, 90.0:150.0:150.0
+> [  0.000000] (1:energy_ptask_test@MyHost1) [MyHost2] Initial peak speed=1E+08 flop/s; Total energy dissipated =0E+00 J
+> [  0.000000] (1:energy_ptask_test@MyHost1) Sleep for 10 seconds
+> [ 10.000000] (1:energy_ptask_test@MyHost1) Done sleeping (duration: 10.00 s).
+> [MyHost1] Current peak speed=1E+08; Energy dissipated during this step=1000.00 J; Total energy dissipated=1000.00 J
+> [MyHost2] Current peak speed=1E+08; Energy dissipated during this step=1000.00 J; Total energy dissipated=1000.00 J
+>
+> [ 10.000000] (1:energy_ptask_test@MyHost1) Run a task of 1E+09 flops on two hosts
+> [ 20.000000] (1:energy_ptask_test@MyHost1) Task done (duration: 10.00 s).
+> [MyHost1] Current peak speed=1E+08 flop/s; Energy dissipated during this step=1200.00 J; Total energy dissipated=2200 J
+> [MyHost2] Current peak speed=1E+08 flop/s; Energy dissipated during this step=2000.00 J; Total energy dissipated=3000 J
+>
+> [ 20.000000] (1:energy_ptask_test@MyHost1) ========= Requesting pstate 2 for both hosts (speed should be of 2E+07 flop/s and is of 2E+07 flop/s)
+> [ 20.000000] (1:energy_ptask_test@MyHost1) Run a task of 1E+09 flops on MyHost1 and 1E+09 flops on MyHost2.
+> [ 70.000000] (1:energy_ptask_test@MyHost1) Task done (duration: 50.00 s).
+> [MyHost1] Current peak speed=2E+07 flop/s; Energy dissipated during this step=5250.00 J; Total energy dissipated=7450 J
+> [MyHost2] Current peak speed=2E+07 flop/s; Energy dissipated during this step=7500.00 J; Total energy dissipated=10500 J
+>
+> [ 70.000000] (1:energy_ptask_test@MyHost1) Run a task with computation and communication on two hosts.
+> [270.000000] (1:energy_ptask_test@MyHost1) Task done (duration: 200.00 s).
+> [MyHost1] Current peak speed=2E+07 flop/s; Energy dissipated during this step=18750.00 J; Total energy dissipated=26200 J
+> [MyHost2] Current peak speed=2E+07 flop/s; Energy dissipated during this step=30000.00 J; Total energy dissipated=40500 J
+>
+> [270.000000] (1:energy_ptask_test@MyHost1) Run a task with only communication on two hosts.
+> [470.000000] (1:energy_ptask_test@MyHost1) Task done (duration: 200.00 s).
+> [MyHost1] Current peak speed=2E+07 flop/s; Energy dissipated during this step=18000.00 J; Total energy dissipated=44200 J
+> [MyHost2] Current peak speed=2E+07 flop/s; Energy dissipated during this step=18000.00 J; Total energy dissipated=58500 J
+>
+> [470.000000] (1:energy_ptask_test@MyHost1) Now is time to quit!
+> [470.000000] (0:maestro@) Total energy consumption: 149700.000000 Joules (used hosts: 102700.000000 Joules; unused/idle hosts: 47000.000000)
+> [470.000000] (0:maestro@) End of simulation.
+> [470.000000] (0:maestro@) Energy consumption of host MyHost1: 44200.000000 Joules
+> [470.000000] (0:maestro@) Energy consumption of host MyHost2: 58500.000000 Joules
+> [470.000000] (0:maestro@) Energy consumption of host MyHost3: 47000.000000 Joules
+
+
+$ ${bindir:=.}/s4u-energy-exec-ptask ${platfdir}/energy_cluster.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  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:energy_ptask_test@MyHost1) [MyHost1] Energetic profile: 100.0:93.33333333333333:200.0, 93.0:90.0:170.0, 90.0:90.0:150.0
+> [  0.000000] (1:energy_ptask_test@MyHost1) [MyHost1] Initial peak speed=1E+08 flop/s; Total energy dissipated =0E+00 J
+> [  0.000000] (1:energy_ptask_test@MyHost1) [MyHost2] Energetic profile: 100.0:93.33333333333333:200.0, 93.0:90.0:170.0, 90.0:90.0:150.0
+> [  0.000000] (1:energy_ptask_test@MyHost1) [MyHost2] Initial peak speed=1E+08 flop/s; Total energy dissipated =0E+00 J
+> [  0.000000] (1:energy_ptask_test@MyHost1) Sleep for 10 seconds
+> [ 10.000000] (1:energy_ptask_test@MyHost1) Done sleeping (duration: 10.00 s).
+> [MyHost1] Current peak speed=1E+08; Energy dissipated during this step=1000.00 J; Total energy dissipated=1000.00 J
+> [MyHost2] Current peak speed=1E+08; Energy dissipated during this step=1000.00 J; Total energy dissipated=1000.00 J
+>
+> [ 10.000000] (1:energy_ptask_test@MyHost1) Run a task of 1E+09 flops on two hosts
+> [ 20.000000] (1:energy_ptask_test@MyHost1) Task done (duration: 10.00 s).
+> [MyHost1] Current peak speed=1E+08 flop/s; Energy dissipated during this step=1200.00 J; Total energy dissipated=2200 J
+> [MyHost2] Current peak speed=1E+08 flop/s; Energy dissipated during this step=1200.00 J; Total energy dissipated=2200 J
+>
+> [ 20.000000] (1:energy_ptask_test@MyHost1) ========= Requesting pstate 2 for both hosts (speed should be of 2E+07 flop/s and is of 2E+07 flop/s)
+> [ 20.000000] (1:energy_ptask_test@MyHost1) Run a task of 1E+09 flops on MyHost1 and 1E+09 flops on MyHost2.
+> [ 70.000000] (1:energy_ptask_test@MyHost1) Task done (duration: 50.00 s).
+> [MyHost1] Current peak speed=2E+07 flop/s; Energy dissipated during this step=5250.00 J; Total energy dissipated=7450 J
+> [MyHost2] Current peak speed=2E+07 flop/s; Energy dissipated during this step=5250.00 J; Total energy dissipated=7450 J
+>
+> [ 70.000000] (1:energy_ptask_test@MyHost1) Run a task with computation and communication on two hosts.
+> [120.000600] (1:energy_ptask_test@MyHost1) Task done (duration: 50.00 s).
+> [MyHost1] Current peak speed=2E+07 flop/s; Energy dissipated during this step=5250.06 J; Total energy dissipated=12700 J
+> [MyHost2] Current peak speed=2E+07 flop/s; Energy dissipated during this step=5250.06 J; Total energy dissipated=12700 J
+>
+> [120.000600] (1:energy_ptask_test@MyHost1) Run a task with only communication on two hosts.
+> [120.081200] (1:energy_ptask_test@MyHost1) Task done (duration: 0.08 s).
+> [MyHost1] Current peak speed=2E+07 flop/s; Energy dissipated during this step=7.25 J; Total energy dissipated=12707 J
+> [MyHost2] Current peak speed=2E+07 flop/s; Energy dissipated during this step=7.25 J; Total energy dissipated=12707 J
+>
+> [120.081200] (1:energy_ptask_test@MyHost1) Now is time to quit!
+> [120.081200] (0:maestro@) Total energy consumption: 25414.634000 Joules (used hosts: 25414.634000 Joules; unused/idle hosts: 0.000000)
+> [120.081200] (0:maestro@) End of simulation.
+> [120.081200] (0:maestro@) Energy consumption of host MyHost1: 12707.317000 Joules
+> [120.081200] (0:maestro@) Energy consumption of host MyHost2: 12707.317000 Joules