spinn_front_end_common.utility_models package¶
Module contents¶
- class spinn_front_end_common.utility_models.ChipPowerMonitorMachineVertex(label: str)¶
Bases:
MachineVertex,AbstractHasAssociatedBinary,AbstractGeneratesDataSpecification,AbstractReceiveBuffersToHostMachine vertex for C code representing functionality to record idle times in a machine graph.
Note
This is an unusual machine vertex, in that it has no associated application vertex.
- Parameters:
label – vertex label
- static binary_start_type() ExecutableType[source]¶
The type of binary that implements this vertex.
- Returns:
start-type
- generate_data_specification(spec: DataSpecificationGenerator, placement: Placement) None[source]¶
Generate a data specification.
- Parameters:
spec – The data specification to write to
placement – The placement the vertex is located at
- get_binary_start_type() ExecutableType[source]¶
- Returns:
The start type of the binary to be run.
- get_recorded_region_ids() List[int][source]¶
Get the recording region IDs that have been recorded using buffering.
- Returns:
The region numbers that have active recording
- get_recording_region_base_address(placement: Placement) int[source]¶
Get the recording region base address.
- Parameters:
placement – the placement object of the core to find the address of
- Returns:
the base address of the recording region
- property sdram_required: AbstractSDRAM¶
The SDRAM space required by the vertex.
- class spinn_front_end_common.utility_models.CommandSender(label: str)¶
Bases:
AbstractOneAppOneMachineVertex[CommandSenderMachineVertex]A utility for sending commands to a vertex (possibly an external device) at fixed times in the simulation or in response to simulation events (e.g., starting and stopping).
- Parameters:
label – The label of this vertex
- add_commands(start_resume_commands: Iterable[MultiCastCommand], pause_stop_commands: Iterable[MultiCastCommand], timed_commands: Iterable[MultiCastCommand], vertex_to_send_to: AbstractVertex) None[source]¶
Add commands to be sent down a given edge.
- Parameters:
start_resume_commands – The commands to send when the simulation starts or resumes from pause
pause_stop_commands – The commands to send when the simulation stops or pauses after running
timed_commands – The commands to send at specific times
vertex_to_send_to – The vertex these commands are to be sent to
- edges_and_partitions() Tuple[List[ApplicationEdge], List[str]][source]¶
Construct application edges from this vertex to the app vertices that this vertex knows how to target (and has keys allocated for).
- Returns:
edges, partition IDs
- get_fixed_key_and_mask(partition_id: str) BaseKeyAndMask[source]¶
Get a fixed key and mask for the application vertex or None if not fixed (the default). See
get_machine_fixed_key_and_mask()for the conditions.- Parameters:
partition_id – The identifier of the partition to get the key for
- Returns:
None or key and mask if fixed
- class spinn_front_end_common.utility_models.CommandSenderMachineVertex(label: str, app_vertex: CommandSender)¶
Bases:
MachineVertex,ProvidesProvenanceDataFromMachineImpl,AbstractHasAssociatedBinary,AbstractGeneratesDataSpecificationMachine vertex for injecting packets at particular times or in response to particular events into a SpiNNaker application.
- Parameters:
label – The label of this vertex
app_vertex
- BINARY_FILE_NAME = 'command_sender_multicast_source.aplx'¶
- class DataRegions(value)[source]¶
Bases:
IntEnumThe ids for each region of the data this Population used.
- COMMANDS_AT_START_RESUME = 2¶
- COMMANDS_AT_STOP_PAUSE = 3¶
- COMMANDS_WITH_ARBITRARY_TIMES = 1¶
- PROVENANCE_REGION = 4¶
- SYSTEM_REGION = 0¶
- add_commands(start_resume_commands: Iterable[MultiCastCommand], pause_stop_commands: Iterable[MultiCastCommand], timed_commands: Iterable[MultiCastCommand], vertex_to_send_to: AbstractVertex) None[source]¶
Add commands to be sent down a given edge.
- Parameters:
start_resume_commands – The commands to send when the simulation starts or resumes from pause
pause_stop_commands – the commands to send when the simulation stops or pauses after running
:param timed_commands:The commands to send at specific times :param vertex_to_send_to: The vertex these commands are to be sent to
- edges_and_partitions() Tuple[List[MachineEdge], List[str]][source]¶
Construct machine edges from this vertex to the machine vertices that this vertex knows how to target (and has keys allocated for).
- Returns:
edges, partition IDs
- generate_data_specification(spec: DataSpecificationGenerator, placement: Placement) None[source]¶
Generate a data specification.
- Parameters:
spec – The data specification to write to
placement – The placement the vertex is located at
- get_binary_start_type() ExecutableType[source]¶
- Returns:
The start type of the binary to be run.
- get_edges_and_partitions(pre_vertex: CS, vertex_type: Type[V], edge_type: Callable[[CS, V], E]) Tuple[List[E], List[str]][source]¶
Construct edges from this vertex to the vertices that this vertex knows how to target (and has keys allocated for).
Note
Do not call this directly from outside either a
CommandSenderor aCommandSenderMachineVertex.- Parameters:
pre_vertex
vertex_type – subclass of
AbstractVertexedge_type – subclass of
AbstractEdge
- Returns:
edges, partition IDs
- get_fixed_key_and_mask(partition_id: str) BaseKeyAndMask[source]¶
- Parameters:
partition_id – The partition to get the key for
- Returns:
The key and mask for the given partition.
- classmethod get_n_command_bytes(commands: Sized) int[source]¶
- Parameters:
commands
- Returns:
Size of the command to send including the number of bytes.
- get_timed_commands_bytes() int[source]¶
The number of bytes in the timed commands
- Returns:
Size of the command to send including the number of bytes and timestamp
- parse_extra_provenance_items(label: str, x: int, y: int, p: int, provenance_data: Sequence[int]) None[source]¶
Convert the remaining provenance words (those not in the standard set) into provenance items.
Called by
get_provenance_data_from_machine()- Parameters:
label – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.
x – x coordinate of the chip where this core
y – y coordinate of the core where this core
p – virtual id of the core
provenance_data – The list of words of raw provenance data.
- property sdram_required: AbstractSDRAM¶
The SDRAM space required by the vertex.
- class spinn_front_end_common.utility_models.DataSpeedUpPacketGatherMachineVertex(x: int, y: int, ip_address: str)¶
Bases:
MachineVertex,AbstractGeneratesDataSpecification,AbstractHasAssociatedBinary,AbstractProvidesProvenanceDataFromMachineMachine vertex for handling fast data transfer between host and SpiNNaker. This machine vertex is only ever placed on chips with a working Ethernet connection; it collaborates with the
ExtraMonitorSupportMachineVertexto write data on other chips.Note
This is an unusual machine vertex, in that it has no associated application vertex.
- Parameters:
x – Where this gatherer is.
y – Where this gatherer is.
ip_address – How to talk directly to the chip where the gatherer is.
- BASE_KEY = 4294967289¶
- BASE_MASK = 4294967291¶
- END_FLAG_KEY = 4294967286¶
- END_FLAG_KEY_OFFSET = 3¶
- FIRST_DATA_KEY = 4294967287¶
- FIRST_DATA_KEY_OFFSET = 2¶
- FLAG_FOR_MISSING_ALL_SEQUENCES = 4294967294¶
- NEW_SEQ_KEY = 4294967288¶
- NEW_SEQ_KEY_OFFSET = 1¶
- TRANSACTION_ID_KEY = 4294967285¶
- TRANSACTION_ID_KEY_OFFSET = 4¶
- generate_data_specification(spec: DataSpecificationGenerator, placement: Placement) None[source]¶
Generate a data specification.
- Parameters:
spec – The data specification to write to
placement – The placement the vertex is located at
- get_binary_start_type() ExecutableType[source]¶
- Returns:
The start type of the binary to be run.
- get_data(extra_monitor: ExtraMonitorSupportMachineVertex, placement: Placement, memory_address: int, length_in_bytes: int) bytearray[source]¶
Gets data from a given core and memory address.
- Parameters:
extra_monitor – the extra monitor used for this data
placement – placement object for where to get data from
memory_address – the address in SDRAM to start reading from
length_in_bytes – the length of data to read in bytes
- Returns:
byte array of the data
- get_provenance_data_from_machine(placement: Placement) None[source]¶
Get provenance data items for a placement and store them in the provenance DB.
- Parameters:
placement – the placement of the object
- static load_application_routing_tables() None[source]¶
Set all chips to have application table loaded in the router.
- static load_system_routing_tables() None[source]¶
Set all chips to have the system table loaded in the router.
- property sdram_required: ConstantSDRAM¶
The SDRAM space required by the vertex.
- send_data_into_spinnaker(x: int, y: int, base_address: int, data: BinaryIO | bytearray | bytes | str | int, *, n_bytes: int | None = None, offset: int = 0) None[source]¶
Sends a block of data into SpiNNaker to a given chip.
- Parameters:
x – chip x for data
y – chip y for data
base_address – the address in SDRAM to start writing memory
data – the data to write or filename to load data from (if a string)
n_bytes – how many bytes to read, or None if not set
offset – where in the data to start from
- set_cores_for_data_streaming() None[source]¶
Helper method for setting the router timeouts to a state usable for data streaming.
- set_router_wait1_timeout(timeout: Tuple[int, int]) None[source]¶
Set the wait1 field for a set of routers.
- Parameters:
timeout – The mantissa and exponent of the timeout value, each between 0 and 15
- class spinn_front_end_common.utility_models.EIEIOParameters(receive_port: int | None = None, receive_sdp_port: int = 1, receive_tag: int | None = None, receive_rate: float = 10.0, virtual_key: int | None = None, prefix: int | None = None, prefix_type: EIEIOPrefix | None = None, check_keys: bool = False, reserve_reverse_ip_tag: bool = False)¶
Bases:
object- Parameters:
board_address – The IP address of the board on which to place this vertex if receiving data, either buffered or live (by default, any board is chosen)
receive_port – The port on the board that will listen for incoming event packets (default is to disable this feature; set a value to enable it, or set the reserve_reverse_ip_tag parameter to True if a random port is to be used)
receive_sdp_port – The SDP port to listen on for incoming event packets (defaults to 1)
receive_tag – The IP tag to use for receiving live events (uses any by default)
receive_rate
virtual_key – The base multicast key to send received events with (assigned automatically by default)
prefix – The prefix to “or” with generated multicast keys (default is no prefix)
prefix_type – Whether the prefix should apply to the upper or lower half of the multicast keys (default is upper half)
check_keys – True if the keys of received events should be verified before sending (default False)
reserve_reverse_ip_tag – True if the source should set up a tag through which it can receive packets; if port is set to None this can be used to enable the reception of packets on a randomly assigned port, which can be read from the database
- class spinn_front_end_common.utility_models.ExtraMonitorSupportMachineVertex(reinject_point_to_point: bool = False, reinject_nearest_neighbour: bool = False, reinject_fixed_route: bool = False)¶
Bases:
MachineVertex,AbstractHasAssociatedBinary,AbstractGeneratesDataSpecification,AbstractProvidesProvenanceDataFromMachineMachine vertex for talking to extra monitor cores. Supports reinjection control and the faster data transfer protocols.
Usually deployed once per chip.
Note
This is an unusual machine vertex, in that it has no associated application vertex.
- Parameters:
reinject_point_to_point – if we reinject point-to-point packets
reinject_nearest_neighbour – if we reinject nearest-neighbour packets
reinject_fixed_route – if we reinject fixed route packets
- generate_data_specification(spec: DataSpecificationGenerator, placement: Placement) None[source]¶
Generate a data specification.
- Parameters:
spec – The data specification to write to
placement – The placement the vertex is located at
- get_binary_start_type() ExecutableType[source]¶
- Returns:
The start type of the binary to be run.
- get_provenance_data_from_machine(placement: Placement) None[source]¶
Get provenance data items for a placement and store them in the provenance DB.
- Parameters:
placement – the placement of the object
- get_reinjection_status() ReInjectionStatus[source]¶
Get the reinjection status from this extra monitor vertex.
- Returns:
the reinjection status for this vertex
- get_reinjection_status_for_vertices() Dict[Chip, ReInjectionStatus][source]¶
Get the reinjection status from a set of extra monitor cores.
- Returns:
Mapping of the Chips to their reinjection status.
- load_application_mc_routes() None[source]¶
Get the extra monitor cores to load up the application-based multicast routes (used by the Data In protocol).
- load_system_mc_routes() None[source]¶
Get the extra monitor cores to load up the system-based multicast routes (used by the Data In protocol).
- property placement: Placement¶
The Placement set by generate_data_specifications
- Raises:
AssertionError – If the placement has not yet been set
- reset_reinjection_counters(extra_monitor_cores_to_set: Iterable[ExtraMonitorSupportMachineVertex]) None[source]¶
Resets the counters for reinjection.
- Parameters:
extra_monitor_cores_to_set – which monitors control the routers to reset the counters of
- property sdram_required: AbstractSDRAM¶
The SDRAM space required by the vertex.
- set_reinjection_packets(point_to_point: bool | None = None, multicast: bool | None = None, nearest_neighbour: bool | None = None, fixed_route: bool | None = None) None[source]¶
Sends the reinjection packets for this vertex
- Parameters:
point_to_point – If point to point should be set, or None if left as before
multicast – If multicast should be set, or None if left as before
nearest_neighbour – If nearest neighbour should be set, or None if left as before
fixed_route – If fixed route should be set, or None if left as before.
- static static_get_binary_file_name() str[source]¶
The name of the binary implementing this vertex.
- Returns:
Name of the aplx files for this vertex
- static static_get_binary_start_type() ExecutableType[source]¶
The type of the binary implementing this vertex.
- Returns:
The System type as this is a System vertex
- class spinn_front_end_common.utility_models.LivePacketGather(params: LivePacketGatherParameters, label: str | None = None)¶
Bases:
ApplicationVertex[LivePacketGatherMachineVertex]A vertex that gathers and forwards multicast packets to the host.
- Parameters:
params – The parameters object
label – An optional label
- property params: LivePacketGatherParameters¶
The params value passed into the init.
- class spinn_front_end_common.utility_models.LivePacketGatherMachineVertex(lpg_params: LivePacketGatherParameters, app_vertex: LivePacketGather | None = None, label: str | None = None)¶
Bases:
MachineVertex,ProvidesProvenanceDataFromMachineImpl,AbstractGeneratesDataSpecification,AbstractHasAssociatedBinaryUsed to gather multicast packets coming from cores and stream them out to a receiving application on host. Only ever deployed on chips with a working Ethernet connection.
- Parameters:
lpg_params – The parameters object
app_vertex – The application vertex
label – An optional label
- KEY_ENTRY_SIZE = 12¶
- TRAFFIC_IDENTIFIER = 'LPG_EVENT_STREAM'¶
- add_incoming_source(m_vertex: MachineVertex, partition_id: str) None[source]¶
Add a machine vertex source incoming into this gatherer.
- Parameters:
m_vertex – The source machine vertex
partition_id – The incoming partition id
- generate_data_specification(spec: DataSpecificationGenerator, placement: Placement) None[source]¶
Generate a data specification.
- Parameters:
spec – The data specification to write to
placement – The placement the vertex is located at
- get_binary_start_type() ExecutableType[source]¶
- Returns:
The start type of the binary to be run.
- property params: LivePacketGatherParameters¶
The lpg_params as passed into the init.
- parse_extra_provenance_items(label: str, x: int, y: int, p: int, provenance_data: Sequence[int]) None[source]¶
Convert the remaining provenance words (those not in the standard set) into provenance items.
Called by
get_provenance_data_from_machine()- Parameters:
label – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.
x – x coordinate of the chip where this core
y – y coordinate of the core where this core
p – virtual id of the core
provenance_data – The list of words of raw provenance data.
- property sdram_required: AbstractSDRAM¶
The SDRAM space required by the vertex.
- class spinn_front_end_common.utility_models.MultiCastCommand(key: int, payload: int | None = None, *, time: int | None = None, repeat: int = 0, delay_between_repeats: int = 0)¶
Bases:
objectA command to be sent to a vertex.
- Parameters:
key – The key of the command
payload – The payload of the command
time – The time within the simulation at which to send the command, or
Noneif this is not a timed commandrepeat – The number of times that the command should be repeated after sending it once. This could be used to ensure that the command is sent despite lost packets. Must be between 0 and 65535
delay_between_repeats – The amount of time in microseconds to wait between sending repeats of the same command. Must be between 0 and 65535, and must be 0 if repeat is 0
- Raises:
ConfigurationException – If the repeat or delay are out of range
- property delay_between_repeats: int¶
The amount of time in microseconds to wait between sending repeats
- class spinn_front_end_common.utility_models.ReverseIPTagMulticastSourceMachineVertex(label: str | None, vertex_slice: Slice | None = None, app_vertex: ReverseIpTagMultiCastSource | None = None, n_keys: int | None = None, eieio_params: EIEIOParameters | None = None, send_buffer_times: _SendBufferTimes = None)¶
Bases:
MachineVertex,AbstractGeneratesDataSpecification,AbstractHasAssociatedBinary,AbstractSupportsDatabaseInjection,ProvidesProvenanceDataFromMachineImpl,AbstractSendsBuffersFromHost,AbstractReceiveBuffersToHostA model which allows events to be injected into SpiNNaker and converted in to multicast packets.
- Parameters:
label – The label of this vertex
vertex_slice – The slice served via this multicast source
app_vertex – The associated application vertex
n_keys – The number of keys to be sent via this multicast source (can’t be None if vertex_slice is also None)
eieio_params – General parameters passed from the application vertex.
send_buffer_times – An array of arrays of time steps at which keys should be sent (one array for each key, default disabled)
label – The optional name of the vertex
vertex_slice – The slice of the application vertex that this machine vertex implements.
app_vertex – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.
n_keys – Number of keys. Only used to create a slice if vertex_slice is None.
eieio_params – Parameters to override the defaults
send_buffer_times – Times to spike at
- enable_recording(new_state: bool = True) None[source]¶
Enable recording of the keys sent.
- Parameters:
new_state
- generate_data_specification(spec: DataSpecificationGenerator, placement: Placement) None[source]¶
Generate a data specification.
- Parameters:
spec – The data specification to write to
placement – The placement the vertex is located at
- get_binary_start_type() ExecutableType[source]¶
- Returns:
The start type of the binary to be run.
- get_next_key(region: int) int[source]¶
Get the next key in the given region.
- Parameters:
region – The region to get the next key from
- Returns:
The next key, or None if there are no more keys
- get_next_timestamp(region: int) int[source]¶
Get the next timestamp at which there are still keys to be sent for the given region.
- Parameters:
region – The region to get the timestamp for
- Returns:
The timestamp of the next available keys
- get_recorded_region_ids() List[int][source]¶
Get the recording region IDs that have been recorded using buffering.
- Returns:
The region numbers that have active recording
- get_recording_region_base_address(placement: Placement) int[source]¶
Get the recording region base address.
- Parameters:
placement – the placement object of the core to find the address of
- Returns:
the base address of the recording region
- get_region_buffer_size(region: int) int[source]¶
- Parameters:
region – Region ID
- Returns:
Size of buffer, in bytes.
- get_regions() Collection[int][source]¶
Get the set of regions for which there are keys to be sent.
- Returns:
Iterable of region IDs
- classmethod get_sdram_usage(send_buffer_times: _SendBufferTimes, recording_enabled: bool, receive_rate: float, n_keys: int) VariableSDRAM[source]¶
- Parameters:
send_buffer_times – When events will be sent
recording_enabled – Whether recording is done
receive_rate – What the expected message receive rate is
n_keys – How many keys are being sent
- Returns:
Variable SDRAM based on the parameters
- get_virtual_key() int[source]¶
Updates and returns the virtual key. None is give a zero value
- Returns:
The key used or 0 if no key used
- is_empty(region: int) bool[source]¶
Return true if there are no spikes to be buffered for the specified region.
- Parameters:
region – The region to get the next key from
- Returns:
Whether there are no keys to send for the region
- is_next_key(region: int, timestamp: int) bool[source]¶
Determine if there are still keys to be sent at the given timestamp for the given region.
- Parameters:
region – The region to determine if there are keys for
timestamp – The timestamp to determine if there are more keys for
- Returns:
Whether there are more keys to send for the parameters
- is_next_timestamp(region: int) bool[source]¶
Determine if there is another timestamp with data to be sent.
- Parameters:
region – The region to determine if there is more data for
- Returns:
Whether there is more data
- parse_extra_provenance_items(label: str, x: int, y: int, p: int, provenance_data: Sequence[int]) None[source]¶
Convert the remaining provenance words (those not in the standard set) into provenance items.
Called by
get_provenance_data_from_machine()- Parameters:
label – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.
x – x coordinate of the chip where this core
y – y coordinate of the core where this core
p – virtual id of the core
provenance_data – The list of words of raw provenance data.
- property reverse_iptags: List[ReverseIPtagResource]¶
The
ReverseIPTags used by this vertex, if any.
- rewind(region: int) None[source]¶
Rewinds the internal buffer in preparation of re-sending the spikes.
- Parameters:
region – The region to rewind
- property sdram_required: AbstractSDRAM¶
The SDRAM space required by the vertex.
- property send_buffer_times: _SendBufferTimes¶
When events will be sent.
- property send_buffers: Dict[int, BufferedSendingRegion]¶
Filled send buffers or an empty dict if there are no send buffers
- class spinn_front_end_common.utility_models.ReverseIpTagMultiCastSource(n_keys: int, label: str | None = None, max_atoms_per_core: int | Tuple[int, ...] | None = 9223372036854775807, receive_port: int | None = None, receive_sdp_port: int = 1, receive_tag: IPTag | None = None, receive_rate: int = 10, virtual_key: int | None = None, prefix: int | None = None, prefix_type: EIEIOPrefix | None = None, check_keys: bool = False, send_buffer_times: ndarray | List[ndarray] | None = None, reserve_reverse_ip_tag: bool = False, splitter: AbstractSplitterCommon | None = None)¶
Bases:
ApplicationVertex,LegacyPartitionerAPIA model which will allow events to be injected into a SpiNNaker machine and converted into multicast packets.
- Parameters:
n_keys – The number of keys to be sent via this multicast source
label – The label of this vertex
max_atoms_per_core – The max number of atoms that can be placed on a core for each dimension, used in partitioning. If the vertex is n-dimensional, with n > 1, the value must be a tuple with a value for each dimension. If it is single-dimensional the value can be a 1-tuple or an int.
receive_port – The port on the board that will listen for incoming event packets (default is to disable this feature; set a value to enable it)
receive_sdp_port – The SDP port to listen on for incoming event packets (defaults to 1)
receive_tag – The IP tag to use for receiving live events (uses any by default)
receive_rate – The estimated rate of packets that will be sent by this source
virtual_key – The base multicast key to send received events with (assigned automatically by default)
prefix – The prefix to “or” with generated multicast keys (default is no prefix)
prefix_type – Whether the prefix should apply to the upper or lower half of the multicast keys (default is upper half)
check_keys – True if the keys of received events should be verified before sending (default False)
send_buffer_times – An array of arrays of times at which keys should be sent (one array for each key, default disabled)
reserve_reverse_ip_tag – Extra flag for input without a reserved port
splitter – the splitter object needed for this vertex
- create_machine_vertex(vertex_slice: Slice, sdram: AbstractSDRAM, label: str | None = None) ReverseIPTagMulticastSourceMachineVertex[source]¶
Create a machine vertex from this application vertex.
- Parameters:
vertex_slice – The slice of atoms that the machine vertex will cover.
sdram – The SDRAM used by the machine vertex.
label – human readable label for the machine vertex
- Returns:
The created machine vertex
- enable_recording(new_state: bool = True) None[source]¶
Turns on or of the recording for this vertex.
- Parameters:
new_state – True if recording should be done
- get_fixed_key_and_mask(partition_id: str) BaseKeyAndMask | None[source]¶
Get a fixed key and mask for the application vertex or None if not fixed (the default). See
get_machine_fixed_key_and_mask()for the conditions.- Parameters:
partition_id – The identifier of the partition to get the key for
- Returns:
None or key and mask if fixed
- get_sdram_used_by_atoms(vertex_slice: Slice) AbstractSDRAM[source]¶
- Parameters:
vertex_slice – the low value of atoms to calculate resources from
- Returns:
The separate SDRAM requirements for a range of atoms.
- class spinn_front_end_common.utility_models.StreamingContextManager(gatherers: Iterable[DataSpeedUpPacketGatherMachineVertex])¶
Bases:
ContextManager[None]The implementation of the context manager object for streaming configuration control.
- Parameters:
gatherers