def end_tick(self, epicurve_part): """Receive the end tick message.""" LOG.debug("MainActor: Received end_tick") self.epicurve_parts.append(epicurve_part) # Check if tick ended if len(self.epicurve_parts) < len(self.behav_ranks): return row = [sum(xs) for xs in zip(*self.epicurve_parts)] self.tick_epicurve.append(row) self.cur_tick += 1 self.epicurve_parts = [] # Check if sim should still be running if self.cur_tick < self.num_ticks: LOG.info("MainActor: Starting tick %d", self.cur_tick) for rank in self.behav_ranks: asys.ActorProxy(rank, BEHAV_AID).start_tick() return # Sim has now ended LOG.info("Writing epicurve to output file.") columns = get_config().disease_model.model_dict["states"] epi_df = pd.DataFrame(self.tick_epicurve, columns=columns) epi_df.to_csv(self.output_file, index=False) asys.stop()
def stop(self, end_time): self.end_time = end_time time_taken = self.end_time - self.start_time mps = self.num_messages / time_taken print("mps: %e" % mps) print("n: %d" % self.num_messages) print("runtime: %.3f" % (perf_counter() - self.prog_start)) xa.stop()
def verify(self, x, xinv): prod = np.dot(x, xinv) eye = np.eye(x.shape[0]) assert np.allclose(prod, eye) self.i += 1 if self.i == self.n: runtime = perf_counter() - self._start_time print("runtime: %e" % runtime) xa.stop()
def pong(self): self.workers_done += 1 if self.workers_done == len(xa.ranks()): self.end = time() print("n_ranks: %d" % len(xa.ranks())) print("n_nodes: %d" % len(xa.nodes())) runtime = (self.end - self.start) print("runtime: %e" % runtime) xa.stop()
def main(self): # Create a greeter on very rank. greeter_id = "greeter" for rank in xa.ranks(): xa.create_actor(rank, greeter_id, Greeter) # Send the greeters the greet message. every_greeter = xa.ActorProxy(xa.EVERY_RANK, greeter_id) every_greeter.greet("world", send_immediate=True) # We are done now. xa.stop()
def maybe_stop(self): if self.num_consumer_done == len(xa.ranks()): self.end = time() print("n_sent: %d" % self.objects_sent) print("n_received: %d" % self.objects_received) print("n_ranks: %d" % len(xa.ranks())) print("n_nodes: %d" % len(xa.nodes())) runtime = (self.end - self.start) print("runtime: %e" % runtime) xa.stop()
def pong(self): time_taken = (perf_counter() - self.ping_start) / 2 self.timings.append(time_taken) if perf_counter() - self.prog_start > RUNTIME: print("mean: %e" % st.mean(self.timings)) print("variance: %e" % st.variance(self.timings)) print("max: %e" % max(self.timings)) print("min: %e" % min(self.timings)) print("n: %d" % len(self.timings)) print("runtime: %.3f" % (perf_counter() - self.prog_start)) xa.stop() return self.ping_start = perf_counter() self.worker.ping()
def _try_start_step(self, starting): if not starting: n_nodes = len(asys.nodes()) nsfd_str = [(name, num, n_nodes) for name, num in self.num_store_flush_done.items()] nsfd_str = ["%s=%d/%d" % tup for tup in nsfd_str] nsfd_str = ",".join(nsfd_str) LOG.log( INFO_FINE, "Can start step? (FCD=%s,%s)", self.flag_coordinator_done, nsfd_str, ) if not self.flag_coordinator_done: return for store_name in self.store_names: if self.num_store_flush_done[store_name] < n_nodes: return if not starting: self.round_end_time = perf_counter() self._write_summary() timestep_generator = asys.local_actor(self.timestep_generator_aid) self.timestep = timestep_generator.get_next_timestep() if self.timestep is None: LOG.info("Simulation finished.") asys.stop() return self.round_start_time = perf_counter() self.round_end_time = None LOG.info("Starting timestep %f", self.timestep.step) self.population_proxy.create_agents(self.timestep) self.coordinator_proxy.step(self.timestep) self.every_runner_proxy.step(self.timestep) self._prepare_for_next_step()