pacman.utilities.utility_objs package

Submodules

pacman.utilities.utility_objs.field module

class pacman.utilities.utility_objs.field.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

pacman.utilities.utility_objs.flexi_field module

class pacman.utilities.utility_objs.flexi_field.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.flexi_field.SUPPORTED_TAGS

Bases: enum.Enum

An enumeration.

APPLICATION = 0
ROUTING = 1

pacman.utilities.utility_objs.resource_tracker module

class pacman.utilities.utility_objs.resource_tracker.ResourceTracker(machine, 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
  • chips (iterable of (int, int) tuples of coordinates of chips) – 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 of (int, int, int, list((int, int)), list((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:
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:

(int, int, int, list((int, int)), list((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 of pacman.model.resources.ResourceContainer) – The resources to be allocated
  • chips (iterable of (int, int)) – An iterable of (x, y) tuples of chips that are to be used
  • processor_ids (list of (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 of lists of pacman.model.resources.IptagResource) – list of lists of ip tag resources
  • group_reverse_ip_tags (list of lists of 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 of (int, int, int, list((int, int)), list((int, int)))

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 of (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 of pacman.model.resources.IptagResource) – iterable of ip tag resources
  • reverse_ip_tags (iterable of 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:

(int, int, int, list((int, int, int, int)), list((int, int)))

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

deduce the number of chips used in this allocation

Returns:the number of chips used during the allocation.
static get_chip_and_core(constraints, chips=None)[source]

Get an assigned chip and core from a set of constraints

Parameters:
  • constraints (iterable of 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 of (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 of (int, int, int)

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:

(str, iterable of pacman.model.resources.IptagResource, iterable of pacman.model.resources.ReverseIPtabResource)

get_maximum_constrained_resources_available(resources, constraints, chips=None)[source]

Get the maximum resources available given the constraints

Parameters:
get_maximum_resources_available(chips=None, processor_id=None, board_address=None, ip_tags=None, reverse_ip_tags=None)[source]

Get the maximum resources available

Parameters:
  • chips (iterable of (int, int)) – An iterable of (x, y) tuples of chips that are to be used
  • processor_id (int) – the processor id
  • board_address (str) – the board address for locating max resources from
  • ip_tags (iterable of pacman.model.resources.IptagResource) – iterable of ip tag resources
  • reverse_ip_tags (iterable of pacman.model.resources.ReverseIptagResource) – iterable of reverse ip tag resources
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 of (str, int) or None) – the details of the ip tags allocated
  • reverse_ip_tags (iterable of (str, int) or None) – the details of the reverse ip tags allocated
Return type:

None

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, 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
  • chips (iterable of (int, int) tuples of coordinates of chips) – 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 of (int, int, int, list((int, int)), list((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:
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:

(int, int, int, list((int, int)), list((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 of pacman.model.resources.ResourceContainer) – The resources to be allocated
  • chips (iterable of (int, int)) – An iterable of (x, y) tuples of chips that are to be used
  • processor_ids (list of (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 of lists of pacman.model.resources.IptagResource) – list of lists of ip tag resources
  • group_reverse_ip_tags (list of lists of 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 of (int, int, int, list((int, int)), list((int, int)))

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 of (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 of pacman.model.resources.IptagResource) – iterable of ip tag resources
  • reverse_ip_tags (iterable of 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:

(int, int, int, list((int, int, int, int)), list((int, int)))

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

deduce the number of chips used in this allocation

Returns:the number of chips used during the allocation.
static get_chip_and_core(constraints, chips=None)[source]

Get an assigned chip and core from a set of constraints

Parameters:
  • constraints (iterable of 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 of (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 of (int, int, int)

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:

(str, iterable of pacman.model.resources.IptagResource, iterable of pacman.model.resources.ReverseIPtabResource)

get_maximum_constrained_resources_available(resources, constraints, chips=None)[source]

Get the maximum resources available given the constraints

Parameters:
get_maximum_resources_available(chips=None, processor_id=None, board_address=None, ip_tags=None, reverse_ip_tags=None)[source]

Get the maximum resources available

Parameters:
  • chips (iterable of (int, int)) – An iterable of (x, y) tuples of chips that are to be used
  • processor_id (int) – the processor id
  • board_address (str) – the board address for locating max resources from
  • ip_tags (iterable of pacman.model.resources.IptagResource) – iterable of ip tag resources
  • reverse_ip_tags (iterable of pacman.model.resources.ReverseIptagResource) – iterable of reverse ip tag resources
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 of (str, int) or None) – the details of the ip tags allocated
  • reverse_ip_tags (iterable of (str, int) or None) – the details of the reverse ip tags allocated
Return type:

None