spinn_front_end_common.interface.buffer_management.storage_objects package

Module contents

class spinn_front_end_common.interface.buffer_management.storage_objects.AbstractDatabase[source]

Bases: object

This API separates the required database calls from the implementation.

Methods here are designed for the convenience of the caller not the database.

There should only ever be a single Database Object in use at any time. In the case of application_graph_changed the first should closed and a new one created.

Do not assume that just because 2 database objects where opened with the same parameters (for example SQLite file) that they hold the same data. In fact the second init is allowed to delete any previous data.

While not recommended implementation objects are allowed to hold data in memory, with the exception of data required by the java which must be in the database once commit is called.

clear()[source]

Clears the data for all regions.

Note

This method will be removed when the database moves to keeping data after reset.

Return type:None
clear_region(x, y, p, region)[source]

Clears the data for a single region.

Note

This method loses information!

Parameters:
  • x (int) – x coordinate of the chip
  • y (int) – y coordinate of the chip
  • p (int) – Core within the specified chip
  • region (int) – Region containing the data to be cleared
Returns:

True if any region was changed

Return type:

bool

close()[source]

Signals that the database can be closed and will not be reused.

Once this is called any other method in this API is allowed to raise any kind of exception.

get_region_data(x, y, p, region)[source]

Get the data stored for a given region of a given core

Parameters:
  • x (int) – x coordinate of the chip
  • y (int) – y coordinate of the chip
  • p (int) – Core within the specified chip
  • region (int) – Region containing the data
Returns:

a buffer containing all the data received during the simulation, and a flag indicating if any data was missing

Note

Implementations should not assume that the total buffer is necessarily shorter than 1GB.

Return type:

tuple(memoryview, bool)

store_data_in_region_buffer(x, y, p, region, missing, data)[source]

Store some information in the corresponding buffer for a specific chip, core and recording region.

Parameters:
  • x (int) – x coordinate of the chip
  • y (int) – y coordinate of the chip
  • p (int) – Core within the specified chip
  • region (int) – Region containing the data to be stored
  • missing (bool) – Whether any data is missing
  • data (bytearray) –

    data to be stored

    Note

    Implementations may assume this to be shorter than 1GB

class spinn_front_end_common.interface.buffer_management.storage_objects.BufferedReceivingData(report_folder)[source]

Bases: object

Stores the information received through the buffering output from the SpiNNaker system.

Parameters:report_folder (str) – The directory to write the database used to store some of the data
clear(x, y, p, region_id)[source]

Clears the data from a given data region (only clears things associated with a given data recording region).

Parameters:
  • x (int) – placement x coordinate
  • y (int) – placement y coordinate
  • p (int) – placement p coordinate
  • region_id (int) – the recording region ID to clear data from
Return type:

None

get_region_data(x, y, p, region)[source]

Get the data stored for a given region of a given core.

Parameters:
  • x (int) – x coordinate of the chip
  • y (int) – y coordinate of the chip
  • p (int) – Core within the specified chip
  • region (int) – Region containing the data
Returns:

a buffer containing all the data received during the simulation, and a flag indicating if any data was missing

Return type:

tuple(memoryview, bool)

get_region_information(x, y, p, region_id)[source]

Get the size, address and is_missing of the region

Parameters:
  • x (int) – The x-coordinate of the core whose data this is
  • y (int) – The y-coordinate of the core whose data this is
  • p (int) – The processor id of the core whose data this is
  • region_id (int) – The id of the region to get the data for
Return type:

tuple(int, int, bool)

has_region_information(x, y, p)[source]

Determine if region information has been stored for this core

Parameters:
  • x (int) – The x-coordinate of the core whose data this is
  • y (int) – The y-coordinate of the core whose data this is
  • p (int) – The processor id of the core whose data this is
Return type:

bool

is_data_from_region_flushed(x, y, p, region)[source]

Determine if data has been stored for this region

Parameters:
  • x (int) – x coordinate of the chip
  • y (int) – y coordinate of the chip
  • p (int) – Core within the specified chip
  • region (int) – Region containing the data
reset()[source]

Perform tasks to restart recording from time=0

resume()[source]

Perform tasks that will continue running without resetting

store_data_in_region_buffer(x, y, p, region, missing, data)[source]

Store some information in the correspondent buffer class for a specific chip, core and region.

Parameters:
  • x (int) – x coordinate of the chip
  • y (int) – y coordinate of the chip
  • p (int) – Core within the specified chip
  • region (int) – Region containing the data to be stored
  • missing (bool) – Whether any data is missing
  • data (bytearray) – data to be stored
store_region_information(x, y, p, sizes_and_addresses)[source]

Store the sizes, addresses and is_missing data of the regions

Parameters:
  • x (int) – The x-coordinate of the core whose data this is
  • y (int) – The y-coordinate of the core whose data this is
  • p (int) – The processor id of the core whose data this is
  • sizes_and_addresses (list(int,int,bool)) – The size and address of each region
class spinn_front_end_common.interface.buffer_management.storage_objects.BufferedSendingRegion[source]

Bases: object

A set of keys to be sent at given timestamps for a given region of data. Note that keys must be added in timestamp order or else an exception will be raised.

add_key(timestamp, key)[source]

Add a key to be sent at a given time.

Parameters:
  • timestamp (int) – The time at which the key is to be sent
  • key (int) – The key to send
add_keys(timestamp, keys)[source]

Add a set of keys to be sent at the given time.

Parameters:
  • timestamp (int) – The time at which the keys are to be sent
  • keys (iterable(int)) – The keys to send
clear()[source]

Clears the buffer.

current_timestamp

The current timestamp in the iterator.

get_n_keys(timestamp)[source]

Get the number of keys for a given timestamp.

Parameters:timestamp – the time stamp to check if there’s still keys to transmit
is_next_key(timestamp)[source]

Determine if there is another key for the given timestamp.

Parameters:timestamp (bool) – the time stamp to check if there’s still keys to transmit
is_next_timestamp
Determines if the region is empty.
True if the region is empty, false otherwise.
Return type:bool
n_timestamps

The number of timestamps available.

Return type:int
next_key

The next key to be sent.

Return type:int
next_timestamp

The next timestamp of the data to be sent, or None if no more data.

Return type:int or None
rewind()[source]

Rewind the buffer to initial position.

timestamps

The timestamps for which there are keys.

Return type:iterable(int)
class spinn_front_end_common.interface.buffer_management.storage_objects.BuffersSentDeque(region, sent_stop_message=False, n_sequences_per_tranmission=64)[source]

Bases: object

A tracker of buffers sent / to send for a region

Parameters:
  • region (int) – The region being managed
  • sent_stop_message (bool) – True if the stop message has been sent
  • n_sequences_per_tranmission (int) – The number of sequences allowed in each transmission set
add_message_to_send(message)[source]

Add a message to send. The message is converted to a sequenced message.

Parameters:message (AbstractEIEIOMessage) – The message to be added
is_empty()[source]

Determine if there are no messages.

Return type:int
is_full

Determine if the number of messages sent is at the limit for the sequencing system.

Return type:bool
messages

The messages that have been added to the set.

Return type:iterable(HostSendSequencedData)
send_stop_message()[source]

Send a message to indicate the end of all the messages.

update_last_received_sequence_number(last_received_sequence_no)[source]

Updates the last received sequence number. If the sequence number is within the valid window, packets before the sequence number within the window are removed, and the last received sequence number is updated, thus moving the window for the next call. If the sequence number is not within the valid window, it is assumed to be invalid and so is ignored.

Parameters:last_received_sequence_no (int) – The new sequence number
Returns:True if update went ahead, False if it was ignored
Return type:bool
class spinn_front_end_common.interface.buffer_management.storage_objects.SqlLiteDatabase(database_file=None)[source]

Bases: spinn_front_end_common.utilities.sqlite_db.SQLiteDB, spinn_utilities.abstract_context_manager.AbstractContextManager

Specific implementation of the Database for SQLite 3.

Note

Not thread safe on the same database file! Threads can access different DBs just fine.

Parameters:database_file (str) – The name of a file that contains (or will contain) an SQLite database holding the data. If omitted, an unshared in-memory database will be used.
clear()[source]

Clears the data for all regions.

Note

This method will be removed when the database moves to keeping data after reset.

Return type:None
clear_region(x, y, p, region)[source]

Clears the data for a single region.

Note

This method loses information!

Parameters:
  • x (int) – x coordinate of the chip
  • y (int) – y coordinate of the chip
  • p (int) – Core within the specified chip
  • region (int) – Region containing the data to be cleared
Returns:

True if any region was changed

Return type:

bool

get_region_data(x, y, p, region)[source]

Get the data stored for a given region of a given core

Parameters:
  • x (int) – x coordinate of the chip
  • y (int) – y coordinate of the chip
  • p (int) – Core within the specified chip
  • region (int) – Region containing the data
Returns:

a buffer containing all the data received during the simulation, and a flag indicating if any data was missing

Note

Implementations should not assume that the total buffer is necessarily shorter than 1GB.

Return type:

tuple(memoryview, bool)

store_data_in_region_buffer(x, y, p, region, missing, data)[source]

Store some information in the corresponding buffer for a specific chip, core and recording region.

Parameters:
  • x (int) – x coordinate of the chip
  • y (int) – y coordinate of the chip
  • p (int) – Core within the specified chip
  • region (int) – Region containing the data to be stored
  • missing (bool) – Whether any data is missing
  • data (bytearray) –

    data to be stored

    Note

    Implementations may assume this to be shorter than 1GB