def compress(self, register): """ Apply the on-machine compression algorithm. :param int register: number of user register to check """ # pylint: disable=too-many-arguments # build progress bar progress_bar = ProgressBar( len(self._routing_tables.routing_tables) * 2, self._progresses_text) self._compressor_app_id = self._transceiver.app_id_tracker.get_new_id() # figure size of SDRAM needed for each chip for storing the routing # table for routing_table in progress_bar.over(self._routing_tables, False): self._load_routing_table(routing_table) # load the router compressor executable executable_targets = self._load_executables() executable_finder = ExecutableFinder(binary_search_paths=[]) read_algorithm_iobuf = True run_system_application( executable_targets, self._compressor_app_id, self._transceiver, self._provenance_file_path, executable_finder, read_algorithm_iobuf, functools.partial( self._check_for_success, register=register), [CPUState.FINISHED], False, "compressor_on_{}_{}_{}.txt", [self._binary_path], progress_bar)
def __call__(self, placements, app_graph, executable_finder, transceiver, machine_graph, routing_infos): """ Loads and runs the bit field generator on chip. :param ~pacman.model.placements.Placements placements: placements :param ~pacman.model.graphs.application.ApplicationGraph app_graph: the app graph :param executable_finder: the executable finder :type executable_finder: ~spinn_front_end_common.utilities.utility_objs.ExecutableFinder :param ~spinnman.transceiver.Transceiver transceiver: the SpiNNMan instance :param ~pacman.model.graphs.machine.MachineGraph machine_graph: the machine graph :param ~pacman.model.routing_info.RoutingInfo routing_infos: the key to edge map """ self.__txrx = transceiver self.__placements = placements self.__aplx = executable_finder.get_executable_path( self._BIT_FIELD_EXPANDER_APLX) # progress bar progress = ProgressBar( app_graph.n_vertices + machine_graph.n_vertices + 1, "Running bitfield generation on chip") # get data expander_cores = self._calculate_core_data(app_graph, progress) # load data bit_field_app_id = transceiver.app_id_tracker.get_new_id() progress.update(1) # run app system_control_logic.run_system_application( expander_cores, bit_field_app_id, transceiver, executable_finder, get_config_bool("Reports", "write_bit_field_iobuf"), self.__check_for_success, [CPUState.FINISHED], False, "bit_field_expander_on_{}_{}_{}.txt", progress_bar=progress) # update progress bar progress.end() # read in bit fields for debugging purposes if get_config_bool("Reports", "generate_bit_field_report"): self._full_report_bit_fields( app_graph, os.path.join(report_default_directory(), self._BIT_FIELD_REPORT_FILENAME)) self._summary_report_bit_fields( app_graph, os.path.join(report_default_directory(), self._BIT_FIELD_SUMMARY_REPORT_FILENAME))
def _rerun_synaptic_cores(synaptic_expander_rerun_cores, transceiver, provenance_file_path, executable_finder, needs_sync_barrier, read_expander_iobuf): """ reruns the synaptic expander :param synaptic_expander_rerun_cores: the cores to rerun the synaptic / matrix generator for :param transceiver: spinnman instance :param provenance_file_path: prov file path :param executable_finder: finder of binary file paths :param read_expander_iobuf: bool for reading off iobuf if needed :rtype: None """ if synaptic_expander_rerun_cores.total_processors != 0: logger.info("rerunning synaptic expander") expander_app_id = transceiver.app_id_tracker.get_new_id() system_control_logic.run_system_application( synaptic_expander_rerun_cores, expander_app_id, transceiver, provenance_file_path, executable_finder, read_expander_iobuf, None, [CPUState.FINISHED], needs_sync_barrier, "rerun_of_synaptic_expander_on_{}_{}_{}.txt")
def _rerun_synaptic_cores( synaptic_expander_rerun_cores, transceiver, executable_finder, needs_sync_barrier, read_expander_iobuf): """ reruns the synaptic expander :param ~.ExecutableTargets synaptic_expander_rerun_cores: the cores to rerun the synaptic matrix generator for :param ~.Transceiver transceiver: spinnman instance :param ~.ExecutableFinder executable_finder: finder of binary file paths :param bool needs_sync_barrier: :param bool read_expander_iobuf: whether to read off iobuf if needed """ if synaptic_expander_rerun_cores.total_processors: logger.info("rerunning synaptic expander") expander_app_id = transceiver.app_id_tracker.get_new_id() run_system_application( synaptic_expander_rerun_cores, expander_app_id, transceiver, executable_finder, read_expander_iobuf, None, [CPUState.FINISHED], needs_sync_barrier, _RERUN_IOBUF_NAME_PATTERN)
def synapse_expander(placements, transceiver, executable_finder, extract_iobuf): """ Run the synapse expander. .. note:: Needs to be done after data has been loaded. :param ~pacman.model.placements.Placements placements: Where all vertices are on the machine. :param ~spinnman.transceiver.Transceiver transceiver: How to talk to the machine. :param executable_finder: How to find the synapse expander binaries. :param bool extract_iobuf: flag for extracting iobuf :type executable_finder: ~spinn_utilities.executable_finder.ExecutableFinder """ synapse_bin = executable_finder.get_executable_path(SYNAPSE_EXPANDER_APLX) delay_bin = executable_finder.get_executable_path(DELAY_EXPANDER_APLX) # Find the places where the synapse expander and delay receivers should run expander_cores, expanded_pop_vertices = _plan_expansion( placements, synapse_bin, delay_bin, transceiver) progress = ProgressBar(expander_cores.total_processors, "Expanding Synapses") expander_app_id = transceiver.app_id_tracker.get_new_id() run_system_application(expander_cores, expander_app_id, transceiver, executable_finder, extract_iobuf, None, [CPUState.FINISHED], False, "synapse_expander_on_{}_{}_{}.txt", progress_bar=progress, logger=logger) progress.end() _fill_in_connection_data(expanded_pop_vertices, transceiver)
def synapse_expander(app_graph, placements, transceiver, provenance_file_path, executable_finder, extract_iobuf): """ Run the synapse expander. .. note:: Needs to be done after data has been loaded. :param ~pacman.model.graphs.application.ApplicationGraph app_graph: The graph containing the vertices that might need expanding. :param ~pacman.model.placements.Placements placements: Where all vertices are on the machine. :param ~spinnman.transceiver.Transceiver transceiver: How to talk to the machine. :param str provenance_file_path: Where provenance data should be written. :param executable_finder: How to find the synapse expander binaries. :param extract_iobuf: bool flag for extracting iobuf :type executable_finder: ~spinn_utilities.executable_finder.ExecutableFinder """ synapse_bin = executable_finder.get_executable_path(SYNAPSE_EXPANDER) delay_bin = executable_finder.get_executable_path(DELAY_EXPANDER) progress = ProgressBar(len(app_graph.vertices) + 2, "Expanding Synapses") # Find the places where the synapse expander and delay receivers should run expander_cores, expanded_pop_vertices = _plan_expansion( app_graph, placements, synapse_bin, delay_bin, progress) expander_app_id = transceiver.app_id_tracker.get_new_id() run_system_application( expander_cores, expander_app_id, transceiver, provenance_file_path, executable_finder, extract_iobuf, functools.partial(_fill_in_connection_data, placements=placements, expanded_pop_vertices=expanded_pop_vertices), [CPUState.FINISHED], False, "synapse_expander_on_{}_{}_{}.txt")
def __call__(self, placements, app_graph, executable_finder, provenance_file_path, transceiver, read_bit_field_generator_iobuf, generating_bitfield_report, default_report_folder, machine_graph, routing_infos, generating_bit_field_summary_report): """ loads and runs the bit field generator on chip :param placements: placements :param app_graph: the app graph :param executable_finder: the executable finder :param provenance_file_path: the path to where provenance data items\ is written :param transceiver: the SpiNNMan instance :param read_bit_field_generator_iobuf: bool flag for report :param generating_bitfield_report: bool flag for report :param default_report_folder: the file path for reports :param machine_graph: the machine graph :param routing_infos: the key to edge map :param generating_bit_field_summary_report: bool flag for making \ summary report :rtype: None """ # progress bar progress = ProgressBar( len(app_graph.vertices) * 2 + 1, "Running bitfield generation on chip") # get data expander_cores = self._calculate_core_data(app_graph, placements, progress, executable_finder, transceiver) # load data bit_field_app_id = transceiver.app_id_tracker.get_new_id() progress.update(1) # run app system_control_logic.run_system_application( expander_cores, bit_field_app_id, transceiver, provenance_file_path, executable_finder, read_bit_field_generator_iobuf, self._check_for_success, [CPUState.FINISHED], False, "bit_field_expander_on_{}_{}_{}.txt", progress_bar=progress) # update progress bar progress.end() # read in bit fields for debugging purposes if generating_bitfield_report: self._read_back_bit_fields(app_graph, transceiver, placements, default_report_folder, self._BIT_FIELD_REPORT_FILENAME) if generating_bit_field_summary_report: self._read_back_and_summarise_bit_fields( app_graph, transceiver, placements, default_report_folder, self._BIT_FIELD_SUMMARY_REPORT_FILENAME)
def __call__( self, routing_tables, transceiver, machine, app_id, provenance_file_path, machine_graph, placements, executable_finder, read_algorithm_iobuf, produce_report, default_report_folder, target_length, routing_infos, time_to_try_for_each_iteration, use_timer_cut_off, machine_time_step, time_scale_factor, threshold_percentage, executable_targets, compress_as_much_as_possible=False, provenance_data_objects=None): """ entrance for routing table compression with bit field :param ~.MulticastRoutingTables routing_tables: :param ~.Transceiver transceiver: :param ~.Machine machine: :param int app_id: :param str provenance_file_path: :param ~.MachineGraph machine_graph: :param ~.Placements placements: :param ~.ExecutableFinder executable_finder: :param bool read_algorithm_iobuf: :param bool produce_report: :param str default_report_folder: :param bool use_timer_cut_off: :param int machine_time_step: :param int time_scale_factor: :param int threshold_percentage: :param ExecutableTargets executable_targets: :param bool compress_as_much_as_possible: :param list(ProvenanceDataItem) provenance_data_objects: :rtype: tuple(ExecutableTargets,list(ProvenanceDataItem)) """ # build provenance data objects if provenance_data_objects is not None: prov_items = provenance_data_objects else: prov_items = list() if len(routing_tables.routing_tables) == 0: return ExecutableTargets(), prov_items # new app id for this simulation routing_table_compressor_app_id = \ transceiver.app_id_tracker.get_new_id() progress_bar = ProgressBar( total_number_of_things_to_do=( len(machine_graph.vertices) + (len(routing_tables.routing_tables) * self.TIMES_CYCLED_ROUTING_TABLES)), string_describing_what_being_progressed=self._PROGRESS_BAR_TEXT) # locate data and on_chip_cores to load binary on (addresses, matrix_addresses_and_size) = self._generate_addresses( machine_graph, placements, transceiver, progress_bar) # create executable targets (compressor_executable_targets, bit_field_sorter_executable_path, bit_field_compressor_executable_path) = self._generate_core_subsets( routing_tables, executable_finder, machine, progress_bar, executable_targets) # load data into sdram on_host_chips = self._load_data( addresses, transceiver, routing_table_compressor_app_id, routing_tables, app_id, machine, compress_as_much_as_possible, progress_bar, compressor_executable_targets, matrix_addresses_and_size, time_to_try_for_each_iteration, bit_field_compressor_executable_path, bit_field_sorter_executable_path, threshold_percentage) # load and run binaries system_control_logic.run_system_application( compressor_executable_targets, routing_table_compressor_app_id, transceiver, provenance_file_path, executable_finder, read_algorithm_iobuf, functools.partial( self._check_bit_field_router_compressor_for_success, host_chips=on_host_chips, sorter_binary_path=bit_field_sorter_executable_path, prov_data_items=prov_items), [CPUState.FINISHED], True, "bit_field_compressor_on_{}_{}_{}.txt", [bit_field_sorter_executable_path], progress_bar) # start the host side compressions if needed if len(on_host_chips) != 0: logger.warning(self._ON_HOST_WARNING_MESSAGE, len(on_host_chips)) progress_bar = ProgressBar( total_number_of_things_to_do=len(on_host_chips), string_describing_what_being_progressed=self._HOST_BAR_TEXT) host_compressor = HostBasedBitFieldRouterCompressor() compressed_pacman_router_tables = MulticastRoutingTables() key_atom_map = host_compressor.generate_key_to_atom_map( machine_graph, routing_infos) for (chip_x, chip_y) in progress_bar.over(on_host_chips, False): bit_field_sdram_base_addresses = defaultdict(dict) host_compressor.collect_bit_field_sdram_base_addresses( chip_x, chip_y, machine, placements, transceiver, bit_field_sdram_base_addresses) host_compressor.start_compression_selection_process( router_table=routing_tables.get_routing_table_for_chip( chip_x, chip_y), produce_report=produce_report, report_folder_path=host_compressor.generate_report_path( default_report_folder), bit_field_sdram_base_addresses=( bit_field_sdram_base_addresses), transceiver=transceiver, machine_graph=machine_graph, placements=placements, machine=machine, target_length=target_length, time_to_try_for_each_iteration=( time_to_try_for_each_iteration), use_timer_cut_off=use_timer_cut_off, compressed_pacman_router_tables=( compressed_pacman_router_tables), key_atom_map=key_atom_map) # load host compressed routing tables for table in compressed_pacman_router_tables.routing_tables: if (not machine.get_chip_at(table.x, table.y).virtual and table.multicast_routing_entries): transceiver.clear_multicast_routes(table.x, table.y) transceiver.load_multicast_routes( table.x, table.y, table.multicast_routing_entries, app_id=app_id) progress_bar.end() return compressor_executable_targets, prov_items