1 /* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "simgrid/s4u.hpp"
8 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Pstate properties test");
10 static int dvfs(std::vector<std::string> args)
12 double workload = 100E6;
13 sg_host_t host = simgrid::s4u::this_actor::getHost();
15 int nb = sg_host_get_nb_pstates(host);
16 XBT_INFO("Count of Processor states=%d", nb);
18 XBT_INFO("Current power peak=%f", host->getSpeed());
21 simgrid::s4u::this_actor::execute(workload);
23 double task_time = simgrid::s4u::Engine::getClock();
24 XBT_INFO("Task1 simulation time: %e", task_time);
29 XBT_INFO("Changing power peak value to %f (at index %d)", host->getPstateSpeed(new_pstate), new_pstate);
31 sg_host_set_pstate(host, new_pstate);
33 XBT_INFO("Current power peak=%f", host->getSpeed());
36 simgrid::s4u::this_actor::execute(workload);
38 task_time = simgrid::s4u::Engine::getClock() - task_time;
39 XBT_INFO("Task2 simulation time: %e", task_time);
41 // Verify the default pstate is set to 0
42 host = simgrid::s4u::Host::by_name_or_null("MyHost2");
43 XBT_INFO("Count of Processor states=%d", sg_host_get_nb_pstates(host));
45 XBT_INFO("Current power peak=%f", host->getSpeed());
49 int main(int argc, char *argv[])
51 simgrid::s4u::Engine e(&argc, argv);
52 std::vector<std::string> args;
54 xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
56 e.loadPlatform(argv[1]); /* - Load the platform description */
58 simgrid::s4u::Actor::createActor("dvfs_test", simgrid::s4u::Host::by_name("MyHost1"), dvfs, args);
59 simgrid::s4u::Actor::createActor("dvfs_test", simgrid::s4u::Host::by_name("MyHost2"), dvfs, args);
63 XBT_INFO("Total simulation time: %e", e.getClock());