spinn_front_end_common.interface package

Submodules

spinn_front_end_common.interface.abstract_spinnaker_base module

main interface for the SpiNNaker tools

class spinn_front_end_common.interface.abstract_spinnaker_base.AbstractSpinnakerBase(configfile, executable_finder, graph_label=None, database_socket_addresses=None, extra_algorithm_xml_paths=None, n_chips_required=None, n_boards_required=None, default_config_paths=None, validation_cfg=None, front_end_versions=None)[source]

Bases: spinn_front_end_common.interface.config_handler.ConfigHandler, spinn_front_end_common.utilities.simulator_interface.SimulatorInterface

Main interface into the tools logic flow.

Parameters:
  • configfile (str) – What the configuration file is called
  • executable_finder (ExecutableFinder) – How to find APLX files to deploy to SpiNNaker
  • graph_label (str) – A label for the overall application graph
  • database_socket_addresses (iterable(SocketAddress)) – How to talk to notification databases
  • extra_algorithm_xml_paths (iterable(str)) – Where to load definitions of extra algorithms from
  • n_chips_required (int) – Overrides the number of chips to allocate from spalloc
  • n_boards_required (int) – Overrides the number of boards to allocate from spalloc
  • default_config_paths (list(str)) – Directories to load configurations from
  • validation_cfg (str) – How to validate configuration files
  • front_end_versions (list(tuple(str,str))) – Information about what software is in use
add_application_edge(edge_to_add, partition_identifier)[source]
Parameters:
  • edge_to_add (ApplicationEdge) – the edge to add to the graph
  • partition_identifier (str) – the partition identifier for the outgoing edge partition
add_application_vertex(vertex)[source]
Parameters:

vertex (ApplicationVertex) – the vertex to add to the graph

Raises:
  • ConfigurationException – when both graphs contain vertices
  • PacmanConfigurationException – If there is an attempt to add the same vertex more than once
add_extraction_timing(timing)[source]

Record the time taken for doing data extraction.

Parameters:timing (timedelta) –
add_live_packet_gatherer_parameters(live_packet_gatherer_params, vertex_to_record_from, partition_ids)[source]

Adds parameters for a new LPG if needed, or adds to the tracker for parameters. Note that LPGs can be inserted to track behaviour either at the application graph level or at the machine graph level, but not both at the same time.

Parameters:
  • live_packet_gatherer_params (LivePacketGatherParameters) – params to look for a LPG
  • vertex_to_record_from (AbstractVertex) – the vertex that needs to send to a given LPG
  • partition_ids (list(str)) – the IDs of the partitions to connect from the vertex
add_machine_edge(edge, partition_id)[source]
Parameters:
  • edge (MachineEdge) – the edge to add to the graph
  • partition_id (str) – the partition identifier for the outgoing edge partition
add_machine_vertex(vertex)[source]
Parameters:

vertex (MachineVertex) – the vertex to add to the graph

Raises:
  • ConfigurationException – when both graphs contain vertices
  • PacmanConfigurationException – If there is an attempt to add the same vertex more than once
add_socket_address(socket_address)[source]

Add the address of a socket used in the run notification protocol.

Parameters:
  • socket_address (SocketAddress) – The address of the socket
  • socket_address – The address of the database socket
Return type:

None

application_graph
The application graph used to derive the runtime machine
configuration.
Return type:ApplicationGraph
buffer_manager

The buffer manager being used for loading/extracting buffers

Return type:BufferManager
config

Provides access to the configuration for front end interfaces.

Return type:ConfigHandler
dsg_algorithm

The DSG algorithm used by the tools

Return type:str
exception_handler(exctype, value, traceback_obj)[source]

Handler of exceptions

Parameters:
  • exctype (type) – the type of exception received
  • value (Exception) – the value of the exception
  • traceback_obj (traceback) – the trace back stuff
extend_extra_load_algorithms(extra_load_algorithms)[source]

Add custom data-loading algorithms to the sequence of such algorithms to be run.

Parameters:extra_load_algorithms (list(str)) – Algorithms to add
extend_extra_mapping_algorithms(extra_mapping_algorithms)[source]

Add custom mapping algorithms to the end of the sequence of mapping algorithms to be run.

Parameters:extra_mapping_algorithms (list(str)) – Algorithms to add
extend_extra_post_run_algorithms(extra_post_run_algorithms)[source]

Add custom post-execution algorithms to the sequence of such algorithms to be run.

Parameters:extra_post_run_algorithms (list(str)) – Algorithms to add
fixed_routes
Return type:dict(tuple(int,int),FixedRouteEntry)
get_current_time()[source]

Get the current simulation time.

Return type:float
get_generated_output(name_of_variable)[source]

Get the value of an inter-algorithm variable.

Parameters:name_of_variable (str) – The variable to retrieve
Returns:The value (of arbitrary type), or None if the variable is not found.
Raises:ConfigurationException – If the simulation hasn’t yet run
get_number_of_available_cores_on_machine

The number of available cores on the machine after taking into account preallocated resources.

Returns:number of available cores
Return type:int
has_ran

Whether the simulation has executed anything at all.

Return type:bool
has_reset_last
increment_none_labelled_edge_count()[source]

Increment the number of new edges which have not been labelled.

machine

The python machine description object.

Return type:Machine
machine_graph
Return type:MachineGraph
no_machine_time_steps

The number of machine time steps.

Return type:int
none_labelled_edge_count

The number of times edges have not been labelled.

Return type:int
original_application_graph
Return type:ApplicationGraph
original_machine_graph
Return type:MachineGraph
placements

Where machine vertices are placed on the machine.

Return type:Placements
prepend_extra_pre_run_algorithms(extra_pre_run_algorithms)[source]

Add custom pre-execution algorithms to the front of the sequence of algorithms to be run.

Parameters:extra_pre_run_algorithms (list(str)) – Algorithms to add
reset()[source]

Code that puts the simulation back at time zero

routing_infos
Return type:RoutingInfo
run(run_time)[source]

Run a simulation for a fixed amount of time

Parameters:run_time (int) – the run duration in milliseconds.
run_until_complete(n_steps=None)[source]

Run a simulation until it completes

Parameters:n_steps (int) – If not None, this specifies that the simulation should be requested to run for the given number of steps. The host will still wait until the simulation itself says it has completed
set_n_boards_required(n_boards_required)[source]

Sets the machine requirements.

Warning

This method should not be called after the machine requirements have be computed based on the graph.

Parameters:n_boards_required (int) – The number of boards required
Raises:ConfigurationException If any machine requirements have already been set
set_up_machine_specifics(hostname)[source]

Adds machine specifics for the different modes of execution.

Parameters:hostname (str) – machine name
stop(turn_off_machine=None, clear_routing_tables=None, clear_tags=None)[source]

End running of the simulation.

Parameters:
  • turn_off_machine (bool) – decides if the machine should be powered down after running the execution. Note that this powers down all boards connected to the BMP connections given to the transceiver
  • clear_routing_tables (bool) – informs the tool chain if it should turn off the clearing of the routing tables
  • clear_tags (bool) – informs the tool chain if it should clear the tags off the machine at stop
stop_run()[source]

Request that the current infinite run stop.

Note

This will need to be called from another thread as the infinite run call is blocking.

tags
Return type:Tags
transceiver

How to talk to the machine.

Return type:Transceiver
update_extra_inputs(extra_inputs)[source]

Supply extra inputs to the runtime algorithms. Mappings are from known names (the logical type names) to the values to bind to them.

Parameters:extra_inputs (dict(str,any)) – The additional inputs to provide
update_extra_mapping_inputs(extra_mapping_inputs)[source]

Supply extra inputs to the mapping algorithms. Mappings are from known names (the logical type names) to the values to bind to them.

Parameters:extra_inputs (dict(str,any)) – The additional inputs to provide
use_virtual_board
Return type:bool True if this run is using a virtual machine
Return type:bool
verify_not_running()[source]

Verify that the simulator is in a state where it can start running.

spinn_front_end_common.interface.abstract_spinnaker_base.DEFAULT_N_VIRTUAL_CORES = 16

Number of cores to be used when using a Virtual Machine and not specified

spinn_front_end_common.interface.abstract_spinnaker_base.MINIMUM_OFF_STATE_TIME = 20

The minimum time a board is kept in the off state, in seconds

spinn_front_end_common.interface.config_handler module

class spinn_front_end_common.interface.config_handler.ConfigHandler(configfile, default_config_paths, validation_cfg)[source]

Bases: object

Superclass of AbstractSpinnakerBase that handles function only dependent of the config and the order its methods are called.

Parameters:
  • configfile (str) – The base name of the configuration file(s). Should not include any path components.
  • default_config_paths (list(str) or None) – The list of files to get default configurations from.
  • validation_cfg (list(str) or None) – The list of files to read a validation configuration from. If None, no such validation is performed.
child_folder(parent, child_name, must_create=False)[source]
Parameters:
  • parent (str) –
  • child_name (str) –
  • must_create (bool) – If True, the directory named by child_name (but not necessarily its parents) must be created by this call, and an exception will be thrown if this fails.
Returns:

The fully qualified name of the child folder.

Return type:

str

Raises:

OSError – if the directory existed ahead of time and creation was required by the user

machine_time_step

The machine timestep, in microseconds

Return type:int
set_up_timings(machine_time_step=None, time_scale_factor=None)[source]

Set up timings of the machine

Parameters:
  • machine_time_step (int or None) – An explicitly specified time step for the machine. If None, the value is read from the config
  • time_scale_factor (int or None) – An explicitly specified time scale factor for the simulation. If None, the value is read from the config
time_scale_factor

The time scaling factor.

Return type:int
write_finished_file()[source]

Write a finished file that allows file removal to only remove folders that are finished.

spinn_front_end_common.interface.java_caller module

class spinn_front_end_common.interface.java_caller.JavaCaller(json_folder, java_call, java_spinnaker_path=None, java_properties=None)[source]

Bases: object

Support class that holds all the stuff for running stuff in Java. This includes the work of preparing data for transmitting to Java and back.

This separates the choices of how to call the Java batch vs streaming, jar locations, parameters, etc from the rest of the python code.

Creates a java caller and checks the user/config parameters.

Parameters:
  • json_folder (str) – The location where the machine JSON is written.
  • java_call (str) – Call to start java. Including the path if required.
  • java_spinnaker_path (str) – The path where the java code can be found. This must point to a local copy of https://github.com/SpiNNakerManchester/JavaSpiNNaker. It must also have been built! If None the assumption is that it is the same parent directory as https://github.com/SpiNNakerManchester/SpiNNFrontEndCommon.
  • java_properties (str) – Optional properties that will be passed to Java. Must start with -D. For example -Dlogging.level=DEBUG
Raises:

ConfigurationException – if simple parameter checking fails.

execute_app_data_specification(use_monitors)[source]
Writes all the data specs for application cores,
uploading the result to the machine.
Parameters:use_monitors (bool) –
Raises:PacmanExternalAlgorithmFailedToCompleteException – On failure of the Java code.
execute_data_specification()[source]

Writes all the data specs, uploading the result to the machine.

Raises:PacmanExternalAlgorithmFailedToCompleteException – On failure of the Java code.
execute_system_data_specification()[source]
Writes all the data specs for system cores,
uploading the result to the machine.
Raises:PacmanExternalAlgorithmFailedToCompleteException – On failure of the Java code.
get_all_data()[source]
Gets all the data from the previously set placements
and put these in the previously set database.
Raises:PacmanExternalAlgorithmFailedToCompleteException – On failure of the Java code.
set_advanced_monitors(placements, tags, monitor_cores, packet_gathers)[source]
Parameters:
Return type:

None

set_machine(machine)[source]

Passes the machine in leaving this class to decide pass it to Java.

Parameters:machine (Machine) – A machine Object
set_placements(placements, transceiver)[source]
Passes in the placements leaving this class to decide pass it to
Java.

This method may obtain extra information about he placements which is why it also needs the transceiver.

Currently the extra information extracted is recording region base address but this could change if recording region saved in the database.

Currently this method uses JSON but that may well change to using the database.

Parameters:
set_report_folder(report_folder)[source]

Passes the database file in.

Parameters:report_folder (str) – Path to directory with SQLite databases and into which java will write.

spinn_front_end_common.interface.simulator_state module

class spinn_front_end_common.interface.simulator_state.Simulator_State(value, doc='')[source]

Bases: enum.Enum

Different states the Simulator could be in.

FINISHED = 3

run ended shutdown not called

INIT = 0

init called

IN_RUN = 1

inside run method

RUN_FOREVER = 2

finished run method, but running forever

SHUTDOWN = 4

shutdown called

STOP_REQUESTED = 5

stop requested in middle of run forever

Module contents