def run(self): print("==== Checking hosts on ====") # Here we can block by online workers (only run if haver 4 workers), # but we can work with less then 4 workers, and in my test, I have only 1. num_hosts = self._get_hosts_on(1) print("Hosts ON: %d" % num_hosts) print("==== Creating random matrices ====") self.matrix_a = self._get_random_matrix(self.a_n, self.a_m) self.matrix_b = self._get_random_matrix(self.b_n, self.b_m) print("==== Created Matrices: ====") self._print_two_matrices(self.matrix_a, self.matrix_b) self.matrix_divide() distributor = Distributor("*", "50010") collector = Collector("*", "50012", 5000) distributor.send_jobs(self._create_jobs()) # For test, check services in rasp's self._check_services(1) results = collector.collect(4) if 'err' in results: print("Error in some RasPI: %s" % results['err']) exit() print("==== Appending matrices ====") C1 = self._matrix_sum(results['A1B1'], results['A2B2']) C2 = self._matrix_sum(results['A3B1'], results['A4B2']) C = C1 + C2 print("==== Final result: ====") self._print_matrix(C)
def end_all(self): distributor = Distributor("*", "50010") distributor.send_jobs([{'id': 0}])