Plus cosmetics on my way, including in the CPP example.
foreach(example actor-create actor-daemon actor-join actor-kill actor-migrate actor-suspend actor-yield # actor-lifetime
async-wait async-waitall async-waitany
- exec-basic exec-async exec-remote)
+ exec-async exec-basic exec-dvfs exec-remote)
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.tesh)
set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/${example}.py)
-$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${bindir:=.}/actor-join.py ${platfdir}/small_platform.xml
+$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/actor-join.py ${platfdir}/small_platform.xml
> [Tremblay:master:(1) 0.000000] [python/INFO] Start sleeper
> [Tremblay:sleeper from master:(2) 0.000000] [python/INFO] Sleeper started
> [Tremblay:master:(1) 0.000000] [python/INFO] Join the sleeper (timeout 2)
if __name__ == '__main__':
e = Engine(sys.argv)
+ if len(sys.argv) < 2:
+ raise AssertionError("Usage: exec-async.py platform_file [other parameters]")
e.load_platform(sys.argv[1])
--- /dev/null
+# 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.
+
+import sys
+from simgrid import *
+
+
+class dvfs:
+ def __call__(self):
+ workload = 100E6
+ host = this_actor.get_host()
+
+ nb = host.get_pstate_count()
+ this_actor.info("Count of Processor states={:d}".format(nb))
+
+ this_actor.info("Current power peak={:f}".format(host.speed))
+
+ # Run a task
+ this_actor.execute(workload)
+
+ task_time = Engine.get_clock()
+ this_actor.info("Task1 duration: {:.2f}".format(task_time))
+
+ # Change power peak
+ new_pstate = 2
+
+ this_actor.info("Changing power peak value to {:f} (at index {:d})".format( host.get_pstate_speed(new_pstate), new_pstate))
+
+ host.pstate = new_pstate
+
+ this_actor.info("Current power peak={:f}".format(host.speed))
+
+ # Run a second task
+ this_actor.execute(workload)
+
+ task_time = Engine.get_clock() - task_time
+ this_actor.info("Task2 duration: {:.2f}".format(task_time))
+
+ # Verify that the default pstate is set to 0
+ host2 = Host.by_name("MyHost2")
+ this_actor.info("Count of Processor states={:d}".format(host2.get_pstate_count()))
+
+ this_actor.info("Current power peak={:f}".format(host2.speed))
+
+if __name__ == '__main__':
+ e = Engine(sys.argv)
+ if len(sys.argv) < 2:
+ raise AssertionError("Usage: exec-dvfs.py platform_file [other parameters] (got {:d} params)".format(len(sys.argv)))
+
+ e.load_platform(sys.argv[1])
+ Actor.create("dvfs_test", Host.by_name("MyHost1"), dvfs())
+ Actor.create("dvfs_test", Host.by_name("MyHost2"), dvfs())
+
+ e.run()
--- /dev/null
+#!/usr/bin/env tesh
+
+p Testing the DVFS-related functions
+
+$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/exec-dvfs.py ${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
+> [ 0.000000] (2:dvfs_test@MyHost2) Current power peak=100000000.000000
+> [ 1.000000] (1:dvfs_test@MyHost1) Task1 duration: 1.00
+> [ 1.000000] (2:dvfs_test@MyHost2) Task1 duration: 1.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 duration: 5.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 duration: 5.00
+> [ 6.000000] (2:dvfs_test@MyHost2) Count of Processor states=3
+> [ 6.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
+
+$ ${pythoncmd:=python3} ${PYTHON_TOOL_OPTIONS:=} ${srcdir:=.}/exec-dvfs.py ${platfdir}/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 duration: 1.00
+> [ 1.000000] (2:dvfs_test@MyHost2) Task1 duration: 1.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 duration: 5.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 duration: 5.00
+> [ 6.000000] (2:dvfs_test@MyHost2) Count of Processor states=3
+> [ 6.000000] (2:dvfs_test@MyHost2) Current power peak=20000000.000000
|br| `examples/s4u/exec-ptask/s4u-exec-ptask.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/exec-ptask/s4u-exec-ptask.cpp>`_
- **Using Pstates on a host:**
- Shows how define a set of pstatesfor a host in the XML, and how the current
- pstate can be accessed/changed with :cpp:func:`simgrid::s4u::Host::get_pstate_speed` and :cpp:func:`simgrid::s4u::Host::set_pstate`.
- |br| `examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp>`_
- |br| `examples/platforms/energy_platform.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/energy_platform.xml>`_
+ `examples/platforms/energy_platform.xml <https://framagit.org/simgrid/simgrid/tree/master/examples/platforms/energy_platform.xml>`_
+ shows how define a set of pstates in the XML. The current pstate
+ of an host can then be accessed and changed from the program.
+
+ - |cpp| `examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp>`_
+ :cpp:func:`simgrid::s4u::Host::get_pstate_speed` and :cpp:func:`simgrid::s4u::Host::set_pstate`.
+ - |py| `examples/python/exec-dvfs/exec-dvfs.py <https://framagit.org/simgrid/simgrid/tree/master/examples/python/exec-dvfs/exec-dvfs.py>`_
+ :py:func:`Host.get_pstate_speed` and :py:func:`Host.set_pstate`.
I/O on Disks and Files
----------------------
simgrid::s4u::this_actor::execute(workload);
double task_time = simgrid::s4u::Engine::get_clock();
- XBT_INFO("Task1 simulation time: %e", task_time);
+ XBT_INFO("Task1 duration: %.2f", task_time);
// Change power peak
int new_pstate = 2;
simgrid::s4u::this_actor::execute(workload);
task_time = simgrid::s4u::Engine::get_clock() - task_time;
- XBT_INFO("Task2 simulation time: %e", task_time);
+ XBT_INFO("Task2 duration: %.2f", task_time);
// Verify that the default pstate is set to 0
host = simgrid::s4u::Host::by_name_or_null("MyHost2");
> [ 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) Task1 duration: 1.00
+> [ 1.000000] (2:dvfs_test@MyHost2) Task1 duration: 1.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) Task2 duration: 5.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) Task2 duration: 5.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
> [ 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) Task1 duration: 1.00
+> [ 1.000000] (2:dvfs_test@MyHost2) Task1 duration: 1.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) Task2 duration: 5.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) Task2 duration: 5.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
// Currently this can be dangling, we should wrap this somehow.
return new simgrid::s4u::Engine(&argc, argv.get());
}))
+ .def_static("get_clock", &Engine::get_clock, "The simulation time, ie the amount of simulated seconds since the simulation start.")
.def("get_all_hosts", &Engine::get_all_hosts, "Returns the list of all hosts found in the platform")
- .def("get_clock", &Engine::get_clock, "Retrieve the simulation time (in seconds)")
.def("load_platform", &Engine::load_platform,
"Load a platform file describing the environment, see :cpp:func:`simgrid::s4u::Engine::load_platform()`")
.def("load_deployment", &Engine::load_deployment,
/* Class Host */
py::class_<simgrid::s4u::Host, std::unique_ptr<Host, py::nodelete>>(m, "Host", "Simulation Engine, see :ref:`class s4u::Host <API_s4u_Host>`")
.def("by_name", &Host::by_name, "Retrieves a host from its name, or die")
+ .def("get_pstate_count", &Host::get_pstate_count, "Retrieve the cound of defined pstate levels, see :cpp:func:`simgrid::s4u::Host::get_pstate_count`")
+ .def("get_pstate_speed", &Host::get_pstate_speed, "Retrieve the maximal speed at the given pstate, see :cpp:func:`simgrid::s4u::Host::get_pstate_speed`")
+ .def_property("pstate", &Host::get_pstate, &Host::set_pstate, "The current pstate")
+
.def("current", &Host::current, "Retrieves the host on which the running actor is located, see :cpp:func:`simgrid::s4u::Host::current()`")
.def_property_readonly("name", [](Host* self) -> const std::string {
return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC
}, "The name of this host")
.def_property_readonly("load", &Host::get_load,
- "Returns the current computation load (in flops per second), see :cpp:func:`simgrid::s4u::Host::get_load()`")
+ "Returns the current computation load (in flops per second). This is the currently achieved speed. See :cpp:func:`simgrid::s4u::Host::get_load()`")
.def_property_readonly("speed", &Host::get_speed,
- "The peak computing speed in flops/s at the current pstate, taking the external load into account, see :cpp:func:`simgrid::s4u::Host::get_speed()`");
+ "The peak computing speed in flops/s at the current pstate, taking the external load into account. This is the max potential speed. See :cpp:func:`simgrid::s4u::Host::get_speed()`");
/* Class Mailbox */
py::class_<simgrid::s4u::Mailbox, std::unique_ptr<Mailbox, py::nodelete>>(m, "Mailbox", "Mailbox, see :ref:`class s4u::Mailbox <API_s4u_Mailbox>`")