Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
356d741698eac9fd574b75b8be50d24479946b0a
[simgrid.git] / examples / python / exec-remote / exec-remote.py
1 # Copyright (c) 2018-2019. 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 *
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         exec = this_actor.exec_init(48.492e6)
19         exec.host = ginette
20         exec.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, fafard.load,
25                                                                                              ginette.load))
26         exec.wait()
27         this_actor.info("Done!")
28
29         this_actor.info("And now, harder. Start a remote task on Ginette and move it to Boivin after 0.5 sec")
30         exec = this_actor.exec_init(73293500)
31         exec.host = ginette
32         exec.start()
33
34         this_actor.sleep_for(0.5)
35         this_actor.info(
36             "Loads before the move: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(
37                 boivin.load,
38                 fafard.load,
39                 ginette.load))
40
41         exec.host = boivin
42
43         this_actor.sleep_for(0.1)
44         this_actor.info(
45             "Loads after the move: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(
46                 boivin.load,
47                 fafard.load,
48                 ginette.load))
49
50         exec.wait()
51         this_actor.info("Done!")
52
53
54 if __name__ == '__main__':
55     e = Engine(sys.argv)
56
57     e.load_platform(sys.argv[1])
58
59     Actor.create("test", Host.by_name("Fafard"), Wizard())
60
61     e.run()