pacman.utilities.utility_objs package¶
Module contents¶
-
class
pacman.utilities.utility_objs.
Field
(lo, hi, value, tag=<SUPPORTED_TAGS.ROUTING: 1>, name=None)[source]¶ Bases:
object
Field object used in a field constraint for key allocation
Parameters: -
tag
¶ field tag
Return type: SUPPORTED_TAGS
-
-
class
pacman.utilities.utility_objs.
ResourceTracker
(machine, plan_n_timesteps, chips=None, preallocated_resources=None)[source]¶ Bases:
object
Tracks the usage of resources of a machine.
Parameters: - machine (Machine) – The machine to track the usage of
- plan_n_timesteps (int) – number of timesteps to plan for
- chips (iterable(tuple(int, int)) or None) – If specified, this list of chips will be used instead of the list from the machine. Note that the order will be maintained, so this can be used either to reduce the set of chips used, or to re-order the chips. Note also that on deallocation, the order is no longer guaranteed.
- preallocated_resources (PreAllocatedResourceContainer or None) –
-
ALLOCATION_SDRAM_ERROR
= 'Allocating of {} bytes of SDRAM on chip {}:{} has failed as there are only {} bytes of SDRAM available on the chip at this time. Please fix and try again'¶
-
allocate_constrained_group_resources
(resource_and_constraint_list, chips=None)[source]¶ Allocates a group of cores on the same chip for these resources
Parameters: - resource_and_constraint_list (list(tuple(ResourceContainer,AbstractConstraint))) – A list of tuples of (resources, list of constraints) to allocate
- chips (iterable(tuple(int,int))) – A list of chips that can be used
Returns: list of The x and y coordinates of the used chip, the processor_id, and the IP tag and reverse IP tag allocation tuples
Return type: iterable(tuple(int, int, int, list(tuple(int, int, int, int)), list(tuple(int, int))))
-
allocate_constrained_resources
(resources, constraints, chips=None)[source]¶ Attempts to use the given resources of the machine, constrained by the given placement constraints.
Parameters: - resources (ResourceContainer) – The resources to be allocated
- constraints (list(AbstractConstraint)) – The constraints to consider
- chips (iterable(tuple(int,int))) – The optional list of (x, y) tuples of chip coordinates of chips that can be used. Note that any chips passed in previously will be ignored
Returns: The x and y coordinates of the used chip, the processor_id, and the IP tag and reverse IP tag allocation tuples
Return type: tuple(int, int, int, list(tuple(int, int, int, int)), list(tuple(int, int)))
Raises: PacmanValueError – If the constraints cannot be met given the current allocation of resources
-
allocate_resources
(resources, chips=None, processor_id=None, board_address=None, ip_tags=None, reverse_ip_tags=None)[source]¶ Attempts to use the given resources of the machine. Can be given specific place to use the resources, or else it will allocate them on the first place that the resources fit.
Parameters: - resources (ResourceContainer) – The resources to be allocated
- vertices – list of vertices for these resources
- chips (iterable(tuple(int,int))) – An iterable of (x, y) tuples of chips that are to be used
- processor_id (int) – The specific processor to use on any chip.
- board_address (str) – The board address to allocate resources of a chip
- ip_tags (iterable(IPtagResource)) – iterable of IP tag resources
- reverse_ip_tags (iterable(ReverseIPtagResource)) – iterable of reverse IP tag resources
Returns: The x and y coordinates of the used chip, the processor_id, and the IP tag and reverse IP tag allocation tuples
Return type: tuple(int, int, int, list(tuple(int, int, int, int)), list(tuple(int, int)))
Raises: PacmanValueError – If there isn’t a chip available that can take the allocation.
-
static
check_constraints
(vertices, additional_placement_constraints=None)[source]¶ Check that the constraints on the given vertices are supported by the resource tracker.
Parameters: - vertices (list(AbstractVertex)) – The vertices to check the constraints of
- additional_placement_constraints (set(AbstractConstraint)) – Additional placement constraints supported by the algorithm doing this check
Raises: PacmanInvalidParameterException – If the constraints cannot be satisfied.
-
static
get_chip_and_core
(constraints, chips=None)[source]¶ Get an assigned chip and core from a set of constraints
Parameters: - constraints (iterable(AbstractConstraint)) – The set of constraints to get the values from. Note that any type of constraint can be in the list but only those relevant will be used
- chips (iterable(tuple(int, int)) or None) – Optional list of tuples of (x, y) coordinates of chips, restricting the allowed chips
Returns: tuple of a chip x and y coordinates, and processor ID, any of which might be None
Return type:
-
static
get_ip_tag_info
(resources, constraints)[source]¶ Get the IP tag resource information
Parameters: - resources (ResourceContainer) – The resources to get the values from
- constraints (list(AbstractConstraint)) – A list of constraints
Returns: A tuple of board address, iterable of IP tag resources and iterable of reverse IP tag resources
Return type: tuple(str, iterable(~IptagResource), iterable(~ReverseIPtagResource))
-
get_maximum_constrained_resources_available
(resources, constraints)[source]¶ Get the maximum resources available given the constraints
Parameters: - resources (ResourceContainer) – The resources of the item to check
- constraints (iterable(AbstractConstraint)) –
Return type:
-
get_maximum_cores_available_on_a_chip
()[source]¶ - Returns the number of available cores of a real chip with the
- maximum number of available cores
Returns: the max cores available on the best real chip Return type: int
-
is_chip_available
(chip_x, chip_y)[source]¶ Check if a given chip is available
Parameters: Returns: True if the chip is available, False otherwise
Return type:
-
plan_n_time_steps
¶
-
unallocate_resources
(chip_x, chip_y, processor_id, resources, ip_tags, reverse_ip_tags)[source]¶ Undo the allocation of resources
Parameters: - chip_x (int) – the x coord of the chip allocated
- chip_y (int) – the y coord of the chip allocated
- processor_id (int) – the processor ID
- resources (ResourceContainer) – The resources to be unallocated
- ip_tags (iterable(tuple(str, int)) or None) – the details of the IP tags allocated
- reverse_ip_tags (iterable(tuple(str, int)) or None) – the details of the reverse IP tags allocated
Return type: