pacman.utilities.utility_objs package¶
Submodules¶
pacman.utilities.utility_objs.field module¶
pacman.utilities.utility_objs.flexi_field module¶
pacman.utilities.utility_objs.resource_tracker module¶
-
class
pacman.utilities.utility_objs.resource_tracker.
ResourceTracker
(machine, plan_n_timesteps, chips=None, preallocated_resources=None)[source]¶ Bases:
object
Tracks the usage of resources of a machine.
Parameters: - machine (
spinn_machine.Machine
) – The machine to track the usage of - plan_n_timesteps (int) – number of timesteps to plan for
- chips (iterable(tuple(int, int))) – 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.
-
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 – A list of tuples of (resources, list of constraints) to allocate
- chips – 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)), 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 (
pacman.model.resources.ResourceContainer
) – The resources to be allocated - constraints (list(
pacman.model.constraints.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)), list(tuple(int, int)))
Raises: PacmanValueError – If the constraints cannot be met given the current allocation of resources
- resources (
-
allocate_group_resources
(group_resources, chips=None, processor_ids=None, board_address=None, group_ip_tags=None, group_reverse_ip_tags=None)[source]¶ Attempts to use the given group of resources on a single chip 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 of the group fit together.
Parameters: - group_resources (list(
pacman.model.resources.ResourceContainer
)) – The resources to be allocated - chips (iterable(tuple(int, int))) – An iterable of (x, y) tuples of chips that are to be used
- processor_ids (list(int or None)) – The specific processor to use on any chip for each resource of the group
- board_address (str) – the board address to allocate resources of a chip
- group_ip_tags (list(list(
pacman.model.resources.IptagResource
))) – list of lists of IP tag resources - group_reverse_ip_tags (list(list(
pacman.model.resources.ReverseIptagResource
))) – list of lists of reverse IP tag resources
Returns: An iterable of tuples 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)), list(tuple(int, int))))
Raises: pacman.exceptions.PacmanValueError – If there aren’t chips available that can take the allocation.
- group_resources (list(
-
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 (
pacman.model.resources.ResourceContainer
) – The resources to be allocated - 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(
pacman.model.resources.IptagResource
)) – iterable of IP tag resources - reverse_ip_tags (iterable(
pacman.model.resources.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: pacman.exceptions.PacmanValueError – If there isn’t a chip available that can take the allocation.
- resources (
-
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 – The vertices to check the constraints of
- additional_placement_constraints – Additional placement constraints supported by the algorithm doing this check
-
chips_available
¶ The chips currently available
-
chips_used
¶ The number of chips used in this allocation.
-
static
get_chip_and_core
(constraints, chips=None)[source]¶ Get an assigned chip and core from a set of constraints
Parameters: - constraints (iterable(
pacman.model.constraints.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(int, int)) – 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: tuple(int or None, int or None, int or None)
- constraints (iterable(
-
static
get_ip_tag_info
(resources, constraints)[source]¶ Get the IP tag resource information
Parameters: - resources (
pacman.model.resources.ResourceContainer
) – The resources to get the values from - constraints (list(
pacman.model.constraints.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(
pacman.model.resources.IptagResource
), iterable(pacman.model.resources.ReverseIPtabResource
))- resources (
-
get_maximum_constrained_resources_available
(resources, constraints)[source]¶ Get the maximum resources available given the constraints
Parameters: - resources (
pacman.model.resources.ResourceContainer
) – The resources of the item to check - chips (iterable(
spinn_machine.Chip
)) – the chips to locate the max available resources of
- resources (
-
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
-
get_maximum_cores_available_on_a_virtual_chip
()[source]¶ returns the number of available cores of a virtual chip with the maximum number of available cores :return: the max cores available on the best real chip :rtype: int
-
get_maximum_resources_available
(area_code=None)[source]¶ Get the maximum resources available
Parameters: area_code – A set of valid (x, y) coordinates to choose from Returns: a resource which shows max resources available Return type: pacman.model.resources.ResourceContainer
-
is_chip_available
(chip_x, chip_y)[source]¶ Check if a given chip is available
Parameters: - chip_x (int) – the x coord of the chip
- chip_y (int) – the y coord of the chip
Returns: True if the chip is available, False otherwise
Return type: bool
-
keys
¶ The chip coordinates assigned
-
sdram_avilable_on_chip
(chip_x, chip_y)[source]¶ Get the available SDRAM on the chip at coordinates chip_x, chip_y
Parameters: - chip_x – x coord of the chip in question
- chip_y – y coord of the chip in question
Returns: the SDRAM remaining
-
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 (
pacman.model.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: None
- machine (
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
-
hi
¶
-
lo
¶
-
name
¶
-
tag
¶
-
value
¶
-
-
class
pacman.utilities.utility_objs.
FlexiField
(flexi_field_name, value=None, instance_n_keys=None, tag=None, nested_level=0)[source]¶ Bases:
object
Field who’s location is not fixed in key allocation
-
instance_n_keys
¶
-
name
¶ The name for this Flexible field
-
tag
¶
-
value
¶
-
-
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 (
spinn_machine.Machine
) – The machine to track the usage of - plan_n_timesteps (int) – number of timesteps to plan for
- chips (iterable(tuple(int, int))) – 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.
-
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 – A list of tuples of (resources, list of constraints) to allocate
- chips – 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)), 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 (
pacman.model.resources.ResourceContainer
) – The resources to be allocated - constraints (list(
pacman.model.constraints.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)), list(tuple(int, int)))
Raises: PacmanValueError – If the constraints cannot be met given the current allocation of resources
- resources (
-
allocate_group_resources
(group_resources, chips=None, processor_ids=None, board_address=None, group_ip_tags=None, group_reverse_ip_tags=None)[source]¶ Attempts to use the given group of resources on a single chip 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 of the group fit together.
Parameters: - group_resources (list(
pacman.model.resources.ResourceContainer
)) – The resources to be allocated - chips (iterable(tuple(int, int))) – An iterable of (x, y) tuples of chips that are to be used
- processor_ids (list(int or None)) – The specific processor to use on any chip for each resource of the group
- board_address (str) – the board address to allocate resources of a chip
- group_ip_tags (list(list(
pacman.model.resources.IptagResource
))) – list of lists of IP tag resources - group_reverse_ip_tags (list(list(
pacman.model.resources.ReverseIptagResource
))) – list of lists of reverse IP tag resources
Returns: An iterable of tuples 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)), list(tuple(int, int))))
Raises: pacman.exceptions.PacmanValueError – If there aren’t chips available that can take the allocation.
- group_resources (list(
-
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 (
pacman.model.resources.ResourceContainer
) – The resources to be allocated - 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(
pacman.model.resources.IptagResource
)) – iterable of IP tag resources - reverse_ip_tags (iterable(
pacman.model.resources.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: pacman.exceptions.PacmanValueError – If there isn’t a chip available that can take the allocation.
- resources (
-
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 – The vertices to check the constraints of
- additional_placement_constraints – Additional placement constraints supported by the algorithm doing this check
-
chips_available
¶ The chips currently available
-
chips_used
¶ The number of chips used in this allocation.
-
static
get_chip_and_core
(constraints, chips=None)[source]¶ Get an assigned chip and core from a set of constraints
Parameters: - constraints (iterable(
pacman.model.constraints.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(int, int)) – 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: tuple(int or None, int or None, int or None)
- constraints (iterable(
-
static
get_ip_tag_info
(resources, constraints)[source]¶ Get the IP tag resource information
Parameters: - resources (
pacman.model.resources.ResourceContainer
) – The resources to get the values from - constraints (list(
pacman.model.constraints.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(
pacman.model.resources.IptagResource
), iterable(pacman.model.resources.ReverseIPtabResource
))- resources (
-
get_maximum_constrained_resources_available
(resources, constraints)[source]¶ Get the maximum resources available given the constraints
Parameters: - resources (
pacman.model.resources.ResourceContainer
) – The resources of the item to check - chips (iterable(
spinn_machine.Chip
)) – the chips to locate the max available resources of
- resources (
-
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
-
get_maximum_cores_available_on_a_virtual_chip
()[source]¶ returns the number of available cores of a virtual chip with the maximum number of available cores :return: the max cores available on the best real chip :rtype: int
-
get_maximum_resources_available
(area_code=None)[source]¶ Get the maximum resources available
Parameters: area_code – A set of valid (x, y) coordinates to choose from Returns: a resource which shows max resources available Return type: pacman.model.resources.ResourceContainer
-
is_chip_available
(chip_x, chip_y)[source]¶ Check if a given chip is available
Parameters: - chip_x (int) – the x coord of the chip
- chip_y (int) – the y coord of the chip
Returns: True if the chip is available, False otherwise
Return type: bool
-
keys
¶ The chip coordinates assigned
-
sdram_avilable_on_chip
(chip_x, chip_y)[source]¶ Get the available SDRAM on the chip at coordinates chip_x, chip_y
Parameters: - chip_x – x coord of the chip in question
- chip_y – y coord of the chip in question
Returns: the SDRAM remaining
-
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 (
pacman.model.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: None
- machine (