1 # Copyright (c) 2010-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.
7 This example demonstrates how to attach a profile to a host or a link, to specify external changes to the resource
9 The first way to do so is to use a file in the XML, while the second is to use the programmatic interface.
13 from simgrid import Actor, Engine, Host, Link, this_actor
16 jupiter = Host.by_name("Jupiter")
17 fafard = Host.by_name("Fafard")
18 lilibeth = Host.by_name("Lilibeth")
19 link1 = Link.by_name("1")
20 link2 = Link.by_name("2")
22 (links, lat) = jupiter.route_to(fafard)
25 path += ("" if not path else ", ") + "link '" + l.name + "'"
26 this_actor.info(f"Path from Jupiter to Fafard: {path} (latency: {lat:.6f}s).")
29 this_actor.info("Fafard: %.0fMflops, Jupiter: %4.0fMflops, Lilibeth: %3.1fMflops, \
30 Link1: (%.2fMB/s %.0fms), Link2: (%.2fMB/s %.0fms)" % (fafard.speed * fafard.available_speed / 1000000,
31 jupiter.speed * jupiter.available_speed / 1000000,
32 lilibeth.speed * lilibeth.available_speed / 1000000,
33 link1.bandwidth / 1000, link1.latency * 1000,
34 link2.bandwidth / 1000, link2.latency * 1000))
35 this_actor.sleep_for(1)
37 if __name__ == '__main__':
39 # Load the platform description
40 e.load_platform(sys.argv[1])
42 # Add a new host programmatically, and attach a simple speed profile to it (alternate between full and half speed
44 lili = e.netzone_root.create_host("Lilibeth", 25e6)
45 lili.set_speed_profile("""0 1.0
49 # Add a watcher of the changes
50 Actor.create("watcher", Host.by_name("Fafard"), watcher)