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.

Parameters:
  • start_resume_callback_function (function() -> None) – 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 (function( spinn_front_end_common.utilities.database.database_reader.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 the return response will be sent.
Raises:SpinnmanIOException – If anything goes wrong
close()[source]

Closes the connection

Returns:Nothing is returned
Return type:None
Raises:None – No known exceptions are raised
class spinn_front_end_common.utilities.database.DatabaseReader(database_path)[source]

Bases: object

A reader for the database.

Parameters:database_path (str) – The path to the database
close()[source]
cursor

The database cursor. Allows custom SQL queries to be performed.

Return type:sqlite3.Cursor
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
get_ip_address(x, y)[source]

Get an IP address to contact a chip

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

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

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)
Return type:tuple(str, int, bool)
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]
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
Returns:tuple of (IP address, port, strip SDP)
Return type:tuple(str, int, bool)
get_machine_live_output_key(label, receiver_label)[source]
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: object

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.

add_application_vertices(application_graph)[source]
Parameters:application_graph
Return type:None
add_machine_objects(machine)[source]

Store the machine object into the database

Parameters:machine – the machine object.
Return type:None
add_placements(placements)[source]

Adds the placements objects into the database

Parameters:
  • placements – the placements object
  • machine_graph – the machine graph object
Return type:

None

add_routing_infos(routing_infos, machine_graph)[source]

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

Parameters:
  • routing_infos – the routing information object
  • machine_graph – the machine graph object
Return type:

None:

add_routing_tables(routing_tables)[source]

Adds the routing tables into the database

Parameters:routing_tables – the routing tables object
Return type:None
add_system_params(time_scale_factor, machine_time_step, runtime)[source]

Write system params into the database

Parameters:
  • time_scale_factor – the time scale factor used in timing
  • machine_time_step – the machine time step used in timing
  • runtime – 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 – the machine graph object
  • tags – the tags object
Return type:

None

add_vertices(machine_graph, data_n_timesteps, graph_mapper, application_graph)[source]

Add the machine graph, graph mapper and application graph into the database.

Parameters:
  • machine_graph – the machine graph object
  • data_n_timesteps – The number of timesteps for which data space will been reserved
  • graph_mapper – the graph mapper object
  • application_graph – the application graph object
Return type:

None

static auto_detect_database(machine_graph)[source]

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

Parameters:machine_graph – the machine graph of the application problem space.
Returns:a bool which represents if the database is needed
create_atom_to_event_id_mapping(application_graph, machine_graph, routing_infos, graph_mapper)[source]
Parameters:
  • application_graph
  • machine_graph
  • routing_infos
  • graph_mapper
Return type:

None

database_path