spinn_front_end_common.interface.ds package¶
Module contents¶
- class spinn_front_end_common.interface.ds.DataSpecificationBase(x: int, y: int, p: int, ds_db: DsSqlliteDatabase, report_writer: TextIO | None = None)¶
Bases:
object
Base class for all vertex data specification creation
- Parameters:
report_writer (TextIOBase or None) – Determines if a text version of the specification is to be written and, if so, where. No report is written if this is None.
- comment(comment: str) None [source]¶
Write a comment to the text version of the specification.
Note
This is ignored by the binary file.
- Parameters:
comment (str) – The comment to write
- end_specification() None [source]¶
Insert a command to indicate that the specification has finished and finish writing.
- abstract reference_memory_region(region: int, ref: int, label: str | None = None) None [source]¶
Insert command to reference another memory region.
- Parameters:
- Raises:
RegionInUseException – If the
region
was already reservedParameterOutOfBoundsException – If the
region
requested was out of the allowed range, or thesize
was too big to fit in SDRAM
- abstract reserve_memory_region(region: int, size: int, label: str | None = None, reference: int | None = None) None [source]¶
Insert command to reserve a memory region.
- Parameters:
- Raises:
RegionInUseException – If the
region
was already reservedParameterOutOfBoundsException – If the
region
requested was out of the allowed range, or thesize
was too big to fit in SDRAM
- switch_write_focus(region: int) None [source]¶
Insert command to switch the region being written to.
- Parameters:
region (int) – The ID of the region to switch to, between 0 and 15
- Raises:
ParameterOutOfBoundsException – If the region identifier is not valid
DataSpecException – If the region has not been allocated
- write_array(array_values: Sequence[int] | Sequence[float] | ndarray, data_type: DataType = DataType.UINT32) None [source]¶
Insert command to write an array, causing the write pointer to move on by (data type size * the array size), in bytes.
- write_value(data: int | float, data_type: DataType = DataType.UINT32) None [source]¶
Insert command to write a value (once) to the current write pointer, causing the write pointer to move on by the number of bytes required to represent the data type. The data is passed as a parameter to this function
Note
This method used to have two extra parameters
repeats
andrepeats_is_register
. They have been removed here. If you need them, usewrite_repeated_value()
- Parameters:
- Raises:
ParameterOutOfBoundsException –
If
data_type
is an integer type, anddata
has a fractional partIf
data
would overflow the data type
UnknownTypeException – If the data type is not known
ValueError – If the data size is invalid
NoRegionSelectedException – If no region has been selected
- class spinn_front_end_common.interface.ds.DataSpecificationGenerator(x: int, y: int, p: int, vertex: AbstractGeneratesDataSpecification | AbstractRewritesDataSpecification, ds_db: DsSqlliteDatabase, report_writer: TextIO | None = None)¶
Bases:
DataSpecificationBase
Used to generate the data specification data in the database
- Parameters:
x (int)
y (int)
p (int)
vertex (AbstractRewritesDataSpecification) – The vertex being written.
report_writer (TextIOBase or None) – Determines if a text version of the specification is to be written and, if so, where. No report is written if this is None.
- Raises:
DsDatabaseException – If this core is not known and no vertex supplied (during reload)
AttributeError – If the vertex is not an AbstractHasAssociatedBinary
KeyError – If there is no Chip as x, y
IntegrityError – If this combination of x, y, p has already been used Even if with the same vertex
- reference_memory_region(region: int, ref: int, label: str | None = None) None [source]¶
Insert command to reference another memory region.
- Parameters:
- Raises:
RegionInUseException – If the
region
was already reservedParameterOutOfBoundsException – If the
region
requested was out of the allowed range, or thesize
was too big to fit in SDRAM
- reserve_memory_region(region: int, size: int, label: str | None = None, reference: int | None = None) None [source]¶
Insert command to reserve a memory region.
- Parameters:
- Raises:
RegionInUseException – If the
region
was already reservedParameterOutOfBoundsException – If the
region
requested was out of the allowed range, or thesize
was too big to fit in SDRAM
- class spinn_front_end_common.interface.ds.DataSpecificationReloader(x: int, y: int, p: int, ds_db: DsSqlliteDatabase, report_writer: TextIO | None = None)¶
Bases:
DataSpecificationBase
Used to reload the data specification data
- Parameters:
report_writer (TextIOBase or None) – Determines if a text version of the specification is to be written and, if so, where. No report is written if this is None.
- reference_memory_region(region: int, ref: int, label: str | None = None) None [source]¶
Insert command to reference another memory region.
- Parameters:
- Raises:
RegionInUseException – If the
region
was already reservedParameterOutOfBoundsException – If the
region
requested was out of the allowed range, or thesize
was too big to fit in SDRAM
- reserve_memory_region(region: int, size: int, label: str | None = None, reference: int | None = None) None [source]¶
Insert command to reserve a memory region.
- Parameters:
- Raises:
RegionInUseException – If the
region
was already reservedParameterOutOfBoundsException – If the
region
requested was out of the allowed range, or thesize
was too big to fit in SDRAM
- class spinn_front_end_common.interface.ds.DataType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
Supported data types. Internally, these are actually tuples.
an identifier for the enum class;
the size in bytes of the type;
the minimum possible value for the type;
the maximum possible value for the type;
the scale of the input value to convert it in integer;
the pattern to use following the struct package encodings to convert the data in binary format;
is whether to apply the scaling when converting to SpiNNaker’s binary format.
the corresponding numpy type (or None to inhibit direct conversion via numpy, scaled conversion still supported);
the text description of the type.
Note
Some types (notably 64-bit fixed-point and floating-point types) are not recommended for use on SpiNNaker due to complications with represent them and lack of hardware/library support.
- FLOAT_32 = 14¶
- FLOAT_64 = 15¶
- INT16 = 5¶
- INT32 = 6¶
- INT64 = 7¶
- INT8 = 4¶
- S015 = 21¶
- S031 = 22¶
- S063 = 23¶
- S07 = 20¶
- S1615 = 12¶
- S3231 = 13¶
- S87 = 11¶
- U016 = 17¶
- U032 = 18¶
- U064 = 19¶
- U08 = 16¶
- U1616 = 9¶
- U3232 = 10¶
- U88 = 8¶
- UINT16 = 1¶
- UINT32 = 2¶
- UINT64 = 3¶
- UINT8 = 0¶
- check_value(value: int | float) None [source]¶
Check the value against the allowed min and max
- Raises:
ValueError – If the value is outside of min to max
- decode_array(values: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | bytes) ndarray[tuple[int, ...], dtype[_ScalarType_co]] [source]¶
Decodes a byte array into iterable of this type.
- Parameters:
values – the bytes to decode into this given data type
- Return type:
numpy array
- decode_numpy_array(array: ndarray[tuple[int, ...], dtype[uint32]]) ndarray[tuple[int, ...], dtype[_ScalarType_co]] [source]¶
Decode the numpy array of SpiNNaker values according to this type.
- encode_as_int(value: int | float) int [source]¶
Returns the value as an integer, according to this type.
- encode_as_numpy_int(value: int | float) uint32 [source]¶
Returns the value as a numpy integer, according to this type.
Note
Only works with integer and fixed point data types.
- encode_as_numpy_int_array(array: ndarray[tuple[int, ...], dtype[_ScalarType_co]]) ndarray[tuple[int, ...], dtype[_ScalarType_co]] [source]¶
Returns the numpy array as an integer numpy array, according to this type.
- class spinn_front_end_common.interface.ds.DsSqlliteDatabase(database_file: str | None = None)¶
Bases:
SQLiteDB
A database for holding data specification details.
- Parameters:
init_file (bool) – Whether to initialise the DB from our DDL file. If not specified, this is guessed from whether we can read the file.
- get_content_sizes(is_system: bool) List[Tuple[int, int]] [source]¶
Returns the sizes of the content and the count of each size.
Will return an empty list if there is no none Null content
- get_core_infos(is_system: bool) List[Tuple[int, int, int, int, int]] [source]¶
Gets a list of id, x, y, p, ethernet_x, ethernet_y for all cores according to is_system
- get_double_region() Iterable[Tuple[int, int, int, int]] [source]¶
- Finds and yields any region that was used in both region definition
and a reference
If all is well this method yields nothing!
Note
Do not use the database for anything else while iterating.
- get_ds_cores() Iterable[Tuple[int, int, int]] [source]¶
Yields the x, y, p for the cores with possible Data Specifications
Includes cores where DataSpecs started even if no regions reserved
Yields nothing if there are no unknown cores
Note
Do not use the database for anything else while iterating.
- get_info_for_cores() Iterable[Tuple[Tuple[int, int, int], int, int, int]] [source]¶
Yields the (x, y, p) and write info for each core
The sizes INCLUDE pointer table size
Yields nothing if no cores known
Note
A DB transaction may be held while this iterator is processing. Reentrant use of this class is not supported.
- get_max_content_size(is_system: bool) int [source]¶
Returns the size of the largest content.
- Parameters:
is_system (bool) – if True returns system cores otherwise application cores
- Return type:
- Raises:
- get_memory_to_malloc(x: int, y: int, p: int) int [source]¶
Gets the expected number of bytes to be written
- get_memory_to_write(x: int, y: int, p: int) int [source]¶
Gets the expected number of bytes to be written
- get_n_ds_cores() int [source]¶
Returns the number for cores there is a data specification saved for.
Includes cores where DataSpecs started even if no regions reserved
- Return type:
- Raises:
- get_reference_pointers(x: int, y: int, p: int) Iterable[Tuple[int, int]] [source]¶
Yields the reference regions and where they point for this core
This may yield nothing if there are no reference pointers or if the core is not known
Note
Do not use the database for anything else while iterating.
- get_region_pointer(x: int, y: int, p: int, region_num: int) int | None [source]¶
Gets the pointer for this region as set during the original load
returns None if the region is known but for some reason the pointer was not set
- Parameters:
- Returns:
The pointer set during the original load
- Return type:
int or None
- Raises:
DsDatabaseException – if the region is not known
- get_region_pointers_and_content(x: int, y: int, p: int) Iterable[Tuple[int, int, bytes | None]] [source]¶
Yields the number, pointers and content for each reserved region
This includes regions with no content set where content will be None
Will yield nothing if there are no regions reserved or if the core is not known
- get_region_size(x: int, y: int, p: int, region_num: int) int [source]¶
Gets the size for a region with this x, y, p and region
- get_region_sizes(x: int, y: int, p: int) Dict[int, int] [source]¶
Gets a dict of the regions and sizes reserved
The returned dict will be empty if there are no regions reserved or if the core is not known.
- get_regions_content(x: int, y: int, p: int) Iterable[Tuple[int, int, bytes]] [source]¶
Yields the number, pointers and content for each region
This does not include regions with no content set
Will yield nothing if there are no regions with content or if the core the is not known
- get_total_regions_size(x: int, y: int, p: int) int [source]¶
Gets the total size of the regions of this core
Does not include the size of the pointer table
Returns 0 even if the core is not known
- get_unlinked_references() Iterable[Tuple[int, int, int, int, int, str]] [source]¶
Finds and yields info on unreferenced links
If all is well this method yields nothing!
Note
Do not use the database for anything else while iterating.
- set_core(x: int, y: int, p: int, vertex: AbstractHasAssociatedBinary) None [source]¶
Creates a database record for the core with this x,y,z
- Parameters:
x (int) – X coordinate of the core
y (int) – Y coordinate of the core
p (int) – Processor ID of the core
vertex (AbstractHasAssociatedBinary) – Vertex to check if it is a system vertex. if missing this method will not create a new record
- Return type:
- Raises:
AttributeError – If the vertex is not an AbstractHasAssociatedBinary
KeyError – If there is no Chip as x, y
IntegrityError – If this combination of x, y, p has already been used Even if with the same vertex
- set_memory_region(x: int, y: int, p: int, region_num: int, size: int, reference: int | None, label: str | None) int [source]¶
Writes the information to reserve a memory region into the database
Typically called after a DS.reserve_memory_region call
- Parameters:
x (int) – X coordinate of the core
y (int) – Y coordinate of the core
p (int) – Processor ID of the core t
region_num (int) – The number of the region to reserve
size (int) – The size to reserve for the region, in bytes
label (str or None) – An optional label for the region
reference (int or None) – A globally unique reference for this region
- Returns:
- set_reference(x: int, y: int, p: int, region_num: int, reference: int, ref_label: str | None) None [source]¶
Writes a outgoing region_reference into the database
- set_region_content(x: int, y: int, p: int, region_num: int, content: bytes, content_debug: str | None) None [source]¶
Sets the content for this region
- set_region_pointer(x: int, y: int, p: int, region_num: int, pointer: int) None [source]¶
Sets the pointer to the start of the address for this x, y, p region.