1 /* Copyright (c) 2007-2010, 2013-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/s4u.hpp"
9 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Pstate properties test");
11 static int dvfs(std::vector<std::string> args)
13 double workload = 100E6;
14 sg_host_t host = simgrid::s4u::this_actor::getHost();
16 int nb = sg_host_get_nb_pstates(host);
17 XBT_INFO("Count of Processor states=%d", nb);
19 XBT_INFO("Current power peak=%f", host->getSpeed());
22 simgrid::s4u::this_actor::execute(workload);
24 double task_time = simgrid::s4u::Engine::getClock();
25 XBT_INFO("Task1 simulation time: %e", task_time);
30 XBT_INFO("Changing power peak value to %f (at index %d)", host->getPstateSpeed(new_pstate), new_pstate);
32 sg_host_set_pstate(host, new_pstate);
34 XBT_INFO("Current power peak=%f", host->getSpeed());
37 simgrid::s4u::this_actor::execute(workload);
39 task_time = simgrid::s4u::Engine::getClock() - task_time;
40 XBT_INFO("Task2 simulation time: %e", task_time);
42 // Verify the default pstate is set to 0
43 host = simgrid::s4u::Host::by_name_or_null("MyHost2");
44 XBT_INFO("Count of Processor states=%d", sg_host_get_nb_pstates(host));
46 XBT_INFO("Current power peak=%f", host->getSpeed());
50 int main(int argc, char *argv[])
52 simgrid::s4u::Engine e(&argc, argv);
53 std::vector<std::string> args;
55 xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
57 e.loadPlatform(argv[1]); /* - Load the platform description */
59 simgrid::s4u::Actor::createActor("dvfs_test", simgrid::s4u::Host::by_name("MyHost1"), dvfs, args);
60 simgrid::s4u::Actor::createActor("dvfs_test", simgrid::s4u::Host::by_name("MyHost2"), dvfs, args);
64 XBT_INFO("Total simulation time: %e", e.getClock());