Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / examples / python / exec-remote / exec-remote.py
1 # Copyright (c) 2018-2023. The SimGrid Team. All rights reserved.
2 #
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.
5
6 import sys
7 from simgrid import Actor, Engine, Host, this_actor
8
9
10 class Wizard:
11     def __call__(self):
12
13         fafard = Host.by_name("Fafard")
14         ginette = Host.by_name("Ginette")
15         boivin = Host.by_name("Boivin")
16
17         this_actor.info("I'm a wizard! I can run a task on the Ginette host from the Fafard one! Look!")
18         activity = this_actor.exec_init(48.492e6)
19         activity.host = ginette
20         activity.start()
21         this_actor.info("It started. Running 48.492Mf takes exactly one second on Ginette (but not on Fafard).")
22
23         this_actor.sleep_for(0.1)
24         this_actor.info("Loads in flops/s: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(boivin.load,
25                                                                                                 fafard.load,
26                                                                                                 ginette.load))
27         activity.wait()
28         this_actor.info("Done!")
29
30         this_actor.info("And now, harder. Start a remote task on Ginette and move it to Boivin after 0.5 sec")
31         activity = this_actor.exec_init(73293500)
32         activity.host = ginette
33         activity.start()
34
35         this_actor.sleep_for(0.5)
36         this_actor.info(
37             "Loads before the move: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(
38                 boivin.load,
39                 fafard.load,
40                 ginette.load))
41
42         activity.host = boivin
43
44         this_actor.sleep_for(0.1)
45         this_actor.info(
46             "Loads after the move: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(
47                 boivin.load,
48                 fafard.load,
49                 ginette.load))
50
51         activity.wait()
52         this_actor.info("Done!")
53
54
55 if __name__ == '__main__':
56     e = Engine(sys.argv)
57
58     e.load_platform(sys.argv[1])
59
60     Actor.create("test", Host.by_name("Fafard"), Wizard())
61
62     e.run()