spinnman.processes package

Module contents

class spinnman.processes.AbstractMultiConnectionProcess(next_connection_selector: ConnectionSelector, n_retries: int = 10, timeout: float = 1.0, n_channels: int = 8, intermediate_channel_waits: int = 7, non_fail_retry_codes: Set[SCPResult] | None = None)

Bases: Generic[R]

A process for talking to SpiNNaker efficiently that uses multiple connections in communication if relevant.

Parameters:
  • next_connection_selector – How to choose the connection.

  • n_retries – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

  • non_fail_retry_codes – Optional set of responses that result in retry but after retrying don’t then result in failure even if returned on the last call.

check_for_error(print_exception: bool = False) None[source]

Check if any errors have been cached and raises them

if print_exception it also logs the error.

Parameters:

print_exception

Raises:

SpinnmanGenericProcessException – If any was found

property connection_selector: ConnectionSelector

The connection selector of the process.

is_error() bool[source]
Returns:

If any errors have been cached.

spinnman.processes.AbstractMultiConnectionProcessConnectionSelector

alias of ConnectionSelector

class spinnman.processes.ApplicationCopyRunProcess(next_connection_selector: ConnectionSelector, timeout: float = 6.0)

Bases: AbstractMultiConnectionProcess

Process to start a binary on a subset of cores on a subset of chips of a machine, performed by, on each chip, copying the data from an adjacent chip and then starting the binary. This goes to each chip in turn, and so detects failures early on, as well as ensuring that the copy and execution is done in the case of success i.e. this ensures that if all commands are successful, the full binary has been copied and started.

Note

The binary must have been loaded to the boot chip before this is called!

Parameters:
  • next_connection_selector – Method to find the next connection to use

  • timeout – How long to wait for a response before raising an Exception

run(size: int, app_id: int, core_subsets: CoreSubsets, checksum: int, wait: bool) None[source]

Run the process.

Parameters:
  • size – The size of the binary to copy

  • app_id – The application id to assign to the running binary

  • core_subsets – The cores to load the binary on to

  • checksum – The checksum of the data to test against

  • wait – Whether to put the binary in “wait” mode or run it straight away

class spinnman.processes.ApplicationRunProcess(next_connection_selector: ConnectionSelector, n_retries: int = 10, timeout: float = 1.0, n_channels: int = 8, intermediate_channel_waits: int = 7, non_fail_retry_codes: Set[SCPResult] | None = None)

Bases: AbstractMultiConnectionProcess[CheckOKResponse]

A process to run an application.

Parameters:
  • next_connection_selector – How to choose the connection.

  • n_retries – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

  • non_fail_retry_codes – Optional set of responses that result in retry but after retrying don’t then result in failure even if returned on the last call.

run(app_id: int, core_subsets: CoreSubsets, wait: bool) None[source]

Runs the application.

param app_id:

param core_subsets:

param wait:

`

class spinnman.processes.ClearRoutesProcess(next_connection_selector: ConnectionSelector, n_retries: int = 10, timeout: float = 1.0, n_channels: int = 8, intermediate_channel_waits: int = 7, non_fail_retry_codes: Set[SCPResult] | None = None)

Bases: AbstractMultiConnectionProcess[CheckOKResponse]

A Process to clear routes

Parameters:
  • next_connection_selector – How to choose the connection.

  • n_retries – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

  • non_fail_retry_codes – Optional set of responses that result in retry but after retrying don’t then result in failure even if returned on the last call.

clear_routes(chips: List[Tuple[int, int]]) None[source]

Clear the routes on the selected chips

Parameters:

chips – A list of x, y, address and value to set

Raises:
class spinnman.processes.ConnectionSelector

Bases: Generic[Conn]

A connection selector for multi-connection processes.

abstractmethod get_next_connection(message: AbstractSCPRequest) Conn[source]
Parameters:

message – The SCP message to be sent

Returns:

The (next) available Connection

class spinnman.processes.FixedConnectionSelector(connection: Conn)

Bases: ConnectionSelector[Conn], Generic[Conn]

A connection selector that only uses a single connection.

Parameters:

connection – The connection to be used

get_next_connection(message: Any) Conn[source]
Parameters:

message – The SCP message to be sent

Returns:

The (next) available Connection

class spinnman.processes.GetCPUInfoProcess(connection_selector: ConnectionSelector)

Bases: AbstractMultiConnectionProcess[Response]

Gets the CPU for processors over the provided connection.

This base class returns info for all states.

Parameters:

connection_selector

get_cpu_info(core_subsets: CoreSubsets) CPUInfos[source]
Parameters:

core_subsets

Returns:

The CpuInfos for the requested cores.

class spinnman.processes.GetExcludeCPUInfoProcess(connection_selector: ConnectionSelector, states: Container[CPUState])

Bases: GetCPUInfoProcess

Gets the CPU for processors over the provided connection.

This class returns all but infos for the requested states.

Parameters:
  • connection_selector

  • states – The states for which info is NOT required.

class spinnman.processes.GetHeapProcess(connection_selector: ConnectionSelector)

Bases: AbstractMultiConnectionProcess[Response]

Gets Heap information using the provided connector.

Parameters:

connection_selector

get_heap(chip_coords: Tuple[int, int], pointer: SystemVariableDefinition = SystemVariableDefinition.sdram_heap_address) Sequence[HeapElement][source]
Parameters:
  • chip_coords – x, y

  • pointer

Returns:

List of HeapElements

class spinnman.processes.GetIncludeCPUInfoProcess(connection_selector: ConnectionSelector, states: Container[CPUState])

Bases: GetCPUInfoProcess

Gets the CPU for processors over the provided connection.

This class returns only infos for the requested states.

Parameters:
  • connection_selector

  • states – The states for which info is required.

class spinnman.processes.GetMachineProcess(connection_selector: ConnectionSelector)

Bases: AbstractMultiConnectionProcess

A process for getting the machine details over a set of connections.

Parameters:

connection_selector

get_machine_details(boot_x: int, boot_y: int, width: int, height: int) Machine[source]
Parameters:
  • boot_x

  • boot_y

  • width

  • height

Returns:

The Machine read from the boot Chip

class spinnman.processes.GetMultiCastRoutesProcess(connection_selector: ConnectionSelector, app_id: int | None = None)

Bases: AbstractMultiConnectionProcess[Response]

A process for reading the multicast routing table of a SpiNNaker chip.

Parameters:
  • connection_selector

  • app_id

get_routes(x: int, y: int, base_address: int) List[MulticastRoutingEntry][source]
Parameters:
  • x

  • y

  • base_address

Returns:

The Routes read from the scamp chip

class spinnman.processes.GetNCoresInStateProcess(connection_selector: ConnectionSelector)

Bases: AbstractMultiConnectionProcess

Gets the state of a core over the provided connection.

Parameters:

connection_selector

get_n_cores_in_state(xys: Iterable[Tuple[int, int]], app_id: int, state: CPUState) int[source]
Parameters:
  • xys

  • app_id

  • state

Returns:

The number of the listed Chips and IP

class spinnman.processes.GetTagsProcess(connection_selector: ConnectionSelector)

Bases: AbstractMultiConnectionProcess

Gets information about the tags over the provided connection.

Parameters:

connection_selector

get_tags(connection: SCAMPConnection) List[AbstractTag][source]
Parameters:

connection

Returns:

The tags read from the connection.

class spinnman.processes.GetVersionProcess(connection_selector: ConnectionSelector, n_retries: int = 10)

Bases: AbstractMultiConnectionProcess[GetVersionResponse]

A process for getting the version of the machine.

Parameters:

connection_selector

get_version(x: int, y: int, p: int) VersionInfo[source]
Parameters:
  • x

  • y

  • p

Returns:

SC&MP/SARK version information

class spinnman.processes.LoadFixedRouteRoutingEntryProcess(next_connection_selector: ConnectionSelector, n_retries: int = 10, timeout: float = 1.0, n_channels: int = 8, intermediate_channel_waits: int = 7, non_fail_retry_codes: Set[SCPResult] | None = None)

Bases: AbstractMultiConnectionProcess

Load a fixed route routing entry onto a chip.

Parameters:
  • next_connection_selector – How to choose the connection.

  • n_retries – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

  • non_fail_retry_codes – Optional set of responses that result in retry but after retrying don’t then result in failure even if returned on the last call.

load_fixed_route(x: int, y: int, fixed_route: RoutingEntry, app_id: int = 0) None[source]

Sends a fixed route to the Chip

Parameters:
  • x – The x-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions.

  • y – The y-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions.

  • fixed_route – the fixed route entry

  • app_id – The ID of the application with which to associate the routes. If not specified, defaults to 0.

class spinnman.processes.LoadMultiCastRoutesProcess(connection_selector: ConnectionSelector)

Bases: AbstractMultiConnectionProcess

A process for loading the multicast routing table on a SpiNNaker chip.

Parameters:

connection_selector

load_routes(x: int, y: int, routes: Collection[MulticastRoutingEntry], app_id: int) None[source]

Converts the routing entries to Machine format and loads then onto the Chip.

Parameters:
  • x

  • y

  • routes

  • app_id

class spinnman.processes.MallocSDRAMProcess(connection_selector: ConnectionSelector)

Bases: AbstractMultiConnectionProcess[_AllocResponse]

A process for allocating a block of SDRAM on a SpiNNaker chip.

Parameters:

connection_selector

property base_address: int

The address of the allocated memory block.

property base_addresses: List[int]

The addresses of the allocated memory blocks.

malloc_sdram(x: int, y: int, size: int, app_id: int, tag: int) None[source]

Allocate space in the SDRAM space.

Parameters:
  • x

  • y

  • size

  • app_id

  • tag

malloc_sdram_multi(allocations: List[Tuple[int, int, int, int, int]]) None[source]

Allocate space in the SDRAM space for multiple chips

Parameters:

allocations – List of (x, y, size, app_id, tag)

class spinnman.processes.MostDirectConnectionSelector(connections: List[SCAMPConnection])

Bases: ConnectionSelector

A selector that goes for the most direct connection for the message.

Parameters:

connections – The connections to be used

get_next_connection(message: AbstractSCPRequest) SCAMPConnection[source]
Parameters:

message – The SCP message to be sent

Returns:

The (next) available Connection

class spinnman.processes.ReadFixedRouteRoutingEntryProcess(connection_selector: ConnectionSelector)

Bases: AbstractMultiConnectionProcess[_FixedRouteResponse]

A process for reading a fixed route routing table entry.

Parameters:

connection_selector – the SC&MP connection selector

read_fixed_route(x: int, y: int, app_id: int = 0) RoutingEntry[source]

Read the fixed route entry installed on a particular chip’s router.

Parameters:
  • x – The x-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions

  • y – The y-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions

  • app_id – The ID of the application with which to associate the routes. If not specified, defaults to 0.

Returns:

The fixed route entry installed the chip’s router.

class spinnman.processes.ReadIOBufProcess(connection_selector: ConnectionSelector)

Bases: AbstractMultiConnectionProcess[Response]

A process for reading IOBUF memory (mostly log messages) from a SpiNNaker core.

Parameters:

connection_selector

read_iobuf(iobuf_size: int, core_subsets: CoreSubsets) Iterable[IOBuffer][source]
Parameters:
  • iobuf_size

  • core_subsets

Returns:

IOBuffer for each core in order

class spinnman.processes.ReadMemoryProcess(connection_selector: ConnectionSelector)

Bases: AbstractMultiConnectionProcess[Response]

A process for reading memory on a SpiNNaker chip.

Parameters:

connection_selector

Read some memory from the neighbour of a core.

Parameters:
  • coordinates

  • link

  • base_address

  • length

Returns:

Data read over the link

read_memory(coordinates: Tuple[int, int, int], base_address: int, length: int) bytearray[source]

Read some memory from a core.

Parameters:
  • coordinates

  • base_address

  • length

Returns:

Data read from the core

class spinnman.processes.ReadRouterDiagnosticsProcess(connection_selector: ConnectionSelector)

Bases: AbstractMultiConnectionProcess[Response]

A process for reading the diagnostic data block from a SpiNNaker router.

Parameters:

connection_selector

get_router_diagnostics(x: int, y: int) RouterDiagnostics[source]
Parameters:
  • x

  • y

Returns:

Router status for this Chip

class spinnman.processes.RoundRobinConnectionSelector(connections: List[SCAMPConnection])

Bases: ConnectionSelector

A connection selector that just spreads work as evenly as possible.

Parameters:

connections – The connections to be used

get_next_connection(message: Any) SCAMPConnection[source]
Parameters:

message – The SCP message to be sent

Returns:

The (next) available Connection

class spinnman.processes.SendSingleCommandProcess(connection_selector: ConnectionSelector, n_retries: int = 3, timeout: float = 1.0, non_fail_retry_codes: Set[SCPResult] | None = None)

Bases: AbstractMultiConnectionProcess, Generic[R]

A process that sends a single command and waits for a simple response.

Parameters:
  • connection_selector

  • n_retries – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout – The timeout, in seconds. Passed to SCPRequestPipeLine

  • non_fail_retry_codes – Optional set of responses that result in retry but after retrying don’t then result in failure even if returned on the last call.

execute(request: AbstractSCPRequest[R]) R[source]
Parameters:

request

Returns:

The response from this request.

class spinnman.processes.SetMemoryProcess(next_connection_selector: ConnectionSelector, n_retries: int = 10, timeout: float = 1.0, n_channels: int = 8, intermediate_channel_waits: int = 7, non_fail_retry_codes: Set[SCPResult] | None = None)

Bases: AbstractMultiConnectionProcess[CheckOKResponse]

A Process to set a single word of memory on a set of cores

Parameters:
  • next_connection_selector – How to choose the connection.

  • n_retries – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

  • non_fail_retry_codes – Optional set of responses that result in retry but after retrying don’t then result in failure even if returned on the last call.

set_values(values: List[Tuple[int, int, int, int]], description: str) None[source]

Set the memory values selected

Parameters:
  • values – A list of x, y, address and value to set

  • description – A description of the operation

Raises:
class spinnman.processes.WriteMemoryProcess(next_connection_selector: ConnectionSelector, n_retries: int = 10, timeout: float = 1.0, n_channels: int = 8, intermediate_channel_waits: int = 7, non_fail_retry_codes: Set[SCPResult] | None = None)

Bases: AbstractMultiConnectionProcess[CheckOKResponse]

A process for writing memory on a SpiNNaker chip.

Parameters:
  • next_connection_selector – How to choose the connection.

  • n_retries – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

  • non_fail_retry_codes – Optional set of responses that result in retry but after retrying don’t then result in failure even if returned on the last call.

Writes memory onto a neighbour of a SpiNNaker chip from a bytearray.

Parameters:
  • coordinates – The X,Y,P coordinates of the core that will write to its neighbour’s memory.

  • link – Along which link is the neighbour.

  • base_address – the address in SDRAM to start writing

  • data – the data to write

  • offset – where in the data to start writing from

  • n_bytes – how much data to write

  • get_sum – whether to return a checksum or 0

Returns:

the data checksum or 0 if get_sum is False

Writes memory onto a neighbour of a SpiNNaker chip from a reader.

Parameters:
  • coordinates – The X,Y,P coordinates of the core that will write to its neighbour’s memory. The P coordinate is normally 0; no reason to not use SCAMP for this.

  • link – Along which link is the neighbour.

  • base_address – the address in SDRAM to start writing

  • reader – the readable object containing the data to write

  • n_bytes – how much data to write

  • get_sum – whether to return a checksum or 0

Returns:

the data checksum or 0 if get_sum is False

write_memory_from_bytearray(coordinates: Tuple[int, int, int], base_address: int, data: bytearray | bytes, offset: int, n_bytes: int, get_sum: bool = False) int[source]

Writes memory onto a SpiNNaker chip from a bytearray.

Parameters:
  • coordinates – The X,Y,P coordinates of the core that will write to memory.

  • base_address – the address in SDRAM to start writing

  • data – the data to write

  • offset – where in the data to start writing from

  • n_bytes – how much data to write

  • get_sum – whether to return a checksum or 0

Returns:

the data checksum or 0 if get_sum is False

write_memory_from_reader(coordinates: Tuple[int, int, int], base_address: int, reader: BinaryIO, n_bytes: int, get_sum: bool = False) int[source]

Writes memory onto a SpiNNaker chip from a reader.

Parameters:
  • coordinates – The X,Y,P coordinates of the core that will write to memory.

  • base_address – the address in SDRAM to start writing

  • reader – the readable object containing the data to write

  • n_bytes – how much data to write

  • get_sum – whether to return a checksum or 0

Returns:

the data checksum or 0 if get_sum is False