Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
activity.host = boivin
this_actor.sleep_for(0.1)
this_actor.info(
"Loads after the move: Boivin={:.0f}; Fafard={:.0f}; Ginette={:.0f}".format(
boivin.load,
fafard.load,
ginette.load))
activity.wait()
this_actor.info("Done!")
if __name__ == '__main__':
e = Engine(sys.argv)
e.load_platform(sys.argv[1])
Actor.create("test", Host.by_name("Fafard"), Wizard())
e.run()
class Sleeper:
"""This actor just sleeps until termination"""
def __init__(self, *args):
# sys.exit(1); simgrid.info("Exiting now (done sleeping or got killed)."))
this_actor.on_exit(lambda: print("BAAA"))
def __call__(self):
this_actor.info("Hello! I go to sleep.")
this_actor.sleep_for(10)
this_actor.info("Done sleeping.")
if __name__ == '__main__':
e = Engine(sys.argv)
if len(sys.argv) < 2:
raise AssertionError(
"Usage: actor-lifetime.py platform_file actor-lifetime_d.xml [other parameters]")
e.load_platform(sys.argv[1]) # Load the platform description
e.register_actor("sleeper", Sleeper)
# Deploy the sleeper processes with explicit start/kill times
e.load_deployment(sys.argv[2])
e.run()
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))
if __name__ == '__main__':
e = Engine(sys.argv)
if len(sys.argv) < 2:
raise AssertionError("Usage: exec-dvfs.py platform_file [other parameters] (got {:d} params)".format(len(sys.argv)))
e.load_platform(sys.argv[1])
Actor.create("dvfs_test", Host.by_name("MyHost1"), Dvfs())
Actor.create("dvfs_test", Host.by_name("MyHost2"), Dvfs())
e.run()
def my_daemon():
"""The daemon, displaying a message every 3 seconds until all other processes stop"""
Actor.self().daemonize()
while True:
this_actor.info("Hello from the infinite loop")
this_actor.sleep_for(3.0)
this_actor.info(
"I will never reach that point: daemons are killed when regular processes are done")
if __name__ == '__main__':
e = Engine(sys.argv)
if len(sys.argv) < 2:
raise AssertionError(
"Usage: actor-daemon.py platform_file [other parameters]")
e.load_platform(sys.argv[1])
Actor.create("worker", Host.by_name("Boivin"), worker)
Actor.create("daemon", Host.by_name("Tremblay"), my_daemon)
e.run()
raise AssertionError("Actor receiver requires 1 parameter, but got {:d}".format(len(args)))
self.id = int(args[0])
def __call__(self):
# FIXME: It should be ok to initialize self.mbox from __init__, but it's currently failing on the OS X Jenkins slave.
self.mbox = Mailbox.by_name("receiver-{:d}".format(self.id))
this_actor.info("Wait for my first message")
while True:
received = self.mbox.get()
this_actor.info("I got a '{:s}'.".format(received))
if received == "finalize":
break # If it's a finalize message, we're done.
if __name__ == '__main__':
e = Engine(sys.argv)
e.load_platform(sys.argv[1]) # Load the platform description
# Register the classes representing the actors
e.register_actor("sender", Sender)
e.register_actor("receiver", Receiver)
e.load_deployment(sys.argv[2])
e.run()
if len(args) != 1: # Receiver actor expects 1 argument: its ID
raise AssertionError(
"Actor receiver requires 1 parameter, but got {:d}".format(len(args)))
self.mbox = Mailbox.by_name("receiver-{:s}".format(args[0]))
def __call__(self):
this_actor.info("Wait for my first message")
while True:
received = self.mbox.get()
this_actor.info("I got a '{:s}'.".format(received))
if received == "finalize":
break # If it's a finalize message, we're done.
if __name__ == '__main__':
e = Engine(sys.argv)
# Load the platform description
e.load_platform(sys.argv[1])
# Register the classes representing the actors
e.register_actor("sender", Sender)
e.register_actor("receiver", Receiver)
e.load_deployment(sys.argv[2])
e.run()
this_actor.info("Start sleeper")
actor = Actor.create("sleeper from master", Host.current(), sleeper)
this_actor.info("Waiting 4")
this_actor.sleep_for(4)
this_actor.info("Join the sleeper after its end (timeout 1)")
actor.join(1)
this_actor.info("Goodbye now!")
this_actor.sleep_for(1)
this_actor.info("Goodbye now!")
if __name__ == '__main__':
e = Engine(sys.argv)
if len(sys.argv) < 2:
raise AssertionError(
"Usage: actor-join.py platform_file [other parameters]")
e.load_platform(sys.argv[1])
Actor.create("master", Host.by_name("Tremblay"), master)
e.run()
this_actor.info("Simulation time {}".format(Engine.get_clock()))