Beispiel #1
0
    def _locate_synaptic_expander_cores(cores, executable_finder, placements,
                                        machine):
        """ removes host based cores for synaptic matrix regeneration

        :param cores: the cores for everything
        :param executable_finder: way to get binary path
        :param machine: spiNNMachine instance.
        :return: new targets for synaptic expander
        """
        new_cores = ExecutableTargets()

        # locate expander executable path
        expander_executable_path = executable_finder.get_executable_path(
            SYNAPSE_EXPANDER)

        # if any ones are going to be ran on host, ignore them from the new
        # core setup
        for core_subset in cores.all_core_subsets:
            chip = machine.get_chip_at(core_subset.x, core_subset.y)
            for processor_id in range(0, chip.n_processors):
                if placements.is_processor_occupied(core_subset.x,
                                                    core_subset.y,
                                                    processor_id):
                    vertex = placements.get_vertex_on_processor(
                        core_subset.x, core_subset.y, processor_id)
                    app_vertex = vertex.app_vertex
                    if isinstance(vertex, AbstractSupportsBitFieldGeneration):
                        if app_vertex.gen_on_machine(vertex.vertex_slice):
                            new_cores.add_processor(
                                expander_executable_path,
                                core_subset.x,
                                core_subset.y,
                                processor_id,
                                executable_type=ExecutableType.SYSTEM)
        return new_cores
    def _load_executables(self):
        """ Loads the router compressor onto the chips.

        :return:
            the executable targets that represent all cores/chips which have
            active routing tables
        :rtype: ExecutableTargets
        """

        # build core subsets
        core_subsets = CoreSubsets()
        for routing_table in self._routing_tables:

            # get the first none monitor core
            chip = self._machine.get_chip_at(routing_table.x, routing_table.y)
            processor = chip.get_first_none_monitor_processor()

            # add to the core subsets
            core_subsets.add_processor(
                routing_table.x, routing_table.y, processor.processor_id)

        # build executable targets
        executable_targets = ExecutableTargets()
        executable_targets.add_subsets(self._binary_path, core_subsets,
                                       ExecutableType.SYSTEM)

        return executable_targets
def _locate_expander_rerun_targets(
        bitfield_targets, executable_finder, placements,
        transceiver):
    """ removes host based cores for synaptic matrix regeneration

    :param ~.ExecutableTargets bitfield_targets: the cores that were used
    :param ~.ExecutableFinder executable_finder: way to get binary path
    :param ~.Placements placements: placements on machine
    :param ~.Transceiver transceiver: spinnman instance
    :return: new targets for synaptic expander
    :rtype: ~.ExecutableTargets
    """

    # locate expander executable path
    expander_executable_path = executable_finder.get_executable_path(
        SYNAPSE_EXPANDER_APLX)

    # if any ones are going to be ran on host, ignore them from the new
    # core setup
    new_cores = ExecutableTargets()
    for placement in __machine_expandables(
            bitfield_targets.all_core_subsets, placements):
        new_cores.add_processor(
            expander_executable_path,
            placement.x, placement.y, placement.p,
            executable_type=ExecutableType.SYSTEM)
        # Write the region to USER1, as that is the best we can do
        write_address_to_user1(
            transceiver, placement.x, placement.y, placement.p,
            placement.vertex.connection_generator_region)
    return new_cores
    def _calculate_core_data(self, app_graph, placements, progress,
                             executable_finder, transceiver):
        """ gets the data needed for the bit field expander for the machine

        :param app_graph: app graph
        :param placements: placements
        :param progress: progress bar
        :param executable_finder: where to find the executable
        :param transceiver: spinnman instance
        :return: data and expander cores
        """

        # cores to place bitfield expander
        expander_cores = ExecutableTargets()

        # bit field expander executable file path
        bit_field_expander_path = executable_finder.get_executable_path(
            self._BIT_FIELD_EXPANDER_APLX)

        # locate verts which can have a synaptic matrix to begin with
        for app_vertex in progress.over(app_graph.vertices, False):
            for machine_vertex in app_vertex.machine_vertices:
                if (isinstance(machine_vertex,
                               AbstractSupportsBitFieldGeneration)):
                    self.__write_single_core_data(machine_vertex, placements,
                                                  transceiver,
                                                  bit_field_expander_path,
                                                  expander_cores)

        return expander_cores
def _plan_expansion(app_graph, placements, synapse_expander_bin,
                    delay_expander_bin, progress):
    expander_cores = ExecutableTargets()
    expanded_pop_vertices = list()

    for vertex in progress.over(app_graph.vertices, finish_at_end=False):
        # Add all machine vertices of the population vertex to ones
        # that need synapse expansion
        if isinstance(vertex, AbstractPopulationVertex):
            gen_on_machine = False
            for m_vertex in vertex.machine_vertices:
                if vertex.gen_on_machine(m_vertex.vertex_slice):
                    placement = placements.get_placement_of_vertex(m_vertex)
                    expander_cores.add_processor(
                        synapse_expander_bin,
                        placement.x,
                        placement.y,
                        placement.p,
                        executable_type=ExecutableType.SYSTEM)
                    gen_on_machine = True
            if gen_on_machine:
                expanded_pop_vertices.append(vertex)
        elif isinstance(vertex, DelayExtensionVertex):
            for m_vertex in vertex.machine_vertices:
                if vertex.gen_on_machine(m_vertex.vertex_slice):
                    placement = placements.get_placement_of_vertex(m_vertex)
                    expander_cores.add_processor(
                        delay_expander_bin,
                        placement.x,
                        placement.y,
                        placement.p,
                        executable_type=ExecutableType.SYSTEM)

    return expander_cores, expanded_pop_vertices
    def _load_executables(routing_tables, compressor_app_id, txrx, machine):
        """ Loads the router compressor onto the chips.

        :param routing_tables: the router tables needed to be compressed
        :param compressor_app_id: the app ID of the compressor compressor
        :param txrx: the spinnman interface
        :param machine: the SpiNNaker machine representation
        :return:\
            the executable targets that represent all cores/chips which have\
            active routing tables
        """

        # build core subsets
        core_subsets = CoreSubsets()
        for routing_table in routing_tables:

            # get the first none monitor core
            chip = machine.get_chip_at(routing_table.x, routing_table.y)
            processor = chip.get_first_none_monitor_processor()

            # add to the core subsets
            core_subsets.add_processor(
                routing_table.x, routing_table.y, processor.processor_id)

        # build executable targets
        executable_targets = ExecutableTargets()
        executable_targets.add_subsets(_BINARY_PATH, core_subsets)

        txrx.execute_application(executable_targets, compressor_app_id)
        return executable_targets
def synapse_expander(
        app_graph, graph_mapper, placements, transceiver,
        provenance_file_path, executable_finder):
    """ Run the synapse expander - needs to be done after data has been loaded
    """

    synapse_expander = executable_finder.get_executable_path(SYNAPSE_EXPANDER)
    delay_expander = 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 = ExecutableTargets()
    for vertex in progress.over(app_graph.vertices, finish_at_end=False):

        # Find population vertices
        if isinstance(
                vertex, (AbstractPopulationVertex, DelayExtensionVertex)):

            # Add all machine vertices of the population vertex to ones
            # that need synapse expansion
            for m_vertex in graph_mapper.get_machine_vertices(vertex):
                vertex_slice = graph_mapper.get_slice(m_vertex)
                if vertex.gen_on_machine(vertex_slice):
                    placement = placements.get_placement_of_vertex(m_vertex)
                    if isinstance(vertex, AbstractPopulationVertex):
                        binary = synapse_expander
                    else:
                        binary = delay_expander
                    expander_cores.add_processor(
                        binary, placement.x, placement.y, placement.p)

    # Launch the delay receivers
    expander_app_id = transceiver.app_id_tracker.get_new_id()
    transceiver.execute_application(expander_cores, expander_app_id)
    progress.update()

    # Wait for everything to finish
    finished = False
    try:
        transceiver.wait_for_cores_to_be_in_state(
            expander_cores.all_core_subsets, expander_app_id,
            [CPUState.FINISHED])
        progress.update()
        finished = True
        _extract_iobuf(expander_cores, transceiver, provenance_file_path)
        progress.end()
    except Exception:
        logger.exception("Synapse expander has failed")
        _handle_failure(
            expander_cores, transceiver, provenance_file_path)
    finally:
        transceiver.stop_application(expander_app_id)
        transceiver.app_id_tracker.free_id(expander_app_id)

        if not finished:
            raise SpynnakerException(
                "The synapse expander failed to complete")
Beispiel #8
0
 def test_front_end_common_load_executable_images(self):
     transceiver = _MockTransceiver(self)
     loader = LoadExecutableImages()
     targets = ExecutableTargets()
     targets.add_processor("test.aplx", 0, 0, 0, SIM)
     targets.add_processor("test.aplx", 0, 0, 1, SIM)
     targets.add_processor("test.aplx", 0, 0, 2, SIM)
     targets.add_processor("test2.aplx", 0, 1, 0, SIM)
     targets.add_processor("test2.aplx", 0, 1, 1, SIM)
     targets.add_processor("test2.aplx", 0, 1, 2, SIM)
     loader.load_app_images(targets, 30, transceiver)
Beispiel #9
0
 def test_front_end_common_load_executable_images(self):
     transceiver = _MockTransceiver(self)
     loader = LoadExecutableImages()
     targets = ExecutableTargets()
     targets.add_processor("test.aplx", 0, 0, 0)
     targets.add_processor("test.aplx", 0, 0, 1)
     targets.add_processor("test.aplx", 0, 0, 2)
     targets.add_processor("test2.aplx", 0, 1, 0)
     targets.add_processor("test2.aplx", 0, 1, 1)
     targets.add_processor("test2.aplx", 0, 1, 2)
     loader.__call__(targets, 30, transceiver, True)
Beispiel #10
0
 def filter_targets(targets, filt):
     """
     :param ExecutableTargets executable_targets:
     :param callable(ExecutableType,bool) filt:
     :rtype: tuple(list(str), ExecutableTargets)
     """
     binaries = []
     cores = ExecutableTargets()
     for exe_type in targets.executable_types_in_binary_set():
         if filt(exe_type):
             for aplx in targets.get_binaries_of_executable_type(exe_type):
                 binaries.append(aplx)
                 cores.add_subsets(
                     aplx, targets.get_cores_for_binary(aplx), exe_type)
     return binaries, cores
    def __call__(self, placements, graph, executable_finder):
        """
        :param ~.Placements placements:
        :param ~.MachineGraph graph:
        :param ExecutableFinder executable_finder:
        :rtype: ExecutableTargets
        """
        self._exe_finder = executable_finder
        self._exe_targets = ExecutableTargets()
        progress = ProgressBar(graph.n_vertices, "Finding binaries")
        for vertex in progress.over(graph.vertices):
            placement = placements.get_placement_of_vertex(vertex)
            self.__get_binary(placement, vertex)

        return self._exe_targets
    def __call__(
            self, placements, graph, executable_finder, graph_mapper=None):
        executable_targets = ExecutableTargets()
        progress = ProgressBar(graph.n_vertices, "Finding binaries")
        for vertex in progress.over(graph.vertices):
            placement = placements.get_placement_of_vertex(vertex)
            self._get_binary(
                placement, vertex, executable_targets, executable_finder)

            if graph_mapper is not None:
                associated_vertex = graph_mapper.get_application_vertex(vertex)
                self._get_binary(
                    placement, associated_vertex, executable_targets,
                    executable_finder)

        return executable_targets
Beispiel #13
0
def _plan_expansion(placements, synapse_expander_bin, delay_expander_bin,
                    transceiver):
    """ Plan the expansion of synapses and set up the regions using USER1

    :param ~pacman.model.placements.Placements: The placements of the vertices
    :param str synapse_expander_bin: The binary name of the synapse expander
    :param str delay_expander_bin: The binary name of the delay expander
    :param ~spinnman.transceiver.Transceiver transceiver:
        How to talk to the machine
    :return: The places to load the synapse expander and delay expander
        executables, and the target machine vertices to read synapses back from
    :rtype: (ExecutableTargets, list(MachineVertex, Placement))
    """
    expander_cores = ExecutableTargets()
    expanded_pop_vertices = list()

    progress = ProgressBar(len(placements), "Preparing to Expand Synapses")
    for placement in progress.over(placements):
        # Add all machine vertices of the population vertex to ones
        # that need synapse expansion
        vertex = placement.vertex
        if isinstance(vertex, AbstractSynapseExpandable):
            if vertex.gen_on_machine():
                expander_cores.add_processor(
                    synapse_expander_bin,
                    placement.x,
                    placement.y,
                    placement.p,
                    executable_type=ExecutableType.SYSTEM)
                expanded_pop_vertices.append((vertex, placement))
                # Write the region to USER1, as that is the best we can do
                write_address_to_user1(transceiver, placement.x, placement.y,
                                       placement.p,
                                       vertex.connection_generator_region)

        elif isinstance(vertex, DelayExtensionMachineVertex):
            if vertex.gen_on_machine():
                expander_cores.add_processor(
                    delay_expander_bin,
                    placement.x,
                    placement.y,
                    placement.p,
                    executable_type=ExecutableType.SYSTEM)

    return expander_cores, expanded_pop_vertices
Beispiel #14
0
    def _calculate_core_data(self, app_graph, progress):
        """ gets the data needed for the bit field expander for the machine

        :param ~.ApplicationGraph app_graph: app graph
        :param ~.ProgressBar progress: progress bar
        :return: data and expander cores
        :rtype: ~.ExecutableTargets
        """
        # cores to place bitfield expander
        expander_cores = ExecutableTargets()

        # bit field expander executable file path
        # locate verts which can have a synaptic matrix to begin with
        for app_vertex in progress.over(app_graph.vertices, False):
            for placement in self.__bitfield_placements(app_vertex):
                self.__write_single_core_data(placement, expander_cores)

        return expander_cores
Beispiel #15
0
    def _load_executables(self, routing_tables, compressor_app_id, transceiver,
                          machine):
        """ loads the router compressor onto the chips.

        :param routing_tables: the router tables needed to be compressed
        :param compressor_app_id: the app id of the compressor compressor
        :param transceiver: the spinnman interface
        :param machine: the spinnaker machine representation
        :return:\
            the executable targets that represent all cores/chips which have\
            active routing tables
        """

        # build core subsets
        core_subsets = CoreSubsets()
        for routing_table in routing_tables:

            # get the first none monitor core
            chip = machine.get_chip_at(routing_table.x, routing_table.y)
            processor = chip.get_first_none_monitor_processor()

            # add to the core subsets
            core_subsets.add_processor(routing_table.x, routing_table.y,
                                       processor.processor_id)

        # build binary path
        binary_path = os.path.join(
            os.path.dirname(on_chip_router_table_compression.__file__),
            "rt_minimise.aplx")

        # build executable targets
        executable_targets = ExecutableTargets()
        executable_targets.add_subsets(binary_path, core_subsets)

        transceiver.execute_application(executable_targets, compressor_app_id)
        return executable_targets
def run_system_application(
        executable_cores, app_id, transceiver, provenance_file_path,
        executable_finder, read_algorithm_iobuf, check_for_success_function,
        cpu_end_states, needs_sync_barrier, filename_template,
        binaries_to_track=None, progress_bar=None):
    """ Executes the given _system_ application. \
        Used for on-chip expanders, compressors, etc.

    :param ~.ExecutableTargets executable_cores:
        the cores to run the executable on
    :param int app_id: the app-id for the executable
    :param ~.Transceiver transceiver: the SpiNNMan instance
    :param str provenance_file_path:
        the path for where provenance data is stored
    :param ExecutableFinder executable_finder: finder for executable paths
    :param bool read_algorithm_iobuf: whether to report IOBUFs
    :param callable check_for_success_function:
        function used to check success;
        expects `executable_cores`, `transceiver` as inputs
    :param set(~.CPUState) cpu_end_states:
        the states that a successful run is expected to terminate in
    :param bool needs_sync_barrier: whether a sync barrier is needed
    :param str filename_template: the IOBUF filename template.
    :param list(str) binaries_to_track:
        A list of binary names to check for exit state.
        Or `None` for all binaries
    :param progress_bar: Possible progress bar to update.
           end() will be called after state checked
    :type progress_bar: ~spinn_utilities.progress_bar.ProgressBar or None

    """

    # load the executable
    transceiver.execute_application(executable_cores, app_id)

    if needs_sync_barrier:

        # fire all signals as required
        transceiver.send_signal(app_id, Signal.SYNC0)

    error = None
    binary_start_types = dict()
    if binaries_to_track is None:
        check_targets = executable_cores
    else:
        check_targets = ExecutableTargets()
        for binary_name in binaries_to_track:
            check_targets.add_subsets(
                binary_name,
                executable_cores.get_cores_for_binary(binary_name))
    for binary_name in executable_cores.binaries:
        binary_start_types[binary_name] = ExecutableType.SYSTEM

    # Wait for the executable to finish
    try:
        transceiver.wait_for_cores_to_be_in_state(
            check_targets.all_core_subsets, app_id, cpu_end_states,
            progress_bar=progress_bar)
        if progress_bar is not None:
            progress_bar.end()
        succeeded = True
    except (SpinnmanTimeoutException, SpinnmanException) as ex:
        succeeded = False
        # Delay the exception until iobuff is ready
        error = ex

    if progress_bar is not None:
        progress_bar.end()

    # Check if any cores have not completed successfully
    if succeeded and check_for_success_function is not None:
        succeeded = check_for_success_function(executable_cores, transceiver)

    # if doing iobuf, read iobuf
    if read_algorithm_iobuf or not succeeded:
        iobuf_reader = ChipIOBufExtractor(
            filename_template=filename_template,
            suppress_progress=False)
        iobuf_reader(
            transceiver, executable_cores, executable_finder,
            system_provenance_file_path=provenance_file_path)

    # stop anything that's associated with the compressor binary
    transceiver.stop_application(app_id)
    transceiver.app_id_tracker.free_id(app_id)

    if error is not None:
        raise error  # pylint: disable=raising-bad-type

    return succeeded
    def test_call(self):
        executor = HostExecuteDataSpecification()
        transceiver = _MockTransceiver(user_0_addresses={0: 1000})
        machine = virtual_machine(2, 2)
        tempdir = tempfile.mkdtemp()

        dsg_targets = DataSpecificationTargets(machine, tempdir)
        with dsg_targets.create_data_spec(0, 0, 0) as spec_writer:
            spec = DataSpecificationGenerator(spec_writer)
            spec.reserve_memory_region(0, 100)
            spec.reserve_memory_region(1, 100, empty=True)
            spec.reserve_memory_region(2, 100)
            spec.switch_write_focus(0)
            spec.write_value(0)
            spec.write_value(1)
            spec.write_value(2)
            spec.switch_write_focus(2)
            spec.write_value(3)
            spec.end_specification()

        region_sizes = dict()
        region_sizes[0, 0,
                     0] = (APP_PTR_TABLE_BYTE_SIZE + sum(spec.region_sizes))

        # Execute the spec
        targets = ExecutableTargets()
        targets.add_processor("text.aplx", 0, 0, 0,
                              ExecutableType.USES_SIMULATION_INTERFACE)
        infos = executor.execute_application_data_specs(
            transceiver,
            machine,
            30,
            dsg_targets,
            False,
            targets,
            report_folder=tempdir,
            region_sizes=region_sizes)

        # Test regions - although 3 are created, only 2 should be uploaded
        # (0 and 2), and only the data written should be uploaded
        # The space between regions should be as allocated regardless of
        # how much data is written
        header_and_table_size = (MAX_MEM_REGIONS + 2) * BYTES_PER_WORD
        regions = transceiver.regions_written
        self.assertEqual(len(regions), 4)

        # Base address for header and table
        self.assertEqual(regions[1][0], 0)

        # Base address for region 0 (after header and table)
        self.assertEqual(regions[2][0], header_and_table_size)

        # Base address for region 2
        self.assertEqual(regions[3][0], header_and_table_size + 200)

        # User 0 write address
        self.assertEqual(regions[0][0], 1000)

        # Size of header and table
        self.assertEqual(len(regions[1][1]), header_and_table_size)

        # Size of region 0
        self.assertEqual(len(regions[2][1]), 12)

        # Size of region 2
        self.assertEqual(len(regions[3][1]), 4)

        # Size of user 0
        self.assertEqual(len(regions[0][1]), 4)

        info = infos[(0, 0, 0)]
        self.assertEqual(info.memory_used, 372)
        self.assertEqual(info.memory_written, 88)
Beispiel #18
0
    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
Beispiel #19
0
    def _generate_core_subsets(
            self, routing_tables, executable_finder, machine, progress_bar,
            system_executable_targets):
        """ generates the core subsets for the binaries

        :param ~.MulticastRoutingTables routing_tables: the routing tables
        :param ~.ExecutableFinder executable_finder: the executable path finder
        :param ~.Machine machine: the spinn machine instance
        :param ~.ProgressBar progress_bar: progress bar
        :param ExecutableTargets system_executable_targets:
            the executables targets to cores
        :return: (targets, sorter path, and compressor path)
        :rtype: tuple(ExecutableTargets, str, str)
        """
        bit_field_sorter_cores = CoreSubsets()
        bit_field_compressor_cores = CoreSubsets()

        _, cores = LoadExecutableImages.filter_targets(
            system_executable_targets, lambda ty: ty is ExecutableType.SYSTEM)

        for routing_table in progress_bar.over(routing_tables, False):
            # add 1 core to the sorter, and the rest to compressors
            sorter = None
            for processor in machine.get_chip_at(
                    routing_table.x, routing_table.y).processors:
                if (not processor.is_monitor and
                        not cores.all_core_subsets.is_core(
                            routing_table.x, routing_table.y,
                            processor.processor_id)):
                    if sorter is None:
                        sorter = processor
                        bit_field_sorter_cores.add_processor(
                            routing_table.x, routing_table.y,
                            processor.processor_id)
                    else:
                        bit_field_compressor_cores.add_processor(
                            routing_table.x, routing_table.y,
                            processor.processor_id)

        # convert core subsets into executable targets
        executable_targets = ExecutableTargets()

        # bit field executable paths
        bit_field_sorter_executable_path = \
            executable_finder.get_executable_path(
                self._BIT_FIELD_SORTER_AND_SEARCH_EXECUTOR_APLX)

        bit_field_compressor_executable_path = \
            executable_finder.get_executable_path(self.compressor_aplx)

        # add the sets
        executable_targets.add_subsets(
            binary=bit_field_sorter_executable_path,
            subsets=bit_field_sorter_cores,
            executable_type=ExecutableType.SYSTEM)
        executable_targets.add_subsets(
            binary=bit_field_compressor_executable_path,
            subsets=bit_field_compressor_cores,
            executable_type=ExecutableType.SYSTEM)

        return (executable_targets, bit_field_sorter_executable_path,
                bit_field_compressor_executable_path)
path = os.path.dirname(os.path.abspath(__file__))


def mock_aplx(id):
    return os.path.join(path, "mock{}.aplx".format(id))


extractor = ChipIOBufExtractor()
executableFinder = ExecutableFinder([path])

transceiver = _PretendTransceiver(
    [IOBuffer(0, 0, 1, text001), IOBuffer(0, 0, 2, text002),
     IOBuffer(1, 1, 1, text111), IOBuffer(1, 1, 2, text112),
     IOBuffer(0, 0, 3, text003)])

executable_targets = ExecutableTargets()
core_subsets = CoreSubsets([CoreSubset(0, 0, [1, 2])])
fooaplx = mock_aplx("foo")
executable_targets.add_subsets(fooaplx, core_subsets)
core_subsets = CoreSubsets([CoreSubset(1, 1, [1, 2])])
baraplx = mock_aplx("bar")
executable_targets.add_subsets(baraplx, core_subsets)
core_subsets = CoreSubsets([CoreSubset(0, 0, [3])])
alphaaplx = mock_aplx("alpha")
executable_targets.add_subsets(alphaaplx, core_subsets)


class TestFrontEndCommonChipIOBufExtractor(unittest.TestCase):

    def testExectuableFinder(self):
        self.assertIn(fooaplx, executableFinder.get_executable_path(fooaplx))