- if len(args) == 2:
- raise AssertionError(
- f"Actor master requires 4 parameters, but only {len(args)}")
- tasks_count = int(args[0])
- compute_cost = int(args[1])
- communicate_cost = int(args[2])
-
- this_actor.info(f"Got {tasks_count} tasks to process")
-
- hosts = Engine.instance().get_all_hosts()
-
- for h in hosts:
- Actor.create(f'Worker-{h.name}', h, worker)
-
- for i in range(tasks_count): # For each task to be executed:
- # - Select a worker in a round-robin way
- mailbox = Mailbox.by_name(f'Worker-{hosts[i%len(hosts)].name}')
-
- # - Send the computation amount to the worker
- if (tasks_count < 10000 or (tasks_count < 100000 and i % 10000 == 0) or i % 100000 == 0):
- this_actor.info(f"Sending task {i} of {tasks_count} to mailbox '{mailbox.name}'")
- mailbox.put(compute_cost, communicate_cost)
-
- this_actor.info("All tasks have been dispatched. Request all workers to stop.")
- for h in hosts:
- # The workers stop when receiving a negative compute_cost
- mailbox = Mailbox.by_name(f'Worker-{h.name}')
- mailbox.put(-1, 0)
+ if len(args) == 2:
+ raise AssertionError(f"Actor master requires 4 parameters, but only {len(args)}")
+ tasks_count = int(args[0])
+ compute_cost = int(args[1])
+ communicate_cost = int(args[2])
+
+ this_actor.info(f"Got {tasks_count} tasks to process")
+
+ hosts = Engine.instance().get_all_hosts()
+
+ for h in hosts:
+ Actor.create(f'Worker-{h.name}', h, worker)
+
+ for i in range(tasks_count): # For each task to be executed:
+ # - Select a worker in a round-robin way
+ mailbox = Mailbox.by_name(f'Worker-{hosts[i%len(hosts)].name}')
+
+ # - Send the computation amount to the worker
+ if (tasks_count < 10000 or (tasks_count < 100000 and i % 10000 == 0) or i % 100000 == 0):
+ this_actor.info(f"Sending task {i} of {tasks_count} to mailbox '{mailbox.name}'")
+ mailbox.put(compute_cost, communicate_cost)
+
+ this_actor.info("All tasks have been dispatched. Request all workers to stop.")
+ for h in hosts:
+ # The workers stop when receiving a negative compute_cost
+ mailbox = Mailbox.by_name(f'Worker-{h.name}')
+ mailbox.put(-1, 0)