def get_maximum_resources_available(self,
                                        chips=None,
                                        processor_id=None,
                                        board_address=None,
                                        ip_tags=None,
                                        reverse_ip_tags=None):
        """ Get the maximum resources available

        :param chips: An iterable of (x, y) tuples of chips that are to be used
        :type chips: iterable of (int, int)
        :param processor_id: the processor id
        :type processor_id: int
        :param board_address: the board address for locating max resources from
        :type board_address: str
        :param ip_tags: iterable of ip tag constraints
        :type ip_tags: iterable of\
                    :py:class:`pacman.model.constraints.tag_allocator_constraints.tag_allocator_require_iptag_constraint.TagAllocatorRequireIptagConstraint`
        :param reverse_ip_tags: iterable of reverse ip tag constraints
        :type reverse_ip_tags: iterable of\
                    :py:class:`pacman.model.constraints.tag_allocator_constraints.tag_allocator_require_reverse_iptag_constraint.TagAllocatorRequireReverseIptagConstraint`
        :return: a resource which shows max resources available
        :rtype: ResourceContainer
        """
        usable_chips = self._get_usable_chips(chips, board_address, ip_tags,
                                              reverse_ip_tags)

        # If the chip is not fixed, find the maximum SDRAM
        # TODO: Also check for the best core
        max_sdram_available = 0
        max_dtcm_available = 0
        max_cpu_available = 0
        for (chip_x, chip_y) in usable_chips:
            key = (chip_x, chip_y)
            chip = self._machine.get_chip_at(chip_x, chip_y)
            sdram_available = self._sdram_available(chip, key)
            ip_tags_available = self._are_ip_tags_available(
                chip, board_address, ip_tags)
            reverse_ip_tags_available = self._are_reverse_ip_tags_available(
                chip, board_address, reverse_ip_tags)

            if (sdram_available > max_sdram_available and ip_tags_available
                    and reverse_ip_tags_available):
                max_sdram_available = sdram_available
                best_processor_id = self._best_core_available(
                    chip, key, processor_id)
                processor = chip.get_processor_with_id(best_processor_id)
                max_dtcm_available = processor.dtcm_available
                max_cpu_available = processor.cpu_cycles_available

            # If all the SDRAM on the chip is available,
            # this chip is unallocated, so the max must be the max
            # TODO: This assumes that the chips are all the same
            if sdram_available == chip.sdram.size:
                break

        # Send the maximums
        return ResourceContainer(DTCMResource(max_dtcm_available),
                                 SDRAMResource(max_sdram_available),
                                 CPUCyclesPerTickResource(max_cpu_available))
    def get_resources_used_by_atoms(self, vertex_slice):
        # **HACK** only way to force no partitioning is to zero dtcm and cpu
        container = ResourceContainer(sdram=SDRAMResource(
            self.BANDIT_REGION_BYTES +
            front_end_common_constants.SYSTEM_BYTES_REQUIREMENT),
                                      dtcm=DTCMResource(0),
                                      cpu_cycles=CPUCyclesPerTickResource(0))

        return container
    def resources_required(self):
        sdram = self._N_PARAMETER_BYTES + self._data_size
        sdram += 1 * self._KEY_ELEMENT_TYPE.size

        resources = ResourceContainer(dtcm=DTCMResource(0),
                                      sdram=SDRAMResource(sdram),
                                      cpu_cycles=CPUCyclesPerTickResource(0),
                                      iptags=[],
                                      reverse_iptags=[])
        return resources
 def test_sdram(self):
     """
     test that adding a sdram resource to a resoruce container works
     correctly
     :return:
     """
     sdram = SDRAMResource(128 * (2 ** 20))
     self.assertEqual(sdram.get_value(), 128 * (2 ** 20))
     sdram = SDRAMResource(128 * (2 ** 19))
     self.assertEqual(sdram.get_value(), 128 * (2 ** 19))
     sdram = SDRAMResource(128 * (2 ** 21))
     self.assertEqual(sdram.get_value(), 128 * (2 ** 21))
    def get_resources_used_by_atoms(self, vertex_slice, graph):
        """ Get the separate resource requirements for a range of atoms

        :param vertex_slice: the low value of atoms to calculate resources from
        :param graph: A reference to the graph containing this vertex.
        :type vertex_slice: pacman.model.graph_mapper.slice.Slice
        :return: a Resource container that contains a \
                    CPUCyclesPerTickResource, DTCMResource and SDRAMResource
        :rtype: ResourceContainer
        :raise None: this method does not raise any known exception
        """
        cpu_cycles = self.get_cpu_usage_for_atoms(vertex_slice, graph)
        dtcm_requirement = self.get_dtcm_usage_for_atoms(vertex_slice, graph)
        sdram_requirement = self.get_sdram_usage_for_atoms(vertex_slice, graph)

        # noinspection PyTypeChecker
        resources = ResourceContainer(cpu=CPUCyclesPerTickResource(cpu_cycles),
                                      dtcm=DTCMResource(dtcm_requirement),
                                      sdram=SDRAMResource(sdram_requirement))
        return resources
    def __init__(
            self, label, machine_time_step, timescale_factor,
            use_prefix=False, key_prefix=None, prefix_type=None,
            message_type=EIEIOType.KEY_32_BIT, right_shift=0,
            payload_as_time_stamps=True, use_payload_prefix=True,
            payload_prefix=None, payload_right_shift=0,
            number_of_packets_sent_per_time_step=0,
            ip_address=None, port=None, strip_sdp=None, board_address=None,
            tag=None,
            constraints=None):

        resources_required = ResourceContainer(
            cpu=CPUCyclesPerTickResource(self.get_cpu_usage()),
            dtcm=DTCMResource(self.get_dtcm_usage()),
            sdram=SDRAMResource(self.get_sdram_usage()))

        if constraints is None:
            constraints = self.get_constraints(
                ip_address, port, strip_sdp, board_address, tag)

        PartitionedVertex.__init__(
            self, resources_required, label, constraints=constraints)
        ProvidesProvenanceDataFromMachineImpl.__init__(
            self, self._LIVE_DATA_GATHER_REGIONS.PROVENANCE.value,
            self.N_ADDITIONAL_PROVENANCE_ITEMS)
        AbstractPartitionedDataSpecableVertex.__init__(
            self, machine_time_step, timescale_factor)

        self._use_prefix = use_prefix
        self._key_prefix = key_prefix
        self._prefix_type = prefix_type
        self._message_type = message_type
        self._right_shift = right_shift
        self._payload_as_time_stamps = payload_as_time_stamps
        self._use_payload_prefix = use_payload_prefix
        self._payload_prefix = payload_prefix
        self._payload_right_shift = payload_right_shift
        self._number_of_packets_sent_per_time_step = \
            number_of_packets_sent_per_time_step