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:
  • lo (int) – the low bit in the routing table entry for this field
  • hi (int) – the high bit in the routing table entry for this field
  • value (int) – the value to store in this field
  • tag (SUPPORTED_TAGS) – field tag
  • name (str or None) – field name
hi

the high bit in the routing table entry for this field

Return type:int
lo

the low bit in the routing table entry for this field

Return type:int
name

field name

Return type:str or UUID
tag

field tag

Return type:SUPPORTED_TAGS
value

the value to store in this field

Return type:int
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:
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, vertices=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
  • vertices – the vertices related to these 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 the constraints cannot be met given the current allocation of 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(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(IPtagResource))) – list of lists of IP tag resources
  • group_reverse_ip_tags (list(list(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, int, int)), list(tuple(int, int))))

Raises:

PacmanValueError – If there aren’t chips available that can take the allocation.

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.

allocate_sdram(chip_x, chip_y, sdram_value)[source]

Allocates SDRAM value directly to a chip

Parameters:
  • chip_x (int) – machine chip x coord.
  • chip_y (int) – machine chip y coord.
  • sdram_value (int) – the number of bytes to allocate
Raises:

PacmanException – when the SDRAM can’t be allocated

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.

chips_available

The chips currently available

Return type:iterable(tuple(int,int))
chips_used

The number of chips used in this allocation.

Return type:int
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:

tuple(int or None, int or None, int or None)

static get_ip_tag_info(resources, constraints)[source]

Get the IP tag resource information

Parameters:
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:
Return type:

ResourceContainer

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
Returns:the max cores available on the best real chip
Return type:int
get_maximum_resources_available(area_code=None)[source]

Get the maximum resources available

Parameters:area_code (iterable(tuple(int,int)) or None) – A set of valid (x, y) coordinates to choose from
Returns:a resource which shows max resources available
Return type: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

Return type:set(tuple(int,int))
plan_n_time_steps
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 (int) – x coord of the chip in question
  • chip_y (int) – y coord of the chip in question
Returns:

the SDRAM remaining

Return type:

int

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:

None

class pacman.utilities.utility_objs.SUPPORTED_TAGS[source]

Bases: enum.Enum

An enumeration.

APPLICATION = 0
ROUTING = 1