def execute_msr(init_goals, rule_classes, use_mpi=True): if not use_mpi: logger = init_logger("msr", log_file="msr.log") log_info(logger,"Started") rewrite_loop(rule_classes, init_goals, logger, (lambda: lambda: None), (lambda _: None), (lambda x: None), None ) log_info(logger,"Shutting Down!") else: comm = MPI.COMM_WORLD rank = comm.Get_rank() # Check rules for dynamic spawning pattern. allow_dynamic_spawning = False for rule_class in rule_classes: rule = rule_class() if rule.req_dynamic_spawning: allow_dynamic_spawning = True break if allow_dynamic_spawning: mp = MSRMasterProcess(rank, init_goals, rule_classes, file_logging=True, output_file="output.log") mp.start() else: logger = init_logger("rank_%s" % rank, log_file="rank_%s.log" % rank) output_logger = init_logger("output", log_file="output.log") log_info(logger,"Started") init_goals = filter_goals_by_rank(init_goals, rank) rewrite_loop(rule_classes, init_goals, logger, receive_fact_future_mpi, send_facts, lambda x: None, lift(loc(rank)), output_logger=output_logger) log_info(logger,"Shutting Down!")
def __init__(self, rank, proc_id, worker_channel, master_channel, init_goals, rule_classes, file_logging=False, output_logger=None): self.initialize(rank, proc_id, worker_channel, master_channel, file_logging=file_logging) self.init_goals = init_goals self.rule_classes = rule_classes self.location = lift( loc(rank, proc_id) ) self.output_logger = output_logger