1 # Copyright (c) 2007-2023. 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.
7 Usage: exec-dvfs.py platform_file [other parameters]
11 from simgrid import Actor, Engine, Host, this_actor
17 host = this_actor.get_host()
19 nb = host.pstate_count
20 this_actor.info("Count of Processor states={:d}".format(nb))
22 this_actor.info("Current power peak={:f}".format(host.speed))
25 this_actor.execute(workload)
27 task_time = Engine.clock
28 this_actor.info("Task1 duration: {:.2f}".format(task_time))
33 this_actor.info("Changing power peak value to {:f} (at index {:d})".format(host.pstate_speed(new_pstate),
36 host.pstate = new_pstate
38 this_actor.info("Changed power peak={:f}".format(host.speed))
41 this_actor.execute(workload)
43 task_time = Engine.clock - task_time
44 this_actor.info("Task2 duration: {:.2f}".format(task_time))
46 # Verify that the default pstate is set to 0
47 host2 = Host.by_name("MyHost2")
48 this_actor.info("Count of Processor states={:d}".format(host2.pstate_count))
50 this_actor.info("Final power peak={:f}".format(host2.speed))
52 if __name__ == '__main__':
55 raise AssertionError("Usage: exec-dvfs.py platform_file [other parameters] (got {:d} params)"
56 .format(len(sys.argv)))
58 e.load_platform(sys.argv[1])
59 Actor.create("dvfs_test", Host.by_name("MyHost1"), Dvfs())
60 Actor.create("dvfs_test", Host.by_name("MyHost2"), Dvfs())