def __init__(self,
                 connection_selector,
                 ignore_chips,
                 ignore_cores,
                 max_core_id,
                 max_sdram_size=None):
        """
        :param scamp_connections: The connections to use for the interaction
        :type scamp_connections: iterable of\
                    :py:class:`spinnman.connections.abstract_classes.abstract_connection.AbstractConnection`
        """
        AbstractMultiConnectionProcess.__init__(self, connection_selector)

        self._ignore_chips = ignore_chips
        self._ignore_cores = ignore_cores
        self._max_core_id = max_core_id
        self._max_sdram_size = max_sdram_size

        # A dictionary of (x, y) -> ChipInfo
        self._chip_info = dict()

        # The machine so far
        self._machine = Machine([])

        # A dictionary of which link goes where from a chip:
        # (x, y, link) -> (x, y)
        self._link_destination = dict()

        # A queue of ChipInfo to be examined
        self._search = deque()
Пример #2
0
 def test_allocate_resources_when_chip_used(self):
     router = Router([])
     sdram = SDRAM()
     empty_chip = Chip(0,
                       0, [],
                       router,
                       sdram,
                       0,
                       0,
                       "127.0.0.1",
                       virtual=False,
                       tag_ids=[1])
     machine = Machine([empty_chip], 0, 0)
     resource_tracker = ResourceTracker(machine)
     with self.assertRaises(PacmanValueError):
         resource_tracker.allocate_resources(
             ResourceContainer(sdram=SDRAMResource(1024)))
    def check_machine_is_booted(self):

        # Check that chip 0, 0 is booted
        result, chip_0_0_data = self._read_chip(0, 0)
        if chip_0_0_data is None:
            logger.error("Could not read from 0, 0: {}", result)
            return None, None

        progress_bar = ProgressBar(
            float(chip_0_0_data.x_size * chip_0_0_data.y_size * 2),
            "Verifying Machine")

        # Go through the chips, link by link
        chip_search = deque([chip_0_0_data])
        seen_chips = OrderedDict({(0, 0): chip_0_0_data})
        link_destination = dict()
        while len(chip_search) > 0:
            chip = chip_search.pop()
            details = seen_chips[chip.x, chip.y]

            for link in range(0, 6):
                chip_data = None
                retries = 3
                while chip_data is None and retries > 0:
                    _, chip_data = self._read_chip_down_link(
                        chip.x, chip.y, link)
                    if chip_data is not None and (
                            self._ignore_chips is None
                            or not self._ignore_chips.is_chip(
                                chip_data.x, chip_data.y)):
                        link_destination[(chip.x, chip.y,
                                          link)] = (chip_data.x, chip_data.y)
                        if (chip_data.x, chip_data.y) not in seen_chips:
                            chip_search.append(chip_data)
                            seen_chips[(chip_data.x, chip_data.y)] = chip_data
                            progress_bar.update()
                    elif link in details.links_available:
                        retries -= 1
                        time.sleep(0.2)
                    else:
                        retries = 0

        # Try to read each found chip
        machine = Machine([])
        for x, y in seen_chips:
            if (self._ignore_chips is None
                    or not self._ignore_chips.is_chip(x, y)):

                # Retry up to 3 times
                retries = 3
                result = None
                chip_details = None
                while retries > 0:
                    result, chip_details = self._read_chip(x, y)
                    if chip_details is not None:
                        self._add_chip(machine, chip_details, link_destination)
                        progress_bar.update()
                        break

                    # Wait between retries
                    time.sleep(0.5)
                    retries -= 1

                # If no version could be read, the machine might be faulty
                if chip_details is None:
                    logger.warn(
                        "Could not get version from chip {}, {}: {}".format(
                            x, y, result))
                    progress_bar.update()
        progress_bar.end()

        return machine, seen_chips