Esempio n. 1
0
    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 application ID of the compressor compressor
        :param txrx: the spinnman interface
        :type txrx: :py:class:`~spinnman.Transceiver`
        :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,
                                       ExecutableType.RUNNING)

        txrx.execute_application(executable_targets, compressor_app_id)
        return executable_targets
Esempio n. 2
0
 def __filter(targets, filt):
     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 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)
Esempio n. 4
0
    def __call__(self,
                 placements,
                 graph,
                 executable_finder,
                 graph_mapper=None):
        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)
            if graph_mapper is not None:
                self.__get_binary(placement,
                                  graph_mapper.get_application_vertex(vertex))

        return self._exe_targets
Esempio n. 5
0
class GraphBinaryGatherer(object):
    """ Extracts binaries to be executed.
    """

    __slots__ = ["_exe_finder", "_exe_targets"]

    def __init__(self):
        self._exe_finder = None
        self._exe_targets = None

    def __call__(self,
                 placements,
                 graph,
                 executable_finder,
                 graph_mapper=None):
        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)
            if graph_mapper is not None:
                self.__get_binary(placement,
                                  graph_mapper.get_application_vertex(vertex))

        return self._exe_targets

    def __get_binary(self, placement, vertex):
        # If we've got junk input (shouldn't happen), ignore it
        if vertex is None:
            return
        # if the vertex cannot generate a DSG, ignore it
        if not isinstance(vertex, AbstractHasAssociatedBinary):
            return

        # Get name of binary from vertex
        binary_name = vertex.get_binary_file_name()
        exec_type = vertex.get_binary_start_type()

        # Attempt to find this within search paths
        binary_path = self._exe_finder.get_executable_path(binary_name)
        if binary_path is None:
            raise ExecutableNotFoundException(binary_name)

        self._exe_targets.add_processor(binary_path, placement.x, placement.y,
                                        placement.p, exec_type)
Esempio n. 6
0
def emergency_recover_state_from_failure(txrx, app_id, vertex, placement):
    """ Used to get at least *some* information out of a core when something\
    goes badly wrong. Not a replacement for what abstract spinnaker base does.

    :param txrx: The transceiver.
    :param app_id: The ID of the application.
    :param vertex: The vertex to retrieve the IOBUF from if it is suspected\
        as being dead
    :type vertex: \
        :py:class:`spinn_front_end_common.abstract_models.AbstractHasAssociatedBinary`
    :param placement: Where the vertex is located.
    """
    # pylint: disable=protected-access
    _emergency_state_check(txrx, app_id)
    target = ExecutableTargets()
    path = get_simulator()._executable_finder.get_executable_path(
        vertex.get_binary_file_name())
    target.add_processor(path, placement.x, placement.y, placement.p,
                         vertex.get_binary_start_type())
    _emergency_iobuf_extract(txrx, target)
    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()

        # 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)

        # 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) * 4
        regions = transceiver.regions_written
        self.assertEqual(len(regions), 4)

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

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

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

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

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

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

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

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

        info = infos[(0, 0, 0)]
        self.assertEqual(info.memory_used, 372)
        self.assertEqual(info.memory_written, 88)
Esempio n. 8
0
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))