Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fa001b93974272c74b700abac2d7949a941e18df
[simgrid.git] / examples / python / exec-basic / exec-basic.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 def executor():
11     # execute() tells SimGrid to pause the calling actor until
12     # its host has computed the amount of flops passed as a parameter
13     this_actor.execute(98095)
14     this_actor.info("Done.")
15     # This simple example does not do anything beyond that
16
17
18 def privileged():
19     # You can also specify the priority of your execution as follows.
20     # An execution of priority 2 computes twice as fast as a regular one.
21     #
22     # So instead of a half/half sharing between the two executions,
23     # we get a 1/3 vs 2/3 sharing.
24     this_actor.execute(98095, priority=2)
25     this_actor.info("Done.")
26
27     # Note that the timings printed when executing this example are a bit misleading,
28     # because the uneven sharing only last until the privileged actor ends.
29     # After this point, the unprivileged one gets 100% of the CPU and finishes
30     # quite quickly.
31
32
33 i = 0
34 if "--" in sys.argv:
35     i = sys.argv.index("--")
36 e = Engine(sys.argv[0:i])
37 e.load_platform(sys.argv[i+1])
38
39 Actor.create("executor", Host.by_name("Tremblay"), executor)
40 Actor.create("privileged", Host.by_name("Tremblay"), privileged)
41
42 e.run()