Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def victim_a_fun():
this_actor.on_exit(lambda: this_actor.info("I have been killed!"))
this_actor.info("Hello!")
this_actor.info("Suspending myself")
this_actor.suspend() # - Start by suspending itself
# - Then is resumed and start to execute a task
this_actor.info("OK, OK. Let's work")
this_actor.execute(1e9)
# - But will never reach the end of it
this_actor.info("Bye!")
def worker():
"""The worker process, working for a while before leaving"""
this_actor.info("Let's do some work (for 10 sec on Boivin).")
this_actor.execute(980.95e6)
this_actor.info("I'm done now. I leave even if it makes the daemon die.")
def executor():
# execute() tells SimGrid to pause the calling actor until
# its host has computed the amount of flops passed as a parameter
this_actor.execute(98095)
this_actor.info("Done.")
# This simple example does not do anything beyond that
"""The Lazy guy only wants to sleep, but can be awaken by the dream_master process"""
this_actor.info("Nobody's watching me ? Let's go to sleep.")
this_actor.suspend() # - Start by suspending itself
this_actor.info("Uuuh ? Did somebody call me ?")
# - Then repetitively go to sleep, but get awaken
this_actor.info("Going to sleep...")
this_actor.sleep_for(10)
this_actor.info("Mmm... waking up.")
this_actor.info("Going to sleep one more time (for 10 sec)...")
this_actor.sleep_for(10)
this_actor.info("Waking up once for all!")
this_actor.info("Ok, let's do some work, then (for 10 sec on Boivin).")
this_actor.execute(980.95e6)
this_actor.info("Mmmh, I'm done now. Goodbye.")
def __call__(self):
workload = 100E6
host = this_actor.get_host()
nb = host.get_pstate_count()
this_actor.info("Count of Processor states={:d}".format(nb))
this_actor.info("Current power peak={:f}".format(host.speed))
# Run a task
this_actor.execute(workload)
task_time = Engine.get_clock()
this_actor.info("Task1 duration: {:.2f}".format(task_time))
# Change power peak
new_pstate = 2
this_actor.info("Changing power peak value to {:f} (at index {:d})".format( host.get_pstate_speed(new_pstate), new_pstate))
host.pstate = new_pstate
this_actor.info("Current power peak={:f}".format(host.speed))
# Run a second task
this_actor.execute(workload)
this_actor.execute(workload)
task_time = Engine.get_clock()
this_actor.info("Task1 duration: {:.2f}".format(task_time))
# Change power peak
new_pstate = 2
this_actor.info("Changing power peak value to {:f} (at index {:d})".format( host.get_pstate_speed(new_pstate), new_pstate))
host.pstate = new_pstate
this_actor.info("Current power peak={:f}".format(host.speed))
# Run a second task
this_actor.execute(workload)
task_time = Engine.get_clock() - task_time
this_actor.info("Task2 duration: {:.2f}".format(task_time))
# Verify that the default pstate is set to 0
host2 = Host.by_name("MyHost2")
this_actor.info("Count of Processor states={:d}".format(host2.get_pstate_count()))
this_actor.info("Current power peak={:f}".format(host2.speed))
def privileged():
# You can also specify the priority of your execution as follows.
# An execution of priority 2 computes twice as fast as a regular one.
#
# So instead of a half/half sharing between the two executions,
# we get a 1/3 vs 2/3 sharing.
this_actor.execute(98095, priority=2)
this_actor.info("Done.")