spinn_machine package

Submodules

spinn_machine.chip module

class spinn_machine.chip.Chip(x, y, processors, router, sdram, nearest_ethernet_x, nearest_ethernet_y, ip_address=None, virtual=False, tag_ids=set([1, 2, 3, 4, 5, 6, 7]))

Bases: object

Represents a chip with a number of cores, an amount of SDRAM shared between the cores, and a router. The chip is iterable over the processors providing (processor_id, processor) where:

  • processor_id is the id of a processor
  • processor is the processor with processor_id
Parameters:
  • x (int) – the x-coordinate of the chip’s position in the two-dimensional grid of chips
  • y (int) – the y-coordinate of the chip’s position in the two-dimensional grid of chips
  • processors (iterable of spinn_machine.Processor) – an iterable of processor objects
  • router (spinn_machine.Router) – a router for the chip
  • sdram (spinn_machine.SDRAM) – an SDRAM for the chip
  • ip_address (str) – the IP address of the chip or None if no Ethernet attached
  • virtual (bool) – boolean which defines if this chip is a virtual one
  • tag_ids (iterable of int) – Id to identify the chip for SDP
  • nearest_ethernet_x (int or None) – the nearest Ethernet x coord
  • nearest_ethernet_y (int or None) – the nearest Ethernet y coord
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If processors contains any two processors with the same processor_id

IPTAG_IDS = set([1, 2, 3, 4, 5, 6, 7])
get_first_none_monitor_processor()

Get the first processor in the list which is not a monitor core

Returns:a processor
get_processor_with_id(processor_id)

Return the processor with the specified id or None if the processor does not exist. Also implemented as __contains__(processor_id)

Parameters:processor_id (int) – the id of the processor to return
Returns:the processor with the specified id or None if no such processor
Return type:spinn_machine.Processor
Raises:None – does not raise any known exceptions
ip_address

The IP address of the chip

Returns:IP address of the chip, or None if there is no Ethernet connected to the chip
Return type:str
Raises:None – does not raise any known exceptions
is_processor_with_id(processor_id)

Determines if a processor with the given id exists in the chip. Also implemented as __getitem__(processor_id)

Parameters:processor_id (int) – the processor id to check for
Returns:True or False based on the existence of the processor
Return type:bool
Raises:None – does not raise any known exceptions
n_processors

The total number of processors

n_user_processors

The total number of processors that are not monitors

nearest_ethernet_x

the x coord of the nearest Ethernet chip

Returns:the x coord of the nearest Ethernet chip
Return type:int
Raises:None – does not raise any known exceptions
nearest_ethernet_y

the y coord of the nearest Ethernet chip

Returns:the y coord of the nearest Ethernet chip
Return type:int
Raises:None – does not raise any known exceptions
processors

An iterable of available processors

Returns:iterable of processors
Return type:iterable of :py:class:spinn_machine.Processor`
Raises:None – does not raise any known exceptions
reserve_a_system_processor()

This method should ONLY be called via Machine.reserve_system_processors

Sets one of the none monitor processors as a system processor

Updates n_user_processors

Returns:The id of the processor reserved, or None if no processor could be found
Return type:int or None
router

The router object associated with the chip

Returns:router associated with the chip
Return type:spinn_machine.Router
Raises:None – does not raise any known exceptions
sdram

The sdram associated with the chip

Returns:sdram associated with the chip
Return type:spinn_machine.SDRAM
Raises:None – does not raise any known exceptions
tag_ids

The tag ids supported by this chip

Returns:the set of ids.
Raises:None – this method does not raise any exception
virtual

boolean which defines if the chip is virtual or not

Returns:if the chip is virtual
Return type:boolean
Raises:None – this method does not raise any known exceptions
x

The x-coordinate of the chip in the two-dimensional grid of chips

Returns:the x-coordinate of the chip
Return type:int
Raises:None – does not raise any known exceptions
y

The y-coordinate of the chip in the two-dimensional grid of chips

Returns:the y-coordinate of the chip
Return type:int
Raises:None – does not raise any known exceptions

spinn_machine.core_subset module

class spinn_machine.core_subset.CoreSubset(x, y, processor_ids)

Bases: object

Represents a subset of the cores on a chip

Parameters:
  • x (int) – The x-coordinate of the chip
  • y (int) – The y-coordinate of the chip
  • processor_ids (iterable of int) – An iterable of processor ids on the chip
add_processor(processor_id)

Adds a processor id to this subset

Parameters:processor_id (int) – A processor id
Returns:Nothing is returned
Return type:None
processor_ids

The subset of processor ids on the chip

Returns:An iterable of processor ids
Return type:iterable of int
x

The x-coordinate of the chip

Returns:The x-coordinate
Return type:int
y

The y-coordinate of the chip

Returns:The y-coordinate
Return type:int

spinn_machine.core_subsets module

class spinn_machine.core_subsets.CoreSubsets(core_subsets=None)

Bases: object

Represents a group of CoreSubsets, with a maximum of one per chip

Parameters:core_subsets (iterable of spinn_machine.CoreSubset) – An iterable of cores for each desired chip
add_core_subset(core_subset)

Add a core subset to the set

Parameters:core_subset (spinn_machine.CoreSubset) – The core subset to add
Returns:Nothing is returned
Return type:None
add_processor(x, y, processor_id)

Add a processor on a given chip to the set

Parameters:
  • x (int) – The x-coordinate of the chip
  • y (int) – The y-coordinate of the chip
  • processor_id (int) – A processor id
Returns:

Nothing is returned

Return type:

None

core_subsets

The one-per-chip subsets

Returns:Iterable of core subsets
Return type:iterable of spinn_machine.CoreSubset
get_core_subset_for_chip(x, y)

Get the core subset for a chip

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
Returns:

The core subset of a chip, which will be empty if not added

Return type:

spinn_machine.CoreSubset

is_chip(x, y)

Determine if the chip with coordinates (x, y) is in the subset

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
Returns:

True if the chip with coordinates (x, y) is in the subset

Return type:

bool

is_core(x, y, processor_id)

Determine if there is a chip with coordinates (x, y) in the subset, which has a core with the given id in the subset

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
  • processor_id (int) – The id of a core
Returns:

True if there is a chip with coordinates (x, y) in the subset, which has a core with the given id in the subset

spinn_machine.exceptions module

exception spinn_machine.exceptions.SpinnMachineAlreadyExistsException(item, value)

Bases: spinn_machine.exceptions.SpinnMachineException

Indicates that something already exists of which there can only be one

Parameters:
  • item (str) – The item of which there is already one of
  • value (str) – The value of the item
item

The item of which there is already one

value

The value of the item

exception spinn_machine.exceptions.SpinnMachineException

Bases: exceptions.Exception

A generic exception which all other exceptions extend

exception spinn_machine.exceptions.SpinnMachineInvalidParameterException(parameter, value, problem)

Bases: spinn_machine.exceptions.SpinnMachineException

Indicates that there is a problem with a parameter value

Parameters:
  • parameter (str) – The name of the parameter that has an invalid value
  • value (str) – The value of the parameter that is invalid
  • problem (str) – The reason for the exception
parameter

The name of the parameter

problem

The problem with the setting of the parameter

value

The value of the parameter

spinn_machine.machine module

class spinn_machine.machine.Machine(chips, boot_x, boot_y)

Bases: object

A Representation of a Machine with a number of Chips. Machine is also iterable, providing ((x, y), chip) where:

  • x is the x-coordinate of a chip
  • y is the y-coordinate of a chip
  • chip is the chip with the given x, y coordinates
Parameters:
  • chips (iterable of spinn_machine.Chip) – An iterable of chips in the machine
  • boot_x (int) – The x-coordinate of the chip used to boot the machine
  • boot_y (int) – The y-coordinate of the chip used to boot the machine
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

BOARD_48_CHIP_GAPS = set([(2, 7), (2, 6), (7, 0), (7, 1), (6, 1), (0, 4), (6, 0), (0, 7), (0, 6), (1, 5), (1, 6), (5, 0), (1, 7), (3, 7), (7, 2), (0, 5)])
MAX_BANDWIDTH_PER_ETHERNET_CONNECTED_CHIP = 2560
add_chip(chip)

Add a chip to the machine

Parameters:chip (spinn_machine.Chip) – The chip to add to the machine
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates already exists
add_chips(chips)

Add some chips to the machine

Parameters:chips (iterable of spinn_machine.Chip) – an iterable of chips
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates as one being added already exists

Add FPGA links that are on a given machine depending on the version of the board.

Parameters:version_no – which version of board to use

Add SpiNNaker links that are on a given machine depending on the version of the board.

Parameters:version_no – which version of board to use
boot_chip

The chip used to boot the machine

Return type:py:class:spinn_machine.Chip
boot_x

The x-coordinate of the chip used to boot the machine

Return type:int
boot_y

The y-coordinate of the chip used to boot the machine

Return type:int
chip_coordinates

An iterable of chip coordinates in the machine

Returns:An iterable of chip coordinates
Return type:iterable of (int, int)
chips

An iterable of chips in the machine

Returns:An iterable of chips
Return type:iterable of spinn_machine.Chip
Raises:None – does not raise any known exceptions

Get a string detailing the number of cores and links

Return type:str
ethernet_connected_chips

The chips in the machine that have an Ethernet connection

Returns:An iterable of chips
Return type:iterable of spinn_machine.Chip
get_chip_at(x, y)

Get the chip at a specific (x, y) location. Also implemented as __getitem__((x, y))

Parameters:
  • x (int) – the x-coordinate of the requested chip
  • y (int) – the y-coordinate of the requested chip
Returns:

the chip at the specified location, or None if no such chip

Return type:

spinn_machine.Chip

Raises:

None – does not raise any known exceptions

Get the x and y coordinates of the chip over the given link

Parameters:
  • x – The x coordinate of the chip to start from
  • y – The y coordinate of the chip to start from
  • link – The id of the link to traverse, between 0 and 5
  • width – The width of the machine being considered
  • height – The height of the machine being considered
get_chips_on_board(chip)

Get the chips that are on the same board as the given chip

Parameters:chip – The chip to find other chips on the same board as
Returns:An iterable of (x, y) coordinates of chips on the same board

Get the number of cores and links from the machine

Returns:tuple of (n_cores, n_links)

Get an FPGA link data item that corresponds to the FPGA and FPGA link for a given board address.

Parameters:
Return type:

spinn_machine.link_data_objects.FPGALinkData

Returns:

the given FPGA link object or None if no such link

Get a spinnaker link with a given id

Parameters:
  • spinnaker_link_id (int) – The id of the link
  • board_address (str or None) – the board address that this spinnaker link is associated with
Returns:

The spinnaker link data or None if no link

Return type:

spinn_machine.link_data_objects.SpinnakerLinkData

has_wrap_arounds

If the machine has wrap around links

Returns:True if wrap around links exist, false otherwise
Return type:bool
is_chip_at(x, y)

Determine if a chip exists at the given coordinates. Also implemented as __contains__((x, y))

Parameters:
  • x (int) – x location of the chip to test for existence
  • y (int) – y location of the chip to test for existence
Returns:

True if the chip exists, False otherwise

Return type:

bool

Raises:

None – does not raise any known exceptions

Determine if a link exists at the given coordinates

Parameters:
  • x (int) – The x location of the chip to test the link of
  • y (int) – The y location of the chip to test the link of
  • link (int) – The link to test the existence of
max_chip_x

The maximum x-coordinate of any chip in the board

Returns:The maximum x-coordinate
Return type:int
max_chip_y

The maximum y-coordinate of any chip in the board

Returns:The maximum y-coordinate
Return type:int
maximum_user_cores_on_chip

The maximum number of user cores on any chip

n_chips
reserve_system_processors()

Sets one of the none monitor system processors as a system processor on every Chip

Updates maximum_user_cores_on_chip

Returns:A CoreSubsets of reserved cores, and a list of (x, y) of chips where a non-system core was not available
Return type:(spinn_machine.CoreSubsets, list of (int, int))

The set of spinnaker links in the machine

Returns:An iterable of spinnaker links
Return type:iterable of spinn_machine.link_data_objects.SpinnakerLinkData
total_available_user_cores

provides total number of cores on the machine which are not monitor cores

Returns:total
Return type:int
total_cores

provides total number of cores on the machine, includes monitors

Returns:total
Return type:int

spinn_machine.multicast_routing_entry module

class spinn_machine.multicast_routing_entry.MulticastRoutingEntry(routing_entry_key, mask, processor_ids, link_ids, defaultable)

Bases: object

Represents an entry in a multicast routing table

Parameters:
  • routing_entry_key (int) – The routing key_combo
  • mask (int) – The route key_combo mask
  • processor_ids (iterable of int) – The destination processor ids
  • link_ids (iterable of int) – The destination link ids
  • defaultable (bool) – if this entry is defaultable (it receives packets from its directly opposite route position)
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException

  • If processor_ids contains the same id more than once
  • If link_ids contains the same id more than once

defaultable

if this entry is a defaultable entry

Returns:the bool that represents if a entry is defaultable or not
Return type:bool

The destination link ids

Returns:An iterable of link ids
Return type:iterable of int
mask

The routing mask

Returns:The routing mask
Return type:int
merge(other_entry)

Merges together two multicast routing entries. The entry to merge must have the same key and mask. The merge will join the processor ids and link ids from both the entries. This could be used to add a new destination to an existing route in a routing table. It is also possible to use the add (+) operator or the or (|) operator with the same effect.

Parameters:other_entry (MulticastRoutingEntry) – The multicast entry to merge with this entry
Returns:A new multicast routing entry with merged destinations
Return type:MulticastRoutingEntry
Raises:spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the key and mask of the other entry do not match
processor_ids

The destination processor ids

Returns:An iterable of processor ids
Return type:iterable of int
routing_entry_key

The routing key

Returns:The routing key
Return type:int

spinn_machine.processor module

class spinn_machine.processor.Processor(processor_id, clock_speed=200000000, is_monitor=False, dtcm_available=65536)

Bases: object

A processor object included in a chip

Parameters:
  • processor_id (int) – id of the processor in the chip
  • clock_speed (int) – The number of cpu cycles per second of the processor
  • is_monitor (bool) – Determines if the processor is considered the monitor processor, and so should not be otherwise allocated
  • dtcm_available (int) – Data Tightly Coupled Memory available
Raises:

spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the clock speed is negative

CLOCK_SPEED = 200000000
DTCM_AVAILABLE = 65536
clock_speed

The clock speed of the processor in cycles per second

Returns:The clock speed in cycles per second
Return type:int
clone_as_system_processor()

Creates a clone of this processor but changing it to a system processor.

The current implementation does not distinguish between monitor processors and reinjector ones but could do so at a later stage.

Returns:A new Processor with the same properties INCLUDING id except now set as a System processor
Return type:spinn_machine.Processor
cpu_cycles_available

The number of cpu cycles available from this processor per ms

Returns:the number of cpu cycles available on this processor
Return type:int
dtcm_available

The amount of DTCM available on this processor

Returns:the amount of DTCM available on this processor
Return type:int
is_monitor

Determines if the processor is the monitor, and therefore not to be allocated

WARNING: Currently rejection processeors are also marked as monitors

Returns:True if the processor is the monitor, False otherwise
Return type:bool
processor_id

The id of the processor

Returns:id of the processor
Return type:int

spinn_machine.router module

class spinn_machine.router.Router(links, emergency_routing_enabled=False, clock_speed=157286400, n_available_multicast_entries=1024)

Bases: object

Represents a router of a chip, with a set of available links. The router is iterable over the links, providing (source_link_id, link) where:

  • source_link_id is the id of a link
  • link is the link with id source_link_id
Parameters:
  • links (iterable of spinn_machine.Link) – iterable of links
  • emergency_routing_enabled (bool) – Determines if the router emergency routing is operating
  • clock_speed (int) – The router clock speed in cycles per second
  • n_available_multicast_entries (int) – The number of entries available in the routing table
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two links have the same source_link_id

ROUTER_DEFAULT_AVAILABLE_ENTRIES = 1024
ROUTER_DEFAULT_CLOCK_SPEED = 157286400

Add a link to the router of the chip

Parameters:link (spinn_machine.Link) – The link to be added
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If another link already exists with the same source_link_id
clock_speed

The clock speed of the router in cycles per second

Returns:The clock speed in cycles per second
Return type:int
Raises:None – does not raise any known exceptions
static convert_routing_table_entry_to_spinnaker_route(routing_table_entry)

Convert a routing table entry represented in software to a binary routing table entry usable on the machine

Parameters:routing_table_entry (spinn_machine.MulticastRoutingEntry) – The entry to convert
Return type:int
emergency_routing_enabled

Indicator of whether emergency routing is enabled

Returns:True if emergency routing is enabled, False otherwise
Return type:bool
Raises:None – does not raise any known exceptions

Get the link with the given id, or None if no such link. Also implemented as __getitem__(source_link_id)

Parameters:source_link_id (int) – The id of the link to find
Returns:The link, or None if no such link
Return type:spinn_machine.Link
Raises:None – No known exceptions are raised
get_neighbouring_chips_coords()

Utility method to convert links into x and y coordinates

Returns:iterable list of destination coordinates in x and y dict
Return type:iterable of dict

Determine if there is a link with id source_link_id. Also implemented as __contains__(source_link_id)

Parameters:source_link_id (int) – The id of the link to find
Returns:True if there is a link with the given id, False otherwise
Return type:bool
Raises:None – No known exceptions are raised

The available links of this router

Returns:an iterable of available links
Return type:iterable of spinn_machine.Link
Raises:None – does not raise any known exceptions
n_available_multicast_entries

The number of available multicast entries in the routing tables

Returns:The number of available entries
Return type:int
Raises:None – does not raise any known exceptions

spinn_machine.sdram module

class spinn_machine.sdram.SDRAM(size=122683392)

Bases: object

Represents the properties of the SDRAM of a chip in the machine

Parameters:size (int) – the space available in SDRAM
DEFAULT_SDRAM_BYTES = 122683392
size

The SDRAM available for user applications

Returns:The space available in bytes
Return type:int

spinn_machine.spinnaker_triad_geometry module

class spinn_machine.spinnaker_triad_geometry.SpiNNakerTriadGeometry(triad_width, triad_height, roots, centre)

Bases: object

Geometry of a “triad” of SpiNNaker boards

The geometry is defined by the arguments to the constructor; the standard arrangement can be obtained from get_spinn5_geometry

Note that the geometry defines what a Triad is in terms of the dimensions of a triad and where the Ethernet chips occur in the triad

Parameters:
  • triad_width (int) – triad_width of a triad in chips
  • triad_height (int) – triad_height of a triad in chips
  • roots (list of (int, int)) – locations of the Ethernet connected chips
  • centre ((float, float)) – the distance from each Ethernet chip to the centre of the hexagon
get_ethernet_chip_coordinates(x, y, width, height, root_x=0, root_y=0)

Get the coordinates of a chip’s local Ethernet connected chip according to this triad geometry object

Warning

local_eth_coord() will always produce the coordinates of the Ethernet-connected SpiNNaker chip on the same SpiNN-5 board as the supplied chip. This chip may not actually be working.

Parameters:
  • x (int) – x-coordinate of the chip to find the nearest Ethernet of
  • y (int) – y-coordinate of the chip to find the nearest Ethernet of
  • width (int) – width of the spinnaker machine (must be a multiple of the triad width of this geometry)
  • height (int) – height of the spinnaker machine (must be a multiple of the triad height of this geometry)
  • root_x (int) – x-coordinate of the boot chip (default 0, 0)
  • root_y (int) – y-coordinate of the boot chip (default 0, 0)
Returns:

The coordinates of the closest Ethernet chip

Return type:

(int, int)

get_local_chip_coordinate(x, y, root_x=0, root_y=0)

Get the coordinates of a chip on its board of a multi-board system relative to the Ethernet chip of the board.

Note

This function assumes the system is constructed from SpiNN-5 boards

Parameters:
  • x (int) – The x-coordinate of the chip to find the location of
  • y (int) – The y-coordinate of the chip to find the location of
  • root_x (int) – The x-coordinate of the boot chip (default 0, 0)
  • root_y (int) – The y-coordinate of the boot chip (default 0, 0)
Returns:

the coordinates of the chip relative to its board

Return type:

(int, int)

static get_spinn5_geometry()

Get the geometry object for a SpiNN-5 arrangement of boards

Returns:a SpiNNakerTriadGeometry object.
spinn5_triad_geometry = None

spinn_machine.virtual_machine module

class spinn_machine.virtual_machine.VirtualMachine(width=None, height=None, with_wrap_arounds=False, version=None, n_cpus_per_chip=18, with_monitors=True, sdram_per_chip=None, down_chips=None, down_cores=None, down_links=None)

Bases: spinn_machine.machine.Machine

A Virtual SpiNNaker machine

Parameters:
  • width (int) – the width of the virtual machine in chips
  • height (int) – the height of the virtual machine in chips
  • with_wrap_arounds (bool) – bool defining if wrap around links exist
  • version (int) – the version id of a board; if None, a machine is created with the correct dimensions, otherwise the machine will be a single board of the given version
  • n_cpus_per_chip (int) – The number of CPUs to put on each chip
  • with_monitors (bool) – True if CPU 0 should be marked as a monitor
  • sdram_per_chip (int or None) – The amount of SDRAM to give to each chip
add_chip(chip)

Add a chip to the machine

Parameters:chip (spinn_machine.Chip) – The chip to add to the machine
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates already exists
chip_coordinates
chips
get_chip_at(x, y)
is_chip_at(x, y)
maximum_user_cores_on_chip
n_chips
reserve_system_processors()

Sets one of the none monitor system processors as a system processor on every Chip

Updates maximum_user_cores_on_chip

:rtype None

Module contents

A python abstraction of a SpiNNaker Machine. The main functionality is provided by spinn_machine.Machine.

Functional Requirements

  • Create a machine which represents the current state of a machine, in terms of the available chips, cores on the chips, SDRAM available, routable links between chips and available routing entries.

  • Create a machine which represents an abstract ideal machine.

    • There can only be one chip in the machine with given x, y coordinates
    • There can only be one processor in each chip with a given processor id
    • There can only be one link in the router of each chip with a given id
  • Add a chip to a given machine to represent an external device.

    • A chip with the same x, y coordinates must not already exist in the machine
  • Add a link to a router of a given chip to represent a connection to an external device.

    • A link with the given id must not already exist in the chip
  • Create a representation of a multicast routing entry to be shared between modules that deal with routing entries.

Use Cases

  • Machine is returned as a representation of the current state of a machine.
  • Machine is used as an outline of a machine on which a simulation will be run e.g. for placement of executables and/or finding routes between placed executables.
  • Machine is extended to add a virtual Chip on the machine representing an external peripheral connected to the machine directly via a link from a chip, so that routes can be directed to and from the external peripheral
  • MulticastRoutingEntry is returned in a list of entries, which indicate the current set of routing entries within a multicast routing table on a chip on the machine.
  • MulticastRoutingEntry is sent in a list of routing entries to set up routing on a chip on the machine.
class spinn_machine.Chip(x, y, processors, router, sdram, nearest_ethernet_x, nearest_ethernet_y, ip_address=None, virtual=False, tag_ids=set([1, 2, 3, 4, 5, 6, 7]))

Bases: object

Represents a chip with a number of cores, an amount of SDRAM shared between the cores, and a router. The chip is iterable over the processors providing (processor_id, processor) where:

  • processor_id is the id of a processor
  • processor is the processor with processor_id
Parameters:
  • x (int) – the x-coordinate of the chip’s position in the two-dimensional grid of chips
  • y (int) – the y-coordinate of the chip’s position in the two-dimensional grid of chips
  • processors (iterable of spinn_machine.Processor) – an iterable of processor objects
  • router (spinn_machine.Router) – a router for the chip
  • sdram (spinn_machine.SDRAM) – an SDRAM for the chip
  • ip_address (str) – the IP address of the chip or None if no Ethernet attached
  • virtual (bool) – boolean which defines if this chip is a virtual one
  • tag_ids (iterable of int) – Id to identify the chip for SDP
  • nearest_ethernet_x (int or None) – the nearest Ethernet x coord
  • nearest_ethernet_y (int or None) – the nearest Ethernet y coord
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If processors contains any two processors with the same processor_id

IPTAG_IDS = set([1, 2, 3, 4, 5, 6, 7])
get_first_none_monitor_processor()

Get the first processor in the list which is not a monitor core

Returns:a processor
get_processor_with_id(processor_id)

Return the processor with the specified id or None if the processor does not exist. Also implemented as __contains__(processor_id)

Parameters:processor_id (int) – the id of the processor to return
Returns:the processor with the specified id or None if no such processor
Return type:spinn_machine.Processor
Raises:None – does not raise any known exceptions
ip_address

The IP address of the chip

Returns:IP address of the chip, or None if there is no Ethernet connected to the chip
Return type:str
Raises:None – does not raise any known exceptions
is_processor_with_id(processor_id)

Determines if a processor with the given id exists in the chip. Also implemented as __getitem__(processor_id)

Parameters:processor_id (int) – the processor id to check for
Returns:True or False based on the existence of the processor
Return type:bool
Raises:None – does not raise any known exceptions
n_processors

The total number of processors

n_user_processors

The total number of processors that are not monitors

nearest_ethernet_x

the x coord of the nearest Ethernet chip

Returns:the x coord of the nearest Ethernet chip
Return type:int
Raises:None – does not raise any known exceptions
nearest_ethernet_y

the y coord of the nearest Ethernet chip

Returns:the y coord of the nearest Ethernet chip
Return type:int
Raises:None – does not raise any known exceptions
processors

An iterable of available processors

Returns:iterable of processors
Return type:iterable of :py:class:spinn_machine.Processor`
Raises:None – does not raise any known exceptions
reserve_a_system_processor()

This method should ONLY be called via Machine.reserve_system_processors

Sets one of the none monitor processors as a system processor

Updates n_user_processors

Returns:The id of the processor reserved, or None if no processor could be found
Return type:int or None
router

The router object associated with the chip

Returns:router associated with the chip
Return type:spinn_machine.Router
Raises:None – does not raise any known exceptions
sdram

The sdram associated with the chip

Returns:sdram associated with the chip
Return type:spinn_machine.SDRAM
Raises:None – does not raise any known exceptions
tag_ids

The tag ids supported by this chip

Returns:the set of ids.
Raises:None – this method does not raise any exception
virtual

boolean which defines if the chip is virtual or not

Returns:if the chip is virtual
Return type:boolean
Raises:None – this method does not raise any known exceptions
x

The x-coordinate of the chip in the two-dimensional grid of chips

Returns:the x-coordinate of the chip
Return type:int
Raises:None – does not raise any known exceptions
y

The y-coordinate of the chip in the two-dimensional grid of chips

Returns:the y-coordinate of the chip
Return type:int
Raises:None – does not raise any known exceptions
class spinn_machine.CoreSubset(x, y, processor_ids)

Bases: object

Represents a subset of the cores on a chip

Parameters:
  • x (int) – The x-coordinate of the chip
  • y (int) – The y-coordinate of the chip
  • processor_ids (iterable of int) – An iterable of processor ids on the chip
add_processor(processor_id)

Adds a processor id to this subset

Parameters:processor_id (int) – A processor id
Returns:Nothing is returned
Return type:None
processor_ids

The subset of processor ids on the chip

Returns:An iterable of processor ids
Return type:iterable of int
x

The x-coordinate of the chip

Returns:The x-coordinate
Return type:int
y

The y-coordinate of the chip

Returns:The y-coordinate
Return type:int
class spinn_machine.CoreSubsets(core_subsets=None)

Bases: object

Represents a group of CoreSubsets, with a maximum of one per chip

Parameters:core_subsets (iterable of spinn_machine.CoreSubset) – An iterable of cores for each desired chip
add_core_subset(core_subset)

Add a core subset to the set

Parameters:core_subset (spinn_machine.CoreSubset) – The core subset to add
Returns:Nothing is returned
Return type:None
add_processor(x, y, processor_id)

Add a processor on a given chip to the set

Parameters:
  • x (int) – The x-coordinate of the chip
  • y (int) – The y-coordinate of the chip
  • processor_id (int) – A processor id
Returns:

Nothing is returned

Return type:

None

core_subsets

The one-per-chip subsets

Returns:Iterable of core subsets
Return type:iterable of spinn_machine.CoreSubset
get_core_subset_for_chip(x, y)

Get the core subset for a chip

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
Returns:

The core subset of a chip, which will be empty if not added

Return type:

spinn_machine.CoreSubset

is_chip(x, y)

Determine if the chip with coordinates (x, y) is in the subset

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
Returns:

True if the chip with coordinates (x, y) is in the subset

Return type:

bool

is_core(x, y, processor_id)

Determine if there is a chip with coordinates (x, y) in the subset, which has a core with the given id in the subset

Parameters:
  • x (int) – The x-coordinate of a chip
  • y (int) – The y-coordinate of a chip
  • processor_id (int) – The id of a core
Returns:

True if there is a chip with coordinates (x, y) in the subset, which has a core with the given id in the subset

Bases: object

Represents a directional link between chips in the machine

Parameters:
  • source_x (int) – The x-coordinate of the source chip of the link
  • source_y (int) – The y-coordinate of the source chip of the link
  • source_link_id (int) – The id of the link in the source chip
  • destination_x (int) – The x-coordinate of the destination chip of the link
  • destination_y (int) – The y-coordinate of the destination chip of the link
  • multicast_default_from (int) – Traffic received on the link identified by multicast_default_from will be sent to the link herein defined if no entry is present in the multicast routing table. On SpiNNaker chips, multicast_default_from is usually the same as multicast_default_to. None if no such default exists, or the link does not exist.
  • multicast_default_to (int) – Traffic received on the link herein defined will be sent to the link identified by multicast_default_from if no entry is present in the multicast routing table. On SpiNNaker chips, multicast_default_to is usually the same as multicast_default_from. None if no such link exists, or the link does not exist.
Raises:

None – No known exceptions are raised

destination_x

The x-coordinate of the destination chip of this link

Returns:The x-coordinate
Return type:int
destination_y

The y-coordinate of the destination chip of this link

Returns:The y-coordinate
Return type:int
multicast_default_from

The id of the link for which this link is the default

Returns:The id of a link, or None if no such link
Return type:int
multicast_default_to

The id of the link to which to send default routed multicast

Returns:The id of a link, or None if no such link
Return type:int

The id of the link on the source chip

Returns:The link id
Return type:int
source_x

The x-coordinate of the source chip of this link

Returns:The x-coordinate
Return type:int
source_y

The y-coordinate of the source chip of this link

Returns:The y-coordinate
Return type:int
class spinn_machine.Machine(chips, boot_x, boot_y)

Bases: object

A Representation of a Machine with a number of Chips. Machine is also iterable, providing ((x, y), chip) where:

  • x is the x-coordinate of a chip
  • y is the y-coordinate of a chip
  • chip is the chip with the given x, y coordinates
Parameters:
  • chips (iterable of spinn_machine.Chip) – An iterable of chips in the machine
  • boot_x (int) – The x-coordinate of the chip used to boot the machine
  • boot_y (int) – The y-coordinate of the chip used to boot the machine
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

BOARD_48_CHIP_GAPS = set([(2, 7), (2, 6), (7, 0), (7, 1), (6, 1), (0, 4), (6, 0), (0, 7), (0, 6), (1, 5), (1, 6), (5, 0), (1, 7), (3, 7), (7, 2), (0, 5)])
MAX_BANDWIDTH_PER_ETHERNET_CONNECTED_CHIP = 2560
add_chip(chip)

Add a chip to the machine

Parameters:chip (spinn_machine.Chip) – The chip to add to the machine
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates already exists
add_chips(chips)

Add some chips to the machine

Parameters:chips (iterable of spinn_machine.Chip) – an iterable of chips
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates as one being added already exists

Add FPGA links that are on a given machine depending on the version of the board.

Parameters:version_no – which version of board to use

Add SpiNNaker links that are on a given machine depending on the version of the board.

Parameters:version_no – which version of board to use
boot_chip

The chip used to boot the machine

Return type:py:class:spinn_machine.Chip
boot_x

The x-coordinate of the chip used to boot the machine

Return type:int
boot_y

The y-coordinate of the chip used to boot the machine

Return type:int
chip_coordinates

An iterable of chip coordinates in the machine

Returns:An iterable of chip coordinates
Return type:iterable of (int, int)
chips

An iterable of chips in the machine

Returns:An iterable of chips
Return type:iterable of spinn_machine.Chip
Raises:None – does not raise any known exceptions

Get a string detailing the number of cores and links

Return type:str
ethernet_connected_chips

The chips in the machine that have an Ethernet connection

Returns:An iterable of chips
Return type:iterable of spinn_machine.Chip
get_chip_at(x, y)

Get the chip at a specific (x, y) location. Also implemented as __getitem__((x, y))

Parameters:
  • x (int) – the x-coordinate of the requested chip
  • y (int) – the y-coordinate of the requested chip
Returns:

the chip at the specified location, or None if no such chip

Return type:

spinn_machine.Chip

Raises:

None – does not raise any known exceptions

Get the x and y coordinates of the chip over the given link

Parameters:
  • x – The x coordinate of the chip to start from
  • y – The y coordinate of the chip to start from
  • link – The id of the link to traverse, between 0 and 5
  • width – The width of the machine being considered
  • height – The height of the machine being considered
get_chips_on_board(chip)

Get the chips that are on the same board as the given chip

Parameters:chip – The chip to find other chips on the same board as
Returns:An iterable of (x, y) coordinates of chips on the same board

Get the number of cores and links from the machine

Returns:tuple of (n_cores, n_links)

Get an FPGA link data item that corresponds to the FPGA and FPGA link for a given board address.

Parameters:
Return type:

spinn_machine.link_data_objects.FPGALinkData

Returns:

the given FPGA link object or None if no such link

Get a spinnaker link with a given id

Parameters:
  • spinnaker_link_id (int) – The id of the link
  • board_address (str or None) – the board address that this spinnaker link is associated with
Returns:

The spinnaker link data or None if no link

Return type:

spinn_machine.link_data_objects.SpinnakerLinkData

has_wrap_arounds

If the machine has wrap around links

Returns:True if wrap around links exist, false otherwise
Return type:bool
is_chip_at(x, y)

Determine if a chip exists at the given coordinates. Also implemented as __contains__((x, y))

Parameters:
  • x (int) – x location of the chip to test for existence
  • y (int) – y location of the chip to test for existence
Returns:

True if the chip exists, False otherwise

Return type:

bool

Raises:

None – does not raise any known exceptions

Determine if a link exists at the given coordinates

Parameters:
  • x (int) – The x location of the chip to test the link of
  • y (int) – The y location of the chip to test the link of
  • link (int) – The link to test the existence of
max_chip_x

The maximum x-coordinate of any chip in the board

Returns:The maximum x-coordinate
Return type:int
max_chip_y

The maximum y-coordinate of any chip in the board

Returns:The maximum y-coordinate
Return type:int
maximum_user_cores_on_chip

The maximum number of user cores on any chip

n_chips
reserve_system_processors()

Sets one of the none monitor system processors as a system processor on every Chip

Updates maximum_user_cores_on_chip

Returns:A CoreSubsets of reserved cores, and a list of (x, y) of chips where a non-system core was not available
Return type:(spinn_machine.CoreSubsets, list of (int, int))

The set of spinnaker links in the machine

Returns:An iterable of spinnaker links
Return type:iterable of spinn_machine.link_data_objects.SpinnakerLinkData
total_available_user_cores

provides total number of cores on the machine which are not monitor cores

Returns:total
Return type:int
total_cores

provides total number of cores on the machine, includes monitors

Returns:total
Return type:int
class spinn_machine.MulticastRoutingEntry(routing_entry_key, mask, processor_ids, link_ids, defaultable)

Bases: object

Represents an entry in a multicast routing table

Parameters:
  • routing_entry_key (int) – The routing key_combo
  • mask (int) – The route key_combo mask
  • processor_ids (iterable of int) – The destination processor ids
  • link_ids (iterable of int) – The destination link ids
  • defaultable (bool) – if this entry is defaultable (it receives packets from its directly opposite route position)
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException

  • If processor_ids contains the same id more than once
  • If link_ids contains the same id more than once

defaultable

if this entry is a defaultable entry

Returns:the bool that represents if a entry is defaultable or not
Return type:bool

The destination link ids

Returns:An iterable of link ids
Return type:iterable of int
mask

The routing mask

Returns:The routing mask
Return type:int
merge(other_entry)

Merges together two multicast routing entries. The entry to merge must have the same key and mask. The merge will join the processor ids and link ids from both the entries. This could be used to add a new destination to an existing route in a routing table. It is also possible to use the add (+) operator or the or (|) operator with the same effect.

Parameters:other_entry (MulticastRoutingEntry) – The multicast entry to merge with this entry
Returns:A new multicast routing entry with merged destinations
Return type:MulticastRoutingEntry
Raises:spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the key and mask of the other entry do not match
processor_ids

The destination processor ids

Returns:An iterable of processor ids
Return type:iterable of int
routing_entry_key

The routing key

Returns:The routing key
Return type:int
class spinn_machine.Processor(processor_id, clock_speed=200000000, is_monitor=False, dtcm_available=65536)

Bases: object

A processor object included in a chip

Parameters:
  • processor_id (int) – id of the processor in the chip
  • clock_speed (int) – The number of cpu cycles per second of the processor
  • is_monitor (bool) – Determines if the processor is considered the monitor processor, and so should not be otherwise allocated
  • dtcm_available (int) – Data Tightly Coupled Memory available
Raises:

spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the clock speed is negative

CLOCK_SPEED = 200000000
DTCM_AVAILABLE = 65536
clock_speed

The clock speed of the processor in cycles per second

Returns:The clock speed in cycles per second
Return type:int
clone_as_system_processor()

Creates a clone of this processor but changing it to a system processor.

The current implementation does not distinguish between monitor processors and reinjector ones but could do so at a later stage.

Returns:A new Processor with the same properties INCLUDING id except now set as a System processor
Return type:spinn_machine.Processor
cpu_cycles_available

The number of cpu cycles available from this processor per ms

Returns:the number of cpu cycles available on this processor
Return type:int
dtcm_available

The amount of DTCM available on this processor

Returns:the amount of DTCM available on this processor
Return type:int
is_monitor

Determines if the processor is the monitor, and therefore not to be allocated

WARNING: Currently rejection processeors are also marked as monitors

Returns:True if the processor is the monitor, False otherwise
Return type:bool
processor_id

The id of the processor

Returns:id of the processor
Return type:int
class spinn_machine.Router(links, emergency_routing_enabled=False, clock_speed=157286400, n_available_multicast_entries=1024)

Bases: object

Represents a router of a chip, with a set of available links. The router is iterable over the links, providing (source_link_id, link) where:

  • source_link_id is the id of a link
  • link is the link with id source_link_id
Parameters:
  • links (iterable of spinn_machine.Link) – iterable of links
  • emergency_routing_enabled (bool) – Determines if the router emergency routing is operating
  • clock_speed (int) – The router clock speed in cycles per second
  • n_available_multicast_entries (int) – The number of entries available in the routing table
Raises:

spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If any two links have the same source_link_id

ROUTER_DEFAULT_AVAILABLE_ENTRIES = 1024
ROUTER_DEFAULT_CLOCK_SPEED = 157286400

Add a link to the router of the chip

Parameters:link (spinn_machine.Link) – The link to be added
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If another link already exists with the same source_link_id
clock_speed

The clock speed of the router in cycles per second

Returns:The clock speed in cycles per second
Return type:int
Raises:None – does not raise any known exceptions
static convert_routing_table_entry_to_spinnaker_route(routing_table_entry)

Convert a routing table entry represented in software to a binary routing table entry usable on the machine

Parameters:routing_table_entry (spinn_machine.MulticastRoutingEntry) – The entry to convert
Return type:int
emergency_routing_enabled

Indicator of whether emergency routing is enabled

Returns:True if emergency routing is enabled, False otherwise
Return type:bool
Raises:None – does not raise any known exceptions

Get the link with the given id, or None if no such link. Also implemented as __getitem__(source_link_id)

Parameters:source_link_id (int) – The id of the link to find
Returns:The link, or None if no such link
Return type:spinn_machine.Link
Raises:None – No known exceptions are raised
get_neighbouring_chips_coords()

Utility method to convert links into x and y coordinates

Returns:iterable list of destination coordinates in x and y dict
Return type:iterable of dict

Determine if there is a link with id source_link_id. Also implemented as __contains__(source_link_id)

Parameters:source_link_id (int) – The id of the link to find
Returns:True if there is a link with the given id, False otherwise
Return type:bool
Raises:None – No known exceptions are raised

The available links of this router

Returns:an iterable of available links
Return type:iterable of spinn_machine.Link
Raises:None – does not raise any known exceptions
n_available_multicast_entries

The number of available multicast entries in the routing tables

Returns:The number of available entries
Return type:int
Raises:None – does not raise any known exceptions
class spinn_machine.SDRAM(size=122683392)

Bases: object

Represents the properties of the SDRAM of a chip in the machine

Parameters:size (int) – the space available in SDRAM
DEFAULT_SDRAM_BYTES = 122683392
size

The SDRAM available for user applications

Returns:The space available in bytes
Return type:int
class spinn_machine.SpiNNakerTriadGeometry(triad_width, triad_height, roots, centre)

Bases: object

Geometry of a “triad” of SpiNNaker boards

The geometry is defined by the arguments to the constructor; the standard arrangement can be obtained from get_spinn5_geometry

Note that the geometry defines what a Triad is in terms of the dimensions of a triad and where the Ethernet chips occur in the triad

Parameters:
  • triad_width (int) – triad_width of a triad in chips
  • triad_height (int) – triad_height of a triad in chips
  • roots (list of (int, int)) – locations of the Ethernet connected chips
  • centre ((float, float)) – the distance from each Ethernet chip to the centre of the hexagon
get_ethernet_chip_coordinates(x, y, width, height, root_x=0, root_y=0)

Get the coordinates of a chip’s local Ethernet connected chip according to this triad geometry object

Warning

local_eth_coord() will always produce the coordinates of the Ethernet-connected SpiNNaker chip on the same SpiNN-5 board as the supplied chip. This chip may not actually be working.

Parameters:
  • x (int) – x-coordinate of the chip to find the nearest Ethernet of
  • y (int) – y-coordinate of the chip to find the nearest Ethernet of
  • width (int) – width of the spinnaker machine (must be a multiple of the triad width of this geometry)
  • height (int) – height of the spinnaker machine (must be a multiple of the triad height of this geometry)
  • root_x (int) – x-coordinate of the boot chip (default 0, 0)
  • root_y (int) – y-coordinate of the boot chip (default 0, 0)
Returns:

The coordinates of the closest Ethernet chip

Return type:

(int, int)

get_local_chip_coordinate(x, y, root_x=0, root_y=0)

Get the coordinates of a chip on its board of a multi-board system relative to the Ethernet chip of the board.

Note

This function assumes the system is constructed from SpiNN-5 boards

Parameters:
  • x (int) – The x-coordinate of the chip to find the location of
  • y (int) – The y-coordinate of the chip to find the location of
  • root_x (int) – The x-coordinate of the boot chip (default 0, 0)
  • root_y (int) – The y-coordinate of the boot chip (default 0, 0)
Returns:

the coordinates of the chip relative to its board

Return type:

(int, int)

static get_spinn5_geometry()

Get the geometry object for a SpiNN-5 arrangement of boards

Returns:a SpiNNakerTriadGeometry object.
spinn5_triad_geometry = None
class spinn_machine.VirtualMachine(width=None, height=None, with_wrap_arounds=False, version=None, n_cpus_per_chip=18, with_monitors=True, sdram_per_chip=None, down_chips=None, down_cores=None, down_links=None)

Bases: spinn_machine.machine.Machine

A Virtual SpiNNaker machine

Parameters:
  • width (int) – the width of the virtual machine in chips
  • height (int) – the height of the virtual machine in chips
  • with_wrap_arounds (bool) – bool defining if wrap around links exist
  • version (int) – the version id of a board; if None, a machine is created with the correct dimensions, otherwise the machine will be a single board of the given version
  • n_cpus_per_chip (int) – The number of CPUs to put on each chip
  • with_monitors (bool) – True if CPU 0 should be marked as a monitor
  • sdram_per_chip (int or None) – The amount of SDRAM to give to each chip
add_chip(chip)

Add a chip to the machine

Parameters:chip (spinn_machine.Chip) – The chip to add to the machine
Returns:Nothing is returned
Return type:None
Raises:spinn_machine.exceptions.SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates already exists
chip_coordinates
chips
get_chip_at(x, y)
is_chip_at(x, y)
maximum_user_cores_on_chip
n_chips
reserve_system_processors()

Sets one of the none monitor system processors as a system processor on every Chip

Updates maximum_user_cores_on_chip

:rtype None