def worker(first_host, second_host): flop_amount = first_host.speed * 5 + second_host.speed * 5 this_actor.info("Let's move to {:s} to execute {:.2f} Mflops (5sec on {:s} and 5sec on {:s})".format( first_host.name, flop_amount / 1e6, first_host.name, second_host.name)) this_actor.set_host(first_host) this_actor.execute(flop_amount) this_actor.info("I wake up on {:s}. Let's suspend a bit".format( this_actor.get_host().name)) this_actor.suspend() this_actor.info("I wake up on {:s}".format(this_actor.get_host().name)) this_actor.info("Done")
def __call__(self): computation_amount = this_actor.get_host().speed this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount)) activity = this_actor.exec_init(computation_amount) activity.start() activity.wait() this_actor.info("Goodbye now!")
def __call__(self): computation_amount = this_actor.get_host().speed this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount)) activity = this_actor.exec_init(computation_amount).start() this_actor.sleep_for(0.5) this_actor.info("I changed my mind, cancel!") activity.cancel() this_actor.info("Goodbye now!")
def __call__(self): this_actor.execute(1e9) for disk in Host.current().get_disks(): this_actor.info("Using disk " + disk.name) disk.read(10000) disk.write(10000) mbox = Mailbox.by_name(this_actor.get_host().name) msg = mbox.get() this_actor.info("I got '%s'." % msg) this_actor.info("Finished executing. Goodbye!")
def __call__(self): for host in self.hosts: mbox = Mailbox.by_name(host.name) msg = "Hello. I'm " + str(this_actor.get_host().name) size = int(1e6) this_actor.info("Sending msg to " + host.name) mbox.put(msg, size) this_actor.info("Done dispatching all messages. Goodbye!")
def __call__(self): computation_amount = this_actor.get_host().speed this_actor.info("Execute {:.0f} flops, should take 1 second.".format(computation_amount)) activity = this_actor.exec_init(computation_amount).start() while not activity.test(): this_actor.info("Remaining amount of flops: {:.0f} ({:.0f}%)".format( activity.remaining, 100 * activity.remaining_ratio)) this_actor.sleep_for(0.3) activity.wait() this_actor.info("Goodbye now!")
def runner(): computation_amount = this_actor.get_host().speed n_task = 10 this_actor.info( "Execute %d tasks of %g flops, should take %d second in a CPU without degradation. It will take the double here." % (n_task, computation_amount, n_task)) tasks = [ this_actor.exec_init(computation_amount).start() for _ in range(n_task) ] this_actor.info("Waiting for all tasks to be done!") for task in tasks: task.wait() this_actor.info("Finished executing. Goodbye now!")
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("Changed 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("Final power peak={:f}".format(host2.speed))
def dream_master(): """The Dream master""" this_actor.info("Let's create a lazy guy.") # Create a lazy_guy process lazy = Actor.create("Lazy", this_actor.get_host(), lazy_guy) this_actor.info("Let's wait a little bit...") this_actor.sleep_for(10) # Wait for 10 seconds this_actor.info("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!") if lazy.is_suspended(): lazy.resume() # Then wake up the lazy_guy else: this_actor.error( "I was thinking that the lazy guy would be suspended now") this_actor.sleep_for(5) # Repeat two times: this_actor.info("Suspend the lazy guy while he's sleeping...") lazy.suspend() # Suspend the lazy_guy while he's asleep this_actor.info("Let him finish his siesta.") this_actor.sleep_for(10) # Wait for 10 seconds this_actor.info("Wake up, lazy guy!") lazy.resume() # Then wake up the lazy_guy again this_actor.sleep_for(5) this_actor.info("Suspend again the lazy guy while he's sleeping...") lazy.suspend() this_actor.info("This time, don't let him finish his siesta.") this_actor.sleep_for(2) this_actor.info("Wake up, lazy guy!") lazy.resume() this_actor.sleep_for(5) this_actor.info( "Give a 2 seconds break to the lazy guy while he's working...") lazy.suspend() this_actor.sleep_for(2) this_actor.info("Back to work, lazy guy!") lazy.resume() this_actor.info("OK, I'm done here.")