SimGrid  3.18
Versatile Simulation of Distributed Systems
examples/s4u/energy-exec/s4u-energy-exec.cpp
/* Copyright (c) 2007-2017. 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(s4u_test, "Messages specific for this s4u example");
static void dvfs()
{
XBT_INFO("Energetic profile: %s", host1->getProperty("watt_per_state"));
XBT_INFO("Initial peak speed=%.0E flop/s; Energy dissipated =%.0E J", host1->getSpeed(),
XBT_INFO("Sleep for 10 seconds");
XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E; Energy dissipated=%.2f J",
// Execute something
double flopAmount = 100E6;
XBT_INFO("Run a task of %.0E flops", flopAmount);
XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Current consumption: from %.0fW to %.0fW"
" depending on load; Energy dissipated=%.0f J",
// ========= Change power peak =========
int pstate = 2;
host1->setPstate(pstate);
XBT_INFO("========= Requesting pstate %d (speed should be of %.0E flop/s and is of %.0E flop/s)", pstate,
host1->getPstateSpeed(pstate), host1->getSpeed());
// Run another task
XBT_INFO("Run a task of %.0E flops", flopAmount);
XBT_INFO("Task done (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
XBT_INFO("Sleep for 4 seconds");
XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
// =========== Turn the other host off ==========
XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 dissipated %.0f J so far.",
host2->turnOff();
XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J",
}
int main(int argc, char* argv[])
{
simgrid::s4u::Engine e(&argc, argv);
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
e.loadPlatform(argv[1]);
e.run();
XBT_INFO("End of simulation.");
return 0;
}