1 /* Copyright (c) 2007-2020. 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");
12 double workload = 100E6;
13 simgrid::s4u::Host* host = simgrid::s4u::this_actor::get_host();
15 int nb = host->get_pstate_count();
16 XBT_INFO("Count of Processor states=%d", nb);
18 XBT_INFO("Current power peak=%f", host->get_speed());
21 simgrid::s4u::this_actor::execute(workload);
23 double task_time = simgrid::s4u::Engine::get_clock();
24 XBT_INFO("Task1 duration: %.2f", task_time);
29 XBT_INFO("Changing power peak value to %f (at index %d)", host->get_pstate_speed(new_pstate), new_pstate);
31 host->set_pstate(new_pstate);
33 XBT_INFO("Current power peak=%f", host->get_speed());
36 simgrid::s4u::this_actor::execute(workload);
38 task_time = simgrid::s4u::Engine::get_clock() - task_time;
39 XBT_INFO("Task2 duration: %.2f", task_time);
41 // Verify that 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", host->get_pstate_count());
45 XBT_INFO("Current power peak=%f", host->get_speed());
49 int main(int argc, char* argv[])
51 simgrid::s4u::Engine e(&argc, argv);
53 xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s ../platforms/energy_platform.xml\n", argv[0], argv[0]);
55 e.load_platform(argv[1]);
57 simgrid::s4u::Actor::create("dvfs_test", simgrid::s4u::Host::by_name("MyHost1"), dvfs);
58 simgrid::s4u::Actor::create("dvfs_test", simgrid::s4u::Host::by_name("MyHost2"), dvfs);
62 XBT_INFO("Total simulation time: %e", e.get_clock());