Esempio n. 1
0
 def process_run_result(self, result):
     result = result.split()
     if result[0] == "CALL":
         if self.handle_call(result[1], result[2:]):
             return False
         else:
             self.run()
             return True
     if result[0] == "PROFILE":
         self.process_profile(result)
         result = self.controller.receive_line()
         return self.process_run_result(result)
     if result[0] == "SYSCALL":
         return_value = self.process_syscall(result)
         if return_value is None:
             self.run()
         else:
             #if self.gcontext.worker.stats_time is not None:
             #    self.gcontext.worker.record_process_start(self.state.pid)
             self.controller.run_drop_syscall_async(return_value)
         return True
     if result[0] == "EXIT":
         exitcode = convert_type(result[1], "int")
         e = event.ExitEvent(self.state.pid, exitcode)
         self.gcontext.add_event(e)
         self.state.set_finished()
         if exitcode != 0:
             self.add_error_and_throw(
                 errormsg.NonzeroExitCode(self, exitcode=exitcode))
         self.state.allocations = self.get_allocations()
         return False
     if result[0] == "REPORT":
         self.add_error_and_throw(
             self.make_error_message_from_report(result))
     raise Exception("Invalid command " + result[0])
Esempio n. 2
0
 def make_conversion(cls, value, arg_position, context):
     return cls.convert(convert_type(value, cls.c_type),
                        arg_position, context)
Esempio n. 3
0
    def initial_run(self, first_worker=True):
        controller = self.gcontext.worker.get_controller(self.state.pid)
        controller.context = self
        self.controller = controller
        result = controller.receive_line()
        if result is None:
            return False

        while True:
            result = result.split()
            if result[0] == "CALL":
                if not first_worker:
                    return True
                if result[1] == "MPI_Initialized":
                    assert len(result) == 3
                    ptr = convert_type(result[2], "ptr")
                    controller.write_int(ptr, 0)
                    result = self.run_sync()
                    continue
                elif result[1] != "MPI_Init":
                    e = errormsg.NoMpiInit(self)
                    self.add_error_and_throw(e)
                break
            elif result[0] == "PROFILE":
                if first_worker:
                    self.process_profile(result)
                result = controller.receive_line()
                continue
            elif result[0] == "EXIT":
                if not first_worker:
                    return True
                exitcode = convert_type(result[1], "int")
                if exitcode != 0:
                    e = errormsg.NonzeroExitCode(self, exitcode=exitcode)
                    self.add_error_and_throw(e)
                    return True
                else:
                    e = errormsg.NoMpiCall(self)
                    self.add_error_and_throw(e)
                return True
            elif result[0] == "REPORT":
                if not first_worker:
                    return False
                e = self.make_error_message_from_report(result)
                self.add_error_and_throw(e)
                return True
            elif result[0] == "SYSCALL":
                return_value = self.process_syscall(result)
                if return_value is None:
                    result = self.run_sync()
                else:
                    #if self.gcontext.worker.stats_time is not None:
                    #    self.gcontext.worker.record_process_start(self.state.pid)
                    result = controller.run_drop_syscall(return_value)
                    #if self.gcontext.worker.stats_time is not None:
                    #    self.gcontext.worker.record_process_stop(self.state.pid)
            else:
                assert 0, "Invalid reposponse " + repr(result)

        # FIXME: Consts pool
        self.gcontext.generator.consts_pool = convert_type(result[4], "ptr")
        controller.write_int(self.gcontext.generator.get_const_ptr(
            consts.MPI_TAG_UB), 0xFFFF)
        function_ptrs = result[5:]  # skip CALL MPI_Init argc argv consts_pool

        # The order of the ops is important,
        # because it has to be synchronous with code in MPI_Init
        operations = [consts.MPI_SUM,
                      consts.MPI_PROD,
                      consts.MPI_MIN,
                      consts.MPI_MAX,
                      consts.MPI_LAND,
                      consts.MPI_LOR,
                      consts.MPI_BAND,
                      consts.MPI_BOR,
                      consts.MPI_MINLOC,
                      consts.MPI_MAXLOC]

        assert len(function_ptrs) == len(ops.buildin_operations)
        assert len(function_ptrs) == len(operations)

        for ptr, op_id in zip(function_ptrs, operations):
            ops.buildin_operations[op_id].fn_ptr = ptr
        return True