spinn_front_end_common.utilities.database package

Module contents

class spinn_front_end_common.utilities.database.DatabaseConnection(start_resume_callback_function=None, stop_pause_callback_function=None, local_host=None, local_port=19999)[source]

Bases: spinnman.connections.udp_packet_connections.udp_connection.UDPConnection

A connection from the toolchain which will be notified when the database has been written, and can then respond when the database has been read, and further wait for notification that the simulation has started.

Note

The machine description database reader can only be used while the registered database callbacks are running.

Parameters:
  • start_resume_callback_function (callable) – A function to be called when the start message has been received. This function should not take any parameters or return anything.
  • local_host (str) – Optional specification of the local hostname or IP address of the interface to listen on
  • local_port (int) – Optional specification of the local port to listen on. Must match the port that the toolchain will send the notification on (19999 by default)
add_database_callback(database_callback_function)[source]

Add a database callback to be called when the database is ready.

Parameters:database_callback_function (callable(DatabaseReader,None)) – A function to be called when the database message has been received. This function should take a single parameter, which will be a DatabaseReader object. Once the function returns, it will be assumed that the database has been read and will not be needed further, and the return response will be sent.
close()[source]

Closes the connection

class spinn_front_end_common.utilities.database.DatabaseReader(database_path)[source]

Bases: spinn_front_end_common.utilities.sqlite_db.SQLiteDB

A reader for the database.

Parameters:database_path (str) – The path to the database
get_atom_id_to_key_mapping(label)[source]

Get a mapping of atom ID to event key for a given vertex

Parameters:label (str) – The label of the vertex
Returns:dictionary of event keys indexed by atom ID
Return type:dict(int, int)
get_configuration_parameter_value(parameter_name)[source]

Get the value of a configuration parameter

Parameters:parameter_name (str) – The name of the parameter
Returns:The value of the parameter
Return type:float or None
get_ip_address(x, y)[source]

Get an IP address to contact a chip

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

The IP address of the Ethernet to use to contact the chip

Return type:

str or None

get_key_to_atom_id_mapping(label)[source]

Get a mapping of event key to atom ID for a given vertex

Parameters:label (str) – The label of the vertex
Returns:dictionary of atom IDs indexed by event key
Return type:dict(int, int)
get_live_input_details(label)[source]

Get the IP address and port where live input should be sent for a given vertex

Parameters:label (str) – The label of the vertex
Returns:tuple of (IP address, port)
Return type:tuple(str, int)
get_live_output_details(label, receiver_label)[source]

Get the IP address, port and whether the SDP headers are to be stripped from the output from a vertex

Parameters:label (str) – The label of the vertex
Returns:tuple of (IP address, port, strip SDP, board address, tag)
Return type:tuple(str, int, bool, str, int)
get_machine_live_input_details(label)[source]

Get the IP address and port where live input should be sent for a given machine vertex

Parameters:label (str) – The label of the vertex
Returns:tuple of (IP address, port)
Return type:tuple(str, int)
get_machine_live_input_key(label)[source]
Parameters:label (str) – The label of the vertex
Return type:tuple(int,int)
get_machine_live_output_details(label, receiver_label)[source]

Get the IP address, port and whether the SDP headers are to be stripped from the output from a machine vertex

Parameters:
  • label (str) – The label of the vertex
  • receiver_label (str) –
Returns:

tuple of (IP address, port, strip SDP, board address, tag)

Return type:

tuple(str, int, bool, str, int)

get_machine_live_output_key(label, receiver_label)[source]
Parameters:
  • label (str) – The label of the vertex
  • receiver_label (str) –
Return type:

tuple(int,int)

get_n_atoms(label)[source]

Get the number of atoms in a given vertex

Parameters:label (str) – The label of the vertex
Returns:The number of atoms
Return type:int
get_placement(label)[source]

Get the placement of a machine vertex with a given label

Parameters:label (str) – The label of the vertex
Returns:The x, y, p coordinates of the vertex
Return type:tuple(int, int, int)
get_placements(label)[source]

Get the placements of an application vertex with a given label

Parameters:label (str) – The label of the vertex
Returns:A list of x, y, p coordinates of the vertices
Return type:list(tuple(int, int, int))
class spinn_front_end_common.utilities.database.DatabaseWriter(database_directory)[source]

Bases: spinn_front_end_common.utilities.sqlite_db.SQLiteDB

The interface for the database system for main front ends. Any special tables needed from a front end should be done by sub classes of this interface.

Parameters:database_directory (str) – Where the database will be written
add_application_vertices(application_graph)[source]

Stores the main application graph description (vertices, edges).

Parameters:application_graph (ApplicationGraph) – The graph to add from
add_machine_objects(machine)[source]

Store the machine object into the database

Parameters:machine (Machine) – the machine object.
add_placements(placements)[source]

Adds the placements objects into the database

Parameters:placements (Placements) – the placements object
add_routing_infos(routing_infos, machine_graph)[source]

Adds the routing information (key masks etc) into the database

Parameters:
  • routing_infos (RoutingInfo) – the routing information object
  • machine_graph (MachineGraph) – the machine graph object
add_routing_tables(routing_tables)[source]

Adds the routing tables into the database

Parameters:routing_tables (MulticastRoutingTables) – the routing tables object
add_system_params(runtime)[source]

Write system params into the database

Parameters:runtime (int) – the amount of time the application is to run for
add_tags(machine_graph, tags)[source]

Adds the tags into the database

Parameters:
  • machine_graph (MachineGraph) – the machine graph object
  • tags (Tags) – the tags object
add_vertices(machine_graph, data_n_timesteps, application_graph)[source]

Add the machine graph into the database.

Parameters:
  • machine_graph (MachineGraph) – The machine graph object
  • data_n_timesteps (int) – The number of timesteps for which data space will been reserved
  • application_graph (ApplicationGraph) – The application graph object
static auto_detect_database(machine_graph)[source]

Auto detects if there is a need to activate the database system

Parameters:machine_graph (MachineGraph) – the machine graph of the application problem space.
Returns:whether the database is needed for the application
Return type:bool
create_atom_to_event_id_mapping(application_graph, machine_graph, routing_infos)[source]
Parameters:
database_path
Return type:str