示例#1
0
    def __init__(self,
                 executable_finder,
                 host_name=None,
                 graph_label=None,
                 database_socket_addresses=None,
                 dsg_algorithm=None,
                 n_chips_required=None,
                 extra_pre_run_algorithms=None,
                 extra_post_run_algorithms=None,
                 time_scale_factor=None,
                 machine_time_step=None):

        global CONFIG_FILE_NAME, SPALLOC_CORES

        # dsg algorithm store for user defined algorithms
        self._user_dsg_algorithm = dsg_algorithm

        # create xml path for where to locate GFE related functions when
        # using auto pause and resume
        extra_xml_path = list()

        front_end_versions = [("SpiNNakerGraphFrontEnd", version)]

        AbstractSpinnakerBase.__init__(
            self,
            configfile=self.CONFIG_FILE_NAME,
            executable_finder=executable_finder,
            graph_label=graph_label,
            database_socket_addresses=database_socket_addresses,
            extra_algorithm_xml_paths=extra_xml_path,
            n_chips_required=n_chips_required,
            default_config_paths=[
                os.path.join(os.path.dirname(__file__), self.CONFIG_FILE_NAME)
            ],
            validation_cfg=os.path.join(os.path.dirname(__file__),
                                        self.VALIDATION_CONFIG_NAME),
            front_end_versions=front_end_versions)

        extra_mapping_inputs = dict()
        extra_mapping_inputs["CreateAtomToEventIdMapping"] = self.config.\
            getboolean("Database", "create_routing_info_to_atom_id_mapping")

        self.update_extra_mapping_inputs(extra_mapping_inputs)
        self.prepend_extra_pre_run_algorithms(extra_pre_run_algorithms)
        self.extend_extra_post_run_algorithms(extra_post_run_algorithms)

        if n_chips_required is None and _is_allocated_machine(self.config):
            self.set_n_chips_required(SPALLOC_CORES)

        self.set_up_machine_specifics(host_name)
        self.set_up_timings(machine_time_step, time_scale_factor)

        # if not set at all, set to 1 for real time execution.
        if self._time_scale_factor is None:
            self._time_scale_factor = 1

        logger.info("Setting time scale factor to {}.".format(
            self._time_scale_factor))
        logger.info("Setting machine time step to {} micro-seconds.".format(
            self._machine_time_step))
示例#2
0
    def run(self, run_time):

        # set up the correct dsg algorithm
        if self._user_dsg_algorithm is not None:
            self.dsg_algorithm = self._user_dsg_algorithm

        # run normal procedure
        AbstractSpinnakerBase.run(self, run_time)
示例#3
0
    def reset(self):
        """ Reset the state of the current network to time t = 0.
        """
        for population in self._populations:
            population._cache_data()

        self.__segment_counter += 1

        # Call superclass implementation
        AbstractSpinnakerBase.reset(self)
示例#4
0
    def run(self, run_time):
        """ Run a simulation for a fixed amount of time

        :param run_time: the run duration in milliseconds.
        """
        # set up the correct DSG algorithm
        if self._user_dsg_algorithm is not None:
            self.dsg_algorithm = self._user_dsg_algorithm

        # run normal procedure
        AbstractSpinnakerBase.run(self, run_time)
示例#5
0
    def _do_delayed_compression(self, name, compressed):
        if name == "SpynnakerMachineBitFieldOrderedCoveringCompressor":
            return self._execute_spynnaker_ordered_covering_compressor()

        if name == "SpynnakerMachineBitFieldPairRouterCompressor":
            return self._execute_spynnaker_pair_compressor()

        return AbstractSpinnakerBase._do_delayed_compression(
            self, name, compressed)
 def test_stop_init(self):
     class_file = sys.modules[self.__module__].__file__
     path = os.path.dirname(os.path.abspath(class_file))
     os.chdir(path)
     interface = AbstractSpinnakerBase(base.CONFIG_FILE, ExecutableFinder())
     mock_contoller = Close_Once()
     interface._machine_allocation_controller = mock_contoller
     self.assertFalse(mock_contoller.closed)
     interface.stop(turn_off_machine=False, clear_routing_tables=False,
                    clear_tags=False)
     self.assertTrue(mock_contoller.closed)
     interface.stop(turn_off_machine=False, clear_routing_tables=False,
                    clear_tags=False)
 def test_stop_init(self):
     class_file = sys.modules[self.__module__].__file__
     path = os.path.dirname(os.path.abspath(class_file))
     os.chdir(path)
     interface = AbstractSpinnakerBase(
         config_handler.CONFIG_FILE, ExecutableFinder())
     mock_contoller = Close_Once()
     interface._machine_allocation_controller = mock_contoller
     self.assertFalse(mock_contoller.closed)
     interface.stop(turn_off_machine=False, clear_routing_tables=False,
                    clear_tags=False)
     self.assertTrue(mock_contoller.closed)
     with self.assertRaises(ConfigurationException):
         interface.stop(turn_off_machine=False, clear_routing_tables=False,
                        clear_tags=False)
 def test_min_init(self):
     class_file = sys.modules[self.__module__].__file__
     path = os.path.dirname(os.path.abspath(class_file))
     os.chdir(path)
     print(path)
     AbstractSpinnakerBase(CONFIG_FILE, ExecutableFinder())
    def add_application_vertex(self, vertex):
        if isinstance(vertex, CommandSender):
            self._command_sender = vertex

        AbstractSpinnakerBase.add_application_vertex(self, vertex)
示例#10
0
 def _do_provenance_reports(self):
     AbstractSpinnakerBase._do_provenance_reports(self)
     self._report_redundant_packet_count()
    def add_application_vertex(self, vertex_to_add):
        if isinstance(vertex_to_add, CommandSender):
            self._command_sender = vertex_to_add

        AbstractSpinnakerBase.add_application_vertex(self, vertex_to_add)
 def __init__(self, machine_time_step=None, time_scale_factor=None):
     AbstractSpinnakerBase.__init__(
         self, base.CONFIG_FILE, ExecutableFinder())
     self.set_up_timings(machine_time_step, time_scale_factor)