1 # Copyright (c) 2007-2022. 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 from simgrid import Actor, Engine, Host, this_actor
13 host = this_actor.get_host()
15 nb = host.get_pstate_count()
16 this_actor.info("Count of Processor states={:d}".format(nb))
18 this_actor.info("Current power peak={:f}".format(host.speed))
21 this_actor.execute(workload)
23 task_time = Engine.clock()
24 this_actor.info("Task1 duration: {:.2f}".format(task_time))
29 this_actor.info("Changing power peak value to {:f} (at index {:d})".format( host.get_pstate_speed(new_pstate), new_pstate))
31 host.pstate = new_pstate
33 this_actor.info("Changed power peak={:f}".format(host.speed))
36 this_actor.execute(workload)
38 task_time = Engine.clock() - task_time
39 this_actor.info("Task2 duration: {:.2f}".format(task_time))
41 # Verify that the default pstate is set to 0
42 host2 = Host.by_name("MyHost2")
43 this_actor.info("Count of Processor states={:d}".format(host2.get_pstate_count()))
45 this_actor.info("Final power peak={:f}".format(host2.speed))
47 if __name__ == '__main__':
50 raise AssertionError("Usage: exec-dvfs.py platform_file [other parameters] (got {:d} params)".format(len(sys.argv)))
52 e.load_platform(sys.argv[1])
53 Actor.create("dvfs_test", Host.by_name("MyHost1"), Dvfs())
54 Actor.create("dvfs_test", Host.by_name("MyHost2"), Dvfs())