SpiNNaker Manchester (PyNN 0.9) and GFE

These pages document the python code for the Spinnaker Projectwhich can be found on github.

This includes sPyNNaker 6, an implementation of PyNN 0.9 for the SpiNNaker platform, It is an implementation of a toolkit for creating simulations of spiking neural networks. sPyNNaker is particularly noted for being able to run very large simulations and in real-time; it is possible to interface external hardware directly to a SpiNNaker system.

The SpiNNakerGraphFrontEnd which is optimised for non-neural simulations. (Hybrid neural/non-neural simulations are also possible; contact the team if you are interested.)

SpiNNUtils

This provides basic utility functions and classes to other parts of SpiNNaker’s tooling. Nothing in here knows anything about SpiNNaker functionality.

SpiNNUtils

Contents

spinn_utilities
spinn_utilities package
Subpackages
spinn_utilities.citation package
Module contents
class spinn_utilities.citation.CitationAggregator[source]

Bases: object

Helper class for building a citation file which references all dependencies.

create_aggregated_citation_file(module_to_start_at, aggregated_citation_file)[source]

Entrance method for building the aggregated citation file.

Parameters:
  • module_to_start_at (python module) – the top level module to figure out its citation file for

  • aggregated_citation_file (str) – file name of aggregated citation file

static locate_path_for_c_dependency(true_software_name)[source]
Parameters:

true_software_name (str) –

Return type:

str or None

class spinn_utilities.citation.CitationUpdaterAndDoiGenerator[source]

Bases: object

static convert_month_name_to_number(version_month)[source]

Convert a python month in text form to a number form.

Parameters:

version_month (str or int) – the text form of the month

Returns:

the month int value

Return type:

int

Raises:

ValueError – when the month name is not recognised

static convert_text_date_to_date(version_month, version_year, version_day)[source]

Convert the 3 components of a date into a CFF date.

Parameters:
  • version_month (str or int) – version month, in text form

  • version_year (int) – version year

  • version_day (int) – version day of month

Returns:

the string representation for the CFF file

Return type:

str

update_citation_file_and_create_doi(citation_file_path, doi_title, create_doi, publish_doi, previous_doi, zenodo_access_token, module_path)[source]

Take a CITATION.cff file and updates the version and date-released fields, and rewrites the CITATION.cff file.

Parameters:
  • citation_file_path (str) – File path to the CITATION.cff file

  • create_doi (bool) – Whether to use Zenodo DOI interface to grab a DOI

  • zenodo_access_token (str) – Access token for Zenodo

  • publish_doi (bool) – Whether to publish the DOI on Zenodo

  • previous_doi (str) – DOI to append the created DOI to

  • doi_title (str) – Title for the created DOI

  • module_path (str) – Path to the module to zip up

  • update_version (bool) – Whether we should update the citation version

spinn_utilities.citation.generate_aggregate(arguments=None)[source]

Command-line tool to generate a single citation.cff from others.

Parameters:

arguments (list(str)) –

Command line arguments.

  • --output_path: Where to write the aggregate file

  • --top_module: The module to start aggregating the citation.cffs from

  • --doi_title: The title of the DOI

  • --zenodo_access_token: The access token for Zenodo

  • --tools_doi: The DOI of the tools

spinn_utilities.configs package
Module contents
class spinn_utilities.configs.CamelCaseConfigParser(defaults=None)[source]

Bases: RawConfigParser

get_bool(section, option)[source]

Get the boolean value of an option.

Parameters:
  • section (str) – What section to get the option from.

  • option (str) – What option to read.

Returns:

The option value.

Return type:

bool

get_float(section, option)[source]

Get the float value of an option.

Parameters:
  • section (str) – What section to get the option from.

  • option (str) – What option to read.

Returns:

The option value.

Return type:

float

get_int(section, option)[source]

Get the integer value of an option.

Parameters:
  • section (str) – What section to get the option from.

  • option (str) – What option to read.

Returns:

The option value

Return type:

int

get_str(section, option)[source]

Get the string value of an option.

Parameters:
  • section (str) – What section to get the option from.

  • option (str) – What option to read.

Returns:

The option value

Return type:

str or None

get_str_list(section, option, token=',')[source]

Get the string value of an option split into a list.

Parameters:
  • section (str) – What section to get the option from.

  • option (str) – What option to read.

  • token – The token to split the string into a list

Returns:

The list (possibly empty) of the option values

Return type:

list(str)

optionxform(optionstr)[source]

Transforms the name of an option to lower case and strips underscores, so matching is more user-friendly.

read(filenames, encoding=None)[source]

Read and parse a filename or a list of filenames.

property read_files

The configuration files that have been actually read.

class spinn_utilities.configs.CaseSensitiveParser(defaults=None, dict_type=<class 'collections.OrderedDict'>, allow_no_value=False, *, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section='DEFAULT', interpolation=<object object>, converters=<object object>)[source]

Bases: RawConfigParser

optionxform(optionstr)[source]

Performs no transformation of option strings.

exception spinn_utilities.configs.ConfigTemplateException[source]

Bases: Exception

Throws when a problem is found with a configuration template.

exception spinn_utilities.configs.NoConfigFoundException[source]

Bases: Exception

Thrown when no configuration value is found.

exception spinn_utilities.configs.UnexpectedConfigException[source]

Bases: Exception

Thrown when an existing Section has an extra configuration value.

spinn_utilities.data package
Submodules
spinn_utilities.data.reset_status module
class spinn_utilities.data.reset_status.ResetStatus(value)[source]

Bases: Enum

Different states the reset could be in.

This class is design to used internally by UtilsDataView.

HARD_RESET = 4
HAS_RUN = 2
NOT_SETUP = 0
SETUP = 1
SOFT_RESET = 3
spinn_utilities.data.run_status module
class spinn_utilities.data.run_status.RunStatus(value)[source]

Bases: Enum

Different states the run could be in.

This is from the perspective of the users script. It says nothing about if there is C code running, i.e., has a sim.run (or similar) call started but not yet returned.

This is combined with the ResetStatus to get the needed status.

This class is design to used internally by UtilsDataView.

IN_RUN = 2
NOT_RUNNING = 12
NOT_SETUP = 0
SHUTDOWN = 5
STOPPING = 4
STOP_REQUESTED = 3
spinn_utilities.data.utils_data_writer module
class spinn_utilities.data.utils_data_writer.UtilsDataWriter(state)[source]

Bases: UtilsDataView

Writer class for the information in UtilsDataView

This and subclass Writers are specifically designed to be used by the simulators (ASB) and unit tests only! Any other usage is not supported.

The Writers are specifically designed to support only one instant (typically held by ASB as self._data_writer).

Creating a new instant of the Writer will clear out any data added by the previous instance.

Unit tests can create a writer by doing …Writer.mock() or Writer.setup(). The mock method adds some default data such as directories and a Virtual 8 * 8 Machine, as well as allowing some back-door methods. …Writer.mock() is the recommended one for unit tests; setup() is more like what ASB does and allows for state changes such as writer.start_running.

ASB __init__() (or it subclasses) will create a new writer so a call to sim.setup will clear all previously held data.

Warning

As the Writers are not designed for general usage the methods can change without notice.

Parameters:

state (DataStatus) – State writer should be in

finish_run()[source]

Puts all data into the state expected after sim.run ends.

get_report_dir_path()[source]

Returns path to existing reports directory.

This is the high level directory which in which timestamp directories and run directories are placed.

As it is only accessed to create timestamp directories and remove old reports, this is not a view method.

Return type:

str

Raises:

SpiNNUtilsException – If the simulation_time_step is currently unavailable

hard_reset()[source]

Puts all data back into the state expected at graph changed and sim.reset.

This resets any data set after sim.setup has finished.

classmethod mock()[source]

Creates a writer in mock mode.

All previous data will be cleared.

This should set the most likely defaults values. But be aware that what is considered the most likely default could change over time.

Unit tests that depend on any valid value being set should be able to depend on Mock.

A unit test that depends on a specific value should call mock() and then set that value.

Returns:

A Data Writer

Return type:

UtilsDataWriter

request_stop()[source]

Used to indicate a user has requested a stop.

This is expected to be called during run from a different thread.

set_report_dir_path(reports_dir_path)[source]

Checks and sets the reports_dir_path.

Parameters:

reports_dir_path (str) –

Raises:

InvalidDirectory – if the reports_dir_path is not a directory

set_run_dir_path(run_dir_path)[source]

Checks and sets the run_dir_path.

Parameters:

run_dir_path (str) –

Raises:

InvalidDirectory – if the run_dir_path is not a directory

classmethod setup()[source]

Creates a writer in normal mode.

All previous data will be cleared

Returns:

A Data Writer

Return type:

UtilsDataWriter

shut_down()[source]

Puts all data into the state expected after sim.end.

Most methods that change data, or state will raise an exception after this call.

Most data however will still be available.

soft_reset()[source]

Puts all data back into the state expected at sim.reset but where the graph has not changed.

start_run()[source]

Puts all data into the state expected after do_run_loop started.

stopping()[source]

Puts all data into the state expected during stop.

Raises:
Module contents
class spinn_utilities.data.DataStatus(value)[source]

Bases: Enum

Different states the Data can be in.

This class is designed to used internally by UtilsDataView

MOCKED = 1

The system is (to be) setup in mocked mode for unit testing.

NOT_SETUP = 0

No setup calls have been done yet.

SETUP = 2

The system is (to be) setup for running user code.

SHUTDOWN = 3

The system has been shut down.

exception(data)[source]

Returns an instance of the most suitable data-not-available exception.

Parameters:

data – Parameter to pass to the relevant constructor.

Return type:

SpiNNUtilsException

class spinn_utilities.data.UtilsDataView[source]

Bases: object

A read only view of the data available at each level.

Note

The state model of this class is designed primarily to support sPyNNaker.

All methods are class methods so can be accessed directly without instantiating a view. There is a stack of subclasses such as MachineDataView, FecDataView, SpynnakerDataView (and more). All inherit all methods. We reserve the right to override methods defined in one View in subclasses.

There are also Writer classes which override the Views but these are specifically designed to only be usable in unit tests and by the simulator (ASB) directly.

You should use the data view most appropriate to what you are doing i.e. If you are accessing it from a class or function in FEC, use FecDataView but if you are accessing it from sPyNNaker, use SpynnakerDataView. This will ensure that any changes to the view local to the code will affect all code in that package

The objects accessed this way should not be changed or added to. Changing or adding to any object accessed is unsupported as bypasses any check or updates done in the writer(s). Objects returned could be changed to immutable versions without notice!

The get… methods will either return a valid value or raise an exception if the data is currently not available. The get methods will will not return None unless specifically documented to do so. As a reasonable effort is made the setters to verify the data types, the get methods can be expected to return the correct type.

There are also several semantic sugar get… methods. Some are slightly faster but many are just to make the code more readable. Some semantic sugar methods do not start with get to keep the same name as the existing function on the object has.

The iterate… methods offer a view over the collections within mutable data objects, particularly ones changed between runs. There is no guarantee if the returned iterator will or will not reflect any changes to the underlying data object, nor that how a method behaves in this way does not change over time. So the methods should be called for every iteration.

Each iterate… method will have a corresponding get_n… which you need to do instead of len(iterate…) as we reserve the right to make any iterate… method return an iterable which does not support len without notice.

add… methods allow for the scripts directly or indirectly to add extra values. They allow the view to add extra safety such as type checking. They will raise an exception if called while the simulator is running.

The has… methods will return True if the value is known and False if not. Semantically they are the same as checking if the get raises an exception. They may be faster if the object needs to be generated on the fly or protected to be made immutable. has… methods have been added where found needed. More can easily be added if required.

The is… methods will return a boolean value to say the simulator is in the expected state. They may throw an exception if called at an unexpected time. For example if called before sim.setup or after sim.end.

While how and where the underpinning DataModel(s) store data can change without notice, methods in View classes can be considered a supported API.

classmethod check_user_can_act()[source]

Checks if the status is such that users can be making calls.

This does not error in the Mocked state

Raises:
classmethod check_valid_simulator()[source]

Throws an error if there is no simulator.

Raises:
classmethod get_executable_finder()[source]

The ExcutableFinder object created at time code is imported.

Return type:

ExcutableFinder

classmethod get_executable_path(executable_name)[source]

Finds an executable within the set of folders. The set of folders is searched sequentially and the first match is returned.

Syntactic sugar for get_executable_finder().get_executable_path()

Parameters:

executable_name (str) – The name of the executable to find

Returns:

The full path of the discovered executable

Return type:

str

Raises:

KeyError – If no executable was found in the set of folders

classmethod get_executable_paths(executable_names)[source]

Finds each executables within the set of folders.

The names are assumed to be comma separated The set of folders is searched sequentially and the first match for each name is returned.

Names not found are ignored and not added to the list.

Syntactic sugar for get_executable_finder().get_executable_paths()

Parameters:

executable_names (str) – The name of the executable to find. Assumed to be comma separated.

Returns:

The full path of the discovered executable, or None if no executable was found in the set of folders

Return type:

list(str)

classmethod get_requires_data_generation()[source]

Reports if data generation is required.

Set to True at the start and by any change that could require data generation or mapping Remains True during the first run after a data change Only set to False at the end of the first run

Return type:

bool

classmethod get_requires_mapping()[source]

Reports if mapping is required.

Set to True at the start and by any change that could require any mapping stage to be called Remains True during the first run after a requires mapping. Only set to False at the end of the first run

Return type:

bool

classmethod get_run_dir_path()[source]

Returns the path to the directory that holds all the reports for run.

This will be the path used by the last run call or to be used by the next run if it has not yet been called.

Note

In unit test mode this returns a temporary directory shared by all path methods.

Return type:

str

Raises:

SpiNNUtilsException – If the run_dir_path is currently unavailable

classmethod is_hard_reset()[source]

Check if the system has been hard reset since the last run finished.

Warning

During the first run after reset this continues to return True!

Returns False after a reset that was considered soft.

Return type:

bool

classmethod is_no_stop_requested()[source]

Checks that a stop request has not been sent.

Return type:

bool

Raises:

NotImplementedError – If this is called from an unexpected state

classmethod is_ran_ever()[source]

Check if the simulation has run at least once, ignoring resets.

Return type:

bool

Raises:

NotImplementedError – If this is called from an unexpected state

classmethod is_ran_last()[source]

Checks if the simulation has run and not been reset.

Return type:

bool

Raises:

NotImplementedError – If this is called from an unexpected state

classmethod is_reset_last()[source]

Reports if sim.reset called since the last sim.run.

Unlike is_soft_reset() and is_hard_reset() this method return False during any sim.run.

It also returns False after a sim.stop or sim.end call starts

Return type:

bool

Raises:

NotImplementedError – If this is called from an unexpected state

classmethod is_running()[source]

Checks if there is currently a simulation running.

That is a call to run has started but not yet stopped.

Return type:

bool

classmethod is_setup()[source]

Checks to see if there is already a simulator.

Return type:

bool

Raises:

NotImplementedError – If this is called from an unexpected state

classmethod is_shutdown()[source]

Determines if simulator has already been shutdown.

This returns False in the Mocked state

Return type:

bool

classmethod is_soft_reset()[source]

Check if the system has been soft reset since the last run finished.

Warning

During the first run after reset this continues to return True!

Returns False after a reset that was considered hard.

Return type:

bool

classmethod is_stop_already_requested()[source]

Checks if there has already been a request stop.

Also checks the state is such that a stop request makes sense.

Returns:

True if the stop has already been requested or if the system is stopping or has already stopped False if the stop request makes sense.

Return type:

bool

Raises:
classmethod is_user_mode()[source]

Determines if simulator is currently not running so user is accessing data.

This returns False in the Mocked state.

Return type:

bool

Raises:

NotImplementedError – If the data has not yet been set up or on an unexpected run_status

classmethod register_binary_search_path(search_path)[source]

Register an additional binary search path for executables.

Syntactic sugar for get_executable_finder().add_path()

Parameters:

search_path (str) – absolute search path for binaries

classmethod set_requires_data_generation()[source]

Sets requires_data_generation to True.

Only the end of a run can set it to False

classmethod set_requires_mapping()[source]

Sets requires_mapping and requires_data_generation to True.

Only the end of a run can set it to False

spinn_utilities.make_tools package
Submodules
spinn_utilities.make_tools.converter module
spinn_utilities.make_tools.converter.convert(src, dest, new_dict)[source]

Converts a whole directory including sub-directories.

Parameters:
  • src (str) – Full source directory

  • dest (str) – Full destination directory

  • new_dict (bool) – Whether we should generate a new dictionary/DB. If not, we add to the existing one.

spinn_utilities.make_tools.log_sqllite_database module
class spinn_utilities.make_tools.log_sqllite_database.LogSqlLiteDatabase(new_dict=False)[source]

Bases: AbstractContextManager

Specific implementation of the Database for SQLite 3.

Note

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

Note

This totally relies on the way SQLite’s type affinities function. You can’t port to a different database engine without a lot of work.

Connects to a log dict. The location of the file can be overridden using the C_LOGS_DICT environment variable.

Parameters:

new_dict (bool) – Flag to say if this is a new dict or not. If True, clears and previous values. If False, makes sure the dict exists.

check_original(original)[source]
close()[source]

Finalises and closes the database.

get_directory_id(src_path, dest_path)[source]
get_file_id(directory_id, file_name)[source]
get_log_info(log_id)[source]
get_max_log_id()[source]
set_log_info(log_level, line_num, original, file_id)[source]
spinn_utilities.make_tools.replacer module
class spinn_utilities.make_tools.replacer.Replacer(new_dict=False)[source]

Bases: LogSqlLiteDatabase

Performs replacements.

Connects to a log dict. The location of the file can be overridden using the C_LOGS_DICT environment variable.

Parameters:

new_dict (bool) – Flag to say if this is a new dict or not. If True, clears and previous values. If False, makes sure the dict exists.

replace(short)[source]
Module contents
class spinn_utilities.make_tools.FileConverter[source]

Bases: object

Converts a file. See convert().

__call__(src, dest, log_file_id, log_database)[source]

Creates the file_convertor to convert one file.

Parameters:
  • src (str) – Absolute path to source file

  • dest (str) – Absolute path to destination file

  • log_file_id (int) – Id in the database for this file

  • log_database (LogSqlLiteDatabase) – The database which handles the mapping of id to log messages.

bracket_count(text)[source]

Net count of open brackets in line.

Parameters:

text (str) –

Return type:

int

static convert(src_dir, dest_dir, file_name)[source]

Static method to create Object and do the conversion.

Parameters:
  • src_dir (str) – Source directory

  • dest_dir (str) – Destination directory

  • file_name (str) – The name of the file to convert within the source directory; it will be made with the same name in the destination directory.

quote_part(text)[source]

Net count of double quotes in line.

Parameters:

text (str) –

Return type:

int

split_by_comma_plus(main, line_num)[source]

Split line by comma and partially parse.

Parameters:
  • main (str) –

  • line_num (int) –

Return type:

list(str)

Raises:

UnexpectedCException

spinn_utilities.matrix package
Module contents
class spinn_utilities.matrix.AbstractMatrix[source]

Bases: object

A rectangular 2D collection of data.

abstract get_data(x, y)[source]

Get the value at a particular X,Y coordinate.

abstract set_data(x, y, value)[source]

Set the value at a particular X,Y coordinate.

class spinn_utilities.matrix.DemoMatrix[source]

Bases: AbstractMatrix

data
get_data(x, y)[source]

Get the value at a particular X,Y coordinate.

set_data(x, y, value)[source]

Set the value at a particular X,Y coordinate.

class spinn_utilities.matrix.DoubleDict(xtype, ytype, matrix)[source]

Bases: object

class spinn_utilities.matrix.XView(x, matrix)[source]

Bases: object

A view along a particular x-slice of a 2D matrix.

class spinn_utilities.matrix.YView(y, matrix)[source]

Bases: object

A view along a particular y-slice of a 2D matrix.

spinn_utilities.ranged package
Submodules
spinn_utilities.ranged.ids_view module
spinn_utilities.ranged.single_view module
spinn_utilities.ranged.slice_view module
Module contents

An implementation of a dictionary and a list that support efficiently working with ranges of values, used to implement efficient collections for PyNN population views and assemblies.

class spinn_utilities.ranged.AbstractDict[source]

Bases: object

Base class for the RangeDictionary and all views. This allows the users to not have to worry if they have a view.

abstract get_default(key)[source]

Gets the default value for a single key. Unless changed, the default is the original value.

Note

Does not change any values but only changes what reset_value would do

Parameters:

key (str) – Existing dict key

Returns:

default for this key.

get_ranges(key=None)[source]

Lists the ranges(s) for all IDs covered by this view. There will be one yield for each range which may cover one or more IDs.

Note

As the data is created in a single call this is not affected by any updates.

Parameters:

key (str or iterable(str) or None) – The key or keys to get the value of. Use None for all

Returns:

List of tuples of (start, stop, value). start is inclusive so is the first ID in the range. stop is exclusive so is the last ID in the range + 1. If key is a str, value is a single object. If key is iterable (list, tuple, set, etc.) of str (or None) value is a dictionary object

abstract get_value(key)[source]

Gets a single shared value for all IDs covered by this view.

Parameters:

key (str or iterable(str) or None) – The key or keys to get the value of. Use None for all

Returns:

If key is a str, this returns the single object. If key is iterable (list, tuple, set, etc.) of str (or None), returns a dictionary object

Raises:

MultipleValuesException – If even one of the keys has multiple values set. But not if other keys not asked for have multiple values

has_key(key)[source]

As the Deprecated dict has_keys function.

Note

Int keys to IDs are not supported.

Parameters:

key (str) – the key

Returns:

If the key is in dict

Return type:

bool

abstract ids()[source]

Returns the IDs in range or view. If the view is setup with IDs out of numerical order the order used to create the view is maintained.

Note

If indexing into a view, you are picking the X’th ID. So if the IDs are [2,3,4,5] the view[2] will be the data for ID 4 and not 2

Returns:

list of IDs

Return type:

list(int)

items()[source]

Returns a list of (key, value) tuples. Works only if the whole ranges/view has single values.

If the key is a str, the values are single objects. If the key is iterable (list, tuple, set, etc.) of str (or None), the values are dictionary objects.

Returns:

List of (key, value) tuples

Return type:

list(tuple)

Raises:

MultipleValuesException – If even one of the keys has multiple values set.

abstract iter_all_values(key, update_save=False)[source]

Iterates over the value(s) for all IDs covered by this view. There will be one yield for each ID even if values are repeated.

Parameters:
  • key (str or iterable(str) or None) – The key or keys to get the value of. Use None for all keys

  • update_save – If set True the iteration will work even if values are updated during iteration. If left False the iterator may be faster but behaviour is undefined and unchecked if any values are changed during iteration.

Returns:

If key is a str, this yields single objects. If key is iterable (list, tuple, set, etc.) of str (or None), yields dictionary objects

abstract iter_ranges(key=None)[source]

Iterates over the ranges(s) for all IDs covered by this view. There will be one yield for each range which may cover one or more IDs.

Warning

This iterator is not update safe! Behaviour is undefined and unchecked if any values are changed during iteration.

Parameters:

key (str or iterable(str) or None) – The key or keys to get the value of. Use None for all

Returns:

yields tuples of (start, stop, value). start is inclusive so is the first ID in the range. stop is exclusive so is the last ID in the range + 1. If key is a str, value is a single object. If key is iterable (list, tuple, set, etc.) of str (or None), value is a dictionary object

iteritems()[source]

Iterates over the (key, value) tuples. Works only if the whole ranges/view has single values.

If the key is a str, the values are single objects. If the key is iterable (list, tuple, set, etc.) of str (or None), the values are dictionary objects

This function is safe for value updates but may miss new keys added during iteration.

Returns:

yield (key, value) tuples

Return type:

iterable(tuple)

Raises:

MultipleValuesException – If even one of the keys has multiple values set.

itervalues()[source]

Iterates over the values. Works only if the whole ranges/view has single values.

If a key is a str, its value is a single object. If a key is an iterable (list, tuple, set, etc.) of str (or None), its value is a dictionary object.

This function is safe for value updates but may miss new keys added during iteration.

Returns:

yield values

Raises:

MultipleValuesException – If even one of the keys has multiple values set.

abstract keys()[source]

Returns the keys in the dictionary

Returns:

keys in the dict

reset(key)[source]

Sets the value(s) for a single key back to the default value.

Parameters:
  • key (str) – Existing dict key

  • default – Value to be used by reset

abstract set_value(key, value, use_list_as_value=False)[source]

Resets a already existing key to the new value. All IDs in the whole range or view will have this key set.

Warning

This method does not allow adding keys. Using dict[str] = will add a new key, but it is not supported for views.

Warning

If a View is created over multiple ranges this method would raise a KeyError if any the ranges does not have the key. (Currently multiple ranges not yet supported.)

Parameters:
  • key (str) – key to value being set

  • value – any object

  • use_list_as_value – True if the value is a list

Raises:

KeyError – If a new key is being used.

values()[source]

Returns a list of values. Works only if the whole ranges/view has single values.

If a key is a str, its value is a single object. If a key is an iterable (list, tuple, set, etc.) of str (or None), its value is a dictionary object.

Returns:

List of values

Raises:

MultipleValuesException – If even one of the keys has multiple values set.

class spinn_utilities.ranged.AbstractList(size, key=None)[source]

Bases: AbstractSized

A ranged implementation of list.

Functions that change the size of the list are not supported. These include:

`__setitem__` where `key` >= `len`
`__delitem__`
`append`
`extend`
`insert`
`pop`
`remove`

Function that manipulate the list based on values are not supported. These include:

`reverse`, `__reversed__`
`sort`

In the current version the IDs are zero-based consecutive numbers so there is no difference between value-based IDs and index-based IDs, but this could change in the future.

Supports the following arithmetic operations over the list:

+

element-wise addition or addition of a single scalar

-

element-wise subtraction or subtraction of a single scalar

*

element-wise multiplication or multiplication by a single scalar

/

element-wise true division or true division by a single scalar

//

element-wise floor division or floor division by a single scalar

Parameters:
  • size (int) – Fixed length of the list

  • key – The dict key this list covers. This is used only for better Exception messages

apply_operation(operation)[source]

Applies a function on the list to create a new one. The values of the new list are created on the fly so any changes to the original lists are reflected.

Parameters:

operation – A function that can be applied over the individual values to create new ones.

Returns:

new list

Return type:

AbstractList

count(x)[source]

Counts the number of elements in the list with value x.

Parameters:

x

Returns:

count of matching elements

Return type:

int

abstract get_default()[source]

Gets the default value of the list. Just in case we later allow to increase the number of elements.

Returns:

Default value

get_single_value_all()[source]

If possible, returns a single value shared by the whole list.

For multiple values use for x in list, iter(list) or list.iter, or one of the iter_ranges methods

Returns:

Value shared by all elements in the list

Raises:

MultipleValuesException – If even one elements has a different value

abstract get_single_value_by_ids(ids)[source]

If possible, returns a single value shared by all the IDs.

For multiple values, use for x in list, iter(list), list.iter, or one of the iter_ranges methods.

Returns:

Value shared by all elements with these IDs

Raises:

MultipleValuesException – If even one elements has a different value. Not thrown if elements outside of the IDs have a different value, even if these elements are between the ones pointed to by IDs

abstract get_single_value_by_slice(slice_start, slice_stop)[source]

If possible, returns a single value shared by the whole slice list.

For multiple values, use for x in list, iter(list), list.iter, or one of the iter_ranges methods

Returns:

Value shared by all elements in the slice

Raises:

MultipleValuesException – If even one elements has a different value. Not thrown if elements outside of the slice have a different value

abstract get_value_by_id(the_id)[source]

Returns the value for one item in the list.

Parameters:

the_id (int) – One of the IDs of an element in the list

Returns:

The value of that element

get_values(selector=None)[source]

Get the value all elements pointed to the selector.

Note

Unlike __get_item__ this method always returns a list even if the selector is a single int.

Parameters:

selector – See AbstractSized.selector_to_ids()

Returns:

returns a list if the item which may be empty or have only single value

Return type:

list

index(x)[source]

Finds the first ID of the first element in the list with the given value.

Parameters:

x – The value to find.

Returns:

The ID/index

Raises:

ValueError – If the value is not found

iter()[source]

Update-safe iterator of all elements.

Note

Duplicate/Repeated elements are yielded for each ID

Returns:

yields each element one by one

iter_by_id(the_id)[source]

Fast but not update-safe iterator by one ID.

While next can only be called once, this is an iterator so it can be mixed in with other iterators.

Parameters:

the_id – ID

Returns:

yields the elements

iter_by_ids(ids)[source]

Fast but not update-safe iterator by collection of IDs.

Note

Duplicate/Repeated elements are yielded for each ID.

Parameters:

ids – IDs

Returns:

yields the elements pointed to by IDs

iter_by_selector(selector=None)[source]

Fast but not update-safe iterator of all elements in the slice.

Parameters:

selector – See AbstractSized.selector_to_ids()

Returns:

yields the selected elements one by one

iter_by_slice(slice_start, slice_stop)[source]

Fast but not update-safe iterator of all elements in the slice.

Note

Duplicate/Repeated elements are yielded for each ID

Returns:

yields each element one by one

abstract iter_ranges()[source]

Fast but not update-safe iterator of the ranges.

Returns:

yields each range one by one

iter_ranges_by_id(the_id)[source]

Iterator of the range for this ID.

Note

The start and stop of the range will be reduced to just the ID

This method purpose is so one a control method can select which iterator to use.

Returns:

yields the one range

iter_ranges_by_ids(ids)[source]

Fast but not update-safe iterator of the ranges covered by these IDs.

For consecutive IDs where the elements have the same value a single range may be yielded.

Note

The start and stop of the range will be reduced to just the IDs

Returns:

yields each range one by one

Return type:

iterable

abstract iter_ranges_by_slice(slice_start, slice_stop)[source]

Fast but not update-safe iterator of the ranges covered by this slice.

Note

The start and stop of the range will be reduced to just the IDs inside the slice.

Returns:

yields each range one by one

abstract range_based()[source]

Shows if the list is suited to deal with ranges or not.

All list must implement all the range functions, but there are times when using ranges will probably be slower than using individual values. For example the individual values may be stored in a list in which case the ranges are created on demand.

Returns:

True if and only if Ranged based calls are recommended.

Return type:

bool

class spinn_utilities.ranged.AbstractSized(size)[source]

Bases: object

Base class for slice and ID checking against size. Subclasses of this support the len() built-in.

Parameters:

size (int) – Fixed length of the list.

selector_to_ids(selector, warn=False)[source]

Gets the list of IDs covered by this selector. The types of selector currently supported are:

None:

Returns all IDs.

slice: Standard python slice.

Negative values and values larger than size are handled using slice’s indices method. This could result in am empty list.

int: Handles negative values as normal.

Checks if ID is within expected range.

iterator(bool): Used as a mask.

If the length of the mask is longer or shorted than number of IDs the result is the shorter of the two, with the remainder of the longer ignored.

iterator(int) but not bool:

Every value checked that it is with the range 0 to size. Negative values are not allowed. Original order and duplication is respected so result may be unordered and contain duplicates.

Parameters:
  • selector – Some object that identifies a range of IDs.

  • warn (bool) – If True, this method will warn about problems with the selector.

Returns:

a (possibly sorted) list of IDs

class spinn_utilities.ranged.AbstractView(range_dict)[source]

Bases: AbstractDict

A view over a ranged dictionary.

Note

The view may currently be read from only with int and int-collection indices, and only be written to with str indices. This may change to become more permissive in future versions.

Use RangeDictionary.view_factory() to create views

get_default(key)[source]

Gets the default value for a single key. Unless changed, the default is the original value.

Note

Does not change any values but only changes what reset_value would do

Parameters:

key (str) – Existing dict key

Returns:

default for this key.

keys()[source]

Returns the keys in the dictionary

Returns:

keys in the dict

class spinn_utilities.ranged.DualList(left, right, operation, key=None)[source]

Bases: AbstractList

A list which combines two other lists with an operation.

Parameters:
  • left (AbstractList) – The first list to combine

  • right (AbstractList) – The second list to combine

  • operation (callable) – The operation to perform as a function that takes two values and returns the result of the operation

  • key – The dict key this list covers. This is used only for better Exception messages

Raises:

ValueError – If list are not the same size

get_default()[source]

Gets the default value of the list. Just in case we later allow to increase the number of elements.

Returns:

Default value

get_single_value_by_ids(ids)[source]

If possible, returns a single value shared by all the IDs.

For multiple values, use for x in list, iter(list), list.iter, or one of the iter_ranges methods.

Returns:

Value shared by all elements with these IDs

Raises:

MultipleValuesException – If even one elements has a different value. Not thrown if elements outside of the IDs have a different value, even if these elements are between the ones pointed to by IDs

get_single_value_by_slice(slice_start, slice_stop)[source]

If possible, returns a single value shared by the whole slice list.

For multiple values, use for x in list, iter(list), list.iter, or one of the iter_ranges methods

Returns:

Value shared by all elements in the slice

Raises:

MultipleValuesException – If even one elements has a different value. Not thrown if elements outside of the slice have a different value

get_value_by_id(the_id)[source]

Returns the value for one item in the list.

Parameters:

the_id (int) – One of the IDs of an element in the list

Returns:

The value of that element

iter_by_slice(slice_start, slice_stop)[source]

Fast but not update-safe iterator of all elements in the slice.

Note

Duplicate/Repeated elements are yielded for each ID

Returns:

yields each element one by one

iter_ranges()[source]

Fast but not update-safe iterator of the ranges.

Returns:

yields each range one by one

iter_ranges_by_slice(slice_start, slice_stop)[source]

Fast but not update-safe iterator of the ranges covered by this slice.

Note

The start and stop of the range will be reduced to just the IDs inside the slice.

Returns:

yields each range one by one

range_based()[source]

Shows if the list is suited to deal with ranges or not.

All list must implement all the range functions, but there are times when using ranges will probably be slower than using individual values. For example the individual values may be stored in a list in which case the ranges are created on demand.

Returns:

True if and only if Ranged based calls are recommended.

Return type:

bool

exception spinn_utilities.ranged.MultipleValuesException(key=None, value1=None, value2=None)[source]

Bases: Exception

class spinn_utilities.ranged.RangeDictionary(size, defaults=None)[source]

Bases: AbstractSized, AbstractDict

Main holding class for a range of similar Dictionary object. Keys in the dictionary must be str object and can not be removed. New keys can be added using the dict[str] = value format. The size (length of the list) is fixed and set at initialisation time.

The Object is set up initially where every ID in the range will share the same value for each key. All keys must be of type str. The default values can be anything, including None.

Warning

Using mutable default values can result in weird problems.

Parameters:
  • size (int) – Fixed number of IDs / Length of lists

  • defaults (dict(str,object)) – Default dictionary where all keys must be str

copy()[source]

Make a copy of this dictionary. Inner ranged entities are deep copied, inner leaf values are shallow copied.

Returns:

The copy.

Return type:

RangeDictionary

copy_into(other)[source]

Turns this dict into a copy of the other dict but keep its id.

Parameters:

other (RangeDictionary) – Another ranged dictionary assumed created by cloning this one

get_default(key)[source]

Gets the default value for a single key. Unless changed, the default is the original value.

Note

Does not change any values but only changes what reset_value would do

Parameters:

key (str) – Existing dict key

Returns:

default for this key.

get_list(key)[source]

Gets the storage unit for a single key.

Note

Mainly intended by Views to access the data for one key directly.

Parameters:

key (str) – a key which must be present in the dict

Return type:

ranged_list.RangedList

get_value(key=None)[source]

Gets a single shared value for all IDs covered by this view.

Parameters:

key (str or iterable(str) or None) – The key or keys to get the value of. Use None for all

Returns:

If key is a str, this returns the single object. If key is iterable (list, tuple, set, etc.) of str (or None), returns a dictionary object

Raises:

MultipleValuesException – If even one of the keys has multiple values set. But not if other keys not asked for have multiple values

get_values_by_id(key, the_id)[source]

Same as get_value() but limited to a single ID.

Parameters:
Returns:

See get_value()

has_key(key)[source]

As the Deprecated dict has_keys function.

Note

Int keys to IDs are not supported.

Parameters:

key (str) – the key

Returns:

If the key is in dict

Return type:

bool

ids()[source]

Returns the IDs in range or view. If the view is setup with IDs out of numerical order the order used to create the view is maintained.

Note

If indexing into a view, you are picking the X’th ID. So if the IDs are [2,3,4,5] the view[2] will be the data for ID 4 and not 2

Returns:

list of IDs

Return type:

list(int)

Returns a list of the IDs in this Range

Returns:

a list of the IDs in this Range

Return type:

list(int)

iter_all_values(key=None, update_save=False)[source]

Iterates over the value(s) for all IDs covered by this view. There will be one yield for each ID even if values are repeated.

Parameters:
  • key (str or iterable(str) or None) – The key or keys to get the value of. Use None for all keys

  • update_save – If set True the iteration will work even if values are updated during iteration. If left False the iterator may be faster but behaviour is undefined and unchecked if any values are changed during iteration.

Returns:

If key is a str, this yields single objects. If key is iterable (list, tuple, set, etc.) of str (or None), yields dictionary objects

iter_ranges(key=None)[source]

Iterates over the ranges(s) for all IDs covered by this view. There will be one yield for each range which may cover one or more IDs.

Warning

This iterator is not update safe! Behaviour is undefined and unchecked if any values are changed during iteration.

Parameters:

key (str or iterable(str) or None) – The key or keys to get the value of. Use None for all

Returns:

yields tuples of (start, stop, value). start is inclusive so is the first ID in the range. stop is exclusive so is the last ID in the range + 1. If key is a str, value is a single object. If key is iterable (list, tuple, set, etc.) of str (or None), value is a dictionary object

iter_ranges_by_id(key=None, the_id=None)[source]

Same as iter_ranges() but limited to one ID.

Parameters:
  • key – see iter_ranges() parameter key

  • the_id (int) – single ID which is the actual ID and not an index into IDs

iter_ranges_by_ids(ids, key=None)[source]

Same as iter_ranges() but limited to a collection of IDs.

The IDs are actual ID values and not indexes into the IDs

Parameters:
  • key – see iter_ranges() parameter key

  • ids – Collection of IDs in the range

Returns:

see iter_ranges()

iter_ranges_by_slice(key, slice_start, slice_stop)[source]

Same as iter_ranges() but limited to a simple slice.

slice_start and slice_stop are actual ID values and not indexes into the IDs. They must also be actual values, so None, max_int, and negative numbers are not supported.

Parameters:
  • key – see iter_ranges() parameter key

  • slice_start – Inclusive i.e. first ID

  • slice_stop – Exclusive to last ID + 1

Returns:

see iter_ranges()

iter_values_by_ids(ids, key=None, update_save=False)[source]

Same as iter_all_values() but limited to a simple slice.

iter_values_by_slice(slice_start, slice_stop, key=None, update_save=False)[source]

Same as iter_all_values() but limited to a simple slice.

keys()[source]

Returns the keys in the dictionary

Returns:

keys in the dict

list_factory(size, value, key)[source]

Defines which class or subclass of RangedList to use.

Main purpose is for subclasses to use a subclass or RangedList. All parameters are pass through ones to the List constructor

Parameters:
  • size – Fixed length of the list

  • value – value to given to all elements in the list

  • key – The dict key this list covers.

Returns:

AbstractList in this case a RangedList

set_default(key, default)[source]

Sets the default value for a single key.

Note

Does not change any values but only changes what reset_value would do

Warning

If called on a view, it sets the default for the whole range and not just the view.

Parameters:
  • key (str) – Existing dict key

  • default – Value to be used by reset; should not be mutable!

set_value(key, value, use_list_as_value=False)[source]

Resets a already existing key to the new value. All IDs in the whole range or view will have this key set.

Warning

This method does not allow adding keys. Using dict[str] = will add a new key, but it is not supported for views.

Warning

If a View is created over multiple ranges this method would raise a KeyError if any the ranges does not have the key. (Currently multiple ranges not yet supported.)

Parameters:
  • key (str) – key to value being set

  • value – any object

  • use_list_as_value – True if the value is a list

Raises:

KeyError – If a new key is being used.

update_safe_iter_all_values(key, ids)[source]

Same as iter_all_values() but limited to a collection of IDs and update-safe.

view_factory(key)[source]

Main function for creating views. This is the preferred way of creating new views as it checks parameters and returns the most efficient view.

Note

The __getitem__ methods called by Object[id] and similar defer to this method so are fine to use.

The ID(s) used are the actual IDs in the range and not indexes on the list of IDs

Parameters:

key – A single int ID, a Slice object, or an iterable of int IDs

Returns:

A view over the range

class spinn_utilities.ranged.RangedList(size=None, value=None, key=None, use_list_as_value=False)[source]

Bases: AbstractList

A list that is able to efficiently hold large numbers of elements that all have the same value.

Parameters:
  • size (int or None) – Fixed length of the list; if None, the value must be a sized object.

  • value (object or Sized) – value to given to all elements in the list

  • key – The dict key this list covers. This is used only for better Exception messages

  • use_list_as_value (bool) – True if the value is a list

static as_list(value, size, ids=None)[source]

Converts (if required) the value into a list of a given size. An exception is raised if value cannot be given size elements.

Note

This method can be extended to add other conversions to list in which case is_list() must also be extended.

Parameters:

value

Returns:

value as a list

Raises:

Exception – if the number of values and the size do not match

copy()[source]

Creates a copy of this list.

Depth is just enough so that any changes done through the RangedList API on other will not change self

Returns:

The copy

Return type:

RangedList

copy_into(other)[source]

Turns this List into a of the other list but keep its ID.

Depth is just enough so that any changes done through the RangedList API on other will not change self

Parameters:

other (RangedList) – Another Ranged List to copy the values from

get_default()[source]

Returns the default value for this list.

Returns:

Default Value

Return type:

object

get_ranges()[source]

Returns a copy of the list of ranges.

Note

As this is a copy it will not reflect any updates.

Return type:

list(tuple(int,int,object))

get_single_value_by_ids(ids)[source]

If possible, returns a single value shared by all the IDs.

For multiple values, use for x in list, iter(list), list.iter, or one of the iter_ranges methods.

Returns:

Value shared by all elements with these IDs

Raises:

MultipleValuesException – If even one elements has a different value. Not thrown if elements outside of the IDs have a different value, even if these elements are between the ones pointed to by IDs

get_single_value_by_slice(slice_start, slice_stop)[source]

If possible, returns a single value shared by the whole slice list.

For multiple values, use for x in list, iter(list), list.iter, or one of the iter_ranges methods

Returns:

Value shared by all elements in the slice

Raises:

MultipleValuesException – If even one elements has a different value. Not thrown if elements outside of the slice have a different value

get_value_by_id(the_id)[source]

Returns the value for one item in the list.

Parameters:

the_id (int) – One of the IDs of an element in the list

Returns:

The value of that element

static is_list(value, size)[source]

Determines if the value should be treated as a list.

Note

This method can be extended to add other checks for list in which case as_list() must also be extended.

Parameters:

value – The value to examine.

iter_by_slice(slice_start, slice_stop)[source]

Fast but not update-safe iterator of all elements in the slice.

Note

Duplicate/Repeated elements are yielded for each ID

Returns:

yields each element one by one

iter_ranges()[source]

Fast but not update-safe iterator of the ranges.

Returns:

yields each range one by one

iter_ranges_by_slice(slice_start, slice_stop)[source]

Fast but not update-safe iterator of the ranges covered by this slice.

Note

The start and stop of the range will be reduced to just the IDs inside the slice.

Returns:

yields each range one by one

range_based()[source]

Shows if the list is suited to deal with ranges or not.

All list must implement all the range functions, but there are times when using ranges will probably be slower than using individual values. For example the individual values may be stored in a list in which case the ranges are created on demand.

Returns:

True if and only if Ranged based calls are recommended.

Return type:

bool

set_default(default)[source]

Sets the default value.

Note

Does not change the value of any element in the list.

Parameters:

default (object) – new default value

set_value(value, use_list_as_value=False)[source]

Sets all elements in the list to this value.

Note

Does not change the default.

Parameters:
  • value – new value

  • use_list_as_value – True if the value to be set is a list

set_value_by_id(the_id, value)[source]

Sets the value for a single ID to the new value.

Note

This method only works for a single positive int ID. Use set or __set__ for slices, tuples, lists and negative indexes.

Parameters:
  • the_id (int) – Single ID

  • value (object) – The value to save

set_value_by_ids(ids, value, use_list_as_value=False)[source]
set_value_by_selector(selector, value, use_list_as_value=False)[source]

Support for the list[x] = format.

Parameters:
  • selector (int or slice or list(int)) – A single ID, a slice of IDs or a list of IDs

  • value (object) –

set_value_by_slice(slice_start, slice_stop, value, use_list_as_value=False)[source]

Sets the value for a single range to the new value.

Note

This method only works for a single positive range. Use set or __set__ for slices, tuples, lists and negative indexes.

Parameters:
  • slice_start (int) – Start of the range

  • slice_stop (int) – Exclusive end of the range

  • value (object) – The value to save

class spinn_utilities.ranged.RangedListOfList(size=None, value=None, key=None, use_list_as_value=False)[source]

Bases: RangedList

Parameters:
  • size (int or None) – Fixed length of the list; if None, the value must be a sized object.

  • value (object or Sized) – value to given to all elements in the list

  • key – The dict key this list covers. This is used only for better Exception messages

  • use_list_as_value (bool) – True if the value is a list

static is_list(value, size)[source]

Determines if the value should be treated as a list.

Note

This method can be extended to add other checks for list in which case as_list() must also be extended.

Parameters:

value – The value to examine.

class spinn_utilities.ranged.SingleList(a_list, operation, key=None)[source]

Bases: AbstractList

A List that performs an operation on the elements of another list.

Parameters:
  • a_list (AbstractList) – The list to perform the operation on

  • operation (callable) – A function which takes a single value and returns the result of the operation on that value

  • key – The dict key this list covers. This is used only for better Exception messages

get_default()[source]

Gets the default value of the list. Just in case we later allow to increase the number of elements.

Returns:

Default value

get_single_value_by_ids(ids)[source]

If possible, returns a single value shared by all the IDs.

For multiple values, use for x in list, iter(list), list.iter, or one of the iter_ranges methods.

Returns:

Value shared by all elements with these IDs

Raises:

MultipleValuesException – If even one elements has a different value. Not thrown if elements outside of the IDs have a different value, even if these elements are between the ones pointed to by IDs

get_single_value_by_slice(slice_start, slice_stop)[source]

If possible, returns a single value shared by the whole slice list.

For multiple values, use for x in list, iter(list), list.iter, or one of the iter_ranges methods

Returns:

Value shared by all elements in the slice

Raises:

MultipleValuesException – If even one elements has a different value. Not thrown if elements outside of the slice have a different value

get_value_by_id(the_id)[source]

Returns the value for one item in the list.

Parameters:

the_id (int) – One of the IDs of an element in the list

Returns:

The value of that element

iter_ranges()[source]

Fast but not update-safe iterator of the ranges.

Returns:

yields each range one by one

iter_ranges_by_slice(slice_start, slice_stop)[source]

Fast but not update-safe iterator of the ranges covered by this slice.

Note

The start and stop of the range will be reduced to just the IDs inside the slice.

Returns:

yields each range one by one

range_based()[source]

Shows if the list is suited to deal with ranges or not.

All list must implement all the range functions, but there are times when using ranges will probably be slower than using individual values. For example the individual values may be stored in a list in which case the ranges are created on demand.

Returns:

True if and only if Ranged based calls are recommended.

Return type:

bool

spinn_utilities.testing package
Submodules
spinn_utilities.testing.log_checker module
spinn_utilities.testing.log_checker.assert_logs_contains_once(level, log_records, message)[source]

Checks if the log records contain exactly one record at the given level with the given sub-message.

Note

While this code does not depend on testfixtures, you will need testfixtures to generate the input data

Parameters:
  • level – The log level. Probably “INFO”, “WARNING” or “ERROR”.

  • log_records – list of log records returned by testfixtures.LogCapture

  • submessage – String which should be part of a log record

Raises:

AssertionError – If the submessage is not present in the log

spinn_utilities.testing.log_checker.assert_logs_error_contains(log_records, submessage)[source]

Checks it the log records contain an ERROR log with this sub-message

Note

While this code does not depend on testfixtures, you will need testfixtures to generate the input data

Parameters:
  • log_records – list of log records returned by testfixtures.LogCapture

  • submessage – String which should be part of an ERROR log

Raises:

AssertionError – If the submessage is not present in the log

spinn_utilities.testing.log_checker.assert_logs_error_not_contains(log_records, submessage)[source]

Checks it the log records do not contain an ERROR log with this sub-message.

Note

While this code does not depend on testfixtures, you will need testfixtures to generate the input data

Parameters:
  • log_records – list of log records returned by testfixtures.LogCapture

  • submessage – String which should be part of an ERROR log

Raises:

AssertionError – If the submessage is present in the log

spinn_utilities.testing.log_checker.assert_logs_info_contains(log_records, sub_message)[source]

Checks it the log records contain an INFO log with this sub-message

Note

While this code does not depend on testfixtures, you will need testfixtures to generate the input data

Parameters:
  • log_records – list of log records returned by testfixtures.LogCapture

  • sub_message – String which should be part of an INFO log

Raises:

AssertionError – If the submessage is not present in the log

spinn_utilities.testing.log_checker.assert_logs_info_not_contains(log_records, submessage)[source]

Checks it the log records do not contain an INFO log with this sub-message.

Note

While this code does not depend on testfixtures, you will need testfixtures to generate the input data

Parameters:
  • log_records – list of log records returned by testfixtures.LogCapture

  • submessage – String which should be part of an INFO log

Raises:

AssertionError – If the submessage is present in the log

spinn_utilities.testing.log_checker.assert_logs_warning_contains(log_records, submessage)[source]

Checks it the log records contain an WARNING log with this sub-message

Note

While this code does not depend on testfixtures, you will need testfixtures to generate the input data

Parameters:
  • log_records – list of log records returned by testfixtures.LogCapture

  • submessage – String which should be part of an WARNING log

Raises:

AssertionError – If the submessage is not present in the log

Module contents
Submodules
spinn_utilities.abstract_base module

A trimmed down version of standard Python Abstract Base classes.

class spinn_utilities.abstract_base.AbstractBase(name, bases, namespace, **kwargs)[source]

Bases: type

Metaclass for defining Abstract Base Classes (AbstractBases).

Use this metaclass to create an AbstractBase. An AbstractBase can be subclassed directly, and then acts as a mix-in class.

This is a trimmed down version of ABC. Unlike ABC you can not register unrelated concrete classes.

Usage:

class C(object, metaclass=AbstractBase):
    @abstractmethod
    def my_abstract_method(self, ...):
        ...
spinn_utilities.abstract_base.abstractmethod(funcobj)[source]

A decorator indicating abstract methods.

Requires that the metaclass is AbstractBase or derived from it. A class that has a metaclass derived from AbstractBase cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms.

Usage:

class C(object, metaclass=AbstractBase):
    @abstractmethod
    def my_abstract_method(self, ...):
        ...
class spinn_utilities.abstract_base.abstractproperty(fget=None, fset=None, fdel=None, doc=None)[source]

Bases: property

A decorator indicating abstract properties.

Requires that the metaclass is AbstractBase or derived from it. A class that has a metaclass derived from AbstractBase cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.

Usage:

class C(object, metaclass=AbstractBase):
    @abstractproperty
    def my_abstract_property(self):
        ...

This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:

class C(object, metaclass=AbstractBase):
    def getx(self): ...
    def setx(self, value): ...
    x = abstractproperty(getx, setx)

Note

When documenting abstract properties, remember to document them as if they are nouns, not verbs; they are things about the object that may be observed as many times as the user of the class desires.

Warning

Implementations should be idempotent; fetching the property twice in a row should get an equivalent value with no (meaningful) change to the state of the object (assuming no other non-property methods of the object are invoked between).

This is an assumption that debuggers make. Do not violate it!

spinn_utilities.abstract_context_manager module
class spinn_utilities.abstract_context_manager.AbstractContextManager[source]

Bases: object

Closable class that supports being used as a simple context manager.

abstract close()[source]

How to actually close the underlying resources.

spinn_utilities.bytestring_utils module
spinn_utilities.bytestring_utils.as_hex(byte_string, start=None, end=None)[source]

Returns the byte string as string showing the hex values

Parameters:
  • byte_string (bytes) – data as a byte string

  • start (int) – the inclusive start of the slice to return. May be None

  • end (int) – the exclusive end of the slice to return. May be None

Returns:

Comma-separated hex values

Return type:

str

spinn_utilities.bytestring_utils.as_string(byte_string, start=None, end=None)[source]

Returns the length and the hex values.

The length is always the full length irrespective of the start and end.

Parameters:
  • byte_string (bytes) – data as a byte string

  • start (int) – The inclusive start of the slice to convert to hexadecimal. May be None

  • end (int) – The exclusive end of the slice to convert to hexadecimal. May be None

Returns:

The length of the byte string and the comma separated hex values, as a descriptive string

Return type:

str

spinn_utilities.classproperty module
spinn_utilities.classproperty.classproperty(func)[source]

Defines a property at the class-level.

Usage:

class C(object):
    _my_property = "Value"

    @classproperty
    def my_property(cls):
        return cls._my_property
spinn_utilities.conf_loader module
spinn_utilities.conf_loader.install_cfg_and_IOError(filename, defaults, config_locations)[source]

Installs a local configuration file based on the templates and raises an exception.

This method is called when no user configuration file is found.

It will create a file in the users home directory based on the defaults. Then it prints a helpful message and throws an error with the same message.

Parameters:
  • filename (str) – Name under which to save the new configuration file

  • defaults (list(str)) – List of full paths to the default configuration files. Each of which must have an associated template file with exactly the same path plus .template.

  • config_locations (list(str)) – List of paths where the user configuration files were looked for. Only used for the message

Raises:

spinn_utilities.configs.NoConfigFoundException – Always raised

spinn_utilities.conf_loader.load_config(filename, defaults, config_parsers=None)[source]

Load the configuration.

Parameters:
  • filename (str) – The base name of the configuration file(s). Should not include any path components.

  • defaults (list(str)) – The list of files to get default configurations from.

  • config_parsers (list(tuple(str, RawConfigParser))) – The parsers to parse the sections of the configuration file with, as a list of (section name, parser); a configuration section will only be parsed if the section_name is found in the configuration files already loaded. The standard logging parser is appended to (a copy of) this list.

Returns:

the fully-loaded and checked configuration

Return type:

RawConfigParser

spinn_utilities.conf_loader.logging_parser(config)[source]

Create the root logger with the given level.

Create filters based on logging levels

Note

You do not normally need to call this function; it is used automatically to parse Logging configuration sections.

spinn_utilities.config_holder module
spinn_utilities.config_holder.add_default_cfg(default)[source]

Adds an extra default configuration file to be read after earlier ones.

Parameters:

default (str) – Absolute path to the configuration file

spinn_utilities.config_holder.clear_cfg_files(unittest_mode)[source]

Clears any previous set configurations and configuration files.

After this method add_default_cfg() and set_cfg_files() need to be called.

Parameters:

unittest_mode (bool) – Flag to put the holder into unit testing mode

spinn_utilities.config_holder.config_options(section)[source]

Return a list of option names for the given section name.

Parameters:

section (str) – What section to list options for.

spinn_utilities.config_holder.get_config_bool(section, option)[source]

Get the boolean value of a configuration option.

Parameters:
  • section (str) – What section to get the option from.

  • option (str) – What option to read.

Returns:

The option value.

Return type:

bool

spinn_utilities.config_holder.get_config_float(section, option)[source]

Get the float value of a configuration option.

Parameters:
  • section (str) – What section to get the option from.

  • option (str) – What option to read.

Returns:

The option value.

Return type:

float

spinn_utilities.config_holder.get_config_int(section, option)[source]

Get the integer value of a configuration option.

Parameters:
  • section (str) – What section to get the option from.

  • option (str) – What option to read.

Returns:

The option value

Return type:

int

spinn_utilities.config_holder.get_config_str(section, option)[source]

Get the string value of a configuration option.

Parameters:
  • section (str) – What section to get the option from.

  • option (str) – What option to read.

Returns:

The option value

Return type:

str or None

spinn_utilities.config_holder.get_config_str_list(section, option, token=',')[source]

Get the string value of a configuration option split into a list.

Parameters:
  • section (str) – What section to get the option from.

  • option (str) – What option to read.

  • token – The token to split the string into a list

Returns:

The list (possibly empty) of the option values

Return type:

list(str)

spinn_utilities.config_holder.has_config_option(section, option)[source]

Check if the section has this configuration option.

Parameters:
  • section (str) – What section to check

  • option (str) – What option to check.

Return type:

bool

Returns:

True if and only if the option is defined. It may be None

spinn_utilities.config_holder.load_config()[source]

Reads in all the configuration files, resetting all values.

Raises:

ConfigException – If called before setting defaults

spinn_utilities.config_holder.run_config_checks(directories, *, exceptions=None, repeaters=None)[source]

Master test.

Parameters:
  • module

  • exceptions

  • repeaters

Raises:

ConfigException – If an incorrect directory passed in

spinn_utilities.config_holder.set_cfg_files(config_file, default)[source]

Adds the configuration files to be loaded.

Parameters:
  • config_file (str) – The base name of the configuration file(s). Should not include any path components.

  • default (str) – Full path to the extra file to get default configurations from.

spinn_utilities.config_holder.set_config(section, option, value)[source]

Sets the value of a configuration option.

This method should only be called by the simulator or by unit tests.

Parameters:
  • section (str) – What section to set the option in.

  • option (str) – What option to set.

  • value (object) – Value to set option to

Raises:

ConfigException – If called unexpectedly

spinn_utilities.config_setup module
spinn_utilities.config_setup.add_spinn_utilities_cfg()[source]
spinn_utilities.config_setup.unittest_setup()[source]

Resets the configurations so only the local default configuration is included.

Note

This file should only be called from SpiNNUtils/unittests

Parameters:

unittest_mode – Flag to indicate in unit tests

spinn_utilities.exceptions module
exception spinn_utilities.exceptions.ConfigException[source]

Bases: SpiNNUtilsException

Raised when reading or setting configurations went wrong.

exception spinn_utilities.exceptions.DataChanged(data)[source]

Bases: SpiNNUtilsException

Raised when trying to get data after some changed.

exception spinn_utilities.exceptions.DataNotMocked(data)[source]

Bases: DataNotYetAvialable

Raised when trying to get data before a mocked simulator has created it.

exception spinn_utilities.exceptions.DataNotYetAvialable(data)[source]

Bases: SpiNNUtilsException

Raised when trying to get data before simulator has created it.

exception spinn_utilities.exceptions.IllegalState(data)[source]

Bases: DataNotYetAvialable

Raised when trying to get data before a mocked simulator has created it.

exception spinn_utilities.exceptions.IllegalWriterException[source]

Bases: SpiNNUtilsException

Raised when trying to create a writer other than setup or Mock.

exception spinn_utilities.exceptions.InvalidDirectory(name, value)[source]

Bases: SpiNNUtilsException

Raised when trying to set an invalid directory.

exception spinn_utilities.exceptions.NotSetupException(data)[source]

Bases: SpiNNUtilsException

Raised when trying to get data before simulator has been setup.

exception spinn_utilities.exceptions.ShutdownException(data)[source]

Bases: SpiNNUtilsException

Raised when trying to get simulator data after it has been shut down.

exception spinn_utilities.exceptions.SimulatorNotRunException[source]

Bases: SpiNNUtilsException

Raised when trying to reset or stop before starting.

exception spinn_utilities.exceptions.SimulatorNotSetupException[source]

Bases: SpiNNUtilsException

Raised when trying to get simulator before it has been setup.

exception spinn_utilities.exceptions.SimulatorRunningException[source]

Bases: SpiNNUtilsException

Raised when trying an action that should not happen while the simulator is running.

exception spinn_utilities.exceptions.SimulatorShutdownException[source]

Bases: SpiNNUtilsException

Raised when trying to get simulator after it has been shut down.

exception spinn_utilities.exceptions.SpiNNUtilsException[source]

Bases: Exception

Superclass of all exceptions from the SpiNNUtils module.

exception spinn_utilities.exceptions.UnexpectedCException[source]

Bases: SpiNNUtilsException

Raised when the converter (which replaces log messages) found a pattern it did not expect and cannot handle.

exception spinn_utilities.exceptions.UnexpectedStateChange[source]

Bases: SpiNNUtilsException

Raised when trying to change the state in an unexpected way.

spinn_utilities.executable_finder module
class spinn_utilities.executable_finder.ExecutableFinder[source]

Bases: object

Manages a set of folders in which to search for binaries, and allows for binaries to be discovered within this path.

add_path(path)[source]

Adds a path to the set of folders to be searched. The path is added to the end of the list, so it is searched after all the paths currently in the list.

Parameters:

path (str) – The path to add

property binary_paths

The set of folders to search for binaries, as a printable colon-separated string.

Return type:

str

check_logs()[source]
clear_logs()[source]
get_executable_path(executable_name)[source]

Finds an executable within the set of folders. The set of folders is searched sequentially and the first match is returned.

Parameters:

executable_name (str) – The name of the executable to find

Returns:

The full path of the discovered executable

Return type:

str

Raises:

KeyError – If no executable was found in the set of folders

get_executable_paths(executable_names)[source]

Finds each executables within the set of folders.

The names are assumed to be comma separated The set of folders is searched sequentially and the first match for each name is returned.

Names not found are ignored and not added to the list.

Parameters:

executable_names (str) – The name of the executable to find. Assumed to be comma separated.

Returns:

The full path of the discovered executable, or None if no executable was found in the set of folders

Return type:

list(str)

spinn_utilities.find_max_success module
spinn_utilities.find_max_success.find_max_success(max_possible, check)[source]

Finds the maximum value that will pass the check

Parameters:
  • max_possible (int) – The maximum value that should be tested.

  • check (Callable[[int], bool]) – A boolean function that given an int value returns True for every value up and including the cut-off and False for every value greater than the cut-off

Returns:

The highest value that returns true for the check but is not more than the max_possible

spinn_utilities.find_max_success.search_for_max_success(best_success, min_fail, check)[source]

Finds the maximum value in the range that pass the check

Parameters:
  • best_success (int) – A minimum value that needs not be tested because it is either known to succeed or is a flag for total failure. Can be negative

  • min_fail (int) – A maximum value that needs not be tested because it is either known to fail or one more than the maximum interesting value but must be greater than best_success but may also be negative

  • check (Callable[[int], bool]) – A boolean function that given an int value returns True for every value up and including the cut-off and False for every value greater than the cut-off

Returns:

The highest value that returns true in the range between best_success and min_fail (both exclusive ends) or best_success if the whole range fails or is empty.

spinn_utilities.helpful_functions module
spinn_utilities.helpful_functions.gcd(*numbers)[source]

Greatest common divisor of 1 or more integers.

GIGO: If any of the values are anything except positive int values this function will either produce incorrect results or raise an exception.

Parameters:

numbers – The positive integers to get the GCD for. This can be one or more int values or a singleton which is an iterator (not empty) of ints.

Returns:

the GCD

Return type:

int

Raises:
  • TypeError – If any value cannot be interpreted as an integer or if no values are provided

  • ZeroDivisionError – May be raised if one of the values is zero

spinn_utilities.helpful_functions.is_singleton(value)[source]

Tests whether the value is a singleton.

Singleton types are strings and any other class that can not be iterated.

Strings are considered singleton as only rarely will someone use a string to represent an iterable of characters.

spinn_utilities.helpful_functions.lcm(*numbers)[source]

Lowest common multiple of 0, 1 or more integers.

GIGO: If any of the values are anything except positive int values this function will either produce incorrect results or raise an exception.

Parameters:

numbers – The Positive integers to get the LCM for. This can be zero, one or more int values or a singleton which is an iterator (possibly empty) of ints.

Returns:

the LCM, or 1 if numbers is empty or an empty iterator

Return type:

int

Raises:
spinn_utilities.index_is_value module
class spinn_utilities.index_is_value.IndexIsValue[source]

Bases: object

Tiny support class that implements object[x] by just returning x itself.

Used for where you want a range from 1 to N but you don’t know N.

Clearly, operations that assume a finite list are not supported.

spinn_utilities.log module
class spinn_utilities.log.ConfiguredFilter(conf)[source]

Bases: object

Allow a parent logger to filter a child logger.

filter(record)[source]

Get the level for the deepest parent, and filter appropriately.

class spinn_utilities.log.ConfiguredFormatter(conf)[source]

Bases: Formatter

Defines the logging format for the SpiNNaker host software.

Initialize the formatter with specified format strings.

Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.

Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting, str.format() ({}) formatting or string.Template formatting in your format string.

Changed in version 3.2: Added the style parameter.

static construct_logging_parents(conf)[source]

Create a dictionary of module names and logging levels.

static deepest_parent(parents, child)[source]

Greediest match between child and parent.

static level_of_deepest_parent(parents, child)[source]

The logging level of the greediest match between child and parent.

class spinn_utilities.log.FormatAdapter(logger, extra=None)[source]

Bases: LoggerAdapter

An adaptor for logging with messages that uses Python format strings.

Example:

log = FormatAdapter(logging.getLogger(__name__))
log.info("this message has {} inside {}", 123, 'itself')
# --> INFO: this message has 123 inside itself

Initialize the adapter with a logger and a dict-like object which provides contextual information. This constructor signature allows easy stacking of LoggerAdapters, if so desired.

You can effectively pass keyword arguments as shown in the following example:

adapter = LoggerAdapter(someLogger, dict(p1=v1, p2=”v2”))

classmethod atexit_handler()[source]
log(level, msg, *args, **kwargs)[source]

Delegate a log call to the underlying logger, applying appropriate transformations to allow the log message to be written using Python format string, rather than via %-substitutions.

process(msg, kwargs)[source]

Process the logging message and keyword arguments passed in to a logging call to insert contextual information. You can either manipulate the message itself, the keyword arguments or both. Return the message and kwargs modified (or not) to suit your needs.

classmethod set_kill_level(level=None)[source]

Allow system to change the level at which a log is changed to an Exception.

Note

This is a static method; it affects all log messages.

Parameters:

level (int) – The level to set. The values in logging are recommended.

classmethod set_log_store(log_store)[source]
exception spinn_utilities.log.LogLevelTooHighException[source]

Bases: Exception

An Exception throw when the System tries to log at a level where an Exception is a better option.

spinn_utilities.log_store module
class spinn_utilities.log_store.LogStore[source]

Bases: object

API supported by classes that can store logs for later retrieval.

abstract get_location()[source]

Retrieves the location of the log store.

Return type:

str

abstract retreive_log_messages(min_level=0)[source]

Retrieves all log messages at or above the min_level.

Parameters:

min_level (int) – Constraint on the minimum logging level to retrieve.

Returns:

A list of messages that satisfy the constraint.

Return type:

list(tuple(int, str))

abstract store_log(level, message, timestamp=None)[source]

Writes the log message for later retrieval.

Parameters:
  • level (int) – The logging level.

  • message (str) – The logged message.

  • timestamp (datetime or None) – The time-stamp of the message.

spinn_utilities.logger_utils module
spinn_utilities.logger_utils.error_once(logger, msg)[source]

Write an error message to the given logger where that message should only be written to the logger once.

Parameters:
  • logger – The logger to write to.

  • msg

    The message to write.

    Note

    This must be a substitution-free message.

spinn_utilities.logger_utils.reset()[source]

Clear the store of what messages have already been seen.

Note

Only normally needed by test code.

spinn_utilities.logger_utils.warn_once(logger, msg)[source]

Write a warning message to the given logger where that message should only be written to the logger once.

Parameters:
  • logger – The logger to write to.

  • msg

    The message to write.

    Note

    This must be a substitution-free message.

spinn_utilities.ordered_set module
class spinn_utilities.ordered_set.OrderedSet(iterable=None)[source]

Bases: MutableSet

add(value)[source]

Add an element.

discard(value)[source]

Remove an element. Do not raise an exception if absent.

peek(last=True)[source]
pop(last=True)[source]

Return the popped value. Raise KeyError if empty.

update(iterable)[source]
spinn_utilities.overrides module
class spinn_utilities.overrides.overrides(super_class_method, extend_doc=True, additional_arguments=None, extend_defaults=False)[source]

Bases: object

A decorator for indicating that a method overrides another method in a superclass. This checks that the method does actually exist, copies the doc-string for the method, and enforces that the method overridden is specified, making maintenance easier.

Parameters:
  • super_class_method – The method to override in the superclass

  • extend_doc (bool) – True the method doc string should be appended to the super-method doc string, False if the documentation should be set to the super-method doc string only if there isn’t a doc string already

  • additional_arguments (iterable(str)) – Additional arguments taken by the subclass method over the superclass method, e.g., that are to be injected

  • extend_defaults (bool) – Whether the subclass may specify extra defaults for the parameters

__call__(method)[source]

Apply the decorator to the given method.

spinn_utilities.package_loader module
spinn_utilities.package_loader.all_modules(directory, prefix, remove_pyc_files=False)[source]

List all the python files found in this directory giving then the prefix.

Any file that ends in either .py or .pyc is assume a python module and added to the result set.

Parameters:
  • directory (str) – path to check for python files

  • prefix (str) – package prefix top add to the file name

Returns:

set of python package names

Return type:

set(str)

spinn_utilities.package_loader.load_module(name, remove_pyc_files=False, exclusions=None, gather_errors=True)[source]

Loads this modules and all its children.

Parameters:
  • name (str) – name of the modules

  • remove_pyc_files (bool) – True if .pyc files should be deleted

  • exclusions (list(str)) – a list of modules to exclude

  • gather_errors (bool) – True if errors should be gathered, False to report on first error

Returns:

None

spinn_utilities.package_loader.load_modules(directory, prefix, remove_pyc_files=False, exclusions=None, gather_errors=True)[source]

Loads all the python files found in this directory, giving them the specified prefix.

Any file that ends in either .py or .pyc is assume a python module and added to the result set.

Parameters:
  • directory (str) – path to check for python files

  • prefix (str) – package prefix top add to the file name

  • remove_pyc_files (bool) – True if .pyc files should be deleted

  • exclusions (list(str)) – a list of modules to exclude

  • gather_errors (bool) – True if errors should be gathered, False to report on first error

Returns:

None

spinn_utilities.ping module
class spinn_utilities.ping.Ping[source]

Bases: object

Platform-independent ping support.

static host_is_reachable(ip_address)[source]

Test if a host is unreachable via ICMP ECHO.

Note

This information may be cached in various ways. Transient failures are not necessarily detected or recovered from.

Parameters:

ip_address (str) – The IP address to ping. Hostnames can be used, but are not recommended.

Return type:

bool

static ping(ip_address)[source]

Send a ping (ICMP ECHO request) to the given host. SpiNNaker boards support ICMP ECHO when booted.

Parameters:

ip_address (str) – The IP address to ping. Hostnames can be used, but are not recommended.

Returns:

return code of subprocess; 0 for success, anything else for failure

Return type:

int

unreachable = {}

The unreachable host cache.

spinn_utilities.progress_bar module
class spinn_utilities.progress_bar.DummyProgressBar(*args, **kwargs)[source]

Bases: ProgressBar

This is a dummy version of the progress bar that just stubs out the internal printing operations with code that does nothing. It otherwise fails in exactly the same way.

class spinn_utilities.progress_bar.ProgressBar(*args, **kwargs)[source]

Bases: object

Progress bar for telling the user where a task is up to.

MAX_LENGTH_IN_CHARS = 60
TOO_MANY_ERROR = 'Too many update steps in progress bar! This may be a sign that something else has gone wrong!'
end()[source]

Close the progress bar, updating whatever is left if needed.

over(collection, finish_at_end=True)[source]

Simple wrapper for the cases where the progress bar is being used to show progress through the iteration over a single collection. The progress bar should have been initialised to the size of the collection being iterated over.

Parameters:
  • collection (Iterable) – The base collection (any iterable) being iterated over

  • finish_at_end (bool) – Flag to say if the bar should finish at the end of the collection

Returns:

An iterable. Expected to be directly used in a for.

Return type:

Iterable

update(amount_to_add=1)[source]

Update the progress bar by a given amount.

Parameters:

amount_to_add

spinn_utilities.require_subclass module
spinn_utilities.require_subclass.require_subclass(required_class)[source]

Decorator that arranges for subclasses of the decorated class to require that they are also subclasses of the given class.

Usage example:

@require_subclass(AbstractVertex)
class AbstractVirtual(object):
    ...
Parameters:

required_class (type) – The class that the subclass of the decorated class must be an instance of (if that subclass is concrete).

spinn_utilities.safe_eval module
class spinn_utilities.safe_eval.SafeEval(*args, **kwargs)[source]

Bases: object

This provides expression evaluation capabilities while allowing the set of symbols exposed to the expression to be strictly controlled.

Sample of use:

>>> import math
>>> def evil_func(x):
...    print("HAHA!")
...    return x/0.0
...
>>> eval_safely = SafeEval(math)
>>> eval_safely.eval("math.sqrt(x)", x=1.23)
1.1090536506409416
>>> eval_safely.eval("evil_func(1.23)")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../safe_eval.py", line 62, in eval
    return eval(expression, self._environment, kwargs)
  File "<string>", line 1, in <module>
NameError: name 'evil_func' is not defined

Warning

This is not guaranteed to be safe under all circumstances. It is not designed to be a fully secured interface; it just discourages abuse.

Parameters:
  • args

    The symbols to use to populate the global reference table.

    Note

    All of these symbols must support the __name__ property, but that includes any function, method of an object, or module. If you want to make an object available by anything other than its inherent name, define it in the eval() call.

  • kwargs – Define the symbols with explicit names. Needed because some symbols (e.g., constants in numpy) do not have names that we can otherwise look up easily.

eval(expression, **kwargs)[source]

Evaluate an expression and return the result.

Parameters:
  • expression (str) – The expression to evaluate

  • kwargs – The extra symbol bindings to use for this evaluation. This is useful for passing in particular parameters to an individual evaluation run.

Returns:

The expression result, the type of which will depend on the expression itself and the operations exposed to it.

spinn_utilities.see module
class spinn_utilities.see.see(documentation_method, extend_doc=True, additional_arguments=None, extend_defaults=False)[source]

Bases: overrides

A decorator for indicating that the documentation of the method is provided by another method with exactly the same arguments.

Note

This has the same effect as overrides in reality, but is provided to show that the method doesn’t actually override.

Parameters:
  • documentation_method – The other method to reference.

  • extend_doc (bool) – True the method doc string should be appended to the other method’s doc string, False if the documentation should be set to the other method’s doc string only if there isn’t a doc string already

  • additional_arguments (iterable(str)) – Additional arguments taken by the decorated method over the referenced method, e.g., that are to be injected

  • extend_defaults (bool) – Whether the decorated method may specify extra defaults for the parameters

spinn_utilities.socket_address module
class spinn_utilities.socket_address.SocketAddress(notify_host_name=None, notify_port_no=None, listen_port=None)[source]

Bases: object

Data holder for a socket interface for notification protocol.

Parameters:
  • notify_host_name (str or None) – Host to talk to tell that the database (and application) is ready.

  • notify_port_no (int or None) – Port to talk to tell that the database (and application) is ready.

  • listen_port (int or None) – Port on which to listen for an acknowledgement that the simulation should start.

property listen_port

The port to listen to for responses.

property notify_host_name

The host name or IP address to send a notification message to.

property notify_port_no

The UDP port number to send a notification message to.

spinn_utilities.timer module
class spinn_utilities.timer.Timer[source]

Bases: object

A timer used for performance measurements.

Recommended usage:

with Timer() as timer:
    ... do stuff that takes time ...

elapsed_time = timer.measured_interval

or alternatively:

timer = Timer()
timer.start_timing()
... do stuff that takes time ...
elapsed_time = timer.take_sample()

Mixing these two styles is not recommended.

property measured_interval

Get how long elapsed during the measured section.

Return type:

datetime.timedelta

start_timing()[source]

Start the timing. Use take_sample() to get the end.

take_sample()[source]

Describes how long has elapsed since the instance that the start_timing() method was last called.

Return type:

datetime.timedelta

Module contents

Indices and tables

SpiNNUtils_github

SpiNNUtils_individual_docs

SpiNNMachine

This package is used to provide a Python representation of a SpiNNaker machine. This contains the basic model of SpiNNaker hardware, as required by the other packages described below.

SpiNNMachine

An abstraction of a SpiNNaker Machine. The main functionality is provided by spinn_machine.Machine.

Functional Requirements

  • Create a machine which represents the current state of a machine, in terms of the available chips, cores on the chips, SDRAM available, routable links between chips and available routing entries.

  • Create a machine which represents an abstract ideal machine.

    • There can only be one chip in the machine with given x, y coordinates

    • There can only be one processor in each chip with a given processor ID

    • There can only be one link in the router of each chip with a given ID

  • Add a chip to a given machine to represent an external device.

    • A chip with the same x, y coordinates must not already exist in the machine

  • Add a link to a router of a given chip to represent a connection to an external device.

    • A link with the given ID must not already exist in the chip

  • Create a representation of a multicast routing entry to be shared between modules that deal with routing entries.

Use Cases

  • Machine is returned as a representation of the current state of a machine.

  • virtual_machine() is used to make an outline of a machine on which a simulation will be run, e.g., for placement of executables and/or finding routes between placed executables.

  • Machine is extended to add a virtual Chip on the machine representing an external peripheral connected to the machine directly via a link from a chip, so that routes can be directed to and from the external peripheral.

  • MulticastRoutingEntry is returned in a list of entries, which indicate the current set of routing entries within a multicast routing table on a chip on the machine.

  • MulticastRoutingEntry is sent in a list of routing entries to set up routing on a chip on the machine.

class spinn_machine.Chip(x, y, n_processors, router, sdram, nearest_ethernet_x, nearest_ethernet_y, ip_address=None, tag_ids=None, down_cores=None, parent_link=None, v_to_p_map=None)[source]

Represents a SpiNNaker chip with a number of cores, an amount of SDRAM shared between the cores, and a router. The chip is iterable over the processors, yielding (processor_id, processor) where:

  • processor_id is the ID of a processor

  • processor is the Processor with processor_id

Parameters:
  • x (int) – the x-coordinate of the chip’s position in the two-dimensional grid of chips

  • y (int) – the y-coordinate of the chip’s position in the two-dimensional grid of chips

  • n_processors (int) – the number of processors including monitor processors.

  • router (Router) – a router for the chip

  • sdram (SDRAM) – an SDRAM for the chip

  • ip_address (str or None) – the IP address of the chip, or None if no Ethernet attached

  • tag_ids (iterable(int) or None) – IDs to identify the chip for SDP can be empty to define no tags or None to allocate tag automatically based on if there is an ip_address

  • nearest_ethernet_x (int or None) – the nearest Ethernet x coordinate

  • nearest_ethernet_y (int or None) – the nearest Ethernet y coordinate

  • down_cores (iterable(int) or None) – Ids of cores that are down for this Chip

  • parent_link (int or None) – The link down which the parent chips is found in the tree of chips towards the root (boot) chip

  • v_to_p_map (bytearray or None) – An array indexed by virtual core which gives the physical core number or 0xFF if no entry for the core

Raises:

SpinnMachineAlreadyExistsException – If processors contains any two processors with the same processor_id

get_first_none_monitor_processor()[source]

Get the first processor in the list which is not a monitor core.

Return type:

Processor or None

get_physical_core_id(virtual_p)[source]

Get the physical core ID from a virtual core ID.

Parameters:

virtual_p (int) – The virtual core ID

Return type:

int or None if core not in map

get_physical_core_string(virtual_p)[source]

Get a string that can be appended to a core to show the physical core, or an empty string if not possible.

Parameters:

virtual_p (int) – The virtual core ID

Return type:

str

get_processor_with_id(processor_id)[source]

Return the processor with the specified ID, or None if the processor does not exist.

Parameters:

processor_id (int) – the ID of the processor to return

Returns:

the processor with the specified ID, or None if no such processor

Return type:

Processor or None

property ip_address

The IP address of the chip, or None if there is no Ethernet connected to the chip.

Return type:

str or None

is_processor_with_id(processor_id)[source]

Determines if a processor with the given ID exists in the chip. Also implemented as __contains__(processor_id)

Parameters:

processor_id (int) – the processor ID to check for

Returns:

Whether the processor with the given ID exists

Return type:

bool

property n_processors

The total number of processors.

Return type:

int

property n_user_processors

The total number of processors that are not monitors.

Return type:

int

property nearest_ethernet_x

The X-coordinate of the nearest Ethernet chip.

Return type:

int

property nearest_ethernet_y

The Y-coordinate of the nearest Ethernet chip.

Return type:

int

property parent_link

The link down which the parent is found in the tree of chips rooted at the machine root chip (probably 0, 0 in most cases). This will be None if the chip information didn’t contain this value.

Return type:

int or None

property processors

An iterable of available processors.

Return type:

iterable(Processor)

property router

The router object associated with the chip.

Return type:

Router

property sdram

The SDRAM associated with the chip.

Return type:

SDRAM

property tag_ids

The tag IDs supported by this chip.

Return type:

iterable(int)

property x

The X-coordinate of the chip in the two-dimensional grid of chips.

Return type:

int

property y

The Y-coordinate of the chip in the two-dimensional grid of chips.

Return type:

int

class spinn_machine.CoreSubset(x, y, processor_ids)[source]

Represents a subset of the cores on a SpiNNaker chip.

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

  • y (int) – The y-coordinate of the chip

  • processor_ids (iterable(int)) – The processor IDs on the chip

add_processor(processor_id)[source]

Adds a processor ID to this subset

Parameters:

processor_id (int) – A processor ID

intersect(other)[source]

Returns a new CoreSubset which is an intersect of this and the other.

Parameters:

other (CoreSubset) – A second CoreSubset with possibly overlapping cores

Returns:

A new CoreSubset with any overlap

Return type:

CoreSubset

property processor_ids

The processor IDs on the chip that in the subset.

Return type:

iterable(int)

property x

The X-coordinate of the chip

Return type:

int

property y

The Y-coordinate of the chip

Return type:

int

class spinn_machine.CoreSubsets(core_subsets=None)[source]

Represents a group of CoreSubsets, with a maximum of one per SpiNNaker chip.

Parameters:

core_subsets (iterable(CoreSubset)) – The cores for each desired chip

add_core_subset(core_subset)[source]

Add a core subset to the set

Parameters:

core_subset (CoreSubset) – The core subset to add

add_core_subsets(core_subsets)[source]

Merges a core subsets into this one.

Parameters:

core_subsets (iterable(CoreSubset)) – the core subsets to add

add_processor(x, y, processor_id)[source]

Add a processor on a given chip to the set.

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

  • y (int) – The y-coordinate of the chip

  • processor_id (int) – A processor ID

property core_subsets

The one-per-chip subsets.

Returns:

Iterable of core subsets

Return type:

iterable(CoreSubset)

get_core_subset_for_chip(x, y)[source]

Get the core subset for a chip.

Parameters:
  • x (int) – The x-coordinate of a chip

  • y (int) – The y-coordinate of a chip

Returns:

The core subset of a chip, which will be empty if not added

Return type:

CoreSubset

intersect(other)[source]

Returns a new CoreSubsets which is an intersect of this and the other.

Parameters:

other (CoreSubsets) – A second CoreSubsets with possibly overlapping cores

Returns:

A new CoreSubsets with any overlap

Return type:

CoreSubsets

is_chip(x, y)[source]

Determine if the chip with coordinates (x, y) is in the subset

Parameters:
  • x (int) – The x-coordinate of a chip

  • y (int) – The y-coordinate of a chip

Returns:

True if the chip with coordinates (x, y) is in the subset

Return type:

bool

is_core(x, y, processor_id)[source]

Determine if there is a chip with coordinates (x, y) in the subset, which has a core with the given ID in the subset

Parameters:
  • x (int) – The x-coordinate of a chip

  • y (int) – The y-coordinate of a chip

  • processor_id (int) – The ID of a core

Returns:

Whether there is a chip with coordinates (x, y) in the subset, which has a core with the given ID in the subset

Return type:

bool

values()[source]
Return type:

iterable(CoreSubset)

class spinn_machine.FixedRouteEntry(processor_ids, link_ids)[source]

Describes the sole entry in a SpiNNaker chip’s fixed route routing table. There is only one fixed route entry per chip.

Parameters:
  • processor_ids (iterable(int)) –

  • link_ids (iterable(int)) –

property link_ids

The destination link IDs.

Return type:

frozenset(int)

property processor_ids

The destination processor IDs.

Return type:

frozenset(int)

class spinn_machine.Link(source_x, source_y, source_link_id, destination_x, destination_y)[source]

Represents a directional link between SpiNNaker chips in the machine.

Parameters:
  • source_x (int) – The x-coordinate of the source chip of the link

  • source_y (int) – The y-coordinate of the source chip of the link

  • source_link_id (int) – The ID of the link in the source chip

  • destination_x (int) – The x-coordinate of the destination chip of the link

  • destination_y (int) – The y-coordinate of the destination chip of the link

property destination_x

The X-coordinate of the destination chip of this link.

Return type:

int

property destination_y

The Y-coordinate of the destination chip of this link.

Return type:

int

property source_link_id

The ID of the link on the source chip.

Return type:

int

property source_x

The X-coordinate of the source chip of this link.

Return type:

int

property source_y

The Y-coordinate of the source chip of this link.

Return type:

int

class spinn_machine.Machine(width, height, chips=None, origin=None)[source]

A representation of a SpiNNaker Machine with a number of Chips. Machine is also iterable, providing ((x, y), chip) where:

  • x is the x-coordinate of a chip,

  • y is the y-coordinate of a chip,

  • chip is the chip with the given (x, y) coordinates.

Use machine_from_chips() and machine_from_size() to determine the correct machine class.

Parameters:
  • width (int) – The width of the machine excluding

  • height (int) – The height of the machine

  • chips (iterable(Chip)) – An iterable of chips in the machine

  • origin (str) – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json

Raises:

SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

add_chip(chip)[source]

Add a chip to the machine.

Parameters:

chip (Chip) – The chip to add to the machine

Raises:

SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates already exists

add_chips(chips)[source]

Add some chips to the machine.

Parameters:

chips (iterable(Chip)) – an iterable of chips

Raises:

SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates as one being added already exists

add_fpga_links()[source]

Add FPGA links that are on a given machine depending on the version of the board.

add_spinnaker_links()[source]

Add SpiNNaker links that are on a given machine depending on the version of the board.

property boot_chip

The chip used to boot the machine.

Return type:

Chip

property chip_coordinates

An iterable of chip coordinates in the machine.

Return type:

iterable(tuple(int,int))

property chips

An iterable of chips in the machine.

Return type:

iterable(Chip)

abstract concentric_xys(radius, start)[source]

A generator that produces coordinates for concentric rings of possible chips based on the links of the chips.

No check is done to see if the chip exists. This may even produce coordinates with negative numbers

Mostly copied from: https://github.com/project-rig/rig/blob/master/rig/geometry.py

Parameters:
  • radius (int) – The radius of rings to produce (0 = start only)

  • start (tuple(int,int)) – The start coordinate

Return type:

tuple(int,int)

cores_and_link_output_string()[source]

Get a string detailing the number of cores and links.

Return type:

str

property ethernet_connected_chips

The chips in the machine that have an Ethernet connection.

Return type:

iterable(Chip)

get_chip_at(x, y)[source]

Get the chip at a specific (x, y) location. Also implemented as __getitem__((x, y))

Parameters:
  • x (int) – the x-coordinate of the requested chip

  • y (int) – the y-coordinate of the requested chip

Returns:

the chip at the specified location, or None if no such chip

Return type:

Chip or None

get_chips_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the actual chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the chips on this board.

Return type:

iterable(Chip)

get_cores_and_link_count()[source]

Get the number of cores and links from the machine.

Links are assumed to be bidirectional so the total links counted is half of the unidirectional links found.

SpiNNaker and FPGA links are not included.

Returns:

tuple of (n_cores, n_links)

Return type:

tuple(int,int)

abstract get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this Ethernet-enabled chip.

Note

The Ethernet chip itself can not be missing if validated.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) of the down chips on this board.

Return type:

iterable(tuple(int,int))

abstract get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x,y)s of chips on this board.

Return type:

iterable(tuple(int,int))

get_existing_xys_on_board(chip)[source]

Get the chips that are on the same board as the given chip.

Parameters:

chip – The chip to find other chips on the same board as

Returns:

An iterable of (x, y) coordinates of chips on the same board

Return type:

iterable(tuple(int,int))

get_fpga_link_with_id(fpga_id, fpga_link_id, board_address=None, chip_coords=None)[source]

Get an FPGA link data item that corresponds to the FPGA and FPGA link for a given board address.

Parameters:
  • fpga_id (int) – the ID of the FPGA that the data is going through. Refer to technical document located here for more detail: https://drive.google.com/file/d/0B9312BuJXntlVWowQlJ3RE8wWVE

  • fpga_link_id (int) – the link ID of the FPGA. Refer to technical document located here for more detail: https://drive.google.com/file/d/0B9312BuJXntlVWowQlJ3RE8wWVE

  • board_address (str or None) – optional board address that this FPGA link is associated with. This is ignored if chip_coords is not None. If this is None and chip_coords is None, the boot board will be assumed.

  • chip_coords (tuple(int, int) or None) – optional chip coordinates that this FPGA link is associated with. If this is None and board_address is None, the boot board will be assumed.

Returns:

the given FPGA link object or None if no such link

Return type:

FPGALinkData

abstract get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local (X, Y) coordinates into global (x,y) coordinates, under the assumption that they are on the board with local (0,0) at global coordinates (ethernet_x, ethernet_y).

This method does take wrap-arounds into consideration.

Warning

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global (x,y)

Parameters:
  • local_x (int) – A valid local x coordinate for a chip

  • local_y (int) – A valid local y coordinate for a chip

  • ethernet_x (int) – The global Ethernet-enabled chip X coordinate for the board the chip is on

  • ethernet_y (int) – The global Ethernet-enabled chip Y coordinate for the board the chip is on

Returns:

global (x,y) coordinates of the chip

Return type:

tuple(int,int)

abstract get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the Ethernet-enabled chip was at position 0,0.

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:

chip (Chip) – A Chip in the machine

Returns:

Local (x, y) coordinates.

Return type:

tuple(int,int)

get_spinnaker_link_with_id(spinnaker_link_id, board_address=None, chip_coords=None)[source]

Get a SpiNNaker link with a given ID.

Parameters:
  • spinnaker_link_id (int) – The ID of the link

  • board_address (str or None) – optional board address that this SpiNNaker link is associated with. This is ignored if chip_coords is not None. If this is None and chip_coords is None, the boot board will be assumed.

  • chip_coords (tuple(int, int) or None) – optional chip coordinates that this SpiNNaker link is associated with. If this is None and board_address is None, the boot board will be assumed.

Returns:

The SpiNNaker link data or None if no link

Return type:

SpinnakerLinkData

get_unused_xy()[source]

Finds an unused (x,y) coordinate on this machine.

This method will not return an (x,y) of an existing chip

This method will not return an (x,y) on any existing board even if that chip does not exist, i.e., it will not return (x,y) of a known dead chip.

It will however return the same unused_xy until a chip is added at that location.

Returns:

an unused (x,y) coordinate

Return type:

(int, int)

abstract get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination.

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The vector

abstract get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination.

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minimisation) the vectors can have any of the 4 combinations of positive and negative x and y The positive one is: destination - source % dimension The negative one is: positive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the positive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)). As the z direction can be used in minimisation The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are already minimum so z is not used.

Warning

GIGO: This method does not check if input parameters make sense.

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The distance in steps

Return type:

int

abstract get_xy_cores_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential (x,y) locations and the typical number of cores of all the chips on the board with this Ethernet-enabled chip.

Includes the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists, nor report the actual number of cores on this chip, as is intended to be called to create the chips.

The number of cores is based on the 1,000,000 core machine where the board where built with the the 17 core chips placed in the same location on nearly every board.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields (x, y, n_cores) where x , y are coordinates of all the potential chips on this board, and n_cores is the typical number of cores for a chip in that position.

Return type:

iterable(tuple(int,int))

abstract get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

Return type:

iterable(tuple(int,int))

property height

The height of the machine, in chips.

Return type:

int

is_chip_at(x, y)[source]

Determine if a chip exists at the given coordinates. Also implemented as __contains__((x, y))

Parameters:
  • x (int) – x location of the chip to test for existence

  • y (int) – y location of the chip to test for existence

Returns:

True if the chip exists, False otherwise

Return type:

bool

is_link_at(x, y, link)[source]

Determine if a link exists at the given coordinates.

Parameters:
  • x (int) – The x location of the chip to test the link of

  • y (int) – The y location of the chip to test the link of

  • link (int) – The link to test the existence of

property local_xys

Provides a list of local (x,y) coordinates for a perfect board on this machine.

Local (x,y)s never include wrap-arounds.

Note

No check is done to see if any board in the machine actually has a chip with this local (x, y).

Return type:

iterable(tuple(int,int))

static max_cores_per_chip()[source]

Gets the max core per chip for the while system.

There is no guarantee that there will be any Chips with this many cores, only that there will be no cores with more.

Returns:

the default cores per chip unless overridden by set

abstract multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one Ethernet-enabled chip.

Returns:

True if this machine can have multiple 48 chip boards

Return type:

bool

property n_chips

The number of chips in the machine.

Return type:

int

one_way_links()[source]
Return type:

iterable(tuple(int,int,int))

static set_max_cores_per_chip(new_max)[source]

Allows setting the max number of cores per chip for the whole system.

Allows virtual machines to go higher than normal.

Real machines can only be capped never increased beyond what they actually have.

Parameters:

new_max (int) – New value to use for the max

Raises:

SpinnMachineException – if max_cores_per_chip has already been used and is now being changed. This exception also happens if the value is set twice to different values. For example in the script and in the configuration file.

property spinnaker_links

The set of SpiNNaker links in the machine.

Return type:

iterable(tuple(tuple(str,int), SpinnakerLinkData))

property total_available_user_cores

The total number of cores on the machine which are not monitor cores.

Return type:

int

property total_cores

The total number of cores on the machine, including monitors.

Return type:

int

unreachable_incoming_chips()[source]

Detects chips that are not reachable from any of their neighbours.

Current implementation does not deal with group of unreachable chips.

Returns:

List (hopefully empty) if the (x,y) coordinates of unreachable chips.

Return type:

list(tuple(int,int))

unreachable_incoming_local_chips()[source]

Detects chips that are not reachable from any of their local neighbours.

Current implementation does not deal with group of unreachable chips.

Returns:

List (hopefully empty) if the (x,y) coordinates of unreachable chips.

Return type:

list(tuple(int,int))

unreachable_outgoing_chips()[source]

Detects chips that can not reach any of their neighbours.

Current implementation does not deal with group of unreachable chips.

Returns:

List (hopefully empty) if the (x,y) coordinates of unreachable chips.

Return type:

list(tuple(int,int))

unreachable_outgoing_local_chips()[source]

Detects chips that can not reach any of their local neighbours.

Current implementation does not deal with group of unreachable chips.

Returns:

List (hopefully empty) if the (x,y) coordinates of unreachable chips.

Return type:

list(tuple(int,int))

validate()[source]

Validates the machine and raises an exception in unexpected conditions.

Assumes that at the time this is called all chips are on the board.

This allows the checks to be avoided when creating a virtual machine (Except of course in testing)

Raises:

SpinnMachineException

  • An Error is raised if there is a chip with a x outside of the range 0 to width -1.

  • An Error is raised if there is a chip with a y outside of the range 0 to height -1.

  • An Error is raise if there is no chip at the declared Ethernet-enabled chip x and y.

  • An Error is raised if an Ethernet-enabled chip is not at a local 0,0.

  • An Error is raised if there is no Ethernet-enabled chip is at 0,0.

  • An Error is raised if this is a unexpected multiple board situation.

where_is_chip(chip)[source]

Returns global and local location for this chip.

This method assumes that chip is on the machine or is a copy of a chip on the machine.

Parameters:

chip (Chip) – A Chip in the machine

Returns:

A human-readable description of the location of a chip.

Return type:

str

where_is_xy(x, y)[source]

Returns global and local location for this chip.

Parameters:
  • x (int) – X coordinate

  • y (int) – Y coordinate

Returns:

A human-readable description of the location of a chip.

Return type:

str

property width

The width of the machine, in chips.

Return type:

int

abstract property wrap

A short string representing the type of wrap.

Return type:

str

abstract xy_over_link(x, y, link)[source]

Get the potential (x,y) location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note

This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning

GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates (x,y) values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x (int) – The x coordinate of a chip that will exist on the machine

  • y (int) – The y coordinate of a chip that will exist on the machine

  • link (int) – The link to another chip that could exist on the machine

Returns:

x and y coordinates of the chip over that link if it is valid or some fictional (x,y) if not.

Return type:

tuple(int,int)

class spinn_machine.MulticastRoutingEntry(routing_entry_key, mask, processor_ids=None, link_ids=None, defaultable=False, spinnaker_route=None)[source]

Represents an entry in a SpiNNaker chip’s multicast routing table. There can be up to 1024 such entries per chip, but some may be reserved for system purposes.

Note

The processor_ids and link_ids parameters are only optional if a spinnaker_route is provided. If a spinnaker_route is provided the processor_ids and link_ids parameters are ignored.

Parameters:
  • routing_entry_key (int) – The routing key_combo

  • mask (int) – The route key_combo mask

  • processor_ids (iterable(int) or None) – The destination processor IDs

  • link_ids (iterable(int) or None) – The destination link IDs

  • defaultable (bool) – If this entry is defaultable (it receives packets from its directly opposite route position)

  • spinnaker_route (int or None) – The processor_ids and link_ids expressed as a single int.

Raises:
property defaultable

Whether this entry is a defaultable entry. An entry is defaultable if it is duplicating the default behaviour of the SpiNNaker router (to pass a message out on the link opposite from where it was received, without routing it to any processors; source and destination chips for a message cannot be defaultable).

Return type:

bool

property link_ids

The destination link IDs.

Return type:

frozenset(int)

property mask

The routing mask.

Return type:

int

merge(other_entry)[source]

Merges together two multicast routing entries. The entry to merge must have the same key and mask. The merge will join the processor IDs and link IDs from both the entries. This could be used to add a new destination to an existing route in a routing table. It is also possible to use the add (+) operator or the or (|) operator with the same effect.

Parameters:

other_entry (MulticastRoutingEntry) – The multicast entry to merge with this entry

Returns:

A new multicast routing entry with merged destinations

Return type:

MulticastRoutingEntry

Raises:

spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the key and mask of the other entry do not match

property processor_ids

The destination processor IDs.

Return type:

frozenset(int)

property routing_entry_key

The routing key.

Return type:

int

property spinnaker_route

The encoded SpiNNaker route.

Return type:

int

class spinn_machine.Processor(processor_id, clock_speed=200000000, is_monitor=False, dtcm_available=65536)[source]

A processor object included in a SpiNNaker chip.

Parameters:
  • processor_id (int) – ID of the processor in the chip

  • clock_speed (int) – The number of CPU cycles per second of the processor

  • is_monitor (bool) – Determines if the processor is considered the monitor processor, and so should not be otherwise allocated

  • dtcm_available (int) – Data Tightly Coupled Memory available

Raises:

spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the clock speed is negative

property clock_speed

The clock speed of the processor in cycles per second.

Return type:

int

property cpu_cycles_available

The number of CPU cycles available from this processor per ms.

Return type:

int

property dtcm_available

The amount of DTCM available on this processor.

Return type:

int

property is_monitor

Determines if the processor is the monitor, and therefore not to be allocated.

Warning

Currently rejection processors are also marked as monitors.

Return type:

bool

property processor_id

The ID of the processor.

Return type:

int

class spinn_machine.Router(links, emergency_routing_enabled=False, n_available_multicast_entries=1023)[source]

Represents a router of a chip, with a set of available links. The router is iterable over the links, providing (source_link_id, link) where:

  • source_link_id is the ID of a link

  • link is the Link with ID source_link_id

Parameters:
  • links (iterable(Link)) – iterable of links

  • emergency_routing_enabled (bool) – Determines if the router emergency routing is operating

  • n_available_multicast_entries (int) – The number of entries available in the routing table

Raises:

SpinnMachineAlreadyExistsException – If any two links have the same source_link_id

add_link(link)[source]

Add a link to the router of the chip.

Parameters:

link (Link) – The link to be added

Raises:

SpinnMachineAlreadyExistsException – If another link already exists with the same source_link_id

static convert_routing_table_entry_to_spinnaker_route(routing_table_entry)[source]

Convert a routing table entry represented in software to a binary routing table entry usable on the machine.

Parameters:

routing_table_entry (MulticastRoutingEntry or FixedRouteEntry) – The entry to convert

Return type:

int

static convert_spinnaker_route_to_routing_ids(route)[source]

Convert a binary routing table entry usable on the machine to lists of route IDs usable in a routing table entry represented in software.

Parameters:

route (int) – The routing table entry

Returns:

The list of processor IDs, and the list of link IDs.

Return type:

tuple(list(int), list(int))

property emergency_routing_enabled

Whether emergency routing is enabled.

Return type:

bool

get_link(source_link_id)[source]

Get the link with the given ID, or None if no such link. Also implemented as __getitem__(source_link_id)

Parameters:

source_link_id (int) – The ID of the link to find

Returns:

The link, or None if no such link

Return type:

Link or None

get_neighbouring_chips_coords()[source]

Utility method to convert links into x and y coordinates.

Returns:

iterable list of destination coordinates in x and y dict

Return type:

iterable(dict(str,int))

is_link(source_link_id)[source]

Determine if there is a link with ID source_link_id. Also implemented as __contains__(source_link_id)

Parameters:

source_link_id (int) – The ID of the link to find

Returns:

True if there is a link with the given ID, False otherwise

Return type:

bool

property links

The available links of this router.

Return type:

iterable(Link)

property n_available_multicast_entries

The number of available multicast entries in the routing tables.

Return type:

int

static opposite(link_id)[source]

Given a valid link_id this method returns its opposite.

GIGO: this method assumes the input is valid. No verification is done

Parameters:

link_id (int) – A valid link_id

Returns:

The link_id for the opposite direction

Return type:

int

class spinn_machine.SpiNNakerTriadGeometry(triad_width, triad_height, roots, centre)[source]

Geometry of a “triad” of SpiNNaker boards.

The geometry is defined by the arguments to the constructor; the standard arrangement can be obtained from get_spinn5_geometry.

Note

The geometry defines what a Triad is in terms of the dimensions of a triad and where the Ethernet chips occur in the triad.

Parameters:
  • triad_width (int) – width of a triad in chips

  • triad_height (int) – height of a triad in chips

  • roots (list(tuple(int, int))) – locations of the Ethernet connected chips

  • centre (tuple(float, float)) – the distance from each Ethernet chip to the centre of the hexagon

get_ethernet_chip_coordinates(x, y, width, height, root_x=0, root_y=0)[source]

Get the coordinates of a chip’s local Ethernet connected chip according to this triad geometry object.

Warning

local_eth_coord() will always produce the coordinates of the Ethernet-connected SpiNNaker chip on the same SpiNN-5 board as the supplied chip. This chip may not actually be working.

Parameters:
  • x (int) – x-coordinate of the chip to find the nearest Ethernet of

  • y (int) – y-coordinate of the chip to find the nearest Ethernet of

  • width (int) – width of the SpiNNaker machine (must be a multiple of the triad width of this geometry)

  • height (int) – height of the SpiNNaker machine (must be a multiple of the triad height of this geometry)

  • root_x (int) – x-coordinate of the boot chip (default 0, 0)

  • root_y (int) – y-coordinate of the boot chip (default 0, 0)

Returns:

The coordinates of the closest Ethernet chip

Return type:

(int, int)

get_local_chip_coordinate(x, y, root_x=0, root_y=0)[source]

Get the coordinates of a chip on its board of a multi-board system relative to the Ethernet chip of the board.

Note

This function assumes the system is constructed from SpiNN-5 boards

Parameters:
  • x (int) – The x-coordinate of the chip to find the location of

  • y (int) – The y-coordinate of the chip to find the location of

  • root_x (int) – The x-coordinate of the boot chip (default 0, 0)

  • root_y (int) – The y-coordinate of the boot chip (default 0, 0)

Returns:

the coordinates of the chip relative to its board

Return type:

(int, int)

get_potential_ethernet_chips(width, height)[source]

Get the coordinates of chips that should be Ethernet chips

Parameters:
  • width (int) – The width of the machine to find the chips in

  • height (int) – The height of the machine to find the chips in

Return type:

list(tuple(int, int))

static get_spinn5_geometry()[source]

Get the geometry object for a SpiNN-5 arrangement of boards

Returns:

a SpiNNakerTriadGeometry object.

spinn_machine.machine_from_chips(chips)[source]

Create a machine with the assumed wrap-around based on the sizes.

The size of the machine is calculated from the list of chips.

Parameters:

chips (list(Chip)) – Full list of all chips on this machine. Or at least a list which includes a chip with the highest X and one with the highest Y (excluding any virtual chips)

Returns:

A subclass of Machine

Return type:

Machine

spinn_machine.machine_from_size(width, height, chips=None, origin=None)[source]

Create a machine with the assumed wrap-around based on the sizes.

This could include a machine with no wrap-arounds, only vertical ones, only horizontal ones or both.

Note

If the sizes do not match the ones for a known wrap-around machine, a machine with no wrap-arounds is assumed.

Parameters:
  • width (int) – The width of the machine excluding any virtual chips

  • height (int) – The height of the machine excluding any virtual chips

  • chips (list(Chip) or None) – Any chips to be added.

  • origin (str or None) – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json

Returns:

A subclass of Machine

Return type:

Machine

spinn_machine.virtual_machine(width, height, n_cpus_per_chip=None, validate=True)[source]

Create a virtual SpiNNaker machine, used for planning execution.

Parameters:
  • width (int) – the width of the virtual machine in chips

  • height (int) – the height of the virtual machine in chips

  • n_cpus_per_chip (int) – The number of CPUs to put on each chip

  • validate (bool) – if True will call the machine validate function

Returns:

a virtual machine (that cannot execute code)

Return type:

Machine

Contents

spinn_machine
spinn_machine package
Subpackages
spinn_machine.data package
Submodules
spinn_machine.data.machine_data_writer module
class spinn_machine.data.machine_data_writer.MachineDataWriter(state)[source]

Bases: UtilsDataWriter, MachineDataView

See UtilsDataWriter.

This class is designed to only be used directly within the SpiNNMachine repository unit tests as all methods are available to subclasses.

Parameters:

state (DataStatus) – State writer should be in

clear_machine()[source]

Clears any previously set machine.

Warning

Designed to only be used by ASB to remove a max machine before allocating an actual one. Any other use is not supported. Will be removed without notice if max_machine is no longer done.

get_user_accessed_machine()[source]

Reports if …View.get_machine has been called outside of sim.run.

Designed to only be used from ASB. Any other use is not supported

set_machine(machine)[source]

Sets the machine.

Parameters:

machine (Machine) –

Raises:

TypeError – it the machine is not a Machine

set_machine_generator(machine_generator)[source]

Registers a function that can be called to give a machine.

Parameters:

machine_generator (function) –

Module contents
class spinn_machine.data.MachineDataView[source]

Bases: UtilsDataView

Adds the extra Methods to the View for Machine level.

See UtilsDataView for a more detailed description.

This class is designed to only be used directly within the SpiNNMachine repository as all methods are available to subclasses

classmethod get_chip_at(x, y)[source]

Gets the chip at (x, y).

Almost Semantic sugar for get_machine().get_chip_at()

The method however does not return None but rather raises a KeyError if the chip is not known

Parameters:
Return type:

Chip

Raises:
classmethod get_machine()[source]

Returns the Machine if it has been set.

In Mock mode will create and return a virtual 8 * 8 board

Raises:

SpiNNUtilsException – If the machine is currently unavailable

Return type:

Machine

classmethod get_nearest_ethernet(x, y)[source]

Gets the nearest Ethernet-enabled chip (x, y) for the chip at (x, y) if it exists.

If there is no machine or no chip at (x, y) this method, or any other issue will just return (x, y)

Note

This method will never request a new machine. Therefore a call to this method will not trigger a hard reset

Parameters:
  • x (int) – Chip X coordinate

  • y (int) – Chip Y coordinate

Returns:

Chip (x,`y`)’s nearest_ethernet info or if that is not available just (x, y)

Return type:

tuple(int, int)

classmethod has_machine()[source]

Reports if a machine is currently set or can be mocked.

Return type:

bool

classmethod where_is_chip(chip)[source]

Gets a string saying where chip is if possible.

Almost Semantic sugar for get_machine().where_is_chip()

The method does not raise an exception rather returns a String of the exception

Note

This method will never request a new machine. Therefore a call to this method will not trigger a hard reset

Parameters:
Return type:

str

classmethod where_is_xy(x, y)[source]

Gets a string saying where chip at x and y is if possible.

Almost Semantic sugar for get_machine().where_is_xy()

The method does not raise an exception rather returns a String of the exception

Note

This method will never request a new machine. Therefore a call to this method will not trigger a hard reset

Parameters:
Return type:

str

spinn_machine.ignores package
Module contents
class spinn_machine.ignores.IgnoreChip(x, y, ip_address=None)[source]

Bases: object

Represents a chip to be ignored when building a machine. This is typically because it has a fault in the SpiNNaker router.

Parameters:
  • x (int or str) – X coordinate of a Chip to ignore

  • y (int or str) – Y coordinate of a Chip to ignore

  • ip_address (str or None) – Optional IP address which, if provided, make x and y local coordinates

ip_address

IP address of the board with the chip; if not None, the coordinates are local to that board

static parse_single_string(downed_chip)[source]

Converts a string into an IgnoreChip object.

The supported format is:

<down_chip_id> = <chip_x>,<chip_y>[,<ip>]

where:

  • <chip_x> is the x-coordinate of a down chip

  • <chip_x> is the y-coordinate of a down chip

  • <ip> is an optional IP address in the 127.0.0.0 format. If provided, the <chip_x>,<chip_y> will be considered local to the board with this IP address.

Two examples:

4,7
6,5,10.11.12.13
Parameters:

downed_chip (str) – representation of one chip to ignore

Returns:

An IgnoreChip Object

Return type:

IgnoreChip

static parse_string(downed_chips)[source]

Converts a string into a (possibly empty) set of IgnoreChip objects.

format is:

down_chips = <down_chip_id>[:<down_chip_id]*
<down_chip_id> = <chip_x>,<chip_y>[,<ip>]

where:

  • <chip_x> is the x-coordinate of a down chip

  • <chip_y> is the y-coordinate of a down chip

  • <ip> is an optional* IP address in the 127.0.0.0 format. If provided, the <chip_x>,<chip_y> will be considered local to the board with this IP address.

The string None (case-insensitive) is used to represent no ignores

An example:

4,7:6,5,10.11.12.13
Parameters:

downed_chips (str) – representation of zero or chips to ignore

Returns:

Set (possibly empty) of IgnoreChips

Return type:

set(IgnoreChip)

x

X coordinate of the chip to ignore

y

Y coordinate of the chip to ignore

class spinn_machine.ignores.IgnoreCore(x, y, p, ip_address=None)[source]

Bases: object

Represents a core to be ignored when building a machine.

Parameters:
  • x (int or str) – X coordinate of a core to ignore

  • y (int or str) – Y coordinate of a core to ignore

  • p (int or str) – The virtual core ID of a core if > 0, or the physical core if <= 0 (actual value will be negated)

  • ip_address (str or None) – Optional IP address which, if provided, make x and y local coordinates

ip_address

IP address of the board with the chip; if not None, the coordinates are local to that board

p

Core ID of the processor to ignore (virtual if positive, physical if negative)

static parse_cores(core_string)[source]

Parses the “core” part of a string, which might be a single core, or otherwise is a range of cores

Parameters:

str – A string to parse

Returns:

A list of cores, which might be just one

Return type:

list(int)

static parse_single_string(downed_core)[source]

Converts a string into an IgnoreCore object.

The format is:

<down_core_id> = <chip_x>,<chip_y>,(<core_id>|<core_range>)[,<ip>]
<core_range> = <core_id>-<core_id>

where:

  • <chip_x> is the x-coordinate of a down chip

  • <chip_x> is the y-coordinate of a down chip

  • <core_id> is the virtual core ID of a core if > 0, or the physical core if <= 0 (actual value will be negated)

  • <ip> is an optional IP address in the 127.0.0.0 format. If provided, the <chip_x>,<chip_y> will be considered local to the board with this IP address

Two examples:

4,7,3
6,5,-2,10.11.12.13
Parameters:

downed_core (str) – representation of one chip to ignore

Returns:

A list of IgnoreCore objects

Return type:

list(IgnoreCore)

static parse_string(downed_cores)[source]

Converts a string into a (possibly empty) set of IgnoreCore objects.

The format is:

down_cores = <down_core_id>[:<down_core_id]* <down_core_id> = <chip_x>,<chip_y>,(<core_id>|<core_range>)[,<ip>] <core_range> = <core_id>-<core_id>

where:

  • <chip_x> is the x-coordinate of a down chip

  • <chip_x> is the y-coordinate of a down chip

  • <core_id> is the virtual core ID of a core if > 0, or the physical core if <= 0 (actual value will be negated)

  • <ip> is an optional IP address in the 127.0.0.0 format. If provided, the <chip_x>,<chip_y> will be considered local to the board with this IP address.

The string None (case insensitive) is used to represent no ignores

An example:

4,7,3:6,5,-2,10.11.12.13,2,3,2-17
Parameters:

downed_cores (str) – representation of zero or chips to ignore

Returns:

Set (possibly empty) of IgnoreCores

Return type:

set(IgnoreCore)

property virtual_p

The virtual processor ID.

When the processor is given as a physical processor, this is converted to a virtual core ID using the typical virtual/physical core map; the mapping in a real machine may be different!

x

X coordinate of the chip with the processor to ignore

y

Y coordinate of the chip with the processor to ignore

Bases: object

Represents a link that should be ignored when building a machine.

Parameters:
  • x (int or str) – X coordinate of a chip with a link to ignore

  • y (int or str) – Y coordinate of a chip with a link to ignore

  • link (int or str) – ID of the link to ignore

  • ip_address (str or None) – Optional IP address which, if provided, makes x and y be local coordinates

ip_address

IP address of the board with the chip; if not None, the coordinates are local to that board

Link ID to ignore

static parse_single_string(downed_link)[source]

Converts a string into an IgnoreLink object.

The format is:

<down_link> = <chip_x>,<chip_y>,<link_id>[,<ip>]

where:

  • <chip_x> is the x-coordinate of a down chip

  • <chip_x> is the y-coordinate of a down chip

  • <link_id> is the link ID

  • <ip> is an optional IP address in the 127.0.0.0 format. If provided, the <chip_x>,<chip_y> will be considered local to the board with this IP address.

Parameters:

downed_link (str) – representation of one link to ignore

Returns:

An IgnoreLink object

Return type:

IgnoreLink

static parse_string(downed_links)[source]

Converts a string into a (possibly empty) set of IgnoreLink objects

The format is:

down_links = <down_link_id>[:<down_link_id]*
<down_link_id> = <chip_x>,<chip_y>,<link_id>[,<ip>]

where:

  • <chip_x> is the x-coordinate of a down chip

  • <chip_x> is the y-coordinate of a down chip

  • <link_id> is the link ID

  • <ip> is an optional IP address in the 127.0.0.0 format. If provided, the <chip_x>,<chip_y> will be considered local to the board with this IP address

The string None (case insensitive) is used to represent no ignores

Parameters:

downed_cores (str) – representation of zero or chips to ignore

Returns:

Set (possibly empty) of IgnoreLinks

Return type:

set(IgnoreLink)

x

X coordinate of the chip with the link to ignore

y

Y coordinate of the chip with the link to ignore

spinn_machine.tags package
Module contents
class spinn_machine.tags.AbstractTag(board_address, tag, port)[source]

Bases: object

Common properties of SpiNNaker IP tags and reverse IP tags.

property board_address

The board address of the tag.

property port

The port of the tag.

property tag

The tag ID of the tag.

class spinn_machine.tags.IPTag(board_address, destination_x, destination_y, tag, ip_address, port=None, strip_sdp=False, traffic_identifier='DEFAULT')[source]

Bases: AbstractTag

Used to hold data that is contained within an IP tag.

Parameters:
  • board_address (str or None) – The IP address of the board on which the tag is allocated

  • destination_x (int) – The x-coordinate where users of this tag should send packets to

  • destination_y (int) – The y-coordinate where users of this tag should send packets to

  • tag (int) – The tag of the SDP packet

  • ip_address (str) – The IP address to which SDP packets with the tag will be sent

  • port (int or None) – The port to which the SDP packets with the tag will be sent, or None if not yet assigned

  • strip_sdp (bool) – Indicates whether the SDP header should be removed

  • traffic_identifier (str) – The identifier for traffic transmitted using this tag

property destination_x

The X-coordinate where users of this tag should send packets to.

property destination_y

The Y-coordinate where users of this tag should send packets to.

property ip_address

The IP address to which SDP packets with this tag will be sent.

property strip_sdp

Whether the SDP header is to be stripped.

property traffic_identifier

The identifier of traffic using this tag.

class spinn_machine.tags.ReverseIPTag(board_address, tag, port, destination_x, destination_y, destination_p, sdp_port=1)[source]

Bases: AbstractTag

Used to hold data that is contained within a Reverse IP tag.

Parameters:
  • board_address (str or None) – The IP address of the board on which the tag is allocated

  • tag (int) – The tag of the SDP packet

  • port (int) – The UDP port on which SpiNNaker will listen for packets

  • destination_x (int) – The x-coordinate of the chip to send packets to

  • destination_y (int) – The y-coordinate of the chip to send packets to

  • destination_p (int) – The ID of the processor to send packets to

  • sdp_port (int) – The optional port number to use for SDP packets that are formed on the machine (default is 1)

property destination_p

The destination processor ID for the chip at (x,y) that packets should be send to for this reverse IP tag.

property destination_x

The destination x coordinate of a chip in the SpiNNaker machine that packets should be sent to for this reverse IP tag.

property destination_y

The destination y coordinate of a chip in the SpiNNaker machine that packets should be sent to for this reverse IP tag.

property sdp_port

The SDP port number of the tag that these packets are to be received on for the processor.

Submodules
spinn_machine.config_setup module
spinn_machine.config_setup.add_spinn_machine_cfg()[source]

Add the local configuration and all dependent configuration files.

spinn_machine.config_setup.unittest_setup()[source]

Resets the configurations so only the local default configuration is included.

Note

This file should only be called from SpiNNMachine/unittests

spinn_machine.exceptions module
exception spinn_machine.exceptions.SpinnMachineAlreadyExistsException(item, value)[source]

Bases: SpinnMachineException

Indicates that something already exists of which there can only be one.

Parameters:
  • item (str) – The item of which there is already one of

  • value (str) – The value of the item

property item

The item of which there is already one.

property value

The value of the item.

exception spinn_machine.exceptions.SpinnMachineException[source]

Bases: Exception

A generic exception which all other exceptions in this package extend.

exception spinn_machine.exceptions.SpinnMachineInvalidParameterException(parameter, value, problem)[source]

Bases: SpinnMachineException

Indicates that there is a problem with a parameter value.

Parameters:
  • parameter (str) – The name of the parameter that has an invalid value

  • value (str) – The value of the parameter that is invalid

  • problem (str) – The reason for the exception

property parameter

The name of the parameter.

property problem

The problem with the setting of the parameter.

property value

The value of the parameter.

spinn_machine.full_wrap_machine module
class spinn_machine.full_wrap_machine.FullWrapMachine(width, height, chips=None, origin=None)[source]

Bases: Machine

Parameters:
  • width (int) – The width of the machine excluding

  • height (int) – The height of the machine

  • chips (iterable(Chip)) – An iterable of chips in the machine

  • origin (str) – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json

Raises:

SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

concentric_xys(radius, start)[source]

A generator that produces coordinates for concentric rings of possible chips based on the links of the chips.

No check is done to see if the chip exists. This may even produce coordinates with negative numbers

Mostly copied from: https://github.com/project-rig/rig/blob/master/rig/geometry.py

Parameters:
  • radius (int) – The radius of rings to produce (0 = start only)

  • start (tuple(int,int)) – The start coordinate

Return type:

tuple(int,int)

get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this Ethernet-enabled chip.

Note

The Ethernet chip itself can not be missing if validated.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) of the down chips on this board.

Return type:

iterable(tuple(int,int))

get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x,y)s of chips on this board.

Return type:

iterable(tuple(int,int))

get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local (X, Y) coordinates into global (x,y) coordinates, under the assumption that they are on the board with local (0,0) at global coordinates (ethernet_x, ethernet_y).

This method does take wrap-arounds into consideration.

Warning

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global (x,y)

Parameters:
  • local_x (int) – A valid local x coordinate for a chip

  • local_y (int) – A valid local y coordinate for a chip

  • ethernet_x (int) – The global Ethernet-enabled chip X coordinate for the board the chip is on

  • ethernet_y (int) – The global Ethernet-enabled chip Y coordinate for the board the chip is on

Returns:

global (x,y) coordinates of the chip

Return type:

tuple(int,int)

get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the Ethernet-enabled chip was at position 0,0.

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:

chip (Chip) – A Chip in the machine

Returns:

Local (x, y) coordinates.

Return type:

tuple(int,int)

get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination.

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The vector

get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination.

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minimisation) the vectors can have any of the 4 combinations of positive and negative x and y The positive one is: destination - source % dimension The negative one is: positive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the positive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)). As the z direction can be used in minimisation The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are already minimum so z is not used.

Warning

GIGO: This method does not check if input parameters make sense.

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The distance in steps

Return type:

int

get_xy_cores_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential (x,y) locations and the typical number of cores of all the chips on the board with this Ethernet-enabled chip.

Includes the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists, nor report the actual number of cores on this chip, as is intended to be called to create the chips.

The number of cores is based on the 1,000,000 core machine where the board where built with the the 17 core chips placed in the same location on nearly every board.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields (x, y, n_cores) where x , y are coordinates of all the potential chips on this board, and n_cores is the typical number of cores for a chip in that position.

Return type:

iterable(tuple(int,int))

get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

Return type:

iterable(tuple(int,int))

multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one Ethernet-enabled chip.

Returns:

True if this machine can have multiple 48 chip boards

Return type:

bool

property wrap

A short string representing the type of wrap.

Return type:

str

Get the potential (x,y) location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note

This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning

GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates (x,y) values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x (int) – The x coordinate of a chip that will exist on the machine

  • y (int) – The y coordinate of a chip that will exist on the machine

  • link (int) – The link to another chip that could exist on the machine

Returns:

x and y coordinates of the chip over that link if it is valid or some fictional (x,y) if not.

Return type:

tuple(int,int)

spinn_machine.horizontal_wrap_machine module
class spinn_machine.horizontal_wrap_machine.HorizontalWrapMachine(width, height, chips=None, origin=None)[source]

Bases: Machine

Parameters:
  • width (int) – The width of the machine excluding

  • height (int) – The height of the machine

  • chips (iterable(Chip)) – An iterable of chips in the machine

  • origin (str) – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json

Raises:

SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

concentric_xys(radius, start)[source]

A generator that produces coordinates for concentric rings of possible chips based on the links of the chips.

No check is done to see if the chip exists. This may even produce coordinates with negative numbers

Mostly copied from: https://github.com/project-rig/rig/blob/master/rig/geometry.py

Parameters:
  • radius (int) – The radius of rings to produce (0 = start only)

  • start (tuple(int,int)) – The start coordinate

Return type:

tuple(int,int)

get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this Ethernet-enabled chip.

Note

The Ethernet chip itself can not be missing if validated.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) of the down chips on this board.

Return type:

iterable(tuple(int,int))

get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x,y)s of chips on this board.

Return type:

iterable(tuple(int,int))

get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local (X, Y) coordinates into global (x,y) coordinates, under the assumption that they are on the board with local (0,0) at global coordinates (ethernet_x, ethernet_y).

This method does take wrap-arounds into consideration.

Warning

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global (x,y)

Parameters:
  • local_x (int) – A valid local x coordinate for a chip

  • local_y (int) – A valid local y coordinate for a chip

  • ethernet_x (int) – The global Ethernet-enabled chip X coordinate for the board the chip is on

  • ethernet_y (int) – The global Ethernet-enabled chip Y coordinate for the board the chip is on

Returns:

global (x,y) coordinates of the chip

Return type:

tuple(int,int)

get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the Ethernet-enabled chip was at position 0,0.

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:

chip (Chip) – A Chip in the machine

Returns:

Local (x, y) coordinates.

Return type:

tuple(int,int)

get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination.

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The vector

get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination.

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minimisation) the vectors can have any of the 4 combinations of positive and negative x and y The positive one is: destination - source % dimension The negative one is: positive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the positive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)). As the z direction can be used in minimisation The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are already minimum so z is not used.

Warning

GIGO: This method does not check if input parameters make sense.

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The distance in steps

Return type:

int

get_xy_cores_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential (x,y) locations and the typical number of cores of all the chips on the board with this Ethernet-enabled chip.

Includes the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists, nor report the actual number of cores on this chip, as is intended to be called to create the chips.

The number of cores is based on the 1,000,000 core machine where the board where built with the the 17 core chips placed in the same location on nearly every board.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields (x, y, n_cores) where x , y are coordinates of all the potential chips on this board, and n_cores is the typical number of cores for a chip in that position.

Return type:

iterable(tuple(int,int))

get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

Return type:

iterable(tuple(int,int))

multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one Ethernet-enabled chip.

Returns:

True if this machine can have multiple 48 chip boards

Return type:

bool

property wrap

A short string representing the type of wrap.

Return type:

str

Get the potential (x,y) location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note

This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning

GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates (x,y) values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x (int) – The x coordinate of a chip that will exist on the machine

  • y (int) – The y coordinate of a chip that will exist on the machine

  • link (int) – The link to another chip that could exist on the machine

Returns:

x and y coordinates of the chip over that link if it is valid or some fictional (x,y) if not.

Return type:

tuple(int,int)

spinn_machine.json_machine module
spinn_machine.json_machine.machine_from_json(j_machine)[source]

Generate a model of a machine from a JSON description of that machine.

Parameters:

j_machine (dict in format returned by json.load or a str representing a path to the JSON file) – JSON description of the machine

Returns:

The machine model.

Return type:

Machine

spinn_machine.json_machine.to_json()[source]

Runs the code to write the machine in Java readable JSON.

Return type:

dict

spinn_machine.json_machine.to_json_path(file_path)[source]

Runs the code to write the machine in Java readable JSON.

Parameters:

file_path (str) – Location to write file to. Warning will overwrite!

Return type:

None

spinn_machine.no_wrap_machine module
class spinn_machine.no_wrap_machine.NoWrapMachine(width, height, chips=None, origin=None)[source]

Bases: Machine

Parameters:
  • width (int) – The width of the machine excluding

  • height (int) – The height of the machine

  • chips (iterable(Chip)) – An iterable of chips in the machine

  • origin (str) – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json

Raises:

SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

concentric_xys(radius, start)[source]

A generator that produces coordinates for concentric rings of possible chips based on the links of the chips.

No check is done to see if the chip exists. This may even produce coordinates with negative numbers

Mostly copied from: https://github.com/project-rig/rig/blob/master/rig/geometry.py

Parameters:
  • radius (int) – The radius of rings to produce (0 = start only)

  • start (tuple(int,int)) – The start coordinate

Return type:

tuple(int,int)

get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this Ethernet-enabled chip.

Note

The Ethernet chip itself can not be missing if validated.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) of the down chips on this board.

Return type:

iterable(tuple(int,int))

get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x,y)s of chips on this board.

Return type:

iterable(tuple(int,int))

get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local (X, Y) coordinates into global (x,y) coordinates, under the assumption that they are on the board with local (0,0) at global coordinates (ethernet_x, ethernet_y).

This method does take wrap-arounds into consideration.

Warning

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global (x,y)

Parameters:
  • local_x (int) – A valid local x coordinate for a chip

  • local_y (int) – A valid local y coordinate for a chip

  • ethernet_x (int) – The global Ethernet-enabled chip X coordinate for the board the chip is on

  • ethernet_y (int) – The global Ethernet-enabled chip Y coordinate for the board the chip is on

Returns:

global (x,y) coordinates of the chip

Return type:

tuple(int,int)

get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the Ethernet-enabled chip was at position 0,0.

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:

chip (Chip) – A Chip in the machine

Returns:

Local (x, y) coordinates.

Return type:

tuple(int,int)

get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination.

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The vector

get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination.

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minimisation) the vectors can have any of the 4 combinations of positive and negative x and y The positive one is: destination - source % dimension The negative one is: positive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the positive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)). As the z direction can be used in minimisation The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are already minimum so z is not used.

Warning

GIGO: This method does not check if input parameters make sense.

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The distance in steps

Return type:

int

get_xy_cores_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential (x,y) locations and the typical number of cores of all the chips on the board with this Ethernet-enabled chip.

Includes the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists, nor report the actual number of cores on this chip, as is intended to be called to create the chips.

The number of cores is based on the 1,000,000 core machine where the board where built with the the 17 core chips placed in the same location on nearly every board.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields (x, y, n_cores) where x , y are coordinates of all the potential chips on this board, and n_cores is the typical number of cores for a chip in that position.

Return type:

iterable(tuple(int,int))

get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

Return type:

iterable(tuple(int,int))

multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one Ethernet-enabled chip.

Returns:

True if this machine can have multiple 48 chip boards

Return type:

bool

property wrap

A short string representing the type of wrap.

Return type:

str

Get the potential (x,y) location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note

This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning

GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates (x,y) values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x (int) – The x coordinate of a chip that will exist on the machine

  • y (int) – The y coordinate of a chip that will exist on the machine

  • link (int) – The link to another chip that could exist on the machine

Returns:

x and y coordinates of the chip over that link if it is valid or some fictional (x,y) if not.

Return type:

tuple(int,int)

spinn_machine.vertical_wrap_machine module
class spinn_machine.vertical_wrap_machine.VerticalWrapMachine(width, height, chips=None, origin=None)[source]

Bases: Machine

Parameters:
  • width (int) – The width of the machine excluding

  • height (int) – The height of the machine

  • chips (iterable(Chip)) – An iterable of chips in the machine

  • origin (str) – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json

Raises:

SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

concentric_xys(radius, start)[source]

A generator that produces coordinates for concentric rings of possible chips based on the links of the chips.

No check is done to see if the chip exists. This may even produce coordinates with negative numbers

Mostly copied from: https://github.com/project-rig/rig/blob/master/rig/geometry.py

Parameters:
  • radius (int) – The radius of rings to produce (0 = start only)

  • start (tuple(int,int)) – The start coordinate

Return type:

tuple(int,int)

get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this Ethernet-enabled chip.

Note

The Ethernet chip itself can not be missing if validated.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) of the down chips on this board.

Return type:

iterable(tuple(int,int))

get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x,y)s of chips on this board.

Return type:

iterable(tuple(int,int))

get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local (X, Y) coordinates into global (x,y) coordinates, under the assumption that they are on the board with local (0,0) at global coordinates (ethernet_x, ethernet_y).

This method does take wrap-arounds into consideration.

Warning

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global (x,y)

Parameters:
  • local_x (int) – A valid local x coordinate for a chip

  • local_y (int) – A valid local y coordinate for a chip

  • ethernet_x (int) – The global Ethernet-enabled chip X coordinate for the board the chip is on

  • ethernet_y (int) – The global Ethernet-enabled chip Y coordinate for the board the chip is on

Returns:

global (x,y) coordinates of the chip

Return type:

tuple(int,int)

get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the Ethernet-enabled chip was at position 0,0.

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:

chip (Chip) – A Chip in the machine

Returns:

Local (x, y) coordinates.

Return type:

tuple(int,int)

get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination.

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The vector

get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination.

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minimisation) the vectors can have any of the 4 combinations of positive and negative x and y The positive one is: destination - source % dimension The negative one is: positive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the positive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)). As the z direction can be used in minimisation The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are already minimum so z is not used.

Warning

GIGO: This method does not check if input parameters make sense.

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The distance in steps

Return type:

int

get_xy_cores_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential (x,y) locations and the typical number of cores of all the chips on the board with this Ethernet-enabled chip.

Includes the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists, nor report the actual number of cores on this chip, as is intended to be called to create the chips.

The number of cores is based on the 1,000,000 core machine where the board where built with the the 17 core chips placed in the same location on nearly every board.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields (x, y, n_cores) where x , y are coordinates of all the potential chips on this board, and n_cores is the typical number of cores for a chip in that position.

Return type:

iterable(tuple(int,int))

get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

Return type:

iterable(tuple(int,int))

multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one Ethernet-enabled chip.

Returns:

True if this machine can have multiple 48 chip boards

Return type:

bool

property wrap

A short string representing the type of wrap.

Return type:

str

Get the potential (x,y) location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note

This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning

GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates (x,y) values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x (int) – The x coordinate of a chip that will exist on the machine

  • y (int) – The y coordinate of a chip that will exist on the machine

  • link (int) – The link to another chip that could exist on the machine

Returns:

x and y coordinates of the chip over that link if it is valid or some fictional (x,y) if not.

Return type:

tuple(int,int)

Module contents

An abstraction of a SpiNNaker Machine. The main functionality is provided by spinn_machine.Machine.

Functional Requirements
  • Create a machine which represents the current state of a machine, in terms of the available chips, cores on the chips, SDRAM available, routable links between chips and available routing entries.

  • Create a machine which represents an abstract ideal machine.

    • There can only be one chip in the machine with given x, y coordinates

    • There can only be one processor in each chip with a given processor ID

    • There can only be one link in the router of each chip with a given ID

  • Add a chip to a given machine to represent an external device.

    • A chip with the same x, y coordinates must not already exist in the machine

  • Add a link to a router of a given chip to represent a connection to an external device.

    • A link with the given ID must not already exist in the chip

  • Create a representation of a multicast routing entry to be shared between modules that deal with routing entries.

Use Cases
  • Machine is returned as a representation of the current state of a machine.

  • virtual_machine() is used to make an outline of a machine on which a simulation will be run, e.g., for placement of executables and/or finding routes between placed executables.

  • Machine is extended to add a virtual Chip on the machine representing an external peripheral connected to the machine directly via a link from a chip, so that routes can be directed to and from the external peripheral.

  • MulticastRoutingEntry is returned in a list of entries, which indicate the current set of routing entries within a multicast routing table on a chip on the machine.

  • MulticastRoutingEntry is sent in a list of routing entries to set up routing on a chip on the machine.

class spinn_machine.Chip(x, y, n_processors, router, sdram, nearest_ethernet_x, nearest_ethernet_y, ip_address=None, tag_ids=None, down_cores=None, parent_link=None, v_to_p_map=None)[source]

Bases: object

Represents a SpiNNaker chip with a number of cores, an amount of SDRAM shared between the cores, and a router. The chip is iterable over the processors, yielding (processor_id, processor) where:

  • processor_id is the ID of a processor

  • processor is the Processor with processor_id

Parameters:
  • x (int) – the x-coordinate of the chip’s position in the two-dimensional grid of chips

  • y (int) – the y-coordinate of the chip’s position in the two-dimensional grid of chips

  • n_processors (int) – the number of processors including monitor processors.

  • router (Router) – a router for the chip

  • sdram (SDRAM) – an SDRAM for the chip

  • ip_address (str or None) – the IP address of the chip, or None if no Ethernet attached

  • tag_ids (iterable(int) or None) – IDs to identify the chip for SDP can be empty to define no tags or None to allocate tag automatically based on if there is an ip_address

  • nearest_ethernet_x (int or None) – the nearest Ethernet x coordinate

  • nearest_ethernet_y (int or None) – the nearest Ethernet y coordinate

  • down_cores (iterable(int) or None) – Ids of cores that are down for this Chip

  • parent_link (int or None) – The link down which the parent chips is found in the tree of chips towards the root (boot) chip

  • v_to_p_map (bytearray or None) – An array indexed by virtual core which gives the physical core number or 0xFF if no entry for the core

Raises:

SpinnMachineAlreadyExistsException – If processors contains any two processors with the same processor_id

get_first_none_monitor_processor()[source]

Get the first processor in the list which is not a monitor core.

Return type:

Processor or None

get_physical_core_id(virtual_p)[source]

Get the physical core ID from a virtual core ID.

Parameters:

virtual_p (int) – The virtual core ID

Return type:

int or None if core not in map

get_physical_core_string(virtual_p)[source]

Get a string that can be appended to a core to show the physical core, or an empty string if not possible.

Parameters:

virtual_p (int) – The virtual core ID

Return type:

str

get_processor_with_id(processor_id)[source]

Return the processor with the specified ID, or None if the processor does not exist.

Parameters:

processor_id (int) – the ID of the processor to return

Returns:

the processor with the specified ID, or None if no such processor

Return type:

Processor or None

property ip_address

The IP address of the chip, or None if there is no Ethernet connected to the chip.

Return type:

str or None

is_processor_with_id(processor_id)[source]

Determines if a processor with the given ID exists in the chip. Also implemented as __contains__(processor_id)

Parameters:

processor_id (int) – the processor ID to check for

Returns:

Whether the processor with the given ID exists

Return type:

bool

property n_processors

The total number of processors.

Return type:

int

property n_user_processors

The total number of processors that are not monitors.

Return type:

int

property nearest_ethernet_x

The X-coordinate of the nearest Ethernet chip.

Return type:

int

property nearest_ethernet_y

The Y-coordinate of the nearest Ethernet chip.

Return type:

int

The link down which the parent is found in the tree of chips rooted at the machine root chip (probably 0, 0 in most cases). This will be None if the chip information didn’t contain this value.

Return type:

int or None

property processors

An iterable of available processors.

Return type:

iterable(Processor)

property router

The router object associated with the chip.

Return type:

Router

property sdram

The SDRAM associated with the chip.

Return type:

SDRAM

property tag_ids

The tag IDs supported by this chip.

Return type:

iterable(int)

property x

The X-coordinate of the chip in the two-dimensional grid of chips.

Return type:

int

property y

The Y-coordinate of the chip in the two-dimensional grid of chips.

Return type:

int

class spinn_machine.CoreSubset(x, y, processor_ids)[source]

Bases: object

Represents a subset of the cores on a SpiNNaker chip.

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

  • y (int) – The y-coordinate of the chip

  • processor_ids (iterable(int)) – The processor IDs on the chip

add_processor(processor_id)[source]

Adds a processor ID to this subset

Parameters:

processor_id (int) – A processor ID

intersect(other)[source]

Returns a new CoreSubset which is an intersect of this and the other.

Parameters:

other (CoreSubset) – A second CoreSubset with possibly overlapping cores

Returns:

A new CoreSubset with any overlap

Return type:

CoreSubset

property processor_ids

The processor IDs on the chip that in the subset.

Return type:

iterable(int)

property x

The X-coordinate of the chip

Return type:

int

property y

The Y-coordinate of the chip

Return type:

int

class spinn_machine.CoreSubsets(core_subsets=None)[source]

Bases: object

Represents a group of CoreSubsets, with a maximum of one per SpiNNaker chip.

Parameters:

core_subsets (iterable(CoreSubset)) – The cores for each desired chip

add_core_subset(core_subset)[source]

Add a core subset to the set

Parameters:

core_subset (CoreSubset) – The core subset to add

add_core_subsets(core_subsets)[source]

Merges a core subsets into this one.

Parameters:

core_subsets (iterable(CoreSubset)) – the core subsets to add

add_processor(x, y, processor_id)[source]

Add a processor on a given chip to the set.

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

  • y (int) – The y-coordinate of the chip

  • processor_id (int) – A processor ID

property core_subsets

The one-per-chip subsets.

Returns:

Iterable of core subsets

Return type:

iterable(CoreSubset)

get_core_subset_for_chip(x, y)[source]

Get the core subset for a chip.

Parameters:
  • x (int) – The x-coordinate of a chip

  • y (int) – The y-coordinate of a chip

Returns:

The core subset of a chip, which will be empty if not added

Return type:

CoreSubset

intersect(other)[source]

Returns a new CoreSubsets which is an intersect of this and the other.

Parameters:

other (CoreSubsets) – A second CoreSubsets with possibly overlapping cores

Returns:

A new CoreSubsets with any overlap

Return type:

CoreSubsets

is_chip(x, y)[source]

Determine if the chip with coordinates (x, y) is in the subset

Parameters:
  • x (int) – The x-coordinate of a chip

  • y (int) – The y-coordinate of a chip

Returns:

True if the chip with coordinates (x, y) is in the subset

Return type:

bool

is_core(x, y, processor_id)[source]

Determine if there is a chip with coordinates (x, y) in the subset, which has a core with the given ID in the subset

Parameters:
  • x (int) – The x-coordinate of a chip

  • y (int) – The y-coordinate of a chip

  • processor_id (int) – The ID of a core

Returns:

Whether there is a chip with coordinates (x, y) in the subset, which has a core with the given ID in the subset

Return type:

bool

values()[source]
Return type:

iterable(CoreSubset)

class spinn_machine.FixedRouteEntry(processor_ids, link_ids)[source]

Bases: object

Describes the sole entry in a SpiNNaker chip’s fixed route routing table. There is only one fixed route entry per chip.

Parameters:
  • processor_ids (iterable(int)) –

  • link_ids (iterable(int)) –

The destination link IDs.

Return type:

frozenset(int)

property processor_ids

The destination processor IDs.

Return type:

frozenset(int)

Bases: object

Represents a directional link between SpiNNaker chips in the machine.

Parameters:
  • source_x (int) – The x-coordinate of the source chip of the link

  • source_y (int) – The y-coordinate of the source chip of the link

  • source_link_id (int) – The ID of the link in the source chip

  • destination_x (int) – The x-coordinate of the destination chip of the link

  • destination_y (int) – The y-coordinate of the destination chip of the link

property destination_x

The X-coordinate of the destination chip of this link.

Return type:

int

property destination_y

The Y-coordinate of the destination chip of this link.

Return type:

int

The ID of the link on the source chip.

Return type:

int

property source_x

The X-coordinate of the source chip of this link.

Return type:

int

property source_y

The Y-coordinate of the source chip of this link.

Return type:

int

class spinn_machine.Machine(width, height, chips=None, origin=None)[source]

Bases: object

A representation of a SpiNNaker Machine with a number of Chips. Machine is also iterable, providing ((x, y), chip) where:

  • x is the x-coordinate of a chip,

  • y is the y-coordinate of a chip,

  • chip is the chip with the given (x, y) coordinates.

Use machine_from_chips() and machine_from_size() to determine the correct machine class.

Parameters:
  • width (int) – The width of the machine excluding

  • height (int) – The height of the machine

  • chips (iterable(Chip)) – An iterable of chips in the machine

  • origin (str) – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json

Raises:

SpinnMachineAlreadyExistsException – If any two chips have the same x and y coordinates

BOARD_48_CHIPS = [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7)]
BOARD_VERSION_FOR_48_CHIPS = [4, 5]
BOARD_VERSION_FOR_4_CHIPS = [2, 3]
CHIPS_PER_BOARD = {(0, 0): 18, (0, 1): 18, (0, 2): 18, (0, 3): 18, (1, 0): 18, (1, 1): 17, (1, 2): 18, (1, 3): 17, (1, 4): 18, (2, 0): 18, (2, 1): 18, (2, 2): 18, (2, 3): 18, (2, 4): 18, (2, 5): 18, (3, 0): 18, (3, 1): 17, (3, 2): 18, (3, 3): 17, (3, 4): 18, (3, 5): 17, (3, 6): 18, (4, 0): 18, (4, 1): 18, (4, 2): 18, (4, 3): 18, (4, 4): 18, (4, 5): 18, (4, 6): 18, (4, 7): 18, (5, 1): 18, (5, 2): 17, (5, 3): 18, (5, 4): 17, (5, 5): 18, (5, 6): 17, (5, 7): 18, (6, 2): 18, (6, 3): 18, (6, 4): 18, (6, 5): 18, (6, 6): 18, (6, 7): 18, (7, 3): 18, (7, 4): 18, (7, 5): 18, (7, 6): 18, (7, 7): 18}
DEFAULT_MAX_CORES_PER_CHIP = 18
DEFAULT_SDRAM_BYTES = 123469792
MAX_BANDWIDTH_PER_ETHERNET_CONNECTED_CHIP = 2560
MAX_CHIPS_PER_48_BOARD = 48
MAX_CHIPS_PER_4_CHIP_BOARD = 4
MAX_CHIP_X_ID_ON_ONE_BOARD = 7
MAX_CHIP_Y_ID_ON_ONE_BOARD = 7
NON_USER_CORES = 1
ROUTER_ENTRIES = 1023
SIZE_X_OF_ONE_BOARD = 8
SIZE_Y_OF_ONE_BOARD = 8
add_chip(chip)[source]

Add a chip to the machine.

Parameters:

chip (Chip) – The chip to add to the machine

Raises:

SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates already exists

add_chips(chips)[source]

Add some chips to the machine.

Parameters:

chips (iterable(Chip)) – an iterable of chips

Raises:

SpinnMachineAlreadyExistsException – If a chip with the same x and y coordinates as one being added already exists

Add FPGA links that are on a given machine depending on the version of the board.

Add SpiNNaker links that are on a given machine depending on the version of the board.

property boot_chip

The chip used to boot the machine.

Return type:

Chip

property chip_coordinates

An iterable of chip coordinates in the machine.

Return type:

iterable(tuple(int,int))

property chips

An iterable of chips in the machine.

Return type:

iterable(Chip)

abstract concentric_xys(radius, start)[source]

A generator that produces coordinates for concentric rings of possible chips based on the links of the chips.

No check is done to see if the chip exists. This may even produce coordinates with negative numbers

Mostly copied from: https://github.com/project-rig/rig/blob/master/rig/geometry.py

Parameters:
  • radius (int) – The radius of rings to produce (0 = start only)

  • start (tuple(int,int)) – The start coordinate

Return type:

tuple(int,int)

Get a string detailing the number of cores and links.

Return type:

str

property ethernet_connected_chips

The chips in the machine that have an Ethernet connection.

Return type:

iterable(Chip)

get_chip_at(x, y)[source]

Get the chip at a specific (x, y) location. Also implemented as __getitem__((x, y))

Parameters:
  • x (int) – the x-coordinate of the requested chip

  • y (int) – the y-coordinate of the requested chip

Returns:

the chip at the specified location, or None if no such chip

Return type:

Chip or None

get_chips_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the actual chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the chips on this board.

Return type:

iterable(Chip)

Get the number of cores and links from the machine.

Links are assumed to be bidirectional so the total links counted is half of the unidirectional links found.

SpiNNaker and FPGA links are not included.

Returns:

tuple of (n_cores, n_links)

Return type:

tuple(int,int)

abstract get_down_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y) coordinates of the down chips on the board with this Ethernet-enabled chip.

Note

The Ethernet chip itself can not be missing if validated.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) of the down chips on this board.

Return type:

iterable(tuple(int,int))

abstract get_existing_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the (x,y)s of actual chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

This method does check if the chip actually exists.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x,y)s of chips on this board.

Return type:

iterable(tuple(int,int))

get_existing_xys_on_board(chip)[source]

Get the chips that are on the same board as the given chip.

Parameters:

chip – The chip to find other chips on the same board as

Returns:

An iterable of (x, y) coordinates of chips on the same board

Return type:

iterable(tuple(int,int))

Get an FPGA link data item that corresponds to the FPGA and FPGA link for a given board address.

Parameters:
  • fpga_id (int) – the ID of the FPGA that the data is going through. Refer to technical document located here for more detail: https://drive.google.com/file/d/0B9312BuJXntlVWowQlJ3RE8wWVE

  • fpga_link_id (int) – the link ID of the FPGA. Refer to technical document located here for more detail: https://drive.google.com/file/d/0B9312BuJXntlVWowQlJ3RE8wWVE

  • board_address (str or None) – optional board address that this FPGA link is associated with. This is ignored if chip_coords is not None. If this is None and chip_coords is None, the boot board will be assumed.

  • chip_coords (tuple(int, int) or None) – optional chip coordinates that this FPGA link is associated with. If this is None and board_address is None, the boot board will be assumed.

Returns:

the given FPGA link object or None if no such link

Return type:

FPGALinkData

abstract get_global_xy(local_x, local_y, ethernet_x, ethernet_y)[source]

Converts the local (X, Y) coordinates into global (x,y) coordinates, under the assumption that they are on the board with local (0,0) at global coordinates (ethernet_x, ethernet_y).

This method does take wrap-arounds into consideration.

Warning

GIGO: This method does not check if input parameters make sense, nor does it check if there is a chip at the resulting global (x,y)

Parameters:
  • local_x (int) – A valid local x coordinate for a chip

  • local_y (int) – A valid local y coordinate for a chip

  • ethernet_x (int) – The global Ethernet-enabled chip X coordinate for the board the chip is on

  • ethernet_y (int) – The global Ethernet-enabled chip Y coordinate for the board the chip is on

Returns:

global (x,y) coordinates of the chip

Return type:

tuple(int,int)

abstract get_local_xy(chip)[source]

Converts the x and y coordinates into the local coordinates on the board as if the Ethernet-enabled chip was at position 0,0.

This method does take wrap-arounds into consideration.

This method assumes that chip is on the machine or is a copy of a chip on the machine

Parameters:

chip (Chip) – A Chip in the machine

Returns:

Local (x, y) coordinates.

Return type:

tuple(int,int)

Get a SpiNNaker link with a given ID.

Parameters:
  • spinnaker_link_id (int) – The ID of the link

  • board_address (str or None) – optional board address that this SpiNNaker link is associated with. This is ignored if chip_coords is not None. If this is None and chip_coords is None, the boot board will be assumed.

  • chip_coords (tuple(int, int) or None) – optional chip coordinates that this SpiNNaker link is associated with. If this is None and board_address is None, the boot board will be assumed.

Returns:

The SpiNNaker link data or None if no link

Return type:

SpinnakerLinkData

get_unused_xy()[source]

Finds an unused (x,y) coordinate on this machine.

This method will not return an (x,y) of an existing chip

This method will not return an (x,y) on any existing board even if that chip does not exist, i.e., it will not return (x,y) of a known dead chip.

It will however return the same unused_xy until a chip is added at that location.

Returns:

an unused (x,y) coordinate

Return type:

(int, int)

abstract get_vector(source, destination)[source]

Get mathematical shortest vector (x, y, z) from source to destination.

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

Use the same algorithm as vector_length using the best x, y pair as minimize(x, y, 0)

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The vector

abstract get_vector_length(source, destination)[source]

Get the mathematical length of the shortest vector (x, y, z) from source to destination.

Use the same algorithm as vector to find the best x, y pair but then is optimised to directly calculate length

This method does not check if the chips and links it assumes to take actually exist. For example long paths along a non-wrapping edge may well travel through the missing area.

This method does take wrap-arounds into consideration as applicable.

From https://github.com/project-rig/rig/blob/master/rig/geometry.py Described in http://jhnet.co.uk/articles/torus_paths

On full wrap-around machines (before minimisation) the vectors can have any of the 4 combinations of positive and negative x and y The positive one is: destination - source % dimension The negative one is: positive - dimension If source is less than dimension the negative one is the wrap around If destination is greater than source the positive one wraps

One no wrap or part wrap boards the x/y that does not wrap is just destination - source

The length of vectors where both x and y have the same sign will be max(abs(x), abs(y)). As the z direction can be used in minimisation The length of vectors where x and y have opposite signs will be abs(x) and abs(y) as these are already minimum so z is not used.

Warning

GIGO: This method does not check if input parameters make sense.

Parameters:
  • source (tuple(int, int)) – (x,y) coordinates of the source chip

  • destination (tuple(int, int)) – (x,y) coordinates of the destination chip

Returns:

The distance in steps

Return type:

int

abstract get_xy_cores_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential (x,y) locations and the typical number of cores of all the chips on the board with this Ethernet-enabled chip.

Includes the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists, nor report the actual number of cores on this chip, as is intended to be called to create the chips.

The number of cores is based on the 1,000,000 core machine where the board where built with the the 17 core chips placed in the same location on nearly every board.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields (x, y, n_cores) where x , y are coordinates of all the potential chips on this board, and n_cores is the typical number of cores for a chip in that position.

Return type:

iterable(tuple(int,int))

abstract get_xys_by_ethernet(ethernet_x, ethernet_y)[source]

Yields the potential x,y locations of all the chips on the board with this Ethernet-enabled chip. Including the Ethernet-enabled chip itself.

Wrap-arounds are handled as appropriate.

Note

This method does not check if the chip actually exists as is intended to be called to create the chips.

Warning

GIGO! This methods assumes that ethernet_x and ethernet_y are the local 0,0 of an existing board, within the width and height of the machine.

Parameters:
  • ethernet_x (int) – The X coordinate of a (local 0,0) legal Ethernet-enabled chip

  • ethernet_y (int) – The Y coordinate of a (local 0,0) legal Ethernet-enabled chip

Returns:

Yields the (x, y) coordinates of all the potential chips on this board.

Return type:

iterable(tuple(int,int))

property height

The height of the machine, in chips.

Return type:

int

is_chip_at(x, y)[source]

Determine if a chip exists at the given coordinates. Also implemented as __contains__((x, y))

Parameters:
  • x (int) – x location of the chip to test for existence

  • y (int) – y location of the chip to test for existence

Returns:

True if the chip exists, False otherwise

Return type:

bool

Determine if a link exists at the given coordinates.

Parameters:
  • x (int) – The x location of the chip to test the link of

  • y (int) – The y location of the chip to test the link of

  • link (int) – The link to test the existence of

property local_xys

Provides a list of local (x,y) coordinates for a perfect board on this machine.

Local (x,y)s never include wrap-arounds.

Note

No check is done to see if any board in the machine actually has a chip with this local (x, y).

Return type:

iterable(tuple(int,int))

static max_cores_per_chip()[source]

Gets the max core per chip for the while system.

There is no guarantee that there will be any Chips with this many cores, only that there will be no cores with more.

Returns:

the default cores per chip unless overridden by set

abstract multiple_48_chip_boards()[source]

Checks that the width and height correspond to the expected size for a multi-board machine made up of more than one 48 chip board.

The assumption is that any size machine can be supported but that only ones with an expected 48 chip board size can have more than one Ethernet-enabled chip.

Returns:

True if this machine can have multiple 48 chip boards

Return type:

bool

property n_chips

The number of chips in the machine.

Return type:

int

Return type:

iterable(tuple(int,int,int))

static set_max_cores_per_chip(new_max)[source]

Allows setting the max number of cores per chip for the whole system.

Allows virtual machines to go higher than normal.

Real machines can only be capped never increased beyond what they actually have.

Parameters:

new_max (int) – New value to use for the max

Raises:

SpinnMachineException – if max_cores_per_chip has already been used and is now being changed. This exception also happens if the value is set twice to different values. For example in the script and in the configuration file.

The set of SpiNNaker links in the machine.

Return type:

iterable(tuple(tuple(str,int), SpinnakerLinkData))

property total_available_user_cores

The total number of cores on the machine which are not monitor cores.

Return type:

int

property total_cores

The total number of cores on the machine, including monitors.

Return type:

int

unreachable_incoming_chips()[source]

Detects chips that are not reachable from any of their neighbours.

Current implementation does not deal with group of unreachable chips.

Returns:

List (hopefully empty) if the (x,y) coordinates of unreachable chips.

Return type:

list(tuple(int,int))

unreachable_incoming_local_chips()[source]

Detects chips that are not reachable from any of their local neighbours.

Current implementation does not deal with group of unreachable chips.

Returns:

List (hopefully empty) if the (x,y) coordinates of unreachable chips.

Return type:

list(tuple(int,int))

unreachable_outgoing_chips()[source]

Detects chips that can not reach any of their neighbours.

Current implementation does not deal with group of unreachable chips.

Returns:

List (hopefully empty) if the (x,y) coordinates of unreachable chips.

Return type:

list(tuple(int,int))

unreachable_outgoing_local_chips()[source]

Detects chips that can not reach any of their local neighbours.

Current implementation does not deal with group of unreachable chips.

Returns:

List (hopefully empty) if the (x,y) coordinates of unreachable chips.

Return type:

list(tuple(int,int))

validate()[source]

Validates the machine and raises an exception in unexpected conditions.

Assumes that at the time this is called all chips are on the board.

This allows the checks to be avoided when creating a virtual machine (Except of course in testing)

Raises:

SpinnMachineException

  • An Error is raised if there is a chip with a x outside of the range 0 to width -1.

  • An Error is raised if there is a chip with a y outside of the range 0 to height -1.

  • An Error is raise if there is no chip at the declared Ethernet-enabled chip x and y.

  • An Error is raised if an Ethernet-enabled chip is not at a local 0,0.

  • An Error is raised if there is no Ethernet-enabled chip is at 0,0.

  • An Error is raised if this is a unexpected multiple board situation.

where_is_chip(chip)[source]

Returns global and local location for this chip.

This method assumes that chip is on the machine or is a copy of a chip on the machine.

Parameters:

chip (Chip) – A Chip in the machine

Returns:

A human-readable description of the location of a chip.

Return type:

str

where_is_xy(x, y)[source]

Returns global and local location for this chip.

Parameters:
  • x (int) – X coordinate

  • y (int) – Y coordinate

Returns:

A human-readable description of the location of a chip.

Return type:

str

property width

The width of the machine, in chips.

Return type:

int

abstract property wrap

A short string representing the type of wrap.

Return type:

str

Get the potential (x,y) location of the chip reached over this link.

Wrap-arounds are handled as appropriate.

Note

This method does not check if either chip source or destination actually exists as is intended to be called to create the links.

It is the callers responsibility to check the validity of this call before making it or the validity of the result.

Warning

GIGO! This methods assumes that x and y are within the width and height of the machine, and that the link goes to another chip on the machine.

On machine without full wrap-around it is possible that this method generates (x,y) values that fall outside of the legal values including negative values, x = width or y = height.

Parameters:
  • x (int) – The x coordinate of a chip that will exist on the machine

  • y (int) – The y coordinate of a chip that will exist on the machine

  • link (int) – The link to another chip that could exist on the machine

Returns:

x and y coordinates of the chip over that link if it is valid or some fictional (x,y) if not.

Return type:

tuple(int,int)

class spinn_machine.MulticastRoutingEntry(routing_entry_key, mask, processor_ids=None, link_ids=None, defaultable=False, spinnaker_route=None)[source]

Bases: object

Represents an entry in a SpiNNaker chip’s multicast routing table. There can be up to 1024 such entries per chip, but some may be reserved for system purposes.

Note

The processor_ids and link_ids parameters are only optional if a spinnaker_route is provided. If a spinnaker_route is provided the processor_ids and link_ids parameters are ignored.

Parameters:
  • routing_entry_key (int) – The routing key_combo

  • mask (int) – The route key_combo mask

  • processor_ids (iterable(int) or None) – The destination processor IDs

  • link_ids (iterable(int) or None) – The destination link IDs

  • defaultable (bool) – If this entry is defaultable (it receives packets from its directly opposite route position)

  • spinnaker_route (int or None) – The processor_ids and link_ids expressed as a single int.

Raises:
property defaultable

Whether this entry is a defaultable entry. An entry is defaultable if it is duplicating the default behaviour of the SpiNNaker router (to pass a message out on the link opposite from where it was received, without routing it to any processors; source and destination chips for a message cannot be defaultable).

Return type:

bool

The destination link IDs.

Return type:

frozenset(int)

property mask

The routing mask.

Return type:

int

merge(other_entry)[source]

Merges together two multicast routing entries. The entry to merge must have the same key and mask. The merge will join the processor IDs and link IDs from both the entries. This could be used to add a new destination to an existing route in a routing table. It is also possible to use the add (+) operator or the or (|) operator with the same effect.

Parameters:

other_entry (MulticastRoutingEntry) – The multicast entry to merge with this entry

Returns:

A new multicast routing entry with merged destinations

Return type:

MulticastRoutingEntry

Raises:

spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the key and mask of the other entry do not match

property processor_ids

The destination processor IDs.

Return type:

frozenset(int)

property routing_entry_key

The routing key.

Return type:

int

property spinnaker_route

The encoded SpiNNaker route.

Return type:

int

class spinn_machine.Processor(processor_id, clock_speed=200000000, is_monitor=False, dtcm_available=65536)[source]

Bases: object

A processor object included in a SpiNNaker chip.

Parameters:
  • processor_id (int) – ID of the processor in the chip

  • clock_speed (int) – The number of CPU cycles per second of the processor

  • is_monitor (bool) – Determines if the processor is considered the monitor processor, and so should not be otherwise allocated

  • dtcm_available (int) – Data Tightly Coupled Memory available

Raises:

spinn_machine.exceptions.SpinnMachineInvalidParameterException – If the clock speed is negative

CLOCK_SPEED = 200000000
DTCM_AVAILABLE = 65536
property clock_speed

The clock speed of the processor in cycles per second.

Return type:

int

property cpu_cycles_available

The number of CPU cycles available from this processor per ms.

Return type:

int

property dtcm_available

The amount of DTCM available on this processor.

Return type:

int

static factory(processor_id, is_monitor=False)[source]
property is_monitor

Determines if the processor is the monitor, and therefore not to be allocated.

Warning

Currently rejection processors are also marked as monitors.

Return type:

bool

property processor_id

The ID of the processor.

Return type:

int

class spinn_machine.Router(links, emergency_routing_enabled=False, n_available_multicast_entries=1023)[source]

Bases: object

Represents a router of a chip, with a set of available links. The router is iterable over the links, providing (source_link_id, link) where:

  • source_link_id is the ID of a link

  • link is the Link with ID source_link_id

Parameters:
  • links (iterable(Link)) – iterable of links

  • emergency_routing_enabled (bool) – Determines if the router emergency routing is operating

  • n_available_multicast_entries (int) – The number of entries available in the routing table

Raises:

SpinnMachineAlreadyExistsException – If any two links have the same source_link_id

MAX_CORES_PER_ROUTER = 18

Add a link to the router of the chip.

Parameters:

link (Link) – The link to be added

Raises:

SpinnMachineAlreadyExistsException – If another link already exists with the same source_link_id

static convert_routing_table_entry_to_spinnaker_route(routing_table_entry)[source]

Convert a routing table entry represented in software to a binary routing table entry usable on the machine.

Parameters:

routing_table_entry (MulticastRoutingEntry or FixedRouteEntry) – The entry to convert

Return type:

int

static convert_spinnaker_route_to_routing_ids(route)[source]

Convert a binary routing table entry usable on the machine to lists of route IDs usable in a routing table entry represented in software.

Parameters:

route (int) – The routing table entry

Returns:

The list of processor IDs, and the list of link IDs.

Return type:

tuple(list(int), list(int))

property emergency_routing_enabled

Whether emergency routing is enabled.

Return type:

bool

Get the link with the given ID, or None if no such link. Also implemented as __getitem__(source_link_id)

Parameters:

source_link_id (int) – The ID of the link to find

Returns:

The link, or None if no such link

Return type:

Link or None

get_neighbouring_chips_coords()[source]

Utility method to convert links into x and y coordinates.

Returns:

iterable list of destination coordinates in x and y dict

Return type:

iterable(dict(str,int))

Determine if there is a link with ID source_link_id. Also implemented as __contains__(source_link_id)

Parameters:

source_link_id (int) – The ID of the link to find

Returns:

True if there is a link with the given ID, False otherwise

Return type:

bool

The available links of this router.

Return type:

iterable(Link)

property n_available_multicast_entries

The number of available multicast entries in the routing tables.

Return type:

int

static opposite(link_id)[source]

Given a valid link_id this method returns its opposite.

GIGO: this method assumes the input is valid. No verification is done

Parameters:

link_id (int) – A valid link_id

Returns:

The link_id for the opposite direction

Return type:

int

class spinn_machine.SpiNNakerTriadGeometry(triad_width, triad_height, roots, centre)[source]

Bases: object

Geometry of a “triad” of SpiNNaker boards.

The geometry is defined by the arguments to the constructor; the standard arrangement can be obtained from get_spinn5_geometry.

Note

The geometry defines what a Triad is in terms of the dimensions of a triad and where the Ethernet chips occur in the triad.

Parameters:
  • triad_width (int) – width of a triad in chips

  • triad_height (int) – height of a triad in chips

  • roots (list(tuple(int, int))) – locations of the Ethernet connected chips

  • centre (tuple(float, float)) – the distance from each Ethernet chip to the centre of the hexagon

get_ethernet_chip_coordinates(x, y, width, height, root_x=0, root_y=0)[source]

Get the coordinates of a chip’s local Ethernet connected chip according to this triad geometry object.

Warning

local_eth_coord() will always produce the coordinates of the Ethernet-connected SpiNNaker chip on the same SpiNN-5 board as the supplied chip. This chip may not actually be working.

Parameters:
  • x (int) – x-coordinate of the chip to find the nearest Ethernet of

  • y (int) – y-coordinate of the chip to find the nearest Ethernet of

  • width (int) – width of the SpiNNaker machine (must be a multiple of the triad width of this geometry)

  • height (int) – height of the SpiNNaker machine (must be a multiple of the triad height of this geometry)

  • root_x (int) – x-coordinate of the boot chip (default 0, 0)

  • root_y (int) – y-coordinate of the boot chip (default 0, 0)

Returns:

The coordinates of the closest Ethernet chip

Return type:

(int, int)

get_local_chip_coordinate(x, y, root_x=0, root_y=0)[source]

Get the coordinates of a chip on its board of a multi-board system relative to the Ethernet chip of the board.

Note

This function assumes the system is constructed from SpiNN-5 boards

Parameters:
  • x (int) – The x-coordinate of the chip to find the location of

  • y (int) – The y-coordinate of the chip to find the location of

  • root_x (int) – The x-coordinate of the boot chip (default 0, 0)

  • root_y (int) – The y-coordinate of the boot chip (default 0, 0)

Returns:

the coordinates of the chip relative to its board

Return type:

(int, int)

get_potential_ethernet_chips(width, height)[source]

Get the coordinates of chips that should be Ethernet chips

Parameters:
  • width (int) – The width of the machine to find the chips in

  • height (int) – The height of the machine to find the chips in

Return type:

list(tuple(int, int))

static get_spinn5_geometry()[source]

Get the geometry object for a SpiNN-5 arrangement of boards

Returns:

a SpiNNakerTriadGeometry object.

spinn5_triad_geometry = None
spinn_machine.machine_from_chips(chips)[source]

Create a machine with the assumed wrap-around based on the sizes.

The size of the machine is calculated from the list of chips.

Parameters:

chips (list(Chip)) – Full list of all chips on this machine. Or at least a list which includes a chip with the highest X and one with the highest Y (excluding any virtual chips)

Returns:

A subclass of Machine

Return type:

Machine

spinn_machine.machine_from_size(width, height, chips=None, origin=None)[source]

Create a machine with the assumed wrap-around based on the sizes.

This could include a machine with no wrap-arounds, only vertical ones, only horizontal ones or both.

Note

If the sizes do not match the ones for a known wrap-around machine, a machine with no wrap-arounds is assumed.

Parameters:
  • width (int) – The width of the machine excluding any virtual chips

  • height (int) – The height of the machine excluding any virtual chips

  • chips (list(Chip) or None) – Any chips to be added.

  • origin (str or None) – Extra information about how this machine was created to be used in the str method. Example “Virtual” or “Json

Returns:

A subclass of Machine

Return type:

Machine

spinn_machine.virtual_machine(width, height, n_cpus_per_chip=None, validate=True)[source]

Create a virtual SpiNNaker machine, used for planning execution.

Parameters:
  • width (int) – the width of the virtual machine in chips

  • height (int) – the height of the virtual machine in chips

  • n_cpus_per_chip (int) – The number of CPUs to put on each chip

  • validate (bool) – if True will call the machine validate function

Returns:

a virtual machine (that cannot execute code)

Return type:

Machine

Indices and tables

SpiNNMachine_github

SpiNNMachine_individual_docs

PACMAN

This package provides utilities for partitioning, placing and routing a graph-based application on a SpiNNaker machine.

PACMAN

Provides various functions which together can be used to take a graph and split it into pieces that can be loaded on to a machine, along with routes between the pieces.

Functional Requirements

  • Creation of an Application Graph of Vertices indicating points of computation within the graph and Edges between the vertices indicating a directional communication between the vertices; and a similar Machine Graph.

    • Vertices in the Application Graph will have a number of atoms - an atom cannot be broken down in to anything smaller.

    • Vertices in the Application Graph must be able to indicate what machine resources are required by any given subset of the atoms.

    • Vertices in the Machine Graph must be able to fit on a single chip of the machine in terms of resource usage.

    • Multiple edges can exist between the same two vertices.

    • It must be possible to build the Machine Graph directly without requiring that it is created by one of the other modules.

    • It is not required that there is a Machine Graph Edge between every pair of Machine Graph Vertex from the same Application Graph Vertex.

    • Where a Machine Graph is created from an Application Graph, it should be possible to find the corresponding Vertices and Edges from one graph to the other.

  • Creation of multicast routing info consisting of key/mask combinations assigned to Edges of the Machine Graph.

    • It must be possible to build this information directly without requiring that it is created by one of the other modules.

    • There should be exactly one key/mask combination for each Edge in the Machine Graph, which will represent all the keys which will be sent in all packets from the Vertex at the start of the Edge down that Edge.

    • It is possible for a Vertex to send several different keys down several different Edges, but only one per Edge (but note that it is acceptable for different keys to be assigned to different Edges between the same two Vertices).

    • There should be no overlap between the key/mask combinations of Edges which come from different Vertices i.e. no two Edges which start at different Vertices should have the same key/mask combination.

  • Partitioning of an Application graph with respect to a machine, such that the resources consumed by each Vertex does not exceed those provided by each chip on the machine.

    • It should be possible to select from a range of partitioning algorithms or provide one, although a default should be provided in the absence of such a choice.

    • Any fixed_location should be met; if there are any that cannot, or that are not understood by the algorithm in use an exception should be thrown.

    • It must be possible to create at least one grouping of the generated Vertices so that each group fits within the resources provided by a single chip on the machine.

    • The machine itself must not be altered by the partitioning, so that it can be used in further processing.

    • The graph itself must not be altered by the partitioning, so that it can be used in further processing.

    • No two Machine Graph Vertices created from a single Application Graph Vertex can contain the same atom.

    • Any Edges in the Application Graph must be split with the Vertices to create a number of Machine Graph edges, such that where there was a vertex v connected to a vertex w by a single edge in the Application Graph, there should be an Edge in the Machine Graph between every Vertex of Application Graph Vertex v and every Vertex of Application Graph Vertex w; for example, if there are 2 Machine Graph Vertices for each of v and w, and one Edge between them in the Application Graph, then there will be 4 new Edges in the Machine Graph for this Edge.

  • Placement of a Machine Graph on a given machine, such that the resources required by any combination of Vertices placed on any chip in the machine does not exceed the resources provided by that chip.

    • It should be possible to choose from a range of placement algorithms or provide one, although a default should be provided in the absence of such a choice.

    • Any fixed_location should be met; if not an exception should be thrown.

    • The machine itself should not be altered by placement so that it can be used in further processing.

    • The graph itself should not be altered by placement so that it can be used in further processing.

    • The returned placements should only contain a single placement for each vertex.

    • The placements should be such that the vertices with edges between them must be able to communicate with each other.

  • Allocation of multicast routing keys and masks to a Machine Graph such that each vertex sends out packets with a different key/mask combination.

    • This can use the placement information if required. If an algorithm requires placement information but none is provided an exception is thrown.

  • Routing of edges between vertices with a given allocation of routing keys and masks with respect to a given machine.

    • It should be possible to choose from a range of routing algorithms, or provide one, although a default should be provided in the absence of such a choice

    • For any vertex, following the routes from the placement of the vertex should result exactly in the set of placements of the destination vertices described by all the edges which start at that vertex. No additional destination should be reached, and no fewer than this set of destinations should be reached.

  • It should be possible to call each of the modules independently. There should be no assumption that one of the other modules has produced the data input for any other module.

  • There should be no assumption about how the inputs and outputs are stored.

  • Any utility functions that provide access to internal structures within a data structure should operate in approximately O(1) time; for example, where an object of type obj holds a number of objects of type subobj with property prop, requesting a list of subobj objects contained within obj with property value prop = value should not iterate through a list of such objects, but should instead maintain a mapping that allows access to such objects in O(1) time. If this is not possible, obj should only provide access to a list of subobj objects, allowing the caller to filter these themselves. This will ensure that no misunderstanding can be made about the speed of operation of a function.

Contents

pacman
pacman package
Subpackages
pacman.data package
Submodules
pacman.data.pacman_data_writer module
class pacman.data.pacman_data_writer.PacmanDataWriter(state)[source]

Bases: MachineDataWriter, PacmanDataView

See spinn_utilities.data.UtilsDataWriter.

This class is designed to only be used directly within the PACMAN repository unit tests as all methods are available to subclasses.

Parameters:

state (DataStatus) – State writer should be in

classmethod add_edge(edge, outgoing_edge_partition_name)[source]

Adds an Application edge to the user graph.

Syntactic sugar for get_graph().add_edge()

Parameters:
  • edge (AbstractEdge) – The edge to add

  • outgoing_edge_partition_name (str) – The name of the edge partition to add the edge to; each edge partition is the partition of edges that start at the same vertex

Return type:

AbstractEdgePartition

Raises:
add_monitor_all_chips(vertex)[source]

Reports that a monitor has been added to every chip. Should be called once for each monitor added to all chips. Should not be called for monitors only added to Ethernet-enabled chips.

Only affect is to change the numbers reported by the get_monitor methods.

Parameters:

vertex (MachineVertex) – One of the vertices added to each core, assumed to be typical of all.

classmethod add_vertex(vertex)[source]

Adds an Application vertex to the user graph.

Syntactic sugar for get_graph().add_vertex()

Parameters:

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

Raises:
set_placements(placements)[source]

Set the placements.

Parameters:

placements (Placements) –

Raises:

TypeError – if the placements is not a Placements

set_plan_n_timesteps(plan_n_timesteps)[source]

Sets the plan_n_timestep. Use None for run forever.

Parameters:

plan_n_timesteps (int or None) –

Raises:
set_precompressed(router_tables)[source]

Sets the precompressed router_tables value.

Parameters:

router_tables (MulticastRoutingTables) – new value

Raises:

TypeError – if the router_tables is not a MulticastRoutingTables

set_routing_infos(routing_infos)[source]

Set the routing_infos.

Parameters:

routing_infos (RoutingInfo) –

Raises:

TypeError – if the routing_infos is not a RoutingInfo

set_routing_table_by_partition(routing_table_by_partition)[source]

Sets the _routing_table_by_partition.

Parameters:

routing_table_by_partition (MulticastRoutingTableByPartition) – raises TypeError: if routing_table_by_partition is no a MulticastRoutingTableByPartition

set_tags(tags)[source]

Set the tags.

Parameters:

tags (Tags) –

Raises:

TypeError – if the tags is not a Tags

set_uncompressed(router_tables)[source]

Sets the uncompressed router_tables value.

Parameters:

router_tables (MulticastRoutingTables) – new value

Raises:

TypeError – if the router_tables is not a MulticastRoutingTables

Module contents
class pacman.data.PacmanDataView[source]

Bases: MachineDataView

Adds the extra Methods to the View for PACMAN level.

See UtilsDataView for a more detailed description.

This class is designed to only be used directly within the PACMAN repository as all methods are available to subclasses

classmethod add_edge(edge, outgoing_edge_partition_name)[source]

Adds an Application edge to the user graph.

Syntactic sugar for get_graph().add_edge()

Parameters:
  • edge (AbstractEdge) – The edge to add

  • outgoing_edge_partition_name (str) – The name of the edge partition to add the edge to; each edge partition is the partition of edges that start at the same vertex

Return type:

AbstractEdgePartition

Raises:
classmethod add_vertex(vertex)[source]

Adds an Application vertex to the user graph.

Syntactic sugar for get_graph().add_vertex()

Parameters:

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

Raises:
classmethod get_edges()[source]

Get all the edges in the graph.

Syntactic sugar for get_graph().edges

Return type:

list(AbstractEdge)

classmethod get_monitor_cores()[source]

The number of cores on every chip reported to be used by monitors. Ethernet-enabled chips may have more.

Does not include the system core reserved by the machine itself.

Return type:

int

classmethod get_monitor_sdram()[source]

The amount of SDRAM on every chip reported to be used by monitors. Ethernet-enabled chips may have more.

Does not include the system SDRAM reserved by the machine itself.

Return type:

int

classmethod get_n_machine_vertices()[source]

Gets the number of machine vertices via the application graph.

Return type:

int

classmethod get_n_partitions()[source]

The partitions in the user application graph.

Syntactic sugar for get_graph().n_outgoing_edge_partitions

Return type:

int

Raises:

SpiNNUtilsException – If the graph is currently unavailable

classmethod get_n_placements()[source]

The number of placements.

Return type:

int

Raises:

SpiNNUtilsException – If the placements are currently unavailable

classmethod get_n_vertices()[source]

The number of vertices in the user application graph.

Syntactic sugar for get_graph().n_vertices

Return type:

int

Raises:

SpiNNUtilsException – If the graph is currently unavailable

classmethod get_outgoing_edge_partitions_starting_at_vertex(vertex)[source]

Get all the edge partitions that start at the given vertex.

Syntactic sugar for get_graph().get_outgoing_edge_partitions_starting_at_vertex()

Parameters:

vertex (AbstractVertex) – The vertex at which the edge partitions to find starts

Return type:

iterable(AbstractEdgePartition)

classmethod get_placement_of_vertex(vertex)[source]

Return the placement information for a vertex.

Syntactic sugar for get_placements().get_placement_of_vertex(vertex). Optimised for speed

Parameters:

vertex (MachineVertex) – The vertex to find the placement of

Returns:

The placement

Return type:

Placement

Raises:
classmethod get_placement_on_processor(x, y, p)[source]

Get the vertex on a specific processor, or raise an exception if the processor has not been allocated.

Parameters:
  • x (int) – the X coordinate of the chip

  • y (int) – the Y coordinate of the chip

  • p (int) – the processor on the chip

Returns:

the vertex placed on the given processor

Return type:

MachineVertex

Raises:
classmethod get_plan_n_timestep()[source]

The number of timesteps to plan for in an auto-pause-resume cycle.

Use by partitioners and such, but not to reserve data regions.

Return type:

int or None

Returns:

The planned number of timesteps, or None if run forever.

classmethod get_precompressed()[source]

Get the pre-compressed routing tables.

This may be the same object as the uncompressed ones if precompression is skipped or determined to be not needed.

Return type:

MulticastRoutingTables

Returns:

The routing tables after the range compressor or if not to be run the original tables

Raises:

SpiNNUtilsException – If the tables is currently unavailable

classmethod get_routing_infos()[source]

The routing information, if known.

Raises:

SpiNNUtilsException – If the routing_infos is currently unavailable

classmethod get_routing_table_by_partition()[source]

The MulticastRoutingTableByPartition, if it has been set.

Return type:

MulticastRoutingTableByPartition

Raises:

SpiNNUtilsException – If the tables is currently unavailable

classmethod get_tags()[source]

The Tags object if known.

Return type:

Tags

Raises:

SpiNNUtilsException – If the tags is currently unavailable

classmethod get_uncompressed()[source]

Get the uncompressed routing tables.

Return type:

MulticastRoutingTables

Returns:

The original routing tables

Raises:

SpiNNUtilsException – If the tables is currently unavailable

classmethod get_vertices_by_type(vertex_type)[source]

The application vertices in the graph of the specific type.

Syntactic sugar for:

for vertex in get_graph().vertices
    if isinstance(vertex, vertex_type)
        ...

Note

The result is a generator so can only be used in a single loop

Parameters:

vertex_type (type or iterable(type)) – The type(s) to filter the vertices on (can be anything acceptable to the isinstance built-in).

Return type:

iterable(AbstractVertex)

Raises:

SpiNNUtilsException – If the graph is currently unavailable

classmethod iterate_machine_vertices()[source]

Iterate over the Machine vertices via the application graph.

Return type:

iterable(MachineVertex)

classmethod iterate_partitions()[source]

The partitions in the user application graphs as an iterator.

Syntactic sugar for get_graph().outgoing_edge_partitions

Return type:

iterable(ApplicationEdgePartition)

Raises:

SpiNNUtilsException – If the graph is currently unavailable

classmethod iterate_placemements()[source]

Iterates over the Placement objects.

Syntactic sugar for get_placements().placements

Return type:

iterable(Placement)

classmethod iterate_placements_by_vertex_type(vertex_type)[source]

Iterate over placements on any chip with this vertex_type.

Parameters:

vertex_type (type) – Class of vertex to find

Return type:

iterable(Placement)

Raises:

SpiNNUtilsException – If the placements are currently unavailable

classmethod iterate_placements_by_xy_and_type(x, y, vertex_type)[source]

Iterate over placements with this x, y and type.

Parameters:
  • x (int) – x coordinate to find placements for.

  • y (int) – y coordinate to find placements for.

  • vertex_type (type) – Class of vertex to find

Return type:

iterable(Placement)

Raises:

SpiNNUtilsException – If the placements are currently unavailable

classmethod iterate_placements_on_core(x, y)[source]

Iterate over placements with this x and y.

Parameters:
  • x (int) – x coordinate to find placements for.

  • y (int) – y coordinate to find placements for.

Return type:

iterable(Placement)

Raises:

SpiNNUtilsException – If the placements are currently unavailable

classmethod iterate_vertices()[source]

The vertices in the user application graph.

Syntactic sugar for get_graph().vertices except that the result is an iterable and not a list.

Return type:

iterable(AbstractVertex)

Raises:

SpiNNUtilsException – If the graph is currently unavailable

pacman.model package
Subpackages
pacman.model.graphs package
Subpackages
pacman.model.graphs.application package
Subpackages
pacman.model.graphs.application.abstract package
Module contents
class pacman.model.graphs.application.abstract.Abstract2DDeviceVertex[source]

Bases: object

A helper for 2D input devices.

Note

This assumes that the input keys will contain a field for each of the X and Y dimensions with X field in the LSBs and the Y field in the next adjacent bits. If the fields are in different places, override the methods: _source_x_shift, _source_y_shift, _source_x_mask and _source_y_mask. If the key has bits in addition to the X and Y values, you can also override _key_shift.

abstract property atoms_shape

The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.

Return type:

tuple(int, …)

class pacman.model.graphs.application.abstract.AbstractOneAppOneMachineVertex(machine_vertex, label, n_atoms=1)[source]

Bases: ApplicationVertex

An application vertex that has a fixed singleton MachineVertex.

Parameters:
  • machine_vertex (MachineVertex) – The fixed machine vertex.

  • label (str) – The optional name of the vertex.

property machine_vertex

Provides access to the machine vertex at all times

Return type:

MachineVertex

property n_atoms

The number of atoms in the vertex.

Return type:

int

remember_machine_vertex(machine_vertex)[source]

Adds the machine vertex to the iterable returned by machine_vertices

Parameters:

machine_vertex (MachineVertex) – A pointer to a machine_vertex

reset()[source]

Forget all machine vertices in the application vertex, and reset the splitter (if any).

Module contents
class pacman.model.graphs.application.Application2DFPGAVertex(width, height, sub_width, sub_height, incoming_fpga_connections=None, outgoing_fpga_connection=None, label=None)[source]

Bases: ApplicationFPGAVertex, Abstract2DDeviceVertex

A device connected to an FPGA with input or output in two dimensions.

Parameters:
  • width (int) – The width of the vertex in atoms

  • height (int) – The height of the vertex in atoms

  • sub_width (int) – The width of the sub-rectangle to break the vertex up into

  • sub_height (int) – The height of the sub-rectangle to break the vertex up into

  • incoming_fpga_connections (list(FPGAConnection) or None) – The connections from one or more FPGAs that that packets are expected to be received from for this device, or None if no incoming traffic is expected from the device

  • outgoing_fpga_connection (FPGAConnection or None) – The connection to an FPGA that packets to be sent to this device should be sent down, or None if no outgoing traffic is expected to be sent to the device.

  • label (str) – The optional name of the vertex.

property atoms_shape

The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.

Return type:

tuple(int, …)

Get the slice to be given to the connection from the given link.

Parameters:
  • link (FPGAConnection) – The FPGA connection to get the slice for

  • index (int) – The index of the connection on the FGPA link, for when n_machine_vertices_per_link > 1

Return type:

Slice

class pacman.model.graphs.application.Application2DSpiNNakerLinkVertex(width, height, sub_width, sub_height, spinnaker_link_id, board_address=None, label=None, incoming=True, outgoing=False)[source]

Bases: ApplicationSpiNNakerLinkVertex, Abstract2DDeviceVertex

Parameters:
  • width (int) – The width of the vertex in atoms

  • height (int) – The height of the vertex in atoms

  • sub_width (int) – The width of the sub-rectangle to break the vertex up into

  • sub_height (int) – The height of the sub-rectangle to break the vertex up into

  • spinnaker_link_id (int) – The index of the spinnaker link to which the device is connected

  • board_address (str) – The optional IP address of the board to which the device is connected e.g. in a multi-board system

  • label (str) – The optional name of the vertex.

  • incoming (bool) – Whether the device supports sending traffic into spinnaker

  • outgoing (bool) – Whether the device supports receiving traffic from spinnaker

property atoms_shape

The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.

Return type:

tuple(int, …)

get_incoming_slice(index)[source]

Get the slice to be given to the connection.

Parameters:

index (int) – The index of the connection, for when n_machine_vertices > 1

Return type:

Slice

class pacman.model.graphs.application.ApplicationEdge(pre_vertex, post_vertex, label=None)[source]

Bases: AbstractEdge

A simple implementation of an application edge.

Parameters:
  • pre_vertex (ApplicationVertex) – The application vertex at the start of the edge.

  • post_vertex (ApplicationVertex) – The application vertex at the end of the edge.

  • label (str or None) – The name of the edge.

property label

The label of the edge.

Return type:

str

property post_vertex

The vertex at the end of the edge.

Return type:

AbstractVertex

property pre_vertex

The vertex at the start of the edge.

Return type:

AbstractVertex

class pacman.model.graphs.application.ApplicationEdgePartition(identifier, pre_vertex)[source]

Bases: AbstractSingleSourcePartition

A simple implementation of an application edge partition that will communicate using SpiNNaker multicast packets. They have the same source(s) and semantics and so can share a single key.

Parameters:
  • identifier (str) – The identifier of the partition

  • pre_vertex (ApplicationVertex) – The source of this partition

add_edge(edge)[source]

Add an edge to the edge partition.

Parameters:

edge (AbstractEdge) – the edge to add

Raises:

PacmanInvalidParameterException – If the edge does not belong in this edge partition

class pacman.model.graphs.application.ApplicationFPGAVertex(n_atoms, incoming_fpga_connections=None, outgoing_fpga_connection=None, label=None, n_machine_vertices_per_link=1)[source]

Bases: ApplicationVirtualVertex

A virtual application vertex connected to one or more FPGA links.

Parameters:
  • n_atoms (int) – The number of atoms in the vertex

  • incoming_fpga_connections (list(FPGAConnection) or None) – The connections from one or more FPGAs that that packets are expected to be received from for this device, or None if no incoming traffic is expected from the device

  • outgoing_fpga_connection (FPGAConnection or None) – The connection to an FPGA that packets to be sent to this device should be sent down, or None if no outgoing traffic is expected to be sent to the device.

  • label (str) – The optional name of the vertex.

  • n_machine_vertices_per_link (int) – The optional number of machine vertices to create for each FPGA link (1 by default)

Get the slice to be given to the connection from the given link.

Parameters:
  • link (FPGAConnection) – The FPGA connection to get the slice for

  • index (int) – The index of the connection on the FGPA link, for when n_machine_vertices_per_link > 1

Return type:

Slice

Get the link data for outgoing connections from the machine.

Parameters:

machine (Machine) – The machine to get the link data from

Return type:

AbstractLinkData

get_outgoing_slice()[source]

Get the slice to be given to the outgoing connection.

Return type:

Slice

property incoming_fpga_connections

The connections from one or more FPGAs that packets are expected to be received from for this device.

Return type:

iterable(FPGAConnection)

property n_atoms

The number of atoms in the vertex.

Return type:

int

The number of machine vertices to create for each link of the FPGA.

Return type:

int

property outgoing_fpga_connection

The connection to one FPGA via one link to which packets are sent to this device.

Return type:

FPGAConnection or None

class pacman.model.graphs.application.ApplicationGraph[source]

Bases: object

An application-level abstraction of a graph.

add_edge(edge, outgoing_edge_partition_name)[source]

Add an edge to the graph and its partition.

If required and possible will create a new partition in the graph

Parameters:
  • edge (ApplicationEdge) – The edge to add

  • outgoing_edge_partition_name (str) – The name of the edge partition to add the edge to; each edge partition is the partition of edges that start at the same vertex

Returns:

The partition the edge was added to.

Return type:

AbstractEdgePartition

Raises:

PacmanInvalidParameterException – If the edge is not of a valid type or if edges have already been added to this partition that start at a different vertex to this one

add_vertex(vertex)[source]

Add a vertex to the graph.

Parameters:

vertex (ApplicationVertex) – The vertex to add

Raises:
property edges

The edges in the graph.

Return type:

iterable(AbstractEdge)

get_outgoing_edge_partition_starting_at_vertex(vertex, outgoing_edge_partition_name)[source]

Get the given outgoing edge partition that starts at the given vertex, or None if no such edge partition exists.

Parameters:
  • vertex (AbstractVertex) – The vertex at the start of the edges in the partition

  • outgoing_edge_partition_name (str) – The name of the edge partition

Returns:

The named edge partition, or None if no such partition exists

Return type:

AbstractEdgePartition or None

get_outgoing_edge_partitions_starting_at_vertex(vertex)[source]

Get all the edge partitions that start at the given vertex.

Parameters:

vertex (AbstractVertex) – The vertex at which the edge partitions to find starts

Return type:

iterable(AbstractEdgePartition)

property n_outgoing_edge_partitions

The number of outgoing edge partitions in the graph.

Return type:

int

property n_vertices

The number of vertices in the graph.

Return type:

int

property outgoing_edge_partitions

The edge partitions in the graph.

Return type:

iterable(AbstractEdgePartition)

reset()[source]

Reset all the application vertices.

vertex_by_label(label)[source]
property vertices

The vertices in the graph.

Return type:

iterable(AbstractVertex)

class pacman.model.graphs.application.ApplicationSpiNNakerLinkVertex(n_atoms, spinnaker_link_id, board_address=None, label=None, n_machine_vertices=1, incoming=True, outgoing=True)[source]

Bases: ApplicationVirtualVertex

A virtual application vertex on a SpiNNaker Link.

Parameters:
  • n_atoms (int) – The number of atoms in the vertex

  • spinnaker_link_id (int) – The index of the spinnaker link to which the device is connected

  • board_address (str) – The optional IP address of the board to which the device is connected e.g. in a multi-board system

  • label (str) – The optional name of the vertex.

property board_address

The board to which this device is connected, or None for the default board.

Return type:

str or None

get_incoming_slice(index)[source]

Get the slice to be given to the connection.

Parameters:

index (int) – The index of the connection, for when n_machine_vertices > 1

Return type:

Slice

get_max_atoms_per_core()[source]

Gets the maximum number of atoms per core, which is either the number of atoms required across the whole application vertex, or a lower value set.

Return type:

int

Get the link data for outgoing connections from the machine.

Parameters:

machine (Machine) – The machine to get the link data from

Return type:

AbstractLinkData

get_outgoing_slice()[source]

Get the slice to be given to the outgoing connection.

Return type:

Slice

property incoming
property n_atoms

The number of atoms in the vertex.

Return type:

int

property n_machine_vertices

The number of machine vertices to create.

Return type:

int

property outgoing

The SpiNNaker link to which this device is connected.

Return type:

int

class pacman.model.graphs.application.ApplicationVertex(label=None, max_atoms_per_core=None, splitter=None)[source]

Bases: AbstractVertex

A vertex that can be broken down into a number of smaller vertices based on the resources that the vertex requires.

Parameters:
  • label (str) – The optional name of the vertex.

  • max_atoms_per_core (None or int or tuple(int,...)) – The max number of atoms that can be placed on a core for each dimension, used in partitioning. If the vertex is n-dimensional, with n > 1, the value must be a tuple with a value for each dimension. If it is single-dimensional the value can be a 1-tuple or an int.

  • splitter (None or AbstractSplitterCommon) – The splitter object needed for this vertex. Leave as None to delegate the choice of splitter to the selector.

add_incoming_edge(edge, partition)[source]

Add an edge incoming to this vertex. This is ignored by default, but could be used to track incoming edges, and/or report faults.

Parameters:
property atoms_shape

The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.

Return type:

tuple(int, …)

get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

get_machine_fixed_key_and_mask(machine_vertex, partition_id)[source]

Get a fixed key and mask for the given machine vertex and partition identifier, or None if not fixed (the default).

If this doesn’t return None, get_fixed_key_and_mask() must also not return None, and the keys returned here must align with those such that for each key:mask returned here, key & app_mask == app_key. It is OK for this to return None and get_fixed_key_and_mask() to return non-None if and only if there is only one machine vertex.

Parameters:
  • machine_vertex (MachineVertex) – A source machine vertex of this application vertex

  • partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

get_max_atoms_per_core()[source]

Gets the maximum number of atoms per core, which is either the number of atoms required across the whole application vertex, or a lower value set.

Return type:

int

get_max_atoms_per_dimension_per_core()[source]

Gets the maximum number of atoms per dimension per core. This will return a tuple with a number for each dimension of the vertex, which might be one if this is a single-dimension vertex.

Return type:

tuple(int,…)

property machine_vertices

The machine vertices that this application vertex maps to.

Return type:

iterable(MachineVertex)

abstract property n_atoms

The number of atoms in the vertex.

Return type:

int

remember_machine_vertex(machine_vertex)[source]

Adds the machine vertex to the iterable returned by machine_vertices

Parameters:

machine_vertex (MachineVertex) – A pointer to a machine_vertex

reset()[source]

Forget all machine vertices in the application vertex, and reset the splitter (if any).

round_n_atoms(n_atoms, label='n_atoms')[source]

Utility function to allow superclasses to make sure n_atoms is an integer.

Parameters:

n_atoms (int or float or numpy.) – Value convertible to int to be used for n_atoms

Returns:

Number of atoms.

Return type:

int

Raises:

PacmanInvalidParameterException – If the value cannot be safely converted to an integer

set_max_atoms_per_dimension_per_core(new_value)[source]

Set the maximum number of atoms per dimension per core.

Can be used to raise or lower the maximum number of atoms per core or per dimension per core.

Parameters:

new_value (None or int or tuple(int,...)) – Value to set. If the vertex is n-dimensional where n > 1, a tuple of n values must be given. If the vertex is 1 dimensional, a 1-tuple or integer can be given. If this is set to None the vertex will have atoms_shape as the maximum.

property splitter
Return type:

AbstractSplitterCommon

class pacman.model.graphs.application.ApplicationVirtualVertex(label=None, max_atoms_per_core=None, splitter=None)[source]

Bases: ApplicationVertex

An application vertex which is virtual.

Parameters:
  • label (str) – The optional name of the vertex.

  • max_atoms_per_core (None or int or tuple(int,...)) – The max number of atoms that can be placed on a core for each dimension, used in partitioning. If the vertex is n-dimensional, with n > 1, the value must be a tuple with a value for each dimension. If it is single-dimensional the value can be a 1-tuple or an int.

  • splitter (None or AbstractSplitterCommon) – The splitter object needed for this vertex. Leave as None to delegate the choice of splitter to the selector.

Get the link data for outgoing connections from the machine.

Parameters:

machine (Machine) – The machine to get the link data from

Return type:

AbstractLinkData

class pacman.model.graphs.application.FPGAConnection(fpga_id: int, fpga_link_id: int, board_address: str, chip_coords: tuple)[source]

Bases: tuple

A connection from or to an FPGA.

Create new instance of FPGAConnection(fpga_id, fpga_link_id, board_address, chip_coords)

property board_address

The IP address of the board with the FPGA, or None for the default board or if using chip_coords

property chip_coords

The coordinates of the chip connected to the FPGA, or None for the default board or if using board_address

property expanded

Get a list of concrete FPGA connections, where fpga_id and fpga_link_id are not None.

Return type:

iterable(FPGAConnection)

property fpga_id

The ID of the FPGA on the board (0, 1 or 2), or None for all of them

The ID of the link of the FPGA (0-15), or None for all of them

property is_concrete

Whether the connection has the FPGA id and link id set.

Return type:

bool

pacman.model.graphs.common package
Submodules
pacman.model.graphs.common.edge_traffic_type module
class pacman.model.graphs.common.edge_traffic_type.EdgeTrafficType(value)[source]

Bases: IntEnum

Indicates the traffic type of an Edge in a graph.

FIXED_ROUTE = 2

Edge communicates using fixed route packets

MULTICAST = 1

Edge communicates using multicast packets

SDRAM = 3

Edge communicates using shared memory

Module contents
class pacman.model.graphs.common.ChipAndCore(x, y, p=None)[source]

Bases: object

A constraint to place a vertex on a specific chip and, optionally, a specific core on that chip.

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

  • y (int) – the y-coordinate of the chip

  • p (int or None) – the processor (if any) of the chip

property p

The processor on the chip, or None if that is not constrained.

Return type:

int or None

property x

The X-coordinate of the chip.

Return type:

int

property y

The Y-coordinate of the chip.

Return type:

int

class pacman.model.graphs.common.MDSlice(lo_atom, hi_atom, shape, start, atoms_shape)[source]

Bases: Slice

Represents a multi-dimensional slice of a vertex.

Parameters:
  • lo_atom (int) – Index of the lowest atom to represent.

  • hi_atom (int) – Index of the highest atom to represent.

  • shape (tuple(int,...)) – The size of each dimension in the slice.

  • start (tuple(int,...)) – The offset to the start index along each dimension.

  • atoms_shape (list(int)) – The shape of atoms (?)

Raises:

PacmanValueError – If the bounds of the slice are invalid.

property as_slice

Converts the Slice to a standard slice object if possible.

Note

Use of this method is not recommended. It fails for multi-dimensional slices and may be removed.

Returns:

a standard built-in slice object

Return type:

slice

Raises:

NotImplementedError – If called on a multi-dimensional slice

property dimension

Get directions or edges as slices for every dimension

This is the width and if available height, depth, etc., of the Slice/Grid as represented as slices form the origin along in that direction.

Return type:

tuple(slice, …)

property end

The end positions of the slice in each dimension

Return type:

tuple(int, …)

classmethod from_string(as_str)[source]

Convert the string form of a MDSlice into an object instance.

Parameters:

as_str (str) – The string to parse

Return type:

MDSlice

get_ids_as_slice_or_list()[source]

Returns the IDs as a built-in slice if possible, otherwise as a list of IDs.

Returns:

a slice or list of IDs

Return type:

slice or list(int)

get_raster_ids()[source]

Get the IDs of the atoms in the slice as they would appear in a “raster scan” of the atoms over the whole shape.

Returns:

A list of the global raster IDs of the atoms in this slice

Return type:

ndarray

get_slice(n)[source]

Get a slice in the n’th dimension

Parameters:

n (int) – The 0-indexed dimension to get the shape of

Type:

slice

property hi_atom

The highest atom represented in the slice.

Note

Use of this method is not recommended. It fails for multi-dimensional slices and may be removed

Return type:

int

property shape

The shape of the atoms over multiple dimensions. By default the shape will be 1-dimensional.

Return type:

tuple(int,…)

property start

The start coordinates of the slice. By default this will be lo_atom in 1 dimension.

Return type:

tuple(int,…)

class pacman.model.graphs.common.Slice(lo_atom, hi_atom)[source]

Bases: object

Represents a simple single-dimensional slice of a vertex.

Note

Multi-dimensional slices are supported by MDSlice.

Parameters:
  • lo_atom (int) – Index of the lowest atom to represent.

  • hi_atom (int) – Index of the highest atom to represent.

Raises:
property as_slice

Converts the Slice to a standard slice object if possible.

Note

Use of this method is not recommended. It fails for multi-dimensional slices and may be removed.

Returns:

a standard built-in slice object

Return type:

slice

Raises:

NotImplementedError – If called on a multi-dimensional slice

property dimension

Get directions or edges as slices for every dimension

This is the width and if available height, depth, etc., of the Slice/Grid as represented as slices form the origin along in that direction.

Return type:

tuple(slice, …)

property end

The end positions of the slice in each dimension

Return type:

tuple(int, …)

classmethod from_string(as_str)[source]

Convert the string form of a Slice into an object instance.

Parameters:

as_str (str) – The string to parse

Return type:

Slice

get_ids_as_slice_or_list()[source]

Returns the IDs as a built-in slice if possible, otherwise as a list of IDs.

Returns:

a slice or list of IDs

Return type:

slice or list(int)

get_raster_ids()[source]

Get the IDs of the atoms in the slice as they would appear in a “raster scan” of the atoms over the whole shape.

Returns:

A list of the global raster IDs of the atoms in this slice

Return type:

ndarray

get_slice(n)[source]

Get a slice in the n’th dimension.

Parameters:

n (int) – Must be 0

Type:

slice

property hi_atom

The highest atom represented in the slice.

Note

Use of this method is not recommended. It fails for multi-dimensional slices and may be removed

Return type:

int

property lo_atom

The lowest atom represented in the slice.

Return type:

int

property n_atoms

The number of atoms represented by the slice.

Return type:

int

property shape

The shape of the atoms over multiple dimensions. By default the shape will be 1-dimensional.

Return type:

tuple(int,…)

property start

The start coordinates of the slice. By default this will be lo_atom in 1 dimension.

Return type:

tuple(int,…)

pacman.model.graphs.machine package
Module contents
class pacman.model.graphs.machine.AbstractSDRAMPartition[source]

Bases: object

An edge partition that contains SDRAM edges.

abstract get_sdram_base_address_for(vertex)[source]

Get the SDRAM base address for a edge given which side the vertex is on.

Parameters:

vertex (MachineVertex) – the vertex to find SDRAM base address of

Returns:

the SDRAM address for this vertex

Return type:

int

abstract get_sdram_size_of_region_for(vertex)[source]

Get the size of the region for a vertex given a edge.

Parameters:

vertex (MachineVertex) – the vertex to find SDRAM size of

Returns:

the SDRAM size for this vertex

Return type:

int

abstract total_sdram_requirements()[source]

Get the total SDRAM required by this outgoing partition.

Returns:

int

class pacman.model.graphs.machine.ConstantSDRAMMachinePartition(identifier, pre_vertex)[source]

Bases: AbstractSingleSourcePartition, AbstractSDRAMPartition

An SDRAM partition that uses a fixed amount of memory. The edges in the partition must agree on how much memory is required.

Parameters:
  • identifier (str) – The identifier of the partition

  • allowed_edge_types (type or tuple(type, ...)) – The types of edges allowed

  • label (str) – An optional label of the partition

add_edge(edge)[source]

Add an edge to the edge partition.

Parameters:

edge (AbstractEdge) – the edge to add

Raises:

PacmanInvalidParameterException – If the edge does not belong in this edge partition

get_sdram_base_address_for(vertex)[source]

Get the SDRAM base address for a edge given which side the vertex is on.

Parameters:

vertex (MachineVertex) – the vertex to find SDRAM base address of

Returns:

the SDRAM address for this vertex

Return type:

int

get_sdram_size_of_region_for(vertex)[source]

Get the size of the region for a vertex given a edge.

Parameters:

vertex (MachineVertex) – the vertex to find SDRAM size of

Returns:

the SDRAM size for this vertex

Return type:

int

property sdram_base_address
total_sdram_requirements()[source]

Get the total SDRAM required by this outgoing partition.

Returns:

int

class pacman.model.graphs.machine.DestinationSegmentedSDRAMMachinePartition(identifier, pre_vertex)[source]

Bases: AbstractSingleSourcePartition, AbstractSDRAMPartition

An SDRAM partition that gives each edge its own slice of memory from a contiguous block. The edges all have the same source vertex.

Parameters:
  • identifier (str) – The identifier of the partition

  • allowed_edge_types (type or tuple(type, ...)) – The types of edges allowed

  • label (str) – An optional label of the partition

add_edge(edge)[source]

Add an edge to the edge partition.

Parameters:

edge (AbstractEdge) – the edge to add

Raises:

PacmanInvalidParameterException – If the edge does not belong in this edge partition

get_sdram_base_address_for(vertex)[source]

Get the SDRAM base address for a edge given which side the vertex is on.

Parameters:

vertex (MachineVertex) – the vertex to find SDRAM base address of

Returns:

the SDRAM address for this vertex

Return type:

int

get_sdram_size_of_region_for(vertex)[source]

Get the size of the region for a vertex given a edge.

Parameters:

vertex (MachineVertex) – the vertex to find SDRAM size of

Returns:

the SDRAM size for this vertex

Return type:

int

property sdram_base_address
total_sdram_requirements()[source]

Get the total SDRAM required by this outgoing partition.

Returns:

int

class pacman.model.graphs.machine.MachineEdge(pre_vertex, post_vertex, label=None)[source]

Bases: AbstractEdge

A simple implementation of a machine edge.

Parameters:
  • pre_vertex (MachineVertex) – The vertex at the start of the edge.

  • post_vertex (MachineVertex) – The vertex at the end of the edge.

  • label (str or None) – The name of the edge.

property label

The label of the edge.

Return type:

str

property post_vertex

The vertex at the end of the edge.

Return type:

MachineVertex

property pre_vertex

The vertex at the start of the edge.

Return type:

MachineVertex

class pacman.model.graphs.machine.MachineFPGAVertex(fpga_id, fpga_link_id, board_address=None, linked_chip_coordinates=None, label=None, app_vertex=None, vertex_slice=None, outgoing_keys_and_masks=None, incoming=True, outgoing=False)[source]

Bases: MachineVertex, AbstractVirtual

A virtual vertex on an FPGA link.

Parameters:
  • label (str or None) – The optional name of the vertex

  • app_vertex (ApplicationVertex or None) – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.

  • vertex_slice (Slice or None) – The slice of the application vertex that this machine vertex implements.

Raises:
property board_address

The IP address of the board to which the device is connected, or None for the boot board, or when using linked chip coordinates.

Return type:

str or None

property fpga_id

Get link data from the machine.

Parameters:

machine (Machine) – The machine to get the data from

Return type:

AbstractLinkData

property incoming

Whether this device sends traffic into SpiNNaker.

Return type:

bool

property linked_chip_coordinates

The coordinates of the chip to which the device is connected, or None for the boot board, or when using a board address.

Return type:

tuple(int, int) or None

property outgoing

Whether this device receives traffic from SpiNNaker.

Return type:

bool

outgoing_keys_and_masks()[source]

Get the keys sent by the device or None if there aren’t any explicitly defined.

Return type:

list(BaseKeyAndMask) or None

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

class pacman.model.graphs.machine.MachineSpiNNakerLinkVertex(spinnaker_link_id, board_address=None, linked_chip_coordinates=None, label=None, app_vertex=None, vertex_slice=None, outgoing_keys_and_masks=None, incoming=True, outgoing=False)[source]

Bases: MachineVertex, AbstractVirtual

A virtual vertex on a SpiNNaker Link.

Parameters:
  • label (str or None) – The optional name of the vertex

  • app_vertex (ApplicationVertex or None) – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.

  • vertex_slice (Slice or None) – The slice of the application vertex that this machine vertex implements.

Raises:
property board_address

The IP address of the board to which the device is connected, or None for the boot board, or when using linked chip coordinates.

Return type:

str or None

Get link data from the machine.

Parameters:

machine (Machine) – The machine to get the data from

Return type:

AbstractLinkData

property incoming

Whether this device sends traffic into SpiNNaker.

Return type:

bool

property linked_chip_coordinates

The coordinates of the chip to which the device is connected, or None for the boot board, or when using a board address.

Return type:

tuple(int, int) or None

property outgoing

Whether this device receives traffic from SpiNNaker.

Return type:

bool

outgoing_keys_and_masks()[source]

Get the keys sent by the device or None if there aren’t any explicitly defined.

Return type:

list(BaseKeyAndMask) or None

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

class pacman.model.graphs.machine.MachineVertex(label=None, app_vertex=None, vertex_slice=None)[source]

Bases: AbstractVertex

A machine graph vertex.

Parameters:
  • label (str or None) – The optional name of the vertex

  • app_vertex (ApplicationVertex or None) – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.

  • vertex_slice (Slice or None) – The slice of the application vertex that this machine vertex implements.

Raises:
property app_vertex

The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.

Return type:

ApplicationVertex or None

get_fixed_location()[source]

The x, y and possibly p the vertex must be placed on.

Typically None! Does not have the value of a normal placements.

Used instead of ChipAndCoreConstraint.

Return type:

None or ChipAndCore

Note

If the Machine vertex has no fixed_location but does have an app_vertex, app_vertex.fixed_location is used. If both have a fixed_location the app level is ignored!

get_n_keys_for_partition(partition_id)[source]

Get the number of keys required by the given partition of edges.

Parameters:

partition_id (str) – The identifier of the partition; the partition_id param is only used by some MachineVertex subclasses

Returns:

The number of keys required

Return type:

int

property index

The index into the collection of machine vertices for an application vertex.

Return type:

int

property iptags

The IPTags used by this vertex, if any.

Return type:

iterable(IPtagResource)

property reverse_iptags

The ReverseIPTags used by this vertex, if any.

Return type:

iterable(ReverseIPtagResource)

abstract property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

property vertex_slice

The slice of the application vertex that this machine vertex implements.

Return type:

Slice

class pacman.model.graphs.machine.MulticastEdgePartition(pre_vertex, identifier)[source]

Bases: AbstractSingleSourcePartition

A simple implementation of a machine edge partition that will communicate with SpiNNaker multicast packets. They have a common set of sources with the same semantics and so can share a single key.

Parameters:
  • pre_vertex (MachineVertex) – the pre vertex of this partition.

  • identifier (str) – The identifier of the partition

class pacman.model.graphs.machine.SDRAMMachineEdge(pre_vertex, post_vertex, label)[source]

Bases: MachineEdge

Parameters:
  • pre_vertex (MachineVertex) – The vertex at the start of the edge.

  • post_vertex (MachineVertex) – The vertex at the end of the edge.

  • label (str or None) – The name of the edge.

property sdram_base_address
property sdram_size
class pacman.model.graphs.machine.SimpleMachineVertex(sdram, label=None, app_vertex=None, vertex_slice=None, iptags=None, reverse_iptags=None)[source]

Bases: MachineVertex

A MachineVertex that stores its own resources.

This class is mainly intended for JSON and testing as it support the minimal API. If a more complex Vertex is required consider the MockMachineVertex.

Parameters:
  • label (str or None) – The optional name of the vertex

  • app_vertex (ApplicationVertex or None) – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.

  • vertex_slice (Slice or None) – The slice of the application vertex that this machine vertex implements.

Raises:
property iptags

The IPTags used by this vertex, if any.

Return type:

iterable(IPtagResource)

property reverse_iptags

The ReverseIPTags used by this vertex, if any.

Return type:

iterable(ReverseIPtagResource)

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

class pacman.model.graphs.machine.SourceSegmentedSDRAMMachinePartition(identifier, pre_vertices)[source]

Bases: AbstractMultiplePartition, AbstractSDRAMPartition

An SDRAM partition that gives each edge its own slice of memory from a contiguous block. The edges all have the same destination vertex.

Parameters:
  • identifier (str) – The identifier of the partition

  • label (str) – A label of the partition

  • pre_vertices (iterable(AbstractVertex)) – The vertices that an edge in this partition may originate at

add_edge(edge)[source]

Add an edge to the edge partition.

Parameters:

edge (AbstractEdge) – the edge to add

Raises:

PacmanInvalidParameterException – If the edge does not belong in this edge partition

get_sdram_base_address_for(vertex)[source]

Get the SDRAM base address for a edge given which side the vertex is on.

Parameters:

vertex (MachineVertex) – the vertex to find SDRAM base address of

Returns:

the SDRAM address for this vertex

Return type:

int

get_sdram_size_of_region_for(vertex)[source]

Get the size of the region for a vertex given a edge.

Parameters:

vertex (MachineVertex) – the vertex to find SDRAM size of

Returns:

the SDRAM size for this vertex

Return type:

int

property sdram_base_address
Return type:

int

total_sdram_requirements()[source]
Return type:

int

Module contents
class pacman.model.graphs.AbstractEdge[source]

Bases: object

A directed edge in a graph between two vertices.

abstract property label

The label of the edge.

Return type:

str

abstract property post_vertex

The vertex at the end of the edge.

Return type:

AbstractVertex

abstract property pre_vertex

The vertex at the start of the edge.

Return type:

AbstractVertex

class pacman.model.graphs.AbstractEdgePartition(identifier, allowed_edge_types)[source]

Bases: object

A collection of edges which start at a single vertex which have the same semantics and so can share a single key or block of SDRAM (depending on edge type).

Parameters:
  • identifier (str) – The identifier of the partition

  • allowed_edge_types (type or tuple(type, ...)) – The types of edges allowed

  • label (str) – An optional label of the partition

add_edge(edge)[source]

Add an edge to the edge partition.

Parameters:

edge (AbstractEdge) – the edge to add

Raises:

PacmanInvalidParameterException – If the edge does not belong in this edge partition

property edges

The edges in this edge partition.

Note

The order in which the edges are added is preserved for when they are requested later. If not, please talk to the software team.

Return type:

iterable(AbstractEdge)

property identifier

The identifier of this edge partition.

Return type:

str

property n_edges

The number of edges in the edge partition.

Return type:

int

abstract property pre_vertices

The vertices associated with this partition.

Note

Most edge partitions will be AbstractSingleSourcePartition and therefore provide the pre_vertex method.

Return type:

iterable(AbstractVertex)

class pacman.model.graphs.AbstractMultiplePartition(pre_vertices, identifier, allowed_edge_types)[source]

Bases: AbstractEdgePartition

An edge partition that has multiple source vertices.

Parameters:
  • identifier (str) – The identifier of the partition

  • allowed_edge_types (type or tuple(type, ...)) – The types of edges allowed

  • label (str) – An optional label of the partition

add_edge(edge)[source]

Add an edge to the edge partition.

Parameters:

edge (AbstractEdge) – the edge to add

Raises:

PacmanInvalidParameterException – If the edge does not belong in this edge partition

property pre_vertices

The vertices associated with this partition.

Note

Most edge partitions will be AbstractSingleSourcePartition and therefore provide the pre_vertex method.

Return type:

iterable(AbstractVertex)

class pacman.model.graphs.AbstractSingleSourcePartition(pre_vertex, identifier, allowed_edge_types)[source]

Bases: AbstractEdgePartition

An edge partition that has a single source vertex.

Parameters:
  • identifier (str) – The identifier of the partition

  • allowed_edge_types (type or tuple(type, ...)) – The types of edges allowed

  • label (str) – An optional label of the partition

add_edge(edge)[source]

Add an edge to the edge partition.

Parameters:

edge (AbstractEdge) – the edge to add

Raises:

PacmanInvalidParameterException – If the edge does not belong in this edge partition

property pre_vertex

The vertex at which all edges in this outgoing edge partition start.

Return type:

AbstractVertex

property pre_vertices

The vertices associated with this partition.

Note

Most edge partitions will be AbstractSingleSourcePartition and therefore provide the pre_vertex method.

Return type:

iterable(AbstractVertex)

class pacman.model.graphs.AbstractSupportsSDRAMEdges[source]

Bases: object

Marks a machine vertex that can have SDRAM edges attached to it.

abstract sdram_requirement(sdram_machine_edge)[source]

Asks a machine vertex for the SDRAM requirement it needs.

Parameters:

sdram_machine_edge (SDRAMMachineEdge) – The SDRAM edge in question

Returns:

The size in bytes this vertex needs for the SDRAM edge.

Return type:

int (most likely a multiple of 4)

class pacman.model.graphs.AbstractVertex(label=None)[source]

Bases: object

A vertex in a graph.

Parameters:

label (str) – The optional name of the vertex

addedToGraph()[source]

Records that the vertex has been added to a graph.

Raises:

PacmanConfigurationException – If there is an attempt to add the same vertex more than once

get_fixed_location()[source]

The x, y and possibly p the vertex must be placed on.

Typically None! Does not have the value of a normal placements.

Used instead of ChipAndCoreConstraint.

Return type:

None or ChipAndCore

property label

The current label to the vertex.

This label could change when the vertex is added to the graph.

Return type:

str

set_fixed_location(x, y, p=None)[source]

Set the location where the vertex must be placed.

Note

If called, must be called prior to the placement algorithms.

Parameters:
  • x (int) – X coordinate of fixed location

  • y (int) – Y coordinate of fixed location

  • p (int) – Processor ID of fixed location

Raises:

PacmanConfigurationException – If a fixed location has already been set to a different location.

set_label(label)[source]

Changes the label for a vertex not yet added to a graph.

Parameters:

label (str) – new value for the label

Raises:

PacmanConfigurationException – If there is an attempt to change the label once the vertex has been added to a graph

class pacman.model.graphs.AbstractVirtual[source]

Bases: object

A vertex which exists outside of the machine, allowing a graph to formally participate in I/O.

Note

Everything that is an instance of AbstractVirtual is also an instance of AbstractVertex.

abstract property board_address

The IP address of the board to which the device is connected, or None for the boot board, or when using linked chip coordinates.

Return type:

str or None

Get link data from the machine.

Parameters:

machine (Machine) – The machine to get the data from

Return type:

AbstractLinkData

abstract property incoming

Whether this device sends traffic into SpiNNaker.

Return type:

bool

abstract property linked_chip_coordinates

The coordinates of the chip to which the device is connected, or None for the boot board, or when using a board address.

Return type:

tuple(int, int) or None

abstract property outgoing

Whether this device receives traffic from SpiNNaker.

Return type:

bool

abstract outgoing_keys_and_masks()[source]

Get the keys sent by the device or None if there aren’t any explicitly defined.

Return type:

list(BaseKeyAndMask) or None

pacman.model.partitioner_interfaces package
Module contents

Legacy interfaces that vertices may implement to support splitters that work using the old model of partitioning.

class pacman.model.partitioner_interfaces.LegacyPartitionerAPI[source]

Bases: object

API used by the vertices which don’t have their own splitters but use what master did before the self partitioning stuff came to be.

Warning

Subclasses of this class must also be subclasses of ApplicationVertex. This is not enforced because of issues with import order, but is required; PACMAN assumes it to be true.

static abstract_methods()[source]

Exposes the abstract methods and properties defined in this class.

:rtype frozenset(str)

abstract create_machine_vertex(vertex_slice, sdram, label=None)[source]

Create a machine vertex from this application vertex.

Parameters:
  • vertex_slice (Slice) – The slice of atoms that the machine vertex will cover.

  • sdram (AbstractSDRAM) – The SDRAM used by the machine vertex.

  • label (str or None) – human readable label for the machine vertex

Returns:

The created machine vertex

Return type:

MachineVertex

abstract get_sdram_used_by_atoms(vertex_slice)[source]

Get the separate SDRAM requirements for a range of atoms.

Parameters:

vertex_slice (Slice) – the low value of atoms to calculate resources from

Return type:

AbstractSDRAM

pacman.model.partitioner_splitters package
Submodules
pacman.model.partitioner_splitters.splitter_reset module
pacman.model.partitioner_splitters.splitter_reset.splitter_reset()[source]

Performs resetting of splitters to indicate a new phase of operation.

Module contents

Basic implementations of a selection of splitters. Splitters are responsible for taking an application vertex and creating one or more machine vertices that implement the functionality, together with the edges to internally connect those vertices up (if needed).

class pacman.model.partitioner_splitters.AbstractSplitterCommon[source]

Bases: object

Common base class for vertex splitters, defining some utility methods.

abstract create_machine_vertices(chip_counter)[source]

Method for specific splitter objects to override.

Parameters:

chip_counter (ChipCounter) – counter of used chips

abstract get_in_coming_slices()[source]

The slices of the input vertices.

Returns:

list of Slices

Return type:

list(Slice)

abstract get_in_coming_vertices(partition_id)[source]

Get machine post-vertices for a given partition.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method returns all that could be used for any source machine vertex in the given partition.

Parameters:

partition_id (str) – The identifier of the incoming partition

Return type:

list(MachineVertex)

get_internal_multicast_partitions()[source]

Get edge partitions between machine vertices that are to be handled by Multicast. Returns empty by default, override if there are Multicast connections between internal vertices

Return type:

list(MulticastEdgePartition)

get_internal_sdram_partitions()[source]

Get edge partitions between machine vertices that are to be handled by SDRAM. Returns empty by default, override if there are SDRAM connections between internal vertices

Return type:

list(AbstractSDRAMPartition)

abstract get_out_going_slices()[source]

The slices of the output vertices.

Returns:

list of Slices

Return type:

list(Slice)

abstract get_out_going_vertices(partition_id)[source]

Get machine pre-vertices.

The output vertices are the ones that will serve as source vertices for external edges.

Parameters:

partition_id (str) – The identifier of the outgoing partition

Return type:

list(MachineVertex)

get_same_chip_groups()[source]

Get a list of lists of vertices and SDRAM which must be allocated on the same chip. By default this returns a list of each machine vertex and its SDRAM; override if there are groups of machine vertices on the same chip.

Return type:

list(list(MachineVertex), AbstractSDRAM)

get_source_specific_in_coming_vertices(source_vertex, partition_id)[source]

Get machine post-vertices for a given source.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method allows filtering of the targets for a specific source machine vertex.

This default method makes every machine vertex a target for the source. This should be overridden if there are specific machine vertices for any given source vertex.

Parameters:
  • source_vertex (ApplicationVertex) – The source to get incoming vertices for

  • partition_id (str) – The identifier of the incoming partition

Returns:

A list of tuples of (target machine vertex, list of source machine or application vertices that should hit the target)

Return type:

list(tuple(MachineVertex, list(MachineVertex or ApplicationVertex)))

property governed_app_vertex

The app vertex to be governed by this splitter object. If None, not yet set.

Return type:

ApplicationVertex

abstract machine_vertices_for_recording(variable_to_record)[source]

Gets the machine vertices which are recording this variable.

Parameters:

variable_to_record (str) – the variable to get machine vertices for.

Returns:

list of machine vertices

Return type:

iterable(MachineVertex)

abstract reset_called()[source]

Reset the splitter to be as if it has not operated a splitting yet.

set_governed_app_vertex(app_vertex)[source]

Sets a application vertex to be governed by this splitter object. Once set it can’t be reset.

Parameters:

app_vertex (ApplicationVertex) – the app vertex to govern

Raises:

PacmanConfigurationException – if the app vertex has already been set.

class pacman.model.partitioner_splitters.SplitterExternalDevice[source]

Bases: AbstractSplitterCommon

A splitter for handling external devices.

create_machine_vertices(chip_counter)[source]

Method for specific splitter objects to override.

Parameters:

chip_counter (ChipCounter) – counter of used chips

get_in_coming_slices()[source]

The slices of the input vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_in_coming_vertices(partition_id)[source]

Get machine post-vertices for a given partition.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method returns all that could be used for any source machine vertex in the given partition.

Parameters:

partition_id (str) – The identifier of the incoming partition

Return type:

list(MachineVertex)

get_out_going_slices()[source]

The slices of the output vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_out_going_vertices(partition_id)[source]

Get machine pre-vertices.

The output vertices are the ones that will serve as source vertices for external edges.

Parameters:

partition_id (str) – The identifier of the outgoing partition

Return type:

list(MachineVertex)

machine_vertices_for_recording(variable_to_record)[source]

Gets the machine vertices which are recording this variable.

Parameters:

variable_to_record (str) – the variable to get machine vertices for.

Returns:

list of machine vertices

Return type:

iterable(MachineVertex)

reset_called()[source]

Reset the splitter to be as if it has not operated a splitting yet.

set_governed_app_vertex(app_vertex)[source]

Sets a application vertex to be governed by this splitter object. Once set it can’t be reset.

Parameters:

app_vertex (ApplicationVertex) – the app vertex to govern

Raises:

PacmanConfigurationException – if the app vertex has already been set.

class pacman.model.partitioner_splitters.SplitterFixedLegacy[source]

Bases: AbstractSplitterCommon

Splitter for old-style vertices.

create_machine_vertices(chip_counter)[source]

Method for specific splitter objects to override.

Parameters:

chip_counter (ChipCounter) – counter of used chips

get_in_coming_slices()[source]

The slices of the input vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_in_coming_vertices(partition_id)[source]

Get machine post-vertices for a given partition.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method returns all that could be used for any source machine vertex in the given partition.

Parameters:

partition_id (str) – The identifier of the incoming partition

Return type:

list(MachineVertex)

get_out_going_slices()[source]

The slices of the output vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_out_going_vertices(partition_id)[source]

Get machine pre-vertices.

The output vertices are the ones that will serve as source vertices for external edges.

Parameters:

partition_id (str) – The identifier of the outgoing partition

Return type:

list(MachineVertex)

machine_vertices_for_recording(variable_to_record)[source]

Gets the machine vertices which are recording this variable.

Parameters:

variable_to_record (str) – the variable to get machine vertices for.

Returns:

list of machine vertices

Return type:

iterable(MachineVertex)

reset_called()[source]

Reset the splitter to be as if it has not operated a splitting yet.

set_governed_app_vertex(app_vertex)[source]

Sets a application vertex to be governed by this splitter object. Once set it can’t be reset.

Parameters:

app_vertex (ApplicationVertex) – the app vertex to govern

Raises:

PacmanConfigurationException – if the app vertex has already been set.

class pacman.model.partitioner_splitters.SplitterOneAppOneMachine[source]

Bases: AbstractSplitterCommon

Splitter that handles AbstractOneAppOneMachineVertex vertices.

create_machine_vertices(chip_counter)[source]

Method for specific splitter objects to override.

Parameters:

chip_counter (ChipCounter) – counter of used chips

get_in_coming_slices()[source]

The slices of the input vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_in_coming_vertices(partition_id)[source]

Get machine post-vertices for a given partition.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method returns all that could be used for any source machine vertex in the given partition.

Parameters:

partition_id (str) – The identifier of the incoming partition

Return type:

list(MachineVertex)

get_out_going_slices()[source]

The slices of the output vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_out_going_vertices(partition_id)[source]

Get machine pre-vertices.

The output vertices are the ones that will serve as source vertices for external edges.

Parameters:

partition_id (str) – The identifier of the outgoing partition

Return type:

list(MachineVertex)

machine_vertices_for_recording(variable_to_record)[source]

Gets the machine vertices which are recording this variable.

Parameters:

variable_to_record (str) – the variable to get machine vertices for.

Returns:

list of machine vertices

Return type:

iterable(MachineVertex)

reset_called()[source]

Reset the splitter to be as if it has not operated a splitting yet.

set_governed_app_vertex(app_vertex)[source]

Sets a application vertex to be governed by this splitter object. Once set it can’t be reset.

Parameters:

app_vertex (ApplicationVertex) – the app vertex to govern

Raises:

PacmanConfigurationException – if the app vertex has already been set.

class pacman.model.partitioner_splitters.SplitterOneToOneLegacy[source]

Bases: AbstractSplitterCommon

create_machine_vertices(chip_counter)[source]

Method for specific splitter objects to override.

Parameters:

chip_counter (ChipCounter) – counter of used chips

get_in_coming_slices()[source]

The slices of the input vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_in_coming_vertices(partition_id)[source]

Get machine post-vertices for a given partition.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method returns all that could be used for any source machine vertex in the given partition.

Parameters:

partition_id (str) – The identifier of the incoming partition

Return type:

list(MachineVertex)

get_out_going_slices()[source]

The slices of the output vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_out_going_vertices(partition_id)[source]

Get machine pre-vertices.

The output vertices are the ones that will serve as source vertices for external edges.

Parameters:

partition_id (str) – The identifier of the outgoing partition

Return type:

list(MachineVertex)

machine_vertices_for_recording(variable_to_record)[source]

Gets the machine vertices which are recording this variable.

Parameters:

variable_to_record (str) – the variable to get machine vertices for.

Returns:

list of machine vertices

Return type:

iterable(MachineVertex)

reset_called()[source]

Reset the splitter to be as if it has not operated a splitting yet.

set_governed_app_vertex(app_vertex)[source]

Sets a application vertex to be governed by this splitter object. Once set it can’t be reset.

Parameters:

app_vertex (ApplicationVertex) – the app vertex to govern

Raises:

PacmanConfigurationException – if the app vertex has already been set.

pacman.model.placements package
Module contents
class pacman.model.placements.Placement(vertex, x, y, p)[source]

Bases: object

The placement of a vertex on to a machine chip and core.

Parameters:
  • vertex (MachineVertex) – The vertex that has been placed

  • x (int) – the x-coordinate of the chip on which the vertex is placed

  • y (int) – the y-coordinate of the chip on which the vertex is placed

  • p (int) – the ID of the processor on which the vertex is placed

property location

The (x,y,p) tuple that represents the location of this placement.

Return type:

tuple(int,int,int)

property p

The ID of the processor of the chip where the vertex is placed.

Return type:

int

property vertex

The vertex that was placed.

Return type:

MachineVertex

property x

The X-coordinate of the chip where the vertex is placed.

Return type:

int

property xy

The (x,y) tuple that represents the chip of this placement.

Return type:

tuple(int,int)

property y

The Y-coordinate of the chip where the vertex is placed.

Return type:

int

class pacman.model.placements.Placements(placements=None)[source]

Bases: object

The placements of vertices on the chips of the machine.

Parameters:

placements (iterable(Placement)) – Any initial placements

Raises:
add_placement(placement)[source]

Add a placement.

Parameters:

placement (Placement) – The placement to add

Raises:
add_placements(placements)[source]

Add some placements.

Parameters:

placements (iterable(Placement)) – The placements to add

property chips_with_placements

The chips with placements on them.

Return type:

iterable(tuple(int,int))

get_placement_of_vertex(vertex)[source]

Return the placement information for a vertex.

Parameters:

vertex (MachineVertex) – The vertex to find the placement of

Returns:

The placement

Return type:

Placement

Raises:

PacmanNotPlacedError – If the vertex has not been placed.

get_placement_on_processor(x, y, p)[source]

Get the placement on a specific processor, or raises an exception if the processor has not been allocated.

Parameters:
  • x (int) – the x coordinate of the chip

  • y (int) – the y coordinate of the chip

  • p (int) – the processor on the chip

Returns:

the placement on the given processor

Return type:

Placement

Raises:

PacmanProcessorNotOccupiedError – If the processor is not occupied

is_processor_occupied(x, y, p)[source]

Determine if a processor has a vertex on it.

Parameters:
  • x (int) – x coordinate of processor.

  • y (int) – y coordinate of processor.

  • p (int) – Index of processor.

Return bool:

Whether the processor has an assigned vertex.

is_vertex_placed(vertex)[source]

Determine if a vertex has been placed.

Parameters:

vertex (MachineVertex) – The vertex to determine the status of

Return type:

bool

iterate_placements_by_vertex_type(vertex_type)[source]

Iterate over placements on any chip with this vertex_type.

Parameters:

vertex_type (class) – Class of vertex to find

Return type:

iterable(Placement)

iterate_placements_by_xy_and_type(x, y, vertex_type)[source]

Iterate over placements with this x, y and this vertex_type.

Parameters:
  • x (int) – x coordinate to find placements for.

  • y (int) – y coordinate to find placements for.

  • vertex_type (class) – Class of vertex to find

Return type:

iterable(Placement)

iterate_placements_on_core(x, y)[source]

Iterate over placements with this x and y.

Parameters:
  • x (int) – x coordinate to find placements for.

  • y (int) – y coordinate to find placements for.

Return type:

iterable(Placement)

property n_placements

The number of placements.

Return type:

int

n_placements_on_chip(x, y)[source]

The number of placements on the given chip.

Parameters:
  • x (int) – x coordinate of chip.

  • y (int) – y coordinate of chip.

Return type:

int

property placements

All of the placements.

Returns:

iterable of placements

Return type:

iterable(Placement)

placements_on_chip(x, y)[source]

Get the placements on a specific chip.

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

  • y (int) – The y-coordinate of the chip

Return type:

iterable(Placement)

pacman.model.resources package
Module contents
class pacman.model.resources.AbstractSDRAM[source]

Bases: object

Represents an amount of SDRAM used on a chip in the machine.

abstract property fixed

The fixed SDRAM cost.

abstract get_total_sdram(n_timesteps)[source]

The total SDRAM.

Parameters:

n_timesteps (int) – number of timesteps to cost for

Returns:

abstract property per_timestep

The extra SDRAM cost for each additional timestep.

Warning

May well be zero.

abstract report(timesteps, indent='', preamble='', target=None)[source]

Writes a description of this SDRAM to the target.

Parameters:
  • timesteps (int) – Number of timesteps to do total cost for

  • indent (str) – Text at the start of this and all children

  • preamble (str) – Additional text at the start but not in children

  • target (file) – Where to write the output. None is standard print

abstract sub_from(other)[source]

Creates a new SDRAM which is the other less this one.

Parameters:

other (AbstractSDRAM) – another SDRAM resource

Returns:

a New AbstractSDRAM

Return type:

AbstractSDRAM

class pacman.model.resources.ConstantSDRAM(sdram)[source]

Bases: AbstractSDRAM

Represents an amount of SDRAM used on a chip in the machine.

This is used when the amount of SDRAM needed is not effected by runtime

Parameters:

sdram (int or int64) – The amount of SDRAM in bytes

property fixed

The fixed SDRAM cost.

get_total_sdram(n_timesteps)[source]

The total SDRAM.

Parameters:

n_timesteps (int) – number of timesteps to cost for

Returns:

property per_timestep

The extra SDRAM cost for each additional timestep.

Warning

May well be zero.

report(timesteps, indent='', preamble='', target=None)[source]

Writes a description of this SDRAM to the target.

Parameters:
  • timesteps (int) – Number of timesteps to do total cost for

  • indent (str) – Text at the start of this and all children

  • preamble (str) – Additional text at the start but not in children

  • target (file) – Where to write the output. None is standard print

sub_from(other)[source]

Creates a new SDRAM which is the other less this one.

Parameters:

other (AbstractSDRAM) – another SDRAM resource

Returns:

a New AbstractSDRAM

Return type:

AbstractSDRAM

class pacman.model.resources.ElementFreeSpace(start_address, size)[source]

Bases: object

Parameters:
  • start_address (int) –

  • size (int) –

property size
Return type:

int

property start_address
Return type:

int

class pacman.model.resources.IPtagResource(ip_address, port, strip_sdp, tag=None, traffic_identifier='DEFAULT')[source]

Bases: object

Represents the ability to have a SpiNNaker machine send messages to you during execution.

Parameters:
  • ip_address (str) – The IP address of the host that will receive data from this tag

  • port (int or None) – The port that will

  • strip_sdp (bool) – Whether the tag requires that SDP headers are stripped before transmission of data

  • tag (int or None) – A fixed tag ID to assign, or None if any tag is OK

  • traffic_identifier (str) – The traffic to be sent using this tag; traffic with the same traffic_identifier can be sent using the same tag

get_value()[source]
Returns:

The description of the IP tag.

Return type:

list(str, int, bool, int, str)

property ip_address

The IP address to assign to the tag.

Return type:

str

property port

The port of the tag.

Return type:

int

property strip_sdp

Whether SDP headers should be stripped for this tag.

Return type:

bool

property tag

The tag required, or None if any tag is OK.

Return type:

int or None

property traffic_identifier

The traffic identifier for this IP tag.

class pacman.model.resources.MultiRegionSDRAM[source]

Bases: VariableSDRAM

A resource for SDRAM that comes in regions.

Note

Adding or subtracting two MultiRegionSDRAM objects will be assumed to be an operation over multiple cores/placements so these functions return a VariableSDRAM object without the regions data.

To add extra SDRAM costs for the same core/placement use the methods add_cost() and merge()

Parameters:
  • fixed_sdram – The amount of SDRAM (in bytes) that represents static overhead

  • per_timestep_sdram (float or numpy.float) – The amount of SDRAM (in bytes) required per timestep. Often represents the space to record a timestep.

add_cost(region, fixed_sdram, per_timestep_sdram=0)[source]

Adds the cost for the specified region.

Parameters:
  • region (int or str or enum) – Key to identify the region

  • fixed_sdram (int or numpy.integer) – The fixed cost for this region.

  • per_timestep_sdram (int or numpy.integer) – The variable cost for this region is any

merge(other)[source]

Combines the other SDRAM costs keeping the region mappings.

Note

This method should only be called when combining cost for the same core/ placement. Use + to combine for different cores

Parameters:

other (MultiRegionSDRAM) – Another mapping of costs by region

nest(region, other)[source]

Combines the other SDRAM cost, in a nested fashion.

The totals for the new region are added to the total of this one. A new region is created summarising the cost of others. If other contains a regions which is the same as one in self they are not combined, but kept separate.

Parameters:
  • region (int or str or enum) – Key to identify the summary region

  • other (AbstractSDRAM) – Another SDRAM model to make combine by nesting

property regions

The map from region identifiers to the to the amount of SDRAM required.

Return type:

dict(int or str or enum, AbstractSDRAM)

report(timesteps, indent='', preamble='', target=None)[source]

Writes a description of this SDRAM to the target.

Parameters:
  • timesteps (int) – Number of timesteps to do total cost for

  • indent (str) – Text at the start of this and all children

  • preamble (str) – Additional text at the start but not in children

  • target (file) – Where to write the output. None is standard print

class pacman.model.resources.ReverseIPtagResource(port=None, sdp_port=1, tag=None)[source]

Bases: object

Represents the ability to talk to a SpiNNaker machine by sending UDP packets to it during execution.

Parameters:
  • port (int or None) – The UDP port to listen to on the board for this tag or None for a default

  • sdp_port (int) – The SDP port number to be used when constructing SDP packets from the received UDP packets for this tag

  • tag (int or None) – A fixed tag ID to assign, or None if any tag is OK

get_value()[source]
Returns:

The description of the reverse IP tag.

Return type:

list(int, int, int)

property port

The port of the tag.

Return type:

int

property sdp_port

The SDP port to use when constructing the SDP message from the received UDP message.

Return type:

int

property tag

The tag required, or None if any tag is OK.

Return type:

int or None

class pacman.model.resources.VariableSDRAM(fixed_sdram, per_timestep_sdram)[source]

Bases: AbstractSDRAM

Represents an amount of SDRAM used on a chip in the machine.

This is where the usage increase as the run time increases

Parameters:
  • fixed_sdram – The amount of SDRAM (in bytes) that represents static overhead

  • per_timestep_sdram (float or numpy.float) – The amount of SDRAM (in bytes) required per timestep. Often represents the space to record a timestep.

property fixed

The fixed SDRAM cost.

get_total_sdram(n_timesteps)[source]

The total SDRAM.

Parameters:

n_timesteps (int) – number of timesteps to cost for

Returns:

property per_timestep

The extra SDRAM cost for each additional timestep.

Warning

May well be zero.

report(timesteps, indent='', preamble='', target=None)[source]

Writes a description of this SDRAM to the target.

Parameters:
  • timesteps (int) – Number of timesteps to do total cost for

  • indent (str) – Text at the start of this and all children

  • preamble (str) – Additional text at the start but not in children

  • target (file) – Where to write the output. None is standard print

sub_from(other)[source]

Creates a new SDRAM which is the other less this one.

Parameters:

other (AbstractSDRAM) – another SDRAM resource

Returns:

a New AbstractSDRAM

Return type:

AbstractSDRAM

pacman.model.routing_info package
Submodules
pacman.model.routing_info.vertex_routing_info module
class pacman.model.routing_info.vertex_routing_info.VertexRoutingInfo(key_and_mask, partition_id)[source]

Bases: object

Associates a partition identifier to its routing information (keys and masks).

Parameters:
  • keys_and_masks (iterable(BaseKeyAndMask)) – The keys allocated to the machine partition

  • partition_id (str) – The partition to set the keys for

  • machine_vertex (MachineVertex) – The vertex to set the keys for

  • index (int) – The index of the machine vertex

get_keys(n_keys=None)[source]

Get the ordered list of individual keys allocated to the edge.

Parameters:

n_keys (int) – Optional limit on the number of keys to return

Returns:

An array of keys

Return type:

ndarray

property key

The first key (or only one if there is only one).

Return type:

int

property key_and_mask

The only key and mask.

Return type:

BaseKeyAndMask

property mask

The first mask (or only one if there is only one).

Return type:

int

property partition_id

The identifier of the partition.

Return type:

str

abstract property vertex

The vertex of the information.

Return type:

ApplicationVertex or MachineVertex

Module contents
class pacman.model.routing_info.AppVertexRoutingInfo(keys_and_masks, partition_id, app_vertex, machine_mask, n_bits_atoms, max_machine_index)[source]

Bases: VertexRoutingInfo

Parameters:
  • keys_and_masks (iterable(BaseKeyAndMask)) – The keys allocated to the machine partition

  • partition_id (str) – The partition to set the keys for

  • machine_vertex (MachineVertex) – The vertex to set the keys for

  • index (int) – The index of the machine vertex

property machine_mask

The mask that covers a specific machine vertex.

Return type:

int

merge_machine_entries(entries)[source]
property n_bits_atoms

The number of bits for the atoms.

Return type:

int

property vertex

The vertex of the information.

Return type:

ApplicationVertex or MachineVertex

class pacman.model.routing_info.BaseKeyAndMask(base_key, mask)[source]

Bases: object

A Key and Mask to be used for routing.

Parameters:
  • base_key (int) – The routing key

  • mask (int) – The routing mask

Raises:

PacmanConfigurationException – If key & mask != key i.e. the key is not valid for the given mask

get_keys(key_array=None, offset=0, n_keys=None)[source]

Get the ordered list of keys that the combination allows.

Parameters:
  • key_array (ndarray(int)) – Optional array into which the returned keys will be placed

  • offset (int) – Optional offset into the array at which to start placing keys

  • n_keys (int) – Optional limit on the number of keys returned. If less than this number of keys are available, only the keys available will be added

Returns:

A tuple of an array of keys and the number of keys added to the array

Return type:

tuple(ndarray(int), int)

property key

The base key.

Return type:

int

property key_combo

The key combined with the mask.

Return type:

int

property mask

The mask.

Return type:

int

property n_keys

The total number of keys that can be generated given the mask.

Return type:

int

class pacman.model.routing_info.MachineVertexRoutingInfo(keys_and_masks, partition_id, machine_vertex, index)[source]

Bases: VertexRoutingInfo

Associates a machine vertex and partition identifier to its routing information (keys and masks).

Parameters:
  • keys_and_masks (iterable(BaseKeyAndMask)) – The keys allocated to the machine partition

  • partition_id (str) – The partition to set the keys for

  • machine_vertex (MachineVertex) – The vertex to set the keys for

  • index (int) – The index of the machine vertex

property index

The index of the vertex.

Return type:

int

property machine_vertex

The machine vertex.

Return type:

MachineVertex

property vertex

The vertex of the information.

Return type:

ApplicationVertex or MachineVertex

class pacman.model.routing_info.RoutingInfo[source]

Bases: object

An association of machine vertices to a non-overlapping set of keys and masks.

add_routing_info(info)[source]

Add a routing information item.

Parameters:

info (VertexRoutingInfo) – The routing information item to add

Raises:

PacmanAlreadyExistsException – If the partition is already in the set of edges

get_first_key_from_pre_vertex(vertex, partition_id)[source]

Get the first key for the partition starting at a vertex.

Parameters:
  • vertex (AbstractVertex) – The vertex which the partition starts at

  • partition_id (str) – The ID of the partition for which to get the routing information

Returns:

The routing key of the partition

Return type:

int

get_routing_info_from_pre_vertex(vertex, partition_id)[source]

Get routing information for a given partition_id from a vertex.

Parameters:
  • vertex (AbstractVertex) – The vertex to search for

  • partition_id (str) – The ID of the partition for which to get the routing information

pacman.model.routing_table_by_partition package
Module contents
class pacman.model.routing_table_by_partition.MulticastRoutingTableByPartition[source]

Bases: object

A set of multicast routing path objects.

add_path_entry(entry, router_x, router_y, source_vertex, partition_id)[source]

Adds a multicast routing path entry.

Parameters:
get_entries_for_router(router_x, router_y)[source]

Get the set of multicast path entries assigned to this router.

Parameters:
  • router_x (int) – the X coordinate of the router

  • router_y (int) – the Y coordinate of the router

Returns:

all router_path_entries for the router.

Return type:

dict((ApplicationVertex or MachineVertex), str), MulticastRoutingTableByPartitionEntry)

get_entry_on_coords_for_edge(source_vertex, partition_id, router_x, router_y)[source]

Get an entry from a specific coordinate.

Parameters:
Return type:

MulticastRoutingTableByPartitionEntry or None

get_routers()[source]

Get the coordinates of all stored routers.

Return type:

iterable(tuple(int, int))

property n_routers

The number of routers stored.

Return type:

int

class pacman.model.routing_table_by_partition.MulticastRoutingTableByPartitionEntry(out_going_links, outgoing_processors, incoming_processor=None, incoming_link=None)[source]

Bases: object

An entry in a path of a multicast route.

Parameters:
  • out_going_links (iterable(int)) – the edges this path entry goes down, each of which is between 0 and 5

  • outgoing_processors (iterable(int)) – the processors this path entry goes to, each of which is between 0 and 17

  • incoming_processor (int) – the direction this entry came from (between 0 and 17)

  • incoming_link (int) – the direction this entry came from in link (between 0 and 5)

Raises:

PacmanInvalidParameterException

property defaultable

The defaultable status of the entry.

Return type:

bool

has_same_route(entry)[source]

The source link for this path entry.

Return type:

int or None

property incoming_processor

The source processor.

Return type:

int or None

The destination links of the entry.

Return type:

set(int)

merge_entry(other)[source]

Merges the another entry with this one and returns a new MulticastRoutingTableByPartitionEntry

Parameters:

other (MulticastRoutingTableByPartitionEntry) – the entry to merge into this one

Returns:

a merged MulticastRoutingTableByPartitionEntry

Raises:

PacmanInvalidParameterException

property processor_ids

The destination processors of the entry.

Return type:

set(int)

property spinnaker_route
pacman.model.routing_tables package
Module contents
class pacman.model.routing_tables.AbstractMulticastRoutingTable[source]

Bases: object

abstract property multicast_routing_entries

The multicast routing entries in the table.

Return type:

iterable(MulticastRoutingEntry)

abstract property number_of_defaultable_entries

The number of multicast routing entries that are set to be defaultable within this multicast routing table.

Return type:

int

abstract property number_of_entries

The number of multicast routing entries there are in the multicast routing table.

Return type:

int

abstract property x

The X-coordinate of the chip of this table.

Return type:

int

abstract property y

The Y-coordinate of the chip of this table.

Return type:

int

class pacman.model.routing_tables.CompressedMulticastRoutingTable(x, y, multicast_routing_entries=None)[source]

Bases: AbstractMulticastRoutingTable

Represents a compressed routing table for a chip.

Parameters:
  • x (int) – The x-coordinate of the chip for which this is the routing table

  • y (int) – The y-coordinate of the chip for which this is the routing tables

  • multicast_routing_entries (iterable(MulticastRoutingEntry)) – The routing entries to add to the table

Raises:

pacman.exceptions.PacmanAlreadyExistsException – If any two routing entries contain the same key-mask combination

add_multicast_routing_entry(multicast_routing_entry)[source]

Adds a routing entry to this table.

Parameters:

multicast_routing_entry (MulticastRoutingEntry) – The route to add

Raises:

pacman.exceptions.PacmanAlreadyExistsException – If a routing entry with the same key-mask combination already exists

property multicast_routing_entries

The multicast routing entries in the table.

Return type:

iterable(MulticastRoutingEntry)

property number_of_defaultable_entries

The number of multicast routing entries that are set to be defaultable within this multicast routing table.

Return type:

int

property number_of_entries

The number of multicast routing entries there are in the multicast routing table.

Return type:

int

property x

The X-coordinate of the chip of this table.

Return type:

int

property y

The Y-coordinate of the chip of this table.

Return type:

int

class pacman.model.routing_tables.MulticastRoutingTables(routing_tables=None)[source]

Bases: object

Represents the multicast routing tables for a number of chips.

Parameters:

routing_tables (iterable(MulticastRoutingTable)) – The routing tables to add

Raises:

PacmanAlreadyExistsException – If any two routing tables are for the same chip

add_routing_table(routing_table)[source]

Add a routing table.

Parameters:

routing_table (MulticastRoutingTable) – a routing table to add

Raises:

PacmanAlreadyExistsException – If a routing table already exists for the chip

get_routing_table_for_chip(x, y)[source]

Get a routing table for a particular chip.

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

  • y (int) – The Y-coordinate of the chip

Returns:

The routing table, or None if no such table exists

Return type:

MulticastRoutingTable or None

property max_number_of_entries

The maximum number of multicast routing entries there are in any multicast routing table.

Will return zero if there are no routing tables

Return type:

int

property routing_tables

The routing tables stored within.

Returns:

an iterable of routing tables

Return type:

iterable(MulticastRoutingTable)

class pacman.model.routing_tables.UnCompressedMulticastRoutingTable(x, y, multicast_routing_entries=None)[source]

Bases: AbstractMulticastRoutingTable

Represents a uncompressed routing table for a chip.

Parameters:
  • x (int) – The x-coordinate of the chip for which this is the routing table

  • y (int) – The y-coordinate of the chip for which this is the routing tables

  • multicast_routing_entries (iterable(MulticastRoutingEntry)) – The routing entries to add to the table

Raises:

PacmanAlreadyExistsException – If any two routing entries contain the same key-mask combination

add_multicast_routing_entry(multicast_routing_entry)[source]

Adds a routing entry to this table.

Parameters:

multicast_routing_entry (MulticastRoutingEntry) – The route to add

Raises:

PacmanAlreadyExistsException – If a routing entry with the same key-mask combination already exists

property multicast_routing_entries

The multicast routing entries in the table.

Return type:

iterable(MulticastRoutingEntry)

property number_of_defaultable_entries

The number of multicast routing entries that are set to be defaultable within this multicast routing table.

Return type:

int

property number_of_entries

The number of multicast routing entries there are in the multicast routing table.

Return type:

int

property x

The X-coordinate of the chip of this table.

Return type:

int

property y

The Y-coordinate of the chip of this table.

Return type:

int

pacman.model.tags package
Module contents
class pacman.model.tags.Tags[source]

Bases: object

Represents assigned IP Tag and Reverse IP Tags.

add_ip_tag(ip_tag, vertex)[source]

Add an IP tag.

Parameters:
  • ip_tag (IPTag) – The tag to add

  • vertex (MachineVertex) – The machine vertex by which the tag is to be used

Raises:

PacmanInvalidParameterException

  • If the combination of (board-address, tag) has already been assigned to an IP tag with different properties

  • If the combination of (board-address, tag) has already been assigned to a reverse IP tag

add_reverse_ip_tag(reverse_ip_tag, vertex)[source]

Add a reverse IP tag.

Parameters:
Raises:

PacmanInvalidParameterException

  • If the combination of (board-address, tag) has already been assigned to an IP tag or Reverse IP tag

  • If the port of the tag has already been assigned on the given board-address

get_ip_tags_for_vertex(vertex)[source]

Get the IP Tags assigned to a given machine vertex.

Parameters:

vertex (MachineVertex) – The vertex to get the tags for

Returns:

An iterable of IPTag, or None if the vertex has no tags

Return type:

iterable(IPTag) or None

get_reverse_ip_tags_for_vertex(vertex)[source]

Get the Reverse IP Tags assigned to a given machine vertex.

Parameters:

vertex (MachineVertex) – The vertex to get the tags for

Returns:

An iterable of ReverseIPTag, or None if the vertex has no tags

Return type:

iterable(ReverseIPTag) or None

property ip_tags

The IP tags assigned.

Return type:

iterable(IPTag)

property ip_tags_vertices

The list of (IPTag, vertex) pairs stored.

Return type:

iterable(tuple(IPTag, MachineVertex))

property reverse_ip_tags

The reverse IP tags assigned.

Return type:

iterable(ReverseIPTag)

Module contents
pacman.operations package
Subpackages
pacman.operations.fixed_route_router package
Module contents
pacman.operations.fixed_route_router.fixed_route_router(destination_class)[source]

Runs the fixed route generator for all boards on machine.

Parameters:

destination_class (type or tuple(type,...)) – the destination class to route packets to

Returns:

router tables for fixed route paths

Return type:

dict(tuple(int,int), FixedRouteEntry)

Raises:
pacman.operations.multi_cast_router_check_functionality package
Module contents
pacman.operations.multi_cast_router_check_functionality.validate_routes(placements, routing_tables)[source]

Go though the placements given and check that the routing entries within the routing tables support reach the correction destinations as well as not producing any cycles.

Parameters:
Raises:

PacmanRoutingException – when either no routing table entry is found by the search on a given router, or a cycle is detected

pacman.operations.partition_algorithms package
Module contents
pacman.operations.partition_algorithms.splitter_partitioner()[source]

Call the splitter of each application vertex to create the machine vertices needed.

Returns:

The number of chips needed to satisfy this partitioning.

Return type:

int

Raises:

PacmanPartitionException – If something goes wrong with the partitioning

pacman.operations.placer_algorithms package
Module contents
pacman.operations.placer_algorithms.place_application_graph(system_placements)[source]

Perform placement of an application graph on the machine.

Note

app_graph must have been partitioned

pacman.operations.router_algorithms package
Module contents
pacman.operations.router_algorithms.basic_dijkstra_routing(bw_per_route_entry=0.01, max_bw=250)[source]

Find routes between the edges with the allocated information, placed in the given places

Parameters:

use_progress_bar (bool) – whether to show a progress bar

Returns:

The discovered routes

Return type:

MulticastRoutingTables

Raises:

PacmanRoutingException – If something goes wrong with the routing

pacman.operations.router_algorithms.ner_route()[source]

basic NER router.

Returns:

a routing table by partition

Return type:

MulticastRoutingTableByPartition

pacman.operations.router_algorithms.ner_route_traffic_aware()[source]

traffic-aware NER router.

Returns:

a routing table by partition

Return type:

MulticastRoutingTableByPartition

pacman.operations.router_algorithms.route_application_graph()[source]

Route the current application graph.

pacman.operations.router_compressors package
Subpackages
pacman.operations.router_compressors.ordered_covering_router_compressor package
Module contents
Ordered Covering

An novel algorithm for the minimisation of SpiNNaker’s multicast routing tables devised by Andrew Mundy.

Background

SpiNNaker routing tables consist of entries made up of a 32-bit key, a 32-bit mask and a 24-bit route value. The key and mask of every entry act as a sieve for the keys found on incoming multicast packets. Each bit of the key-mask pair can be considered as matching 0, 1 or 2 values in the same bit of a multicast packet key:

Key

Mask

Matches Key Values

Written

0

0

0 or 1

X

0

1

0

0

1

1

1

1

1

0

Nothing

!

If a packet matches the key-mask of an entry then the packet is transmitted to the cores and links indicated by the route field.

For example, if the table were:

Key

Mask

Route

0000

1111

North, North East

0111

0111

South

Which, from now on, will be written as:

0000 -> N NE
X111 -> S

Then any packets with the key 0000 would be sent out of the north and north-east links. Any packets with the keys 0111 or 1111 would be sent out of the south link only.

Entries in table are ordered, with entries at the top of the table having higher priority than those lower down the table. Only the highest priority entry which matches a packet is used. If, for example, the table were:

0000 -> N NE
1111 -> 1 2
X111 -> S

Then packets with the keys 0000 and 0111 would be treated as before. However, packets with the key 1111 would be sent to cores 1 and 2 as only the higher priority entry has effect.

Merging routing table entries

Routing tables can be minimised by merging together entries with equivalent routes. This is done by creating a new key-mask pair with an X wherever the key-mask pairs of any of the original entries differed.

For example, merging of the entries:

0000 -> N
0001 -> N

Would lead to the new entry:

000X -> N

Which would match any of the keys matched by the original entries but no more. In contrast the merge of 0001 and 0010 would generate the new entry 00XX which would match keys matched by either of the original entries but also 0000 and 0011.

Clearly, if we are to attempt to minimise tables such as:

0001 -> N
0010 -> N
0000 -> S, SE
0011 -> SE

We need a set of rules for:

  1. Where merged entries are to be inserted into the table

  2. Which merges are allowed

“Ordered Covering”

The algorithm implemented here, “Ordered Covering”, provides the following rule:

  • The only merges allowed are those which:

    1. would not cause one of the entries in the merge to be “hidden” below an entry of lesser generality than the merged entry but which matched any of the same keys. For example, merging 0010 and 0001 would not be allowed if the new entry would be placed below the existing entry 000X as this would “hide” 0001.

    2. would not cause an entry “contained” within an entry of higher generality to be hidden by the insertion of a new entry. For example, if the entry XXXX had been formed by merging the entries 0011 and 1100 then merging of the entries 1101 and 1110 would not be allowed as it would cause the entry 11XX to be inserted above XXXX in the table and would hide 1100.

Following these rules ensures that the minimised table will be functionally equivalent to the original table provided that the original table was invariant under reordering OR was provided in increasing order of generality.

As a heuristic:

  • Routing tables are to be kept sorted in increasing order of “generality”, that is the number of X``s in the entry. An entry with the key-mask pair ``00XX must be placed below any entries with fewer X``s in their key-mask pairs (e.g., below ``0000 and 000X).

    1. New entries must also be inserted below any entries of the same generality. If XX00 were already present in the table the new entry 0XX0 must be inserted below it.

based on https://github.com/project-rig/rig/blob/master/rig/routing_table/ordered_covering.py

Implementation API
pacman.operations.router_compressors.ordered_covering_router_compressor.get_generality(key, mask)[source]

Count the number of Xs in the key-mask pair.

For example, there are 32 Xs in 0x00000000/0x00000000:

>>> get_generality(0x0, 0x0)
32

And no Xs in 0xffffffff/0xffffffff:

>>> get_generality(0xffffffff, 0xffffffff)
0
Parameters:
  • key (int) –

  • mask (int) –

Return type:

int

pacman.operations.router_compressors.ordered_covering_router_compressor.intersect(key_a, mask_a, key_b, mask_b)[source]

Return if key-mask pairs intersect (i.e., would both match some of the same keys).

For example, the key-mask pairs 00XX and 001X both match the keys 0010 and 0011 (i.e., they do intersect):

>>> intersect(0b0000, 0b1100, 0b0010, 0b1110)
True

But the key-mask pairs 00XX and 11XX do not match any of the same keys (i.e., they do not intersect):

>>> intersect(0b0000, 0b1100, 0b1100, 0b1100)
False
Parameters:
  • key_a (int) –

  • mask_a (int) – The first key-mask pair

  • key_b (int) –

  • mask_b (int) – The second key-mask pair

Return type:

bool

Returns:

True if the two key-mask pairs intersect, otherwise False.

pacman.operations.router_compressors.ordered_covering_router_compressor.minimise(routing_table, use_timer_cut_off=False, time_to_run_for_before_raising_exception=None)[source]

Reduce the size of a routing table by merging together entries where possible and by removing any remaining default routes.

Warning

The input routing table must also include entries which could be removed and replaced by default routing.

Warning

It is assumed that the input routing table is not in any particular order and may be reordered into ascending order of generality (number of don’t cares/Xs in the key-mask) without affecting routing correctness. It is also assumed that if this table is unordered it is at least orthogonal (i.e., there are no two entries which would match the same key) and reorderable.

Parameters:
  • routing_table (list(Entry)) – Routing entries to be merged.

  • use_timer_cut_off (bool) – flag for timing cut-off to be used.

  • time_to_run_for_before_raising_exception (int or None) – The time to run for in seconds before raising an exception

Returns:

The compressed table entries

Return type:

list(Entry)

Raises:

MinimisationFailedError – If the smallest table that can be produced is larger than target_length.

pacman.operations.router_compressors.ordered_covering_router_compressor.ordered_covering(routing_table, target_length, aliases=None, no_raise=False, use_timer_cut_off=False, time_to_run_for=None)[source]

Reduce the size of a routing table by merging together entries where possible.

Warning

The input routing table must also include entries which could be removed and replaced by default routing.

Warning

It is assumed that the input routing table is not in any particular order and may be reordered into ascending order of generality (number of don’t cares/Xs in the key-mask) without affecting routing correctness. It is also assumed that if this table is unordered it is at least orthogonal (i.e., there are no two entries which would match the same key) and reorderable.

Parameters:
  • routing_table (list(Entry)) – Routing entries to be merged.

  • target_length (int or None) – Target length of the routing table; the minimisation procedure will halt once either this target is reached or no further minimisation is possible. If None then the table will be made as small as possible.

  • aliases (dict(tuple(int, int), set(tuple(int, int))) – Dictionary of which keys and masks in the routing table are combinations of other (now removed) keys and masks; this allows us to consider only the keys and masks the user actually cares about when determining if inserting a new entry will break the correctness of the table. This should be supplied when using this method to update an already minimised table.

  • no_raise (bool) – If False (the default) then an error will be raised if the table cannot be minimised to be smaller than target_length and target_length is not None. If True then a table will be returned regardless of the size of the final table.

Returns:

new routing table, A new aliases dictionary.

Return type:

tuple(list(Entry), dict(tuple(int,int), set(tuple(int,int))))

Raises:

MinimisationFailedError – If the smallest table that can be produced is larger than target_length.

pacman.operations.router_compressors.ordered_covering_router_compressor.ordered_covering_compressor()[source]

Compressor from rig that has been tied into the main tool chain stack.

Return type:

MulticastRoutingTables

pacman.operations.router_compressors.ordered_covering_router_compressor.remove_default_routes(table, target_length, check_for_aliases=True)[source]

Remove from the routing table any entries which could be replaced by default routing.

Parameters:
  • table (list(Entry)) – Routing entries to be merged.

  • target_length (int or None) – Target length of the routing table; the minimisation procedure will halt once either this target is reached or no further minimisation is possible. If None then the table will be made as small as possible.

  • check_for_aliases (bool) –

    If True (the default), default-route candidates are checked for aliased entries before suggesting a route may be default routed. This check is required to ensure correctness in the general case but has a runtime complexity of O(N2) in the worst case for N-entry tables.

    If False, the alias-check is skipped resulting in O(N) runtime. This option should only be used if the supplied table is guaranteed not to contain any aliased entries.

Return type:

list(Entry)

Raises:

MinimisationFailedError – If the smallest table that can be produced is larger than target_length.

Submodules
pacman.operations.router_compressors.routing_compression_checker module
pacman.operations.router_compressors.routing_compression_checker.calc_remainders(o_code, c_code)[source]
Parameters:
  • o_code (str) –

  • c_code (str) –

Return type:

list(str)

pacman.operations.router_compressors.routing_compression_checker.codify(route, length=32)[source]

This method discovers all the routing keys covered by this route.

Starts of with the assumption that the key is always covered.

Whenever a mask bit is zero the list of covered keys is doubled to include both the key with a zero and a one at that place.

Parameters:
  • route (MulticastRoutingEntry) – single routing Entry

  • length (int) – length in bits of the key and mask (defaults to 32)

Returns:

set of routing_keys covered by this route

Return type:

str

pacman.operations.router_compressors.routing_compression_checker.codify_table(table, length=32)[source]
Parameters:
  • table (MulticastRoutingTable) –

  • length (int) –

Return type:

dict(str, MulticastRoutingEntry)

pacman.operations.router_compressors.routing_compression_checker.compare_route(o_route, compressed_dict, o_code=None, start=0, f=None)[source]
Parameters:
pacman.operations.router_compressors.routing_compression_checker.compare_tables(original, compressed)[source]

Compares the two tables without generating any output.

Parameters:
  • original (MulticastRoutingTable) – The original routing tables

  • compressed (MulticastRoutingTable) – The compressed routing tables. Which will be considered in order.

Raises:

PacmanRoutingException if there is any error

pacman.operations.router_compressors.routing_compression_checker.covers(o_code, c_code)[source]
Parameters:
  • o_code (str) –

  • c_code (str) –

Return type:

bool

Module contents
class pacman.operations.router_compressors.AbstractCompressor(ordered=True, accept_overflow=False)[source]

Bases: object

abstract compress_table(router_table)[source]
Parameters:

router_table (UnCompressedMulticastRoutingTable) – Original routing table for a single chip

Returns:

Raw compressed routing table entries for the same chip

Return type:

list(Entry)

compress_tables(router_tables, progress)[source]

Compress all the unordered routing tables.

Tables who start of smaller than target_length are not compressed

Parameters:
Returns:

The compressed but still unordered routing tables

Return type:

MulticastRoutingTables

Raises:

MinimisationFailedError – on failure

class pacman.operations.router_compressors.Entry(key, mask, defaultable, spinnaker_route)[source]

Bases: object

Parameters:
  • key (int) –

  • mask (int) –

  • defaultable (bool) –

  • spinnaker_route (int) –

defaultable
static from_MulticastRoutingEntry(mre)[source]
Parameters:

mre (MulticastRoutingEntry) –

Return type:

Entry

key
mask
spinnaker_route
to_MulticastRoutingEntry()[source]
Return type:

MulticastRoutingEntry

class pacman.operations.router_compressors.RangeCompressor[source]

Bases: object

compress_table(uncompressed)[source]

Compresses all the entries for a single table.

Compressed the entries for this unordered table returning a new table with possibly fewer entries

Parameters:

uncompressed (UnCompressedMulticastRoutingTable) – Original Routing table for a single chip

Returns:

Compressed routing table for the same chip

Return type:

list(Entry)

static cut_off(key, power)[source]
static next_power(number)[source]
pacman.operations.router_compressors.pair_compressor(ordered=True, accept_overflow=False, verify=False)[source]
Parameters:
  • accept_overflow (bool) – A flag which should only be used in testing to stop raising an exception if result is too big

  • verify (bool) – If set to true will verify the length before returning

Return type:

MulticastRoutingTables

pacman.operations.router_compressors.range_compressor(accept_overflow=True)[source]
Parameters:
  • router_tables (MulticastRoutingTables) –

  • accept_overflow (bool) – A flag which should only be used in testing to stop raising an exception if result is too big

Return type:

MulticastRoutingTables

pacman.operations.routing_info_allocator_algorithms package
Module contents
class pacman.operations.routing_info_allocator_algorithms.ZonedRoutingInfoAllocator[source]

Bases: object

A routing key allocator that uses fixed zones that are the same for all vertices. This will hopefully make the keys more compressible.

Keys will have the format:

      <--- 32 bits --->
Key:  | A | P | M | X |
Mask: |11111111111|   | (i.e. 1s covering A, P and M fields)
Field A:

The index of the application vertex.

Field P:

The index of the name of outgoing edge partition of the vertex.

Field M:

The index of the machine vertex of the application vertex.

Field X:

Space for the maximum number of keys required by any outgoing edge partition.

The A and P are combined into a single index (AP) so that applications with multiple partitions use multiple entries while ones with only 1 use just one.

The split between the AP bit and other parts is always fixed This also means that all machine vertices of the same application vertex and partition will have a shared key.

The split between the M and X may vary depending on how the allocator is called.

In “global” mode the widths of the fields are predetermined and fixed such that every key will have every field in the same place in the key, and the mask is the same for every vertex. The global approach is particularly sensitive to the one large and many small vertices limit.

In “flexible” mode the size of the M and X will change for each application/partition. Every vertex for a application/partition pair but different pairs may have different masks. This should result in less gaps between the machine vertexes. Even in non-flexible mode if the sizes are too big to keep M and X the same size they will be allowed to change for those vertexes will a very high number of atoms.

__call__(extra_allocations, flexible)[source]
Parameters:
  • extra_allocations (list(tuple(ApplicationVertex,str))) – Additional (vertex, partition identifier) pairs to allocate keys to. These might not appear in partitions in the graph due to being added by the system.

  • flexible (bool) – Determines if flexible can be use. If False, global settings will be attempted

Returns:

The routing information

Return type:

RoutingInfo

Raises:

PacmanRouteInfoAllocationException – If something goes wrong with the allocation

pacman.operations.routing_table_generators package
Module contents
class pacman.operations.routing_table_generators.ZonedRoutingTableGenerator[source]

Bases: object

An algorithm that can produce routing tables in zones.

__call__(routing_infos, routing_table_by_partitions, machine, info_by_app_vertex)[source]
Parameters:
Return type:

MulticastRoutingTables

pacman.operations.routing_table_generators.basic_routing_table_generator()[source]

An basic algorithm that can produce routing tables.

Return type:

MulticastRoutingTables

pacman.operations.routing_table_generators.merged_routing_table_generator()[source]

Creates routing entries by merging adjacent entries from the same application vertex when possible.

Return type:

MulticastRoutingTables

pacman.operations.tag_allocator_algorithms package
Module contents
pacman.operations.tag_allocator_algorithms.basic_tag_allocator()[source]

Basic tag allocator that goes though the boards available and applies the IP tags and reverse IP tags as needed.

Note

This does not actually allocate the tags, but just produces the plan of what to allocate. Allocations need access to the running machine.

Parameters:
  • machine (Machine) – The machine to set up tags to be allocated.

  • placements (Placements) – The placed vertices.

Returns:

list of IP Tags, list of Reverse IP Tags, tag allocation holder

Return type:

tuple(list(IPTag), list(ReverseIPTag), Tags)

Module contents

The algorithms in the sub-packages are generally callable.

pacman.utilities package
Subpackages
pacman.utilities.algorithm_utilities package
Submodules
pacman.utilities.algorithm_utilities.partition_algorithm_utilities module

A collection of methods which support partitioning algorithms.

pacman.utilities.algorithm_utilities.partition_algorithm_utilities.get_multidimensional_slices(app_vertex)[source]

Get the multi-dimensional slices of an application vertex such that each is sized to the maximum atoms per dimension per core except the last, which might be smaller in one or more dimensions.

Parameters:

app_vertex (ApplicationVertex) – The vertex to get the slices of

Returns:

The slices

Return type:

list(Slice)

pacman.utilities.algorithm_utilities.partition_algorithm_utilities.get_single_dimension_slices(app_vertex)[source]
Get the single dimension slices of an application vertex

such that each is sized to the maximum atoms per dimension per core except the last which might be smaller in one or more dimensions

Parameters:

app_vertex (ApplicationVertex) – The vertex to get the slices of

pacman.utilities.algorithm_utilities.routes_format module
pacman.utilities.algorithm_utilities.routes_format.format_route(entry)[source]

How to render a single routing entry.

Parameters:

entry (MulticastRoutingEntry) –

Return type:

str

pacman.utilities.algorithm_utilities.routing_algorithm_utilities module
pacman.utilities.algorithm_utilities.routing_algorithm_utilities.a_star(sink, heuristic_source, sources)[source]

Use A* to find a path from any of the sources to the sink.

Note

The heuristic means that the search will proceed towards heuristic_source without any concern for any other sources. This means that the algorithm may miss a very close neighbour in order to pursue its goal of reaching heuristic_source. This is not considered a problem since 1) the heuristic source will typically be in the direction of the rest of the tree and near by and often the closest entity 2) it prevents us accidentally forming loops in the rest of the tree since we’ll stop as soon as we touch any part of it.

Parameters:
  • sink (tuple(int,int)) – (x, y)

  • heuristic_source (tuple(int,int)) – (x, y) An element from sources which is used as a guiding heuristic for the A* algorithm.

  • sources (set(tuple(int,int))) – set([(x, y), …])

Returns:

[(int, (x, y)), …] A path starting with a coordinate in sources and terminating at connected neighbour of sink (i.e. the path does not include sink). The direction given is the link down which to proceed from the given (x, y) to arrive at the next point in the path.

Return type:

list(tuple(int,tuple(int,int)))

Modify a RoutingTree to route-around dead links in a Machine.

Uses A* to reconnect disconnected branches of the tree (due to dead links in the machine).

Parameters:

root (RoutingTree) – The root of the RoutingTree which contains nothing but RoutingTrees (i.e. no vertices and links).

Returns:

A new RoutingTree is produced rooted as before.

Return type:

RoutingTree

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.convert_a_route(routing_tables, source_vertex, partition_id, incoming_processor, incoming_link, route, targets_by_chip)[source]

Converts the algorithm specific partition_route back to standard SpiNNaker and adds it to the routing_tables.

Parameters:
pacman.utilities.algorithm_utilities.routing_algorithm_utilities.get_app_partitions()[source]

Find all application partitions.

Note

Where a vertex splitter indicates that it has internal partitions but is not the source of an external partition, a “fake” empty application partition is added. This allows the calling algorithm to loop over the returned list and look at the set of edges and internal partitions to get a complete picture of all targets for each source machine vertex at once.

Returns:

list of partitions

Note

Where there are only internal multicast partitions, the partition will have no edges. Caller should use vertex.splitter.get_internal_multicast_partitions for details.

Return type:

list(ApplicationEdgePartition)

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.get_targets_by_chip(vertices)[source]

Get the target links and cores on the relevant chips.

Parameters:
Returns:

A dict of (x, y) to target (cores, links)

Return type:

dict((int, int), (list, list))

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.least_busy_dimension_first(traffic, vector, start)[source]

List the (x, y) steps on a route that goes through the least busy routes first.

Parameters:
  • traffic (dict(tuple(int,int), int)) – A dictionary of (x, y): count of routes

  • vector (tuple(int, int, int)) – (x, y, z) The vector which the path should cover.

  • start (tuple(int, int)) –

    (x, y) The coordinates from which the path should start.

    Note

    This is a 2D coordinate.

Returns:

min route

Return type:

list(tuple(int,tuple(int, int)))

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.longest_dimension_first(vector, start)[source]

List the (x, y) steps on a longest-dimension first route.

Parameters:
  • vector (tuple(int,int,int)) – (x, y, z) The vector which the path should cover.

  • start (tuple(int,int)) –

    (x, y) The coordinates from which the path should start.

    Note

    This is a 2D coordinate.

Returns:

min route

Return type:

list(tuple(int,tuple(int, int)))

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.most_direct_route(source, dest, machine)[source]

Find the most direct route from source to target on the machine.

Parameters:
  • source (tuple(int,int)) – The source x, y coordinates

  • dest (tuple(int,int)) – The destination x, y coordinates

  • machine (Machine) – The machine on which to route

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.nodes_to_trees(nodes, start, route)[source]

Convert a list of nodes into routing trees, adding them to existing routes.

Parameters:

Quickly determine if a route uses any dead links.

Parameters:

root (RoutingTree) – The root of the RoutingTree which contains nothing but RoutingTrees (i.e. no vertices and links).

Returns:

True if the route uses any dead/missing links, False otherwise.

Return type:

bool

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.route_to_endpoint(vertex)[source]
Parameters:
Return type:

int

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.vector_to_nodes(dm_vector, start)[source]

Convert a vector to a set of nodes.

Parameters:
  • dm_vector (list(tuple(int,int))) – A vector made up of a list of (dimension, magnitude), where dimensions are x=0, y=1, z=diagonal=2

  • start (tuple(int,int)) – The x, y coordinates of the start

Returns:

A list of (link_id, (target_x, target_y)) of nodes on a route

Return type:

list(tuple(int,tuple(int, int)))

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.vertex_xy(vertex)[source]
Parameters:
Return type:

tuple(int,int)

pacman.utilities.algorithm_utilities.routing_algorithm_utilities.vertex_xy_and_route(vertex)[source]

Get the non-virtual chip coordinates, the vertex, and processor or link to follow to get to the vertex.

Parameters:

vertex (MachineVertex) –

Returns:

the (x,y) coordinates of the target vertex mapped to a tuple of the vertex, core and link. One of core or link is provided the other is None

Return type:

tuple(tuple(int, int), tuple(MachineVertex, int, None)) or tuple(tuple(int, int), tuple(MachineVertex, None, int))

pacman.utilities.algorithm_utilities.routing_tree module

An explicit representation of a routing tree in a machine.

This representation of a route explicitly describes a tree-structure and the complete path taken by a route. This is used during place and route in preference to a set of RoutingTableEntry tuples since it is more easily verified and more accurately represents the problem at hand.

Based on https://github.com/project-rig/rig/blob/master/rig/place_and_route/routing_tree.py

class pacman.utilities.algorithm_utilities.routing_tree.RoutingTree(chip, label=None)[source]

Bases: object

Explicitly defines a multicast route through a SpiNNaker machine.

Each instance represents a single hop in a route and recursively refers to following steps.

Parameters:

chip (tuple(int,int)) – The chip the route is currently passing through.

append_child(child)[source]
Parameters:

child (tuple(int, RoutingTree or MachineVertex)) –

property children

A iterable of the next steps in the route represented by a (route, object) tuple.

Note

Up until Rig 1.5.1, this structure used sets to store children. This was changed to lists since sets incur a large memory overhead and in practice the set-like behaviour of the list of children is not useful.

The object indicates the intended destination of this step in the route. It may be one of:

  • RoutingTree representing the continuation of the routing tree after following a given link.

  • A vertex (i.e. some other Python object) when the route terminates at the supplied vertex.

Note

The direction may be None and so additional logic may be required to determine what core to target to reach the vertex.

Return type:

iterable(tuple(int, RoutingTree or MachineVertex))

property chip

The chip the route is currently passing through.

Return type:

tuple(int,int)

property is_leaf
property label
remove_child(child)[source]
Parameters:

child (tuple(int, RoutingTree or MachineVertex)) –

traverse()[source]

Traverse the tree yielding the direction taken to a node, the coordinates of that node and the directions leading from the Node.

Returns:

A sequence of (direction, (x, y), set(route)) describing the route taken. At each step, we have the direction taken to reach a Node in the tree, the (x, y) coordinate of that Node and routes leading to children of the Node.

Return type:

iterable(tuple(int, tuple(int,int), set(int)))

Module contents
pacman.utilities.file_format_schemas package
Subpackages
pacman.utilities.file_format_schemas.unused package
Module contents
Module contents

A simple bit of support code for validation.

pacman.utilities.file_format_schemas.validate(json_obj, schema_filename)[source]

Check that the given JSON object (or array) is valid against the given schema. The schema is given by filename relative to this package.

Parameters:
  • json_obj (dict or list) – The entity to validate

  • schema_filename (str) – The name of the file containing the schema (e.g., “routes.json”)

Raises:
  • IOError – If the schema file doesn’t exist.

  • ValidationError – If the JSON object isn’t valid.

pacman.utilities.utility_objs package
Module contents
class pacman.utilities.utility_objs.ChipCounter(n_cores_per_chip=15, sdram_per_chip=104857600)[source]

Bases: object

A counter of how many chips are needed to hold machine vertices. This does not look at the fixed_locations of the vertices at all. The value produced will be a (hopefully) worst-case estimate and should not be used to decide failure in terms of space!

add_core(resources)[source]
property n_chips
Return type:

int

class pacman.utilities.utility_objs.Field(lo, hi, value, tag=SUPPORTED_TAGS.ROUTING, name=None)[source]

Bases: object

Field object used in a field constraint for key allocation.

Parameters:
  • lo (int) – the low bit in the routing table entry for this field

  • hi (int) – the high bit in the routing table entry for this field

  • value (int) – the value to store in this field

  • tag (SUPPORTED_TAGS) – field tag

  • name (str or None) – field name

property hi

The high bit in the routing table entry for this field.

Return type:

int

property lo

The low bit in the routing table entry for this field.

Return type:

int

property name

The field name.

Return type:

str or UUID

property tag

The field tag.

Return type:

SUPPORTED_TAGS

property value

The value to store in this field.

Return type:

int

class pacman.utilities.utility_objs.SUPPORTED_TAGS(value)[source]

Bases: Enum

An enumeration.

APPLICATION = 0
ROUTING = 1
Submodules
pacman.utilities.constants module
class pacman.utilities.constants.EDGES(value)

Bases: Enum

An enumeration.

EAST = 0
NORTH = 2
NORTH_EAST = 1
SOUTH = 5
SOUTH_WEST = 4
WEST = 3
pacman.utilities.constants.SARK_PER_MALLOC_SDRAM_USAGE = 8

The number of bytes used by SARK per memory allocation

pacman.utilities.json_utils module

Miscellaneous minor functions for converting between JSON and Python objects.

pacman.utilities.json_utils.iptag_resource_from_json(json_dict)[source]
pacman.utilities.json_utils.iptag_resource_to_json(iptag)[source]
pacman.utilities.json_utils.iptag_resources_from_json(json_list)[source]
pacman.utilities.json_utils.iptag_resources_to_json(iptags)[source]
pacman.utilities.json_utils.json_to_object(json_object)[source]

Makes sure this is a JSON object reading in a file if required

Parameters:

json_object (dict or list or str) – Either a JSON Object or a string pointing to a file

Returns:

a JSON object

Return type:

dict or list

pacman.utilities.json_utils.key_mask_to_json(key_mask)[source]
pacman.utilities.json_utils.placement_from_json(json_dict, graph=None)[source]
pacman.utilities.json_utils.placement_to_json(placement)[source]
pacman.utilities.json_utils.placements_to_json()[source]
pacman.utilities.json_utils.reverse_iptag_from_json(json_dict)[source]
pacman.utilities.json_utils.reverse_iptag_to_json(iptag)[source]
pacman.utilities.json_utils.reverse_iptags_from_json(json_list)[source]
pacman.utilities.json_utils.reverse_iptags_to_json(iptags)[source]
pacman.utilities.json_utils.vertex_from_json(json_dict)[source]
pacman.utilities.json_utils.vertex_lookup(label, graph=None)[source]
pacman.utilities.json_utils.vertex_to_json(vertex)[source]
pacman.utilities.utility_calls module
pacman.utilities.utility_calls.allocator_bits_needed(size)[source]

Get the bits needed for the routing info allocator.

Parameters:

size (int) – The size to calculate the number of bits for

Returns:

the number of bits required for that size

Return type:

int

pacman.utilities.utility_calls.compress_bits_from_bit_array(bit_array, bit_positions)[source]

Compress specific positions from a bit array of 32 uint8 value, where is a 1 or 0, into a 32-bit value.

Parameters:
  • bit_array (ndarray(uint8)) – The array to extract the value from

  • bit_positions (ndarray(int)) – The positions of the bits to extract, each value being between 0 and 31

Return type:

int

pacman.utilities.utility_calls.compress_from_bit_array(bit_array)[source]

Compress a bit array of 32 uint8 values, where each is a 1 or 0, into a 32-bit value.

Parameters:

bit_array (ndarray(uint8)) – The array to compress

Return type:

int

pacman.utilities.utility_calls.expand_to_bit_array(value)[source]

Expand a 32-bit value in to an array of length 32 of uint8 values, each of which is a 1 or 0.

Parameters:

value (int) – The value to expand

Return type:

ndarray(uint8)

pacman.utilities.utility_calls.get_field_based_index(base_key, vertex_slice, shift=0)[source]

Map field based keys back to indices.

Parameters:
  • base_key (int) – The base key

  • vertex_slice (Slice) – The slice to translate

  • shift (int) – The left shift to apply to the atom key before adding to the key. Can be used to make space for additional information at the bottom of the key.

Return type:

dict(int,int)

pacman.utilities.utility_calls.get_field_based_keys(key, vertex_slice, shift=0)[source]

Translate a vertex slice with potentially multiple dimensions into a list of keys, one for each atom of the vertex, by putting the values into fields of the keys based on the shape of the slice.

Parameters:
  • key (int) – The base key

  • vertex_slice (Slice) – The slice to translate

  • shift (int) – The left shift to apply to the atom key before adding to the key. Can be used to make space for additional information at the bottom of the key.

Return type:

list(int)

pacman.utilities.utility_calls.get_key_ranges(key, mask)[source]

Get a generator of base_key, n_keys pairs that represent ranges allowed by the mask.

Parameters:
  • key (int) – The base key

  • mask (int) – The mask

Return type:

iterable(tuple(int,int))

pacman.utilities.utility_calls.get_n_bits(n_values)[source]

Determine how many bits are required for the given number of values.

Parameters:

n_values (int) – the number of values (starting at 0)

Returns:

the number of bits required to express that many values

Return type:

int

pacman.utilities.utility_calls.get_n_bits_for_fields(field_sizes)[source]

Get the number of bits required for the fields in the vertex slice.

Parameters:

field_sizes (iterable(int)) – The sizes each of the fields

Return type:

int

pacman.utilities.utility_calls.is_equal_or_None(a, b)[source]

If a and b are both not None, return True if and only if they are equal, otherwise return True.

Return type:

bool

pacman.utilities.utility_calls.is_single(iterable)[source]

Test if there is exactly one item in the iterable.

Return type:

bool

pacman.utilities.utility_calls.md5(string)[source]

Get the MD5 hash of the given string, which is UTF-8 encoded.

Parameters:

string (str) –

Return type:

str

Module contents
Submodules
pacman.config_setup module
pacman.config_setup.add_pacman_cfg()[source]

Add the local configuration and all dependent configuration files.

pacman.config_setup.unittest_setup()[source]

Resets the configurations so only the local default configuration is included.

Note

This file should only be called from PACMAN/unittests

pacman.exceptions module
exception pacman.exceptions.MachineHasDisconnectedSubRegion[source]

Bases: PacmanException

Some part of the machine has no paths connecting it to the rest of the machine.

exception pacman.exceptions.MinimisationFailedError[source]

Bases: PacmanException

A routing table could not be minimised to reach a specified target.

exception pacman.exceptions.PacmanAlgorithmFailedToGenerateOutputsException[source]

Bases: PacmanException

An algorithm has not generated the correct outputs for some unknown reason.

exception pacman.exceptions.PacmanAlreadyExistsException(item_type, item_id)[source]

Bases: PacmanException

Something already exists and that adding another would be a conflict.

Parameters:
  • item_type (str) – The type of the item that already exists

  • item_id (str) – The ID of the item which is in conflict

exception pacman.exceptions.PacmanAlreadyPlacedError[source]

Bases: ValueError

Multiple placements are being made for a vertex.

exception pacman.exceptions.PacmanCanNotFindChipException[source]

Bases: PacmanException

The chip was not in the list of chips.

exception pacman.exceptions.PacmanConfigurationException[source]

Bases: PacmanException

Something went wrong with configuring some part of PACMAN.

exception pacman.exceptions.PacmanElementAllocationException[source]

Bases: PacmanException

Something went wrong with element allocation.

exception pacman.exceptions.PacmanException[source]

Bases: Exception

Indicates a general exception from Pacman.

exception pacman.exceptions.PacmanExternalAlgorithmFailedToCompleteException[source]

Bases: PacmanException

An algorithm ran from outside the software stack has failed to complete for some unknown reason.

exception pacman.exceptions.PacmanInvalidParameterException(parameter, value, problem)[source]

Bases: PacmanException

A parameter has an invalid value.

Parameters:
  • parameter (str) – The name of the parameter

  • value (str) – The value of the parameter

  • problem (str) – The problem with the value of the parameter

exception pacman.exceptions.PacmanNoMergeException[source]

Bases: PacmanException

There are no merges worth performing.

exception pacman.exceptions.PacmanNotExistException[source]

Bases: PacmanException

A routing table entry was attempted to be removed from a routing table which didn’t have such an entry.

exception pacman.exceptions.PacmanNotFoundError[source]

Bases: KeyError, PacmanException

Some object has not been found when requested.

exception pacman.exceptions.PacmanNotPlacedError[source]

Bases: KeyError

No placements are made for a vertex.

exception pacman.exceptions.PacmanPartitionException[source]

Bases: PacmanException

Something went wrong with partitioning.

exception pacman.exceptions.PacmanPlaceException[source]

Bases: PacmanException

Something went wrong with placement.

exception pacman.exceptions.PacmanProcessorAlreadyOccupiedError[source]

Bases: ValueError

Multiple placements are being made to a processor.

exception pacman.exceptions.PacmanProcessorNotOccupiedError[source]

Bases: KeyError

No placement has been made to a processor.

exception pacman.exceptions.PacmanPruneException[source]

Bases: PacmanException

Something went wrong with pruning.

exception pacman.exceptions.PacmanRouteInfoAllocationException[source]

Bases: PacmanException

Something went wrong with route info allocation.

exception pacman.exceptions.PacmanRoutingException[source]

Bases: PacmanException

Something went wrong with routing.

exception pacman.exceptions.PacmanTooBigToPlace[source]

Bases: PacmanException

A request by a splitter to put some vertices on a single chip cannot be satisfied; not enough space is available.

exception pacman.exceptions.PacmanTypeError[source]

Bases: TypeError, PacmanException

An object is of incorrect type.

exception pacman.exceptions.PacmanValueError[source]

Bases: ValueError, PacmanException

A value is invalid for some reason.

exception pacman.exceptions.PartitionMissingEdgesException[source]

Bases: PacmanException

After partitioning, a partition does not have the edges it expects.

exception pacman.exceptions.SDRAMEdgeSizeException[source]

Bases: PacmanException

A constant SDRAM partition has discovered its edges have inconsistent size requests.

Module contents

Provides various functions which together can be used to take a graph and split it into pieces that can be loaded on to a machine, along with routes between the pieces.

Functional Requirements
  • Creation of an Application Graph of Vertices indicating points of computation within the graph and Edges between the vertices indicating a directional communication between the vertices; and a similar Machine Graph.

    • Vertices in the Application Graph will have a number of atoms - an atom cannot be broken down in to anything smaller.

    • Vertices in the Application Graph must be able to indicate what machine resources are required by any given subset of the atoms.

    • Vertices in the Machine Graph must be able to fit on a single chip of the machine in terms of resource usage.

    • Multiple edges can exist between the same two vertices.

    • It must be possible to build the Machine Graph directly without requiring that it is created by one of the other modules.

    • It is not required that there is a Machine Graph Edge between every pair of Machine Graph Vertex from the same Application Graph Vertex.

    • Where a Machine Graph is created from an Application Graph, it should be possible to find the corresponding Vertices and Edges from one graph to the other.

  • Creation of multicast routing info consisting of key/mask combinations assigned to Edges of the Machine Graph.

    • It must be possible to build this information directly without requiring that it is created by one of the other modules.

    • There should be exactly one key/mask combination for each Edge in the Machine Graph, which will represent all the keys which will be sent in all packets from the Vertex at the start of the Edge down that Edge.

    • It is possible for a Vertex to send several different keys down several different Edges, but only one per Edge (but note that it is acceptable for different keys to be assigned to different Edges between the same two Vertices).

    • There should be no overlap between the key/mask combinations of Edges which come from different Vertices i.e. no two Edges which start at different Vertices should have the same key/mask combination.

  • Partitioning of an Application graph with respect to a machine, such that the resources consumed by each Vertex does not exceed those provided by each chip on the machine.

    • It should be possible to select from a range of partitioning algorithms or provide one, although a default should be provided in the absence of such a choice.

    • Any fixed_location should be met; if there are any that cannot, or that are not understood by the algorithm in use an exception should be thrown.

    • It must be possible to create at least one grouping of the generated Vertices so that each group fits within the resources provided by a single chip on the machine.

    • The machine itself must not be altered by the partitioning, so that it can be used in further processing.

    • The graph itself must not be altered by the partitioning, so that it can be used in further processing.

    • No two Machine Graph Vertices created from a single Application Graph Vertex can contain the same atom.

    • Any Edges in the Application Graph must be split with the Vertices to create a number of Machine Graph edges, such that where there was a vertex v connected to a vertex w by a single edge in the Application Graph, there should be an Edge in the Machine Graph between every Vertex of Application Graph Vertex v and every Vertex of Application Graph Vertex w; for example, if there are 2 Machine Graph Vertices for each of v and w, and one Edge between them in the Application Graph, then there will be 4 new Edges in the Machine Graph for this Edge.

  • Placement of a Machine Graph on a given machine, such that the resources required by any combination of Vertices placed on any chip in the machine does not exceed the resources provided by that chip.

    • It should be possible to choose from a range of placement algorithms or provide one, although a default should be provided in the absence of such a choice.

    • Any fixed_location should be met; if not an exception should be thrown.

    • The machine itself should not be altered by placement so that it can be used in further processing.

    • The graph itself should not be altered by placement so that it can be used in further processing.

    • The returned placements should only contain a single placement for each vertex.

    • The placements should be such that the vertices with edges between them must be able to communicate with each other.

  • Allocation of multicast routing keys and masks to a Machine Graph such that each vertex sends out packets with a different key/mask combination.

    • This can use the placement information if required. If an algorithm requires placement information but none is provided an exception is thrown.

  • Routing of edges between vertices with a given allocation of routing keys and masks with respect to a given machine.

    • It should be possible to choose from a range of routing algorithms, or provide one, although a default should be provided in the absence of such a choice

    • For any vertex, following the routes from the placement of the vertex should result exactly in the set of placements of the destination vertices described by all the edges which start at that vertex. No additional destination should be reached, and no fewer than this set of destinations should be reached.

  • It should be possible to call each of the modules independently. There should be no assumption that one of the other modules has produced the data input for any other module.

  • There should be no assumption about how the inputs and outputs are stored.

  • Any utility functions that provide access to internal structures within a data structure should operate in approximately O(1) time; for example, where an object of type obj holds a number of objects of type subobj with property prop, requesting a list of subobj objects contained within obj with property value prop = value should not iterate through a list of such objects, but should instead maintain a mapping that allows access to such objects in O(1) time. If this is not possible, obj should only provide access to a list of subobj objects, allowing the caller to filter these themselves. This will ensure that no misunderstanding can be made about the speed of operation of a function.

Indices and tables

PACMAN_github

PACMAN_individual_docs

SpiNNMan

This package provides a transceiver for communicating with a SpiNNaker machine.

SpiNNMan

Used to communicate with a SpiNNaker Board. The main part of this package is the Transceiver class. This can be used to send and receive packets in various SpiNNaker formats, depending on what connections are available.

Functional Requirements

  1. Connect to and communicate with a machine using a number of different connections.

  2. Boot a machine with the expected version of the software.

    • If the machine is already booted but the version is not the version expected, an exception will be thrown.

  3. Check the version of the software which the machine is booted with.

  4. Query the state of the machine to determine:

    • What the current state of the machine is in terms of the chips and cores available, the SDRAM available on the chips and which links are available between which chips.

    • What external links to the host exist (and separately add the discovered links to the set of links used to communicate with the machine).

    • What is running on the machine and where, and what the current status of those processes are.

    • How many cores are in a given state.

    • What is in the IOBUF buffers.

    • What the current routing entries for a given router are.

    • What the routing status counter values are.

  5. Load application binaries on to the machine, either to individual cores or via a “flood-fill” mechanism to multiple cores simultaneously (which may be a subset of the cores on a subset of the chips).

  6. Write data to SDRAM, either on an individual chip, or via a “flood-fill” mechanism to multiple chips simultaneously.

  7. Send a signal to an application.

  8. Read data from SDRAM on an individual chip.

  9. Send and receive SpiNNaker packets where the connections allow this.

    • If no connection supports this packet type, an exception is thrown.

    • The user should be able to select which connection is used. Selection of a connection which does not support the traffic type will also result in an exception.

  10. Send and receive SCP and SDP packets where the connections allow this.

    • If no connection supports the packet type, an exception is thrown.

    • The user should be able to select which connection is used. Selection of a connection which does not support the traffic type will also result in an exception.

  11. It should be possible to call any of the functions simultaneously, including the same function more than once.

    • Where possible, multiple connections should be used to overlap calls.

    • The functions should not return until they have confirmed that any messages sent have been received, and any responses have been received.

    • Functions should not respond with the result of a different function.

    • Functions can further sub-divide the call into a number of separate calls that can be divided across the available connections, so long as the other requirements are met.

  12. More than one machine can be connected to the same host.

    • Once the subset of connections has been worked out for each machine, the operation of these machines should be independent.

Use Cases

Contents

spinnman
spinnman package
Subpackages
spinnman.connections package
Subpackages
spinnman.connections.abstract_classes package
Module contents
class spinnman.connections.abstract_classes.AbstractSCPConnection[source]

Bases: Connection

A sender and receiver of SCP messages.

abstract property chip_x

The X-coordinate of the chip at which messages sent down this connection will arrive at first.

Return type:

int

abstract property chip_y

The Y-coordinate of the chip at which messages sent down this connection will arrive at first.

Return type:

int

abstract get_scp_data(scp_request)[source]

Returns the data of an SCP request as it would be sent down this connection.

abstract is_ready_to_receive(timeout=0)[source]

Determines if there is an SCP packet to be read without blocking.

Parameters:

timeout (int) – The time to wait before returning if the connection is not ready

Returns:

True if there is an SCP packet to be read

Return type:

bool

abstract receive_scp_response(timeout=1.0)[source]

Receives an SCP response from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed

Returns:

The SCP result, the sequence number, the data of the response and the offset at which the data starts (i.e., where the SDP header starts).

Return type:

tuple(SCPResult, int, bytes, int)

Raises:
abstract send_scp_request(scp_request)[source]

Sends an SCP request down this connection.

Messages must have the following properties:

  • source_port is None or 7

  • source_cpu is None or 31

  • source_chip_x is None or 0

  • source_chip_y is None or 0

tag in the message is optional; if not set, the default set in the constructor will be used. sequence in the message is optional; if not set, (sequence number last assigned + 1) % 65536 will be used

Parameters:

scp_request (AbstractSCPRequest) – message packet to send

Raises:

SpinnmanIOException – If there is an error sending the message

class spinnman.connections.abstract_classes.Connection[source]

Bases: AbstractContextManager

An abstract connection to the SpiNNaker board over some medium.

abstract close()[source]

Closes the connection.

abstract is_connected()[source]

Determines if the medium is connected at this point in time.

Returns:

True if the medium is connected, False otherwise

Return type:

bool

Raises:

SpinnmanIOException – If there is an error when determining the connectivity of the medium.

class spinnman.connections.abstract_classes.Listenable[source]

Bases: object

An interface for connections that can listen for incoming messages.

Implementing this interface means that the connection can be used with ConnectionListener.

abstract get_receive_method()[source]

Get the method that receives for this connection.

abstract is_ready_to_receive(timeout=0)[source]

Determines if there is an SCP packet to be read without blocking.

Parameters:

timeout (int) – The time to wait before returning if the connection is not ready

Returns:

True if there is an SCP packet to be read

Return type:

bool

spinnman.connections.udp_packet_connections package
Module contents
class spinnman.connections.udp_packet_connections.BMPConnection(connection_data)[source]

Bases: UDPConnection, AbstractSCPConnection

A BMP connection which supports queries to the BMP of a SpiNNaker machine.

Parameters:

connection_data (BMPConnectionData) – The description of what to connect to.

property boards

The set of boards supported by the BMP.

Return type:

iterable(int)

property cabinet

The cabinet ID of the BMP.

Return type:

int

property chip_x

Defined to satisfy the AbstractSCPConnection - always 0 for a BMP.

property chip_y

Defined to satisfy the AbstractSCPConnection - always 0 for a BMP.

property frame

The frame ID of the BMP.

Return type:

int

get_scp_data(scp_request)[source]

Returns the data of an SCP request as it would be sent down this connection.

receive_scp_response(timeout=1.0)[source]

Receives an SCP response from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed

Returns:

The SCP result, the sequence number, the data of the response and the offset at which the data starts (i.e., where the SDP header starts).

Return type:

tuple(SCPResult, int, bytes, int)

Raises:
send_scp_request(scp_request)[source]

Sends an SCP request down this connection.

Messages must have the following properties:

  • source_port is None or 7

  • source_cpu is None or 31

  • source_chip_x is None or 0

  • source_chip_y is None or 0

tag in the message is optional; if not set, the default set in the constructor will be used. sequence in the message is optional; if not set, (sequence number last assigned + 1) % 65536 will be used

Parameters:

scp_request (AbstractSCPRequest) – message packet to send

Raises:

SpinnmanIOException – If there is an error sending the message

class spinnman.connections.udp_packet_connections.BootConnection(remote_host=None)[source]

Bases: UDPConnection

A connection to the SpiNNaker board that uses UDP to for booting.

Parameters:

remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

receive_boot_message(timeout=None)[source]

Receives a boot message from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed.

Returns:

a boot message

Return type:

SpinnakerBootMessage

Raises:
send_boot_message(boot_message)[source]

Sends a SpiNNaker boot message using this connection.

Parameters:

boot_message (SpinnakerBootMessage) – The message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message

class spinnman.connections.udp_packet_connections.EIEIOConnection(local_host=None, local_port=None, remote_host=None, remote_port=None)[source]

Bases: UDPConnection, Listenable

A UDP connection for sending and receiving raw EIEIO messages.

Parameters:
  • local_host (str) – The local host name or IP address to bind to. If not specified defaults to bind to all interfaces, unless remote_host is specified, in which case binding is done to the IP address that will be used to send packets

  • local_port (int) – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

  • remote_port (int) – The remote port to send packets to. If remote_host is None, this is ignored. If remote_host is specified specified, this must also be specified for the connection to allow sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

get_receive_method()[source]

Get the method that receives for this connection.

receive_eieio_message(timeout=None)[source]

Receives an EIEIO message from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed

Returns:

an EIEIO message

Return type:

AbstractEIEIOMessage

Raises:
send_eieio_message(eieio_message)[source]

Sends an EIEIO message down this connection.

Parameters:

eieio_message (AbstractEIEIOMessage) – The EIEIO message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message

send_eieio_message_to(eieio_message, ip_address, port)[source]
class spinnman.connections.udp_packet_connections.IPAddressesConnection(local_host=None, local_port=54321)[source]

Bases: UDPConnection

A connection that detects any UDP packet that is transmitted by SpiNNaker boards prior to boot.

Parameters:
  • local_host (str) – The local host name or IP address to bind to. If not specified defaults to bind to all interfaces, unless remote_host is specified, in which case binding is done to the IP address that will be used to send packets

  • local_port (int) – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

  • remote_port (int) – The remote port to send packets to. If remote_host is None, this is ignored. If remote_host is specified specified, this must also be specified for the connection to allow sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

receive_ip_address(timeout=None)[source]
class spinnman.connections.udp_packet_connections.SCAMPConnection(chip_x=255, chip_y=255, local_host=None, local_port=None, remote_host=None, remote_port=None)[source]

Bases: SDPConnection, AbstractSCPConnection

A UDP connection to SCAMP on the board.

Parameters:
  • chip_x (int) – The x-coordinate of the chip on the board with this remote_host

  • chip_y (int) – The y-coordinate of the chip on the board with this remote_host

  • local_host (str) – The optional IP address or host name of the local interface to listen on

  • local_port (int) – The optional local port to listen on

  • remote_host (str) – The optional remote host name or IP address to send messages to. If not specified, sending will not be possible using this connection

  • remote_port (int) – The optional remote port number to send messages to. If not specified, sending will not be possible using this connection

property chip_x

The X-coordinate of the chip at which messages sent down this connection will arrive at first.

Return type:

int

property chip_y

The Y-coordinate of the chip at which messages sent down this connection will arrive at first.

Return type:

int

get_scp_data(scp_request, x=None, y=None)[source]

Returns the data of an SCP request as it would be sent down this connection.

Parameters:
  • x (int) – Optional: x-coordinate of where to send to

  • y (int) – Optional: y-coordinate of where to send to

receive_scp_response(timeout=1.0)[source]

Receives an SCP response from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed

Returns:

The SCP result, the sequence number, the data of the response and the offset at which the data starts (i.e., where the SDP header starts).

Return type:

tuple(SCPResult, int, bytes, int)

Raises:
receive_scp_response_with_address(timeout=1.0)[source]
send_scp_request(scp_request)[source]

Sends an SCP request down this connection.

Messages must have the following properties:

  • source_port is None or 7

  • source_cpu is None or 31

  • source_chip_x is None or 0

  • source_chip_y is None or 0

tag in the message is optional; if not set, the default set in the constructor will be used. sequence in the message is optional; if not set, (sequence number last assigned + 1) % 65536 will be used

Parameters:

scp_request (AbstractSCPRequest) – message packet to send

Raises:

SpinnmanIOException – If there is an error sending the message

send_scp_request_to(scp_request, x, y, ip_address)[source]
update_chip_coordinates(x, y)[source]
class spinnman.connections.udp_packet_connections.SDPConnection(chip_x=None, chip_y=None, local_host=None, local_port=None, remote_host=None, remote_port=None)[source]

Bases: UDPConnection, Listenable

A connection that talks SpiNNaker Datagram Protocol.

Parameters:
  • chip_x (int) – The optional x-coordinate of the chip at the remote end of the connection. If not specified, it will not be possible to send SDP messages that require a response with this connection.

  • chip_y (int) – The optional y-coordinate of the chip at the remote end of the connection. If not specified, it will not be possible to send SDP messages that require a response with this connection.

  • local_host (str) – The optional IP address or host name of the local interface to listen on

  • local_port (int) – The optional local port to listen on

  • remote_host (str) – The optional remote host name or IP address to send messages to. If not specified, sending will not be possible using this connection

  • remote_port (int) – The optional remote port number to send messages to. If not specified, sending will not be possible using this connection

get_receive_method()[source]

Get the method that receives for this connection.

receive_sdp_message(timeout=None)[source]

Receives an SDP message from this connection. Blocks until the message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed.

Returns:

The received SDP message

Return type:

SDPMessage

Raises:
send_sdp_message(sdp_message)[source]

Sends an SDP message down this connection.

Parameters:

sdp_message (SDPMessage) – The SDP message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message.

class spinnman.connections.udp_packet_connections.UDPConnection(local_host=None, local_port=None, remote_host=None, remote_port=None)[source]

Bases: Connection, Listenable

A connection that routes messages via UDP to some remote host.

Subclasses of this should be aware that UDP messages may be dropped, reordered, or duplicated, and that there’s no way to tell whether the other end of the connection truly exists except by listening for occasional messages from them. There is also an upper size limit on messages, formally of 64kB, but usually of about 1500 bytes (the typical maximum size of an Ethernet packet); SDP messages have lower maximum lengths.

Parameters:
  • local_host (str) – The local host name or IP address to bind to. If not specified defaults to bind to all interfaces, unless remote_host is specified, in which case binding is done to the IP address that will be used to send packets

  • local_port (int) – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

  • remote_port (int) – The remote port to send packets to. If remote_host is None, this is ignored. If remote_host is specified specified, this must also be specified for the connection to allow sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

close()[source]

Closes the connection.

get_receive_method()[source]

Get the method that receives for this connection.

is_connected()[source]

Determines if the medium is connected at this point in time.

Returns:

True if the medium is connected, False otherwise

Return type:

bool

Raises:

SpinnmanIOException – If there is an error when determining the connectivity of the medium.

is_ready_to_receive(timeout=0)[source]

Determines if there is an SCP packet to be read without blocking.

Parameters:

timeout (int) – The time to wait before returning if the connection is not ready

Returns:

True if there is an SCP packet to be read

Return type:

bool

property local_ip_address

The local IP address to which the connection is bound, as a dotted string, e.g., 0.0.0.0.

Return type:

str

property local_port

The number of the local port to which the connection is bound.

Return type:

int

receive(timeout=None)[source]

Receive data from the connection.

Parameters:

timeout (float) – The timeout in seconds, or None to wait forever

Returns:

The data received as a byte-string

Return type:

bytes

Raises:
receive_with_address(timeout=None)[source]

Receive data from the connection along with the address where the data was received from.

Parameters:

timeout (float) – The timeout, or None to wait forever

Returns:

A tuple of the data received and a tuple of the (address, port) received from

Return type:

tuple(bytes, tuple(str, int))

Raises:
property remote_ip_address

The remote IP address to which the connection is connected, or None if not connected remotely.

Return type:

str

property remote_port

The remote port number to which the connection is connected, or None if not connected remotely.

Return type:

int

send(data)[source]

Send data down this connection.

Parameters:

data (bytes or bytearray) – The data to be sent

Raises:

SpinnmanIOException – If there is an error sending the data

send_to(data, address)[source]

Send data down this connection.

Parameters:
  • data (bytes or bytearray) – The data to be sent as a byte-string

  • address (tuple(str,int)) – A tuple of (address, port) to send the data to

Raises:

SpinnmanIOException – If there is an error sending the data

spinnman.connections.udp_packet_connections.update_sdp_header_for_udp_send(sdp_header, source_x, source_y)[source]

Apply defaults to the SDP header for sending over UDP.

Parameters:

sdp_header (SDPHeader) – The SDP header values

Module contents
class spinnman.connections.ConnectionListener(connection, n_processes=4, timeout=1)[source]

Bases: Thread, AbstractContextManager

Thread that listens to a connection and calls callbacks with new messages when they arrive.

Parameters:
  • connection (Listenable) – A connection to listen to

  • n_processes (int) – The number of threads to use when calling callbacks

  • timeout (float) – How long to wait for messages before checking to see if the connection is to be terminated.

add_callback(callback)[source]

Add a callback to be called when a message is received.

Parameters:

callback (Callable) – A callable which takes a single parameter, which is the message received; the result of the callback will be ignored.

close()[source]

Closes the listener.

Note

This does not close the provider of the messages; this instead marks the listener as closed. The listener will not truly stop until the get message call returns.

run()[source]

Implements the listening thread.

class spinnman.connections.SCPRequestPipeLine(connection, n_channels=1, intermediate_channel_waits=0, n_retries=10, packet_timeout=1.0)[source]

Bases: object

Allows a set of SCP requests to be grouped together in a communication across a number of channels for a given connection.

This class implements an SCP windowing, first suggested by Andrew Mundy. This extends the idea by having both send and receive windows. These are represented by the n_channels and the intermediate_channel_waits parameters respectively. This seems to help with the timeout issue; when a timeout is received, all requests for which a reply has not been received can also timeout.

Parameters:
  • connection (SCAMPConnection) – The connection over which the communication is to take place

  • n_channels (int) – The number of requests to send before checking for responses. If None, this will be determined automatically

  • intermediate_channel_waits (int) – The number of outstanding responses to wait for before continuing sending requests. If None, this will be determined automatically

  • n_retries (int) – The number of times to resend any packet for any reason before an error is triggered

  • packet_timeout (float) – The number of elapsed seconds after sending a packet before it is considered a timeout.

finish()[source]

Indicate the end of the packets to be sent. This must be called to ensure that all responses are received and handled.

property n_channels

The number of requests to send before checking for responses.

Return type:

int

property n_resent

The number of packets that have been resent.

Return type:

int

property n_retry_code_resent

The number of resends due to reasons for which automated retry is the correct response in-protocol.

Return type:

int

property n_timeouts

The number of timeouts that occurred.

Return type:

int

send_request(request, callback, error_callback)[source]

Add an SCP request to the set to be sent.

Parameters:
  • request (AbstractSCPRequest) – The SCP request to be sent

  • callback (Callable) – A callback function to call when the response has been received; takes a SCPResponse as a parameter, or None if the response doesn’t need to be processed

  • error_callback (Callable) – A callback function to call when an error is found when processing the message; takes the original AbstractSCPRequest, the exception caught and a list of tuples of (filename, line number, function name, text) as a traceback

class spinnman.connections.TokenBucket(tokens, fill_rate)[source]

Bases: object

An implementation of the token bucket algorithm. Usage:

>>> bucket = TokenBucket(80, 0.5)
>>> print(bucket.consume(10))
True

Not thread safe.

Parameters:
  • tokens (int) – the total tokens in the bucket

  • fill_rate (float) – the rate in tokens/second that the bucket will be refilled.

consume(tokens, block=True)[source]

Consume tokens from the bucket. Returns True if there were sufficient tokens.

If there are not enough tokens and block is True, sleeps until the bucket is replenished enough to satisfy the deficiency.

If there are not enough tokens and block is False, returns False.

It is an error to consume more tokens than the bucket capacity.

Parameters:
  • tokens (int) –

  • block (bool) –

Return type:

bool

property tokens

The number of tokens currently in the bucket.

Return type:

int

spinnman.data package
Submodules
spinnman.data.spinnman_data_writer module
class spinnman.data.spinnman_data_writer.SpiNNManDataWriter(state)[source]

Bases: MachineDataWriter, SpiNNManDataView

See UtilsDataWriter

This class is designed to only be used directly within the SpiNNMan repository unit tests as all methods are available to subclasses

Parameters:

state (DataStatus) – State writer should be in

set_transceiver(transceiver)[source]

Sets the transceiver object.

Parameters:

transceiver (Transceiver) –

Raises:

TypeError – If the transceiver is not a Transceiver

Module contents
class spinnman.data.SpiNNManDataView[source]

Bases: MachineDataView

Adds the extra Methods to the View for SpiNNMan level.

See UtilsDataView for a more detailed description.

This class is designed to only be used directly within the SpiNNMan repository as all methods are available to subclasses

classmethod free_id(app_id)[source]

Frees up an app_id.

previously get_transceiver().app_id_tracker().free_id(app_id)

Parameters:

app_id (int) –

classmethod get_app_id()[source]

Gets the main app_id used by the transceiver.

This method will create a new app_id if one has not yet been created.

Return type:

int

classmethod get_new_id()[source]

Gets a new id from the current app_id_tracker

previously get_transceiver().app_id_tracker().get_new_id()

Return type:

AppIdTracker

classmethod get_scamp_connection_selector()[source]

Gets the SCAMP connection selector from the transceiver.

Syntactic sugar for get_transceiver().scamp_connection_selector()

Return type:

MostDirectConnectionSelector

Raises:

SpiNNUtilsException – If the transceiver is currently unavailable

classmethod get_transceiver()[source]

The transceiver description.

Return type:

Transceiver

Raises:

SpiNNUtilsException – If the transceiver is currently unavailable

classmethod has_transceiver()[source]

Reports if a transceiver is currently set.

Return type:

bool

classmethod read_memory(x, y, base_address, length, cpu=0)[source]

Read some areas of memory (usually SDRAM) from the board.

Syntactic sugar for get_transceiver().read_memory().

Parameters:
  • x (int) – The x-coordinate of the chip where the memory is to be read from

  • y (int) – The y-coordinate of the chip where the memory is to be read from

  • base_address (int) – The address in SDRAM where the region of memory to be read starts

  • length (int) – The length of the data to be read in bytes

  • cpu (int) – the core ID used to read the memory of; should usually be 0 when reading from SDRAM, but may be other values when reading from DTCM.

Returns:

A bytearray of data read

Return type:

bytes

Raises:
classmethod write_memory(x, y, base_address, data, n_bytes=None, offset=0, cpu=0, is_filename=False)[source]

Write to the SDRAM on the board.

Syntactic sugar for get_transceiver().write_memory().

Parameters:
  • x (int) – The x-coordinate of the chip where the memory is to be written to

  • y (int) – The y-coordinate of the chip where the memory is to be written to

  • base_address (int) – The address in SDRAM where the region of memory is to be written

  • data (RawIOBase or bytes or bytearray or int or str) –

    The data to write. Should be one of the following:

    • An instance of RawIOBase

    • A bytearray/bytes

    • A single integer - will be written in little-endian byte order

    • A filename of a data file (in which case is_filename must be set to True)

  • n_bytes (int) –

    The amount of data to be written in bytes. If not specified:

    • If data is an RawIOBase, an error is raised

    • If data is a byte string (bytearray or bytes), the length of the byte string will be used

    • If data is an int, 4 will be used

    • If data is a str, the length of the file will be used

  • offset (int) – The offset from which the valid data begins

  • cpu (int) – The optional CPU to write to

  • is_filename (bool) – True if data is a filename

Raises:
spinnman.messages package
Subpackages
spinnman.messages.eieio package
Subpackages
spinnman.messages.eieio.command_messages package
Module contents
class spinnman.messages.eieio.command_messages.EIEIOCommandHeader(command)[source]

Bases: object

EIEIO header for command packets.

property bytestring

The byte-string of the header.

Return type:

bytes

property command
static from_bytestring(data, offset)[source]

Read an EIEIO command header from a byte-string.

Parameters:
  • data (bytes or bytearray) – The byte-string to read the data from

  • offset (int) – The offset where the valid data starts

Returns:

an EIEIO command header

Return type:

EIEIOCommandHeader

Raises:
class spinnman.messages.eieio.command_messages.EIEIOCommandMessage(eieio_command_header, data=None, offset=0)[source]

Bases: AbstractEIEIOMessage

An EIEIO command message.

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

property bytestring

The bytes of the message.

Return type:

bytes

property data
property eieio_header

The header of the message.

Return type:

EIEIOCommandHeader

static from_bytestring(command_header, data, offset)[source]
static get_min_packet_length()[source]
property offset
class spinnman.messages.eieio.command_messages.EventStopRequest[source]

Bases: EIEIOCommandMessage

Packet used for the buffering input technique which causes the parser of the input packet to terminate its execution.

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

class spinnman.messages.eieio.command_messages.HostDataRead(n_requests, sequence_no, channel, region_id, space_read)[source]

Bases: EIEIOCommandMessage

Packet sent by the host computer to the SpiNNaker system in the context of the buffering output technique to signal that the host has completed reading data from the output buffer, and that such space can be considered free to use again.

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

property bytestring

The bytes of the message.

Return type:

bytes

channel(ack_id)[source]
static from_bytestring(command_header, data, offset)[source]
static get_min_packet_length()[source]
property n_requests
region_id(ack_id)[source]
property sequence_no
space_read(ack_id)[source]
class spinnman.messages.eieio.command_messages.HostDataReadAck(sequence_no)[source]

Bases: EIEIOCommandMessage

Packet sent by the host computer to the SpiNNaker system in the context of the buffering output technique to signal that the host has received a request to read data.

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

property bytestring

The bytes of the message.

Return type:

bytes

static from_bytestring(command_header, data, offset)[source]
property sequence_no
class spinnman.messages.eieio.command_messages.HostSendSequencedData(region_id, sequence_no, eieio_data_message)[source]

Bases: EIEIOCommandMessage

Packet sent from the host to the SpiNNaker system in the context of buffering input mechanism to identify packet which needs to be stored in memory for future use.

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

property bytestring

The bytes of the message.

Return type:

bytes

property eieio_data_message
static from_bytestring(command_header, data, offset)[source]
static get_min_packet_length()[source]
property region_id
property sequence_no
class spinnman.messages.eieio.command_messages.NotificationProtocolDatabaseLocation(database_path=None)[source]

Bases: EIEIOCommandMessage

Packet which contains the path to the database created by the toolchain which is to be used by any software which interfaces with SpiNNaker. Also the acknowledgement of that message.

This message is not sent to SpiNNaker boards but rather to an auxiliary tool (e.g., data visualiser).

Parameters:

database_path (str) – The location of the database. If None, this is an acknowledgement, stating that the database has now been read.

property bytestring

The bytes of the message.

Return type:

bytes

property database_path
static from_bytestring(command_header, data, offset)[source]
class spinnman.messages.eieio.command_messages.NotificationProtocolPauseStop[source]

Bases: EIEIOCommandMessage

Packet which indicates that the toolchain has paused or stopped.

This message is not sent to SpiNNaker boards but rather to an auxiliary tool (e.g., data visualiser).

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

static from_bytestring(command_header, data, offset)[source]
class spinnman.messages.eieio.command_messages.NotificationProtocolStartResume[source]

Bases: EIEIOCommandMessage

Packet which indicates that the toolchain has started or resumed.

This message is not sent to SpiNNaker boards but rather to an auxiliary tool (e.g., data visualiser).

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

static from_bytestring(command_header, data, offset)[source]
class spinnman.messages.eieio.command_messages.PaddingRequest[source]

Bases: EIEIOCommandMessage

Packet used to pad space in the buffering area, if needed.

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

static get_min_packet_length()[source]
class spinnman.messages.eieio.command_messages.SpinnakerRequestBuffers(x, y, p, region_id, sequence_no, space_available)[source]

Bases: EIEIOCommandMessage

Message used in the context of the buffering input mechanism which is sent by the SpiNNaker system to the host computer to ask for more data to inject during the simulation.

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

property bytestring

The bytes of the message.

Return type:

bytes

static from_bytestring(command_header, data, offset)[source]
static get_min_packet_length()[source]
property p
property region_id
property sequence_no
property space_available
property x
property y
class spinnman.messages.eieio.command_messages.SpinnakerRequestReadData(x, y, p, region_id, sequence_no, n_requests, channel, start_address, space_to_be_read)[source]

Bases: EIEIOCommandMessage

Message used in the context of the buffering output mechanism which is sent from the SpiNNaker system to the host computer to signal that some data is available to be read.

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

property bytestring

The bytes of the message.

Return type:

bytes

channel(request_id)[source]
static from_bytestring(command_header, data, offset)[source]
static get_min_packet_length()[source]
property n_requests
property p
region_id(request_id)[source]
property sequence_no
space_to_be_read(request_id)[source]
start_address(request_id)[source]
property x
property y
class spinnman.messages.eieio.command_messages.StartRequests[source]

Bases: EIEIOCommandMessage

Packet used in the context of buffering input for the host computer to signal to the SpiNNaker system that, if needed, it is possible to send more “SpinnakerRequestBuffers” packet.

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

class spinnman.messages.eieio.command_messages.StopRequests[source]

Bases: EIEIOCommandMessage

Packet used in the context of buffering input for the host computer to signal to the SpiNNaker system that to stop sending “SpinnakerRequestBuffers” packet.

Parameters:
  • eieio_command_header (EIEIOCommandHeader) – The header of the message

  • data (bytes) – Optional incoming data

  • offset (int) – Offset into the data where valid data begins

spinnman.messages.eieio.data_messages package
Module contents
class spinnman.messages.eieio.data_messages.AbstractDataElement[source]

Bases: object

A marker interface for possible data elements in the EIEIO data packet.

abstract get_bytestring(eieio_type)[source]

Get a byte-string for the given type

Parameters:

eieio_type (EIEIOType) – The type of the message being written

Returns:

A byte-string for the element

Return type:

bytes

Raises:

SpinnmanInvalidParameterException – If the type is incompatible with the element

class spinnman.messages.eieio.data_messages.EIEIODataHeader(eieio_type, tag=0, prefix=None, prefix_type=EIEIOPrefix.LOWER_HALF_WORD, payload_base=None, is_time=False, count=0)[source]

Bases: object

EIEIO header for data packets.

Parameters:
  • eieio_type (EIEIOType) – the type of message

  • tag (int) – the tag of the message (0 by default)

  • prefix (int or None) – the key prefix of the message or None if not prefixed

  • prefix_type (EIEIOPrefix) – the position of the prefix (upper or lower)

  • payload_base (int or None) – The base payload to be applied, or None if no base payload

  • is_time (bool) – True if the payloads should be taken to be timestamps, or False otherwise

  • count (int) – Count of the number of items in the packet

property bytestring

The byte-string of the header.

Return type:

bytes

property count
property eieio_type
static from_bytestring(data, offset)[source]

Read an EIEIO data header from a byte-string.

Parameters:
  • data (bytes) – The byte-string to be read

  • offset (int) – The offset at which the data starts

Returns:

an EIEIO header

Return type:

EIEIODataHeader

static get_header_size(eieio_type, is_prefix=False, is_payload_base=False)[source]

Get the size of a header with the given parameters.

Parameters:
  • eieio_type (EIEIOType) – the type of message

  • is_prefix (bool) – True if there is a prefix, False otherwise

  • is_payload_base (bool) – True if there is a payload base, False otherwise

Returns:

The size of the header in bytes

Return type:

int

increment_count()[source]
property is_time
property payload_base
property prefix
property prefix_type
reset_count()[source]
property size
property tag
class spinnman.messages.eieio.data_messages.EIEIODataMessage(eieio_header, data=None, offset=0)[source]

Bases: AbstractEIEIOMessage

An EIEIO Data message.

Parameters:
  • eieio_header (EIEIODataHeader) – The header of the message

  • data (bytes) – Optional data contained within the packet

  • offset (int) – Optional offset where the valid data starts

add_element(element)[source]

Add an element to the message. The correct type of element must be added, depending on the header values.

Parameters:

element (AbstractDataElement) – The element to be added

Raises:
add_key(key)[source]

Add a key to the packet.

Parameters:

key (int) – The key to add

Raises:

SpinnmanInvalidParameterException – If the key is too big for the format, or the format expects a payload

add_key_and_payload(key, payload)[source]

Adds a key and payload to the packet.

Parameters:
  • key (int) – The key to add

  • payload (int) – The payload to add

Raises:

SpinnmanInvalidParameterException – If the key or payload is too big for the format, or the format doesn’t expect a payload

property bytestring

The bytes of the message.

Return type:

bytes

static create(eieio_type, count=0, data=None, offset=0, key_prefix=None, payload_prefix=None, timestamp=None, prefix_type=EIEIOPrefix.LOWER_HALF_WORD)[source]

Create a data message.

Parameters:
  • eieio_type (EIEIOType) – The type of the message

  • count (int) – The number of items in the message

  • data (bytes) – The data in the message

  • offset (int) – The offset in the data where the actual data starts

  • key_prefix (int) – The prefix of the keys

  • payload_prefix (int) – The prefix of the payload

  • timestamp (int) – The timestamp of the packet

  • prefix_type (EIEIOPrefix) – The type of the key prefix if 16-bits

property eieio_header

The header of the message.

Return type:

EIEIODataHeader

get_min_packet_length()[source]

Get the minimum length of a message instance in bytes.

Return type:

int

property is_next_element

Whether there is another element to be read.

Return type:

bool

property max_n_elements

The maximum number of elements that can fit in the packet.

Return type:

int

static min_packet_length(eieio_type, is_prefix=False, is_payload_base=False, is_timestamp=False)[source]

The minimum length of a message with the given header, in bytes.

Parameters:
  • eieio_type (EIEIOType) – the type of message

  • is_prefix (bool) – True if there is a prefix, False otherwise

  • is_payload_base (bool) – True if there is a payload base, False otherwise

  • is_timestamp (bool) – True if there is a timestamp, False otherwise

Returns:

The minimum size of the packet in bytes

Return type:

int

property n_elements

The number of elements in the packet.

Return type:

int

property next_element

The next element to be read, or None if no more elements. The exact type of element returned depends on the packet type.

Return type:

AbstractDataElement

property size

The size of the packet with the current contents.

Return type:

int

class spinnman.messages.eieio.data_messages.KeyDataElement(key)[source]

Bases: AbstractDataElement

A data element that contains just a key.

get_bytestring(eieio_type)[source]

Get a byte-string for the given type

Parameters:

eieio_type (EIEIOType) – The type of the message being written

Returns:

A byte-string for the element

Return type:

bytes

Raises:

SpinnmanInvalidParameterException – If the type is incompatible with the element

property key
class spinnman.messages.eieio.data_messages.KeyPayloadDataElement(key, payload, payload_is_timestamp=False)[source]

Bases: AbstractDataElement

A data element that contains a key and a payload.

get_bytestring(eieio_type)[source]

Get a byte-string for the given type

Parameters:

eieio_type (EIEIOType) – The type of the message being written

Returns:

A byte-string for the element

Return type:

bytes

Raises:

SpinnmanInvalidParameterException – If the type is incompatible with the element

property key
property payload
property payload_is_timestamp
Module contents
class spinnman.messages.eieio.AbstractEIEIOMessage[source]

Bases: object

Interface for an EIEIOMessage.

abstract property bytestring

The bytes of the message.

Return type:

bytes

abstract property eieio_header

The header of the message.

class spinnman.messages.eieio.EIEIOPrefix(value)[source]

Bases: Enum

Possible prefixing of keys in EIEIO packets.

LOWER_HALF_WORD = 0
UPPER_HALF_WORD = 1
class spinnman.messages.eieio.EIEIOType(value)[source]

Bases: Enum

Possible types of EIEIO packets.

KEY_16_BIT = 0
KEY_32_BIT = 2
KEY_PAYLOAD_16_BIT = 1
KEY_PAYLOAD_32_BIT = 3
property key_bytes

The number of bytes used by each key element.

Return type:

int

property max_value

The maximum value of the key or payload (if there is a payload).

Return type:

int

property payload_bytes

The number of bytes used by each payload element.

Return type:

int

spinnman.messages.eieio.read_eieio_command_message(data, offset)[source]

Reads the content of an EIEIO command message and returns an object identifying the command which was contained in the packet, including any parameter, if required by the command.

Parameters:
  • data (bytes) – data received from the network as a byte-string

  • offset (int) – offset at which the parsing operation should start

Returns:

an object which inherits from EIEIOCommandMessage which contains parsed data received from the network

Return type:

EIEIOCommandMessage

spinnman.messages.eieio.read_eieio_data_message(data, offset)[source]

Reads the content of an EIEIO data message and returns an object identifying the data which was contained in the packet.

Parameters:
  • data (bytes) – data received from the network as a byte-string

  • offset (int) – offset at which the parsing operation should start

Returns:

an object which inherits from EIEIODataMessage which contains parsed data received from the network

Return type:

EIEIODataMessage

spinnman.messages.scp package
Subpackages
spinnman.messages.scp.abstract_messages package
Module contents
class spinnman.messages.scp.abstract_messages.AbstractSCPRequest(sdp_header, scp_request_header, argument_1=None, argument_2=None, argument_3=None, data=None)[source]

Bases: object

Represents an Abstract SCP Request.

Parameters:
  • sdp_header (SDPHeader) – The SDP header of the request

  • scp_request_header (SCPRequestHeader) – The SCP header of the request

  • argument_1 (int) – The first argument, or None if no first argument

  • argument_2 (int) – The second argument, or None if no second argument

  • argument_3 (int) – The third argument, or None if no third argument

  • data (bytearray or bytes or None) – The optional data, or None if no data

DEFAULT_DEST_X_COORD = 255
DEFAULT_DEST_Y_COORD = 255
property argument_1

The first argument, or None if no first argument.

Return type:

int

property argument_2

The second argument, or None if no second argument.

Return type:

int

property argument_3

The third argument, or None if no third argument.

Return type:

int

property bytestring

The request as a byte-string.

Return type:

bytes

property data

The data, or None if no data.

Return type:

bytearray

abstract get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

property scp_request_header

The SCP request header of the message.

Return type:

SCPRequestHeader

property sdp_header

The SDP header of the message.

Return type:

SDPHeader

class spinnman.messages.scp.abstract_messages.AbstractSCPResponse[source]

Bases: object

Represents an abstract SCP Response.

read_bytestring(data, offset)[source]

Reads a packet from a byte-string of data.

Parameters:
  • data (bytes) – The byte-string to be read

  • offset (int) – The offset in the data from which the response should be read

abstract read_data_bytestring(data, offset)[source]

Reads the remainder of the data following the header.

Parameters:
  • data (bytes) – The byte-string to read from

  • offset (int) – The offset into the data after the headers

property scp_response_header

The SCP header from the response.

Return type:

SCPResponseHeader

property sdp_header

The SDP header from the response.

Return type:

SDPHeader

class spinnman.messages.scp.abstract_messages.BMPRequest(boards, scp_request_header, argument_1=None, argument_2=None, argument_3=None, data=None)[source]

Bases: AbstractSCPRequest

An SCP request intended to be sent to a BMP.

Parameters:
  • boards (int or list(int) or tuple(int)) – The board or boards to be addressed by this request

  • scp_request_header (SCPRequestHeader) – The SCP request header

  • argument_1 (int) – The optional first argument

  • argument_2 (int) – The optional second argument

  • argument_3 (int) – The optional third argument

  • data (bytes) – The optional data to be sent

static get_board_mask(boards)[source]

Get the board mask given a board ID or collection of board IDs.

static get_first_board(boards)[source]

Get the first board ID given a board ID or collection of board IDs.

class spinnman.messages.scp.abstract_messages.BMPResponse[source]

Bases: AbstractSCPResponse

Represents an SCP request that’s tailored for the BMP connection.

spinnman.messages.scp.enums package
Module contents
class spinnman.messages.scp.enums.AllocFree(value)[source]

Bases: Enum

The SCP Allocation and Free codes.

ALLOC_ROUTING = 3
ALLOC_SDRAM = 0
FREE_ROUTING_BY_APP_ID = 5
FREE_ROUTING_BY_POINTER = 4
FREE_SDRAM_BY_APP_ID = 2
FREE_SDRAM_BY_POINTER = 1
class spinnman.messages.scp.enums.BMPInfo(value)[source]

Bases: Enum

The SCP BMP Information Types.

ADC = 3
CAN_STATUS = 2
IP_ADDR = 4
SERIAL = 0
class spinnman.messages.scp.enums.IPTagCommand(value)[source]

Bases: Enum

SCP IP tag Commands.

CLR = 3
GET = 2
NEW = 0
SET = 1
TTO = 4
class spinnman.messages.scp.enums.LEDAction(value)[source]

Bases: Enum

The SCP LED actions.

OFF = 2
ON = 3
TOGGLE = 1
class spinnman.messages.scp.enums.PowerCommand(value)[source]

Bases: Enum

The SCP Power Commands.

POWER_OFF = 0
POWER_ON = 1
class spinnman.messages.scp.enums.SCPCommand(value)[source]

Bases: Enum

The SCP Commands.

CMD_ALLOC = 28
CMD_APLX = 4
CMD_APP_COPY_RUN = 21
CMD_AR = 19
CMD_AS = 24
CMD_BMP_INFO = 48
CMD_BMP_POWER = 57
CMD_DPRI = 30
CMD_FFD = 23
CMD_FILL = 5
CMD_FLASH_COPY = 49
CMD_FLASH_ERASE = 50
CMD_FLASH_WRITE = 51
CMD_INFO = 31
CMD_IPTAG = 26
CMD_LED = 25
CMD_NNP = 20
CMD_READ = 2
CMD_REMAP = 16
CMD_RESET = 55
CMD_RTR = 29
CMD_RUN = 1
CMD_SIG = 22
CMD_SROM = 27
CMD_SYNC = 32
CMD_TUBE = 64
CMD_VER = 0
CMD_WRITE = 3
class spinnman.messages.scp.enums.SCPResult(value)[source]

Bases: Enum

The SCP Result codes.

RC_ARG = 132
RC_BUF = 138
RC_CMD = 131
RC_CPU = 136
RC_DEAD = 137
RC_LEN = 129
RC_OK = 128
RC_P2P_BUSY = 141
RC_P2P_NOREPLY = 139
RC_P2P_REJECT = 140
RC_P2P_TIMEOUT = 142
RC_PKT_TX = 143
RC_PORT = 133
RC_ROUTE = 135
RC_SUM = 130
RC_TIMEOUT = 134
class spinnman.messages.scp.enums.Signal(value)[source]

Bases: Enum

SCP Signals.

Parameters:
  • value (int) – The value used for the signal

  • signal_type (SignalType) – The “type” of the signal

CONTINUE = 7
EXIT = 8
INITIALISE = 0
PAUSE = 6
POWER_DOWN = 1
START = 3
STOP = 2
SYNC0 = 4
SYNC1 = 5
TIMER = 9
USER_0 = 10
USER_1 = 11
USER_2 = 12
USER_3 = 13
property signal_type
class spinnman.messages.scp.enums.SignalType(value)[source]

Bases: Enum

The type of signal, determined by how it is transmitted.

MULTICAST = 0
NEAREST_NEIGHBOUR = 2
POINT_TO_POINT = 1
spinnman.messages.scp.impl package
Submodules
spinnman.messages.scp.impl.count_state_response module
class spinnman.messages.scp.impl.count_state_response.CountStateResponse[source]

Bases: AbstractSCPResponse

An SCP response to a request for the number of cores in a given state.

property count

The count of the number of cores with the requested state.

Return type:

int

read_data_bytestring(data, offset)[source]

Reads the remainder of the data following the header.

Parameters:
  • data (bytes) – The byte-string to read from

  • offset (int) – The offset into the data after the headers

spinnman.messages.scp.impl.get_chip_info_response module
class spinnman.messages.scp.impl.get_chip_info_response.GetChipInfoResponse[source]

Bases: AbstractSCPResponse

An SCP response to a request for the version of software running.

property chip_info

The chip information received.

Return type:

ChipSummaryInfo

read_data_bytestring(data, offset)[source]

Reads the remainder of the data following the header.

Parameters:
  • data (bytes) – The byte-string to read from

  • offset (int) – The offset into the data after the headers

spinnman.messages.scp.impl.get_version_response module
class spinnman.messages.scp.impl.get_version_response.GetVersionResponse[source]

Bases: AbstractSCPResponse

An SCP response to a request for the version of software running.

read_data_bytestring(data, offset)[source]

Reads the remainder of the data following the header.

Parameters:
  • data (bytes) – The byte-string to read from

  • offset (int) – The offset into the data after the headers

property version_info

The version information received.

Return type:

VersionInfo

spinnman.messages.scp.impl.iptag_get_info_response module
class spinnman.messages.scp.impl.iptag_get_info_response.IPTagGetInfoResponse[source]

Bases: AbstractSCPResponse

An SCP response to a request for information about IP tags.

property fixed_size

The count of the number of fixed IP tag entries.

Return type:

int

property pool_size

The count of the IP tag pool size.

Return type:

int

read_data_bytestring(data, offset)[source]

Reads the remainder of the data following the header.

Parameters:
  • data (bytes) – The byte-string to read from

  • offset (int) – The offset into the data after the headers

property transient_timeout

The timeout for transient IP tags (i.e. responses to SCP commands).

Return type:

int

Module contents
class spinnman.messages.scp.impl.AppCopyRun(x, y, link, size, app_id, processors, chksum, wait=False)[source]

Bases: AbstractSCPRequest

An SCP request to copy an application and start it.

Parameters:
  • x (int) – The x-coordinate of the chip to read from, between 0 and 255

  • y (int) – The y-coordinate of the chip to read from, between 0 and 255

  • link (int) – The ID of the link from which to copy

  • size (int) – The number of bytes to read, must be divisible by 4

  • app_id (int) – The app to associate the copied binary with

  • processors (list(int)) – The processors to start on the chip

  • chksum (int) – The checksum of the data to copy

  • wait (bool) – Whether to start in wait mode or not

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.AppStop(app_id)[source]

Bases: AbstractSCPRequest

An SCP Request to stop an application.

Parameters:

app_id (int) – The ID of the application, between 0 and 255

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.ApplicationRun(app_id, x, y, processors, wait=False)[source]

Bases: AbstractSCPRequest

An SCP request to run an application loaded on a chip.

Parameters:
  • app_id (int) – The ID of the application to run, between 16 and 255

  • x (int) – The x-coordinate of the chip to run on, between 0 and 255

  • y (int) – The y-coordinate of the chip to run on, between 0 and 255

  • processors (list(int)) – The processors on the chip where the executable should be started, between 1 and 17

  • wait (bool) – True if the processors should enter a “wait” state on starting

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.BMPGetVersion(board)[source]

Bases: BMPRequest

An SCP request to read the version of software running on a core.

Parameters:

board (int) – The board to get the version from

Raises:

SpinnmanInvalidParameterException

  • If the chip coordinates are out of range

  • If the processor is out of range

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.BMPSetLed(led, action, boards)[source]

Bases: BMPRequest

Set the LED(s) of a board to either on, off or toggling.

This class is currently deprecated and untested as there is no known use except for Transceiver.set_led which is itself deprecated.

Parameters:
  • led (int or list(int)) – Number of the LED or an iterable of LEDs to set the state of (0-7)

  • action (LEDAction) – State to set the LED to, either on, off or toggle

  • boards (int or list(int)) – Specifies the board to control the LEDs of. This may also be an iterable of multiple boards (in the same frame).

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.CheckOKResponse(operation, command)[source]

Bases: AbstractSCPResponse

An SCP response to a request which returns nothing other than OK.

Parameters:
  • operation (str) – The operation being performed

  • command (str or Enum or int) – The command that was sent

read_data_bytestring(data, offset)[source]

Reads the remainder of the data following the header.

Parameters:
  • data (bytes) – The byte-string to read from

  • offset (int) – The offset into the data after the headers

class spinnman.messages.scp.impl.CountState(app_id, state)[source]

Bases: AbstractSCPRequest

An SCP Request to get a count of the cores in a particular state.

Parameters:
  • app_id (int) – The ID of the application, between 0 and 255

  • state (CPUState) – The state to count

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.DoSync(do_sync)[source]

Bases: AbstractSCPRequest

An SCP Request to control synchronization.

Parameters:

do_sync (bool) – Whether to synchronize or not

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.FillRequest(x, y, base_address, data, size)[source]

Bases: AbstractSCPRequest

An SCP request to fill a region of memory on a chip with repeated data

Parameters:
  • x (int) – The x-coordinate of the chip to read from, between 0 and 255

  • y (int) – The y-coordinate of the chip to read from, between 0 and 255

  • base_address (int) – The positive base address to start the fill from

  • data (int) – The data to fill in the space with

  • size (int) – The number of bytes to fill in

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.FixedRouteInit(x, y, entry, app_id)[source]

Bases: AbstractSCPRequest

Sets a fixed route entry.

Parameters:
  • x (int) – The x-coordinate of the chip, between 0 and 255, this is not checked due to speed restrictions

  • y (int) – The y-coordinate of the chip, between 0 and 255, this is not checked due to speed restrictions

  • entry (int) – the fixed route entry converted for writing

  • app_id (int) – The ID of the application with which to associate the routes. If not specified, defaults to 0.

Raises:

SpinnmanInvalidParameterException

  • If x is out of range

  • If y is out of range

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.FixedRouteRead(x, y, app_id)[source]

Bases: AbstractSCPRequest

Gets a fixed route entry.

Parameters:
  • x (int) – The x-coordinate of the chip, between 0 and 255, this is not checked due to speed restrictions

  • y (int) – The y-coordinate of the chip, between 0 and 255, this is not checked due to speed restrictions

  • app_id (int) – The ID of the application with which to associate the routes. If not specified, defaults to 0.

Raises:

SpinnmanInvalidParameterException

  • If x is out of range

  • If y is out of range

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.FloodFillData(nearest_neighbour_id, block_no, base_address, data, offset=0, length=None)[source]

Bases: AbstractSCPRequest

A request to start a flood fill of data.

Parameters:
  • nearest_neighbour_id (int) – The ID of the packet, between 0 and 127

  • block_no (int) – Which block this block is, between 0 and 255

  • base_address (int) – The base address where the data is to be loaded

  • data (bytes) – The data to load, between 4 and 256 bytes and the size must be divisible by 4

property bytestring

The request as a byte-string.

Return type:

bytes

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.FloodFillEnd(nearest_neighbour_id, app_id=0, processors=None, wait=False)[source]

Bases: AbstractSCPRequest

A request to start a flood fill of data.

Parameters:
  • nearest_neighbour_id (int) – The ID of the packet, between 0 and 127

  • app_id (int) – The application ID to start using the data, between 16 and 255. If not specified, no application is started

  • processors (list(int)) – A list of processors on which to start the application, each between 1 and 17. If not specified, no application is started.

  • wait (bool) – True if the binary should go into a “wait” state before executing

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.FloodFillStart(nearest_neighbour_id, n_blocks, x=None, y=None)[source]

Bases: AbstractSCPRequest

A request to start a flood fill of data.

Parameters:
  • nearest_neighbour_id (int) – The ID of the packet, between 0 and 127

  • n_blocks (int) – The number of blocks of data that will be sent, between 0 and 255

  • x (int) – The x-coordinate of the chip to load the data on to. If not specified, the data will be loaded on to all chips

  • y (int) – The y-coordinate of the chip to load the data on to. If not specified, the data will be loaded on to all chips

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.GetChipInfo(x, y, with_size=False)[source]

Bases: AbstractSCPRequest

An SCP request to read the chip information from a core.

Parameters:
  • x (int) – The x-coordinate of the chip to read from, between 0 and 255

  • y (int) – The y-coordinate of the chip to read from, between 0 and 255

  • with_size (bool) – Whether the size should be included in the response

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.GetVersion(x, y, p)[source]

Bases: AbstractSCPRequest

An SCP request to read the version of software running on a core.

Parameters:
  • x (int) – The x-coordinate of the chip to read from, between 0 and 255

  • y (int) – The y-coordinate of the chip to read from, between 0 and 255

  • p (int) – The ID of the processor to read the version from, between 0 and 31

Raises:

SpinnmanInvalidParameterException

  • If the chip coordinates are out of range

  • If the processor is out of range

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.IPTagClear(x, y, tag)[source]

Bases: AbstractSCPRequest

An SCP Request to clear an IP Tag.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

  • tag (int) – The tag, between 0 and 7

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.IPTagGet(x, y, tag)[source]

Bases: AbstractSCPRequest

An SCP Request to get an IP tag.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

  • tag (int) – The tag to get details of, between 0 and 7

  • tag – The tag, between 0 and 7

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.IPTagGetInfo(x, y)[source]

Bases: AbstractSCPRequest

An SCP Request information about IP tags.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.IPTagSet(x, y, host, port, tag, strip, use_sender=False)[source]

Bases: AbstractSCPRequest

An SCP Request to set an IP Tag.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

  • host (bytearray or list(int)) – The host address, as an array of 4 bytes

  • port (int) – The port, between 0 and 65535

  • tag (int) – The tag, between 0 and 7

  • strip (bool) – if the SDP header should be striped from the packet

  • use_sender (bool) – if the sender IP address and port should be used

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.IPTagSetTTO(x, y, tag_timeout)[source]

Bases: AbstractSCPRequest

An SCP request to set the transient timeout for future SCP requests.

Parameters:
  • x (int) – The x-coordinate of the chip to run on, between 0 and 255

  • y (int) – The y-coordinate of the chip to run on, between 0 and 255

  • tag_timeout (IPTAG_TIME_OUT_WAIT_TIMES) – The timeout value

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.ReadADC(board)[source]

Bases: BMPRequest

SCP Request for the data from the BMP including voltages and temperature.

This class is currently deprecated and untested as there is no known use except for Transceiver.read_adc_data which is itself deprecated.

Note

The equivalent code in Java is not deprecated.

Parameters:

board (int) – which board to request the ADC register from

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.ReadFPGARegister(fpga_num, register, board)[source]

Bases: BMPRequest

Requests the data from a FPGA’s register.

Sets up a read FPGA register request.

Parameters:
  • fpga_num (int) – FPGA number (0, 1 or 2) to communicate with.

  • register (int) – Register address to read to (will be rounded down to the nearest 32-bit word boundary).

  • board (int) – which board to request the FPGA register from

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

Bases: AbstractSCPRequest

An SCP request to read a region of memory via a link on a chip.

Parameters:
  • x (int) – The x-coordinate of the chip to read from, between 0 and 255

  • y (int) – The y-coordinate of the chip to read from, between 0 and 255

  • link (int) – The ID of the link down which to send the query

  • base_address (int) – The positive base address to start the read from

  • size (int) – The number of bytes to read, between 1 and 256

  • cpu (int) – The CPU core to use, normally 0 (or if a BMP, the board slot number)

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.ReadMemory(x, y, base_address, size, cpu=0)[source]

Bases: AbstractSCPRequest

An SCP request to read a region of memory on a chip.

Parameters:
  • x (int) – The x-coordinate of the chip to read from, between 0 and 255

  • y (int) – The y-coordinate of the chip to read from, between 0 and 255

  • base_address (int) – The positive base address to start the read from

  • size (int) – The number of bytes to read, between 1 and 256

Raises:

SpinnmanInvalidParameterException

  • If the chip coordinates are out of range

  • If the base address is not a positive number

  • If the size is out of range

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.ReverseIPTagSet(x, y, destination_x, destination_y, destination_p, port, tag, sdp_port)[source]

Bases: AbstractSCPRequest

An SCP Request to set an IP Tag.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

  • destination_x (int) – The x-coordinate of the destination chip, between 0 and 255

  • destination_y (int) – The y-coordinate of the destination chip, between 0 and 255

  • destination_p (int) – The ID of the destination processor, between 0 and 17

  • port (int) – The port, between 0 and 65535

  • tag (int) – The tag, between 0 and 7

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.RouterAlloc(x, y, app_id, n_entries)[source]

Bases: AbstractSCPRequest

An SCP Request to allocate space for routing entries.

Parameters:
  • x (int) – The x-coordinate of the chip to allocate on, between 0 and 255

  • y (int) – The y-coordinate of the chip to allocate on, between 0 and 255

  • app_id (int) – The ID of the application, between 0 and 255

  • n_entries (int) – The number of entries to allocate

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.RouterClear(x, y)[source]

Bases: AbstractSCPRequest

A request to clear the router on a chip.

Parameters:
  • x (int) – The x-coordinate of the chip, between 0 and 255

  • y (int) – The y-coordinate of the chip, between 0 and 255

Raises:

SpinnmanInvalidParameterException

  • If x is out of range

  • If y is out of range

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.RouterInit(x, y, n_entries, table_address, base_address, app_id)[source]

Bases: AbstractSCPRequest

A request to initialize the router on a chip.

Parameters:
  • x (int) – The x-coordinate of the chip, between 0 and 255

  • y (int) – The y-coordinate of the chip, between 0 and 255

  • n_entries (int) – The number of entries in the table, more than 0

  • table_address (int) – The allocated table address

  • base_address (int) – The base_address containing the entries

  • app_id (int) – The ID of the application with which to associate the routes. If not specified, defaults to 0.

Raises:

SpinnmanInvalidParameterException

  • If x is out of range

  • If y is out of range

  • If n_entries is 0 or less

  • If table_address is not positive

  • If base_address is not positive

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.SDRAMAlloc(x, y, app_id, size, tag=None, retry_tag=True)[source]

Bases: AbstractSCPRequest

An SCP Request to allocate space in the SDRAM space.

Parameters:
  • x (int) – The x-coordinate of the chip to allocate on, between 0 and 255

  • y (int) – The y-coordinate of the chip to allocate on, between 0 and 255

  • app_id (int) – The ID of the application, between 0 and 255

  • size (int) – The size in bytes of memory to be allocated

  • tag (int) – The tag for the SDRAM, a 8-bit (chip-wide) tag that can be looked up by a SpiNNaker application to discover the address of the allocated block. If 0 then no tag is applied.

  • retry_tag (bool) – If a tag is used, add a safety check to retry the tag. This can avoid issues with re-allocating memory on a retry message.

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.SDRAMDeAlloc(x, y, app_id, base_address=None)[source]

Bases: AbstractSCPRequest

An SCP Request to free space in the SDRAM.

Parameters:
  • x (int) – The x-coordinate of the chip to allocate on, between 0 and 255

  • y (int) – The y-coordinate of the chip to allocate on, between 0 and 255

  • app_id (int) – The ID of the application, between 0 and 255

  • base_address (int or None) – The start address in SDRAM to which the block needs to be deallocated, or None if deallocating via app_id

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.SendSignal(app_id, signal)[source]

Bases: AbstractSCPRequest

An SCP Request to send a signal to cores.

Parameters:
  • app_id (int) – The ID of the application, between 0 and 255

  • signal (Signal) – The signal to send

Raises:

SpinnmanInvalidParameterException – If app_id is out of range

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.SetLED(x, y, cpu, led_states)[source]

Bases: AbstractSCPRequest

A request to change the state of an SetLED.

This class is currently deprecated and untested as there is no known use except for Transceiver.set_led which is itself deprecated.

Parameters:
  • x (int) – The x-coordinate of the chip, between 0 and 255

  • y (int) – The y-coordinate of the chip, between 0 and 255

  • cpu (int) – The CPU-number to use to set the SetLED.

  • led_states (dict(int,int)) – A dictionary mapping SetLED index to state with 0 being off, 1 on and 2 inverted.

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.SetPower(power_command, boards, delay=0.0, board_to_send_to=0)[source]

Bases: BMPRequest

An SCP request for the BMP to power on or power off a rack of boards.

Note

There is currently a bug in the BMP that means some boards don’t respond to power commands not sent to BMP 0. Thus changing the board_to_send_to parameter is not recommended!

Parameters:
  • power_command (PowerCommand) – The power command being sent

  • boards (int or list(int)) – The boards on the same backplane to power on or off

  • delay (float) – Number of seconds delay between power state changes of the different boards.

  • board_to_send_to (int) –

    The optional board to send the command to if this is to be sent to a frame of boards.

    Note

    Leave this at the default because of hardware bugs.

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.WriteFPGARegister(fpga_num, addr, value, board)[source]

Bases: BMPRequest

A request for writing a word to a FPGA (SPI) register.

See the SpI/O project’s spinnaker_fpga design’s README for a listing of FPGA registers. The SpI/O project can be found on GitHub at: https://github.com/SpiNNakerManchester/spio/

Parameters:
  • fpga_num (int) – FPGA number (0, 1 or 2) to communicate with.

  • addr (int) – Register address to read or write to (will be rounded down to the nearest 32-bit word boundary).

  • value (int) – A 32-bit int value to write to the register

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

Bases: AbstractSCPRequest

A request to write memory on a neighbouring chip.

Parameters:
  • x (int) – The x-coordinate of the chip whose neighbour will be written to, between 0 and 255

  • y (int) – The y-coordinate of the chip whose neighbour will be written to, between 0 and 255

  • cpu (int) – The CPU core to use, normally 0 (or if a BMP, the board slot number)

  • link (int) – The link number to write to between 0 and 5 (or if a BMP, the FPGA between 0 and 2)

  • base_address (int) – The base_address to start writing to

  • data (bytes) – Up to 256 bytes of data to write

property bytestring

The request as a byte-string.

Return type:

bytes

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinnman.messages.scp.impl.WriteMemory(x, y, base_address, data, cpu=0)[source]

Bases: AbstractSCPRequest

A request to write memory on a chip.

Parameters:
  • x (int) – The x-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions

  • y (int) – The y-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions

  • base_address (int) – The base_address to start writing to the base address is not checked to see if its not valid

  • data (bytearray or bytes) – between 1 and 256 bytes of data to write; this is not checked due to speed restrictions

property bytestring

The request as a byte-string.

Return type:

bytes

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

Module contents
class spinnman.messages.scp.SCPRequestHeader(command, sequence=0)[source]

Bases: object

Represents the header of an SCP Request Each optional parameter in the constructor can be set to a value other than None once, after which it is immutable. It is an error to set a parameter that is not currently None.

Parameters:
  • command (SCPCommand) – The SCP command

  • sequence (int) – The number of the SCP packet in order of all packets sent or received, between 0 and 65535

Raises:

SpinnmanInvalidParameterException – If one of the parameters is incorrect

property bytestring

The header as a byte-string.

Return type:

bytes

property command

The command of the SCP packet.

Return type:

SCPCommand

property sequence

The sequence number of the SCP packet, between 0 and 65535.

Return type:

int

class spinnman.messages.scp.SCPResponseHeader(result=None, sequence=None)[source]

Bases: object

Represents the header of an SCP Response.

Parameters:
static from_bytestring(data, offset)[source]

Read a header from a byte-string.

Parameters:
  • data (bytes) – The byte-string to read from

  • offset (int) –

property result

The result of the SCP response.

Return type:

SCPResult

property sequence

The sequence number of the SCP response, between 0 and 65535.

Return type:

int

spinnman.messages.sdp package
Module contents
class spinnman.messages.sdp.SDPFlag(value)[source]

Bases: Enum

SDPFlag for the message.

REPLY_EXPECTED = 135
REPLY_EXPECTED_NO_P2P = 167
REPLY_NOT_EXPECTED = 7
REPLY_NOT_EXPECTED_NO_P2P = 39
class spinnman.messages.sdp.SDPHeader(flags=None, tag=None, destination_port=None, destination_cpu=None, destination_chip_x=None, destination_chip_y=None, source_port=None, source_cpu=None, source_chip_x=None, source_chip_y=None)[source]

Bases: object

Represents the header of an SDP message. Each optional parameter in the constructor can be set to a value other than None once, after which it is immutable. It is an error to set a parameter that is not currently None.

Parameters:
  • flags (SDPFlag) – Any flags for the packet

  • tag (int) – The IP tag of the packet between 0 and 255, or None if it is to be set later

  • destination_port (int) – The destination port of the packet between 0 and 7

  • destination_cpu (int) – The destination processor ID within the chip between 0 and 31

  • destination_chip_x (int) – The x-coordinate of the destination chip between 0 and 255

  • destination_chip_y (int) – The y-coordinate of the destination chip between 0 and 255

  • source_port (int) – The source port of the packet between 0 and 7, or None if it is to be set later

  • source_cpu (int) – The source processor ID within the chip between 0 and 31, or None if it is to be set later

  • source_chip_x (int) – The x-coordinate of the source chip between 0 and 255, or None if it is to be set later

  • source_chip_y (int) – The y-coordinate of the source chip between 0 and 255, or None if it is to be set later

property bytestring

The header as a byte-string.

Return type:

bytes

property destination_chip_x

The x-coordinate of the destination chip of the packet, between 0 and 255 (settable).

Return type:

int

property destination_chip_y

The y-coordinate of the destination chip of the packet, between 0 and 255 (settable).

Return type:

int

property destination_cpu

The core on the destination chip, between 0 and 31 (settable).

Return type:

int

property destination_port

The destination SDP port of the packet, between 0 and 7 (settable).

Return type:

int

property flags

The flags of the packet (settable).

Return type:

SDPFlag

static from_bytestring(data, offset)[source]

Read the header from a byte-string.

Parameters:
  • data (bytes or bytearray) – The byte-string to read the header from

  • offset (int) – The offset into the data from which to start reading

get_physical_cpu_id()[source]
property source_chip_x

The x-coordinate of the source chip of the packet, between 0 and 255 (settable).

Return type:

int

property source_chip_y

The y-coordinate of the source chip of the packet, between 0 and 255 (settable).

Return type:

int

property source_cpu

The core on the source chip, between 0 and 31 (settable).

Return type:

int

property source_port

The source SDP port of the packet, between 0 and 7 (settable).

Return type:

int

property tag

The tag of the packet, between 0 and 255 (settable).

Return type:

int

class spinnman.messages.sdp.SDPMessage(sdp_header, data=None, offset=0)[source]

Bases: object

Wraps up an SDP message with a header and optional data.

Parameters:
  • sdp_header (SDPHeader) – The header of the message

  • data (bytes or bytearray or None) – The data of the SDP packet, or None if no data

  • offset (int) – The offset where the valid data starts

property bytestring

The byte-string of the message.

Return type:

bytes

property data

The data in the packet.

Return type:

bytes or bytearray or None

static from_bytestring(data, offset)[source]
Parameters:
Return type:

SDPMessage

property offset

The offset where the valid data starts.

Return type:

int

property sdp_header

The header of the packet.

Return type:

SDPHeader

spinnman.messages.spinnaker_boot package
Subpackages
spinnman.messages.spinnaker_boot.boot_data package
Module contents

This package contains no Python code.

Module contents
class spinnman.messages.spinnaker_boot.SpinnakerBootMessage(opcode, operand_1, operand_2, operand_3, data=None, offset=0)[source]

Bases: object

A message used for booting the board.

Parameters:
  • opcode (SpinnakerBootOpCode) – The operation of this packet

  • operand_1 (int) – The first operand

  • operand_2 (int) – The second operand

  • operand_3 (int) – The third operand

  • data (bytes or bytearray) – The optional data, up to 256 words

  • offset (int) – The offset of the valid data

Raises:

SpinnmanInvalidParameterException – If the opcode is not a valid value

property bytestring

The message as a byte-string.

Return type:

bytes

property data

The data, or None if no data.

Return type:

bytes or bytearray

static from_bytestring(data, offset)[source]
Parameters:
Return type:

SpinnakerBootMessage

property opcode

The operation of this packet.

Return type:

SpinnakerBootOpCode

property operand_1

The first operand.

Return type:

int

property operand_2

The second operand.

Return type:

int

property operand_3

The third operand.

Return type:

int

class spinnman.messages.spinnaker_boot.SpinnakerBootMessages(board_version=None, extra_boot_values=None)[source]

Bases: object

A set of boot messages to be sent to boot the board.

Parameters:
Raises:
property messages

An iterable of message to be sent.

Return type:

iterable(SpinnakerBootMessage)

class spinnman.messages.spinnaker_boot.SpinnakerBootOpCode(value)[source]

Bases: Enum

Boot message Operation Codes.

FLOOD_FILL_BLOCK = 3
FLOOD_FILL_CONTROL = 5
FLOOD_FILL_START = 1
HELLO = 65
class spinnman.messages.spinnaker_boot.SystemVariableDefinition(value)[source]

Bases: Enum

Defines the system variables available.

Parameters:
  • data_type (_DataType) – The data type of the variable

  • offset (int) – The offset from the start of the system variable structure where the variable is found

  • default (object) – The default value assigned to the variable if not overridden

  • array_size (int or None) – The length of the array, or None if not an array

allocated_tag_table_address = _Definition(offset=220, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The address of the allocated tag table')
app_data_table_address = _Definition(offset=228, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The address of the application data table')
property array_size
board_info = _Definition(offset=248, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='A pointer to the board information structure')
board_test_flags = _Definition(offset=103, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='Board testing flags')
boot_signature = _Definition(offset=92, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The boot signature')
clock_divisor = _Definition(offset=14, data_type=<_DataType.BYTE: 1>, default=51, array_size=None, doc='The clock divisors for system & router clocks')
clock_drift = _Definition(offset=56, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The clock drift')
clock_milliseconds = _Definition(offset=16, data_type=<_DataType.LONG: 8>, default=0, array_size=None, doc='The time since startup in milliseconds')
cpu_clock_mhz = _Definition(offset=36, data_type=<_DataType.SHORT: 2>, default=200, array_size=None, doc='The CPU clock frequency in MHz')
cpu_information_base_address = _Definition(offset=204, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The base address of the CPU information blocks')
property data_type
debug_x = _Definition(offset=5, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The x-coordinate of the chip to send debug messages to')
debug_y = _Definition(offset=4, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The y-coordinate of the chip to send debug messages to')
property default
ethernet_ip_address = _Definition(offset=240, data_type=<_DataType.BYTE_ARRAY: 16>, default=b'\x00\x00\x00\x00', array_size=4, doc='The IP address of the chip')
first_free_router_entry = _Definition(offset=224, data_type=<_DataType.SHORT: 2>, default=0, array_size=None, doc='The ID of the first free router entry')
fixed_route_copy = _Definition(offset=244, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='A (virtual) copy of the router FR register')
hardware_version = _Definition(offset=10, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The version of the hardware in use')
iobuf_size = _Definition(offset=80, data_type=<_DataType.INT: 4>, default=16384, array_size=None, doc='The size of the iobuf buffer in bytes')
is_ethernet_available = _Definition(offset=11, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='Indicates if Ethernet is available on this chip')
is_peer_to_peer_available = _Definition(offset=6, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='Indicates if peer-to-peer is working on the chip')
is_root_chip = _Definition(offset=64, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='Indicates if this is the root chip')
last_biff_id = _Definition(offset=102, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='Last ID used in BIFF packet')
led_0 = _Definition(offset=48, data_type=<_DataType.INT: 4>, default=1, array_size=None, doc='The first part of the LED definitions')
led_1 = _Definition(offset=52, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The last part of the LED definitions')
led_half_period_10_ms = _Definition(offset=43, data_type=<_DataType.BYTE: 1>, default=1, array_size=None, doc='The LED half-period in 10 ms units, or 1 to show load')
lock = _Definition(offset=100, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The lock')
log_peer_to_peer_sequence_length = _Definition(offset=13, data_type=<_DataType.BYTE: 1>, default=4, array_size=None, doc='Log (base 2) of the peer-to-peer sequence length')
ltpc_period = _Definition(offset=26, data_type=<_DataType.SHORT: 2>, default=0, array_size=None, doc='')
monitor_mailbox_flags = _Definition(offset=236, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The monitor incoming mailbox flags')
n_active_peer_to_peer_addresses = _Definition(offset=226, data_type=<_DataType.SHORT: 2>, default=0, array_size=None, doc='The number of active peer-to-peer addresses')
n_scamp_working_cores = _Definition(offset=189, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The number of SCAMP working cores')
n_shared_message_buffers = _Definition(offset=65, data_type=<_DataType.BYTE: 1>, default=7, array_size=None, doc='The number of shared message buffers')
n_working_cores = _Definition(offset=188, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The number of working cores')
nearest_ethernet_x = _Definition(offset=9, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The y-coordinate of the nearest chip with Ethernet')
nearest_ethernet_y = _Definition(offset=8, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The x-coordinate of the nearest chip with Ethernet')
nearest_neighbour_delay_us = _Definition(offset=66, data_type=<_DataType.BYTE: 1>, default=20, array_size=None, doc='The delay between nearest-neighbour packets in microseconds')
nearest_neighbour_forward = _Definition(offset=40, data_type=<_DataType.BYTE: 1>, default=63, array_size=None, doc='Nearest-Neighbour forward parameter')
nearest_neighbour_last_id = _Definition(offset=7, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The last ID used in nearest neighbour transaction')
nearest_neighbour_memory_pointer = _Definition(offset=96, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The memory pointer for nearest neighbour global operations')
nearest_neighbour_retry = _Definition(offset=41, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='Nearest-Neighbour retry parameter')
netinit_bc_wait_time = _Definition(offset=44, data_type=<_DataType.BYTE: 1>, default=50, array_size=None, doc='The time to wait after last BC during network initialisation in 10 ms units')
netinit_phase = _Definition(offset=45, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The phase of boot process (see enum netinit_phase_e)')
property offset
p2p_b_repeats = _Definition(offset=12, data_type=<_DataType.BYTE: 1>, default=4, array_size=None, doc='Number of times to send out P2PB packets')
p2p_root_x = _Definition(offset=47, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The x-coordinate of the chip from which the system was booted')
p2p_root_y = _Definition(offset=46, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The y-coordinate of the chip from which the system was booted')
padding_2 = _Definition(offset=68, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='A word of padding')
padding_3 = _Definition(offset=190, data_type=<_DataType.SHORT: 2>, default=0, array_size=None, doc='A short of padding')
padding_4 = _Definition(offset=252, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='A word of padding')
peer_to_peer_hop_table_address = _Definition(offset=216, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The address of the peer-to-peer hop tables')
physical_to_virtual_core_map = _Definition(offset=148, data_type=<_DataType.BYTE_ARRAY: 16>, default=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', array_size=20, doc='The physical core ID to virtual core ID map')
random_seed = _Definition(offset=60, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The random seed')
router_table_copy_address = _Definition(offset=212, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The address of the copy of the routing tables')
router_time_phase_timer = _Definition(offset=32, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The router time-phase timer')
sdram_base_address = _Definition(offset=192, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The base address of SDRAM')
sdram_clock_frequency_mhz = _Definition(offset=38, data_type=<_DataType.SHORT: 2>, default=130, array_size=None, doc='The SDRAM clock frequency in MHz')
sdram_heap_address = _Definition(offset=76, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The base address of the user SDRAM heap')
shared_message_buffer_address = _Definition(offset=232, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The address of the shared message buffers')
shared_message_count_in_use = _Definition(offset=108, data_type=<_DataType.SHORT: 2>, default=0, array_size=None, doc='The number of shared message buffers in use')
shared_message_first_free_address = _Definition(offset=104, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='Pointer to the first free shared message buffer')
shared_message_maximum_used = _Definition(offset=110, data_type=<_DataType.SHORT: 2>, default=0, array_size=None, doc='The maximum number of shared message buffers used')
software_watchdog_count = _Definition(offset=67, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The number of watch dog timeouts before an error is raised')
status_map = _Definition(offset=128, data_type=<_DataType.BYTE_ARRAY: 16>, default=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', array_size=20, doc='The status map set during SCAMP boot')
system_buffer_words = _Definition(offset=88, data_type=<_DataType.INT: 4>, default=32768, array_size=None, doc='The size of the system buffer in words')
system_ram_base_address = _Definition(offset=196, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The base address of System RAM')
system_ram_heap_address = _Definition(offset=72, data_type=<_DataType.INT: 4>, default=1024, array_size=None, doc='The base address of the system SDRAM heap')
system_sdram_base_address = _Definition(offset=200, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The base address of System SDRAM')
system_sdram_bytes = _Definition(offset=84, data_type=<_DataType.INT: 4>, default=8388608, array_size=None, doc='The size of the system SDRAM in bytes')
system_sdram_heap_address = _Definition(offset=208, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The base address of the system SDRAM heap')
time_milliseconds = _Definition(offset=24, data_type=<_DataType.SHORT: 2>, default=0, array_size=None, doc='The number of milliseconds in the current second')
time_phase_scale = _Definition(offset=15, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The time-phase scaling factor')
unix_timestamp = _Definition(offset=28, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The time in seconds since midnight, 1st January 1970')
user_temp_0 = _Definition(offset=112, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The first user variable')
user_temp_1 = _Definition(offset=116, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The second user variable')
user_temp_2 = _Definition(offset=120, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The third user variable')
user_temp_4 = _Definition(offset=124, data_type=<_DataType.INT: 4>, default=0, array_size=None, doc='The fourth user variable')
virtual_to_physical_core_map = _Definition(offset=168, data_type=<_DataType.BYTE_ARRAY: 16>, default=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', array_size=20, doc='The virtual core ID to physical core ID map')
x = _Definition(offset=1, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The x-coordinate of the chip')
x_size = _Definition(offset=3, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The number of chips in the x-dimension')
y = _Definition(offset=0, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The y-coordinate of the chip')
y_size = _Definition(offset=2, data_type=<_DataType.BYTE: 1>, default=0, array_size=None, doc='The number of chips in the y-dimension')
Submodules
spinnman.messages.multicast_message module
class spinnman.messages.multicast_message.MulticastMessage(key, payload=None)[source]

Bases: object

A SpiNNaker Multicast message, comprising a key (determining the target locations) and an optional payload.

Parameters:
  • key (int) – The key of the packet

  • payload (int) – The optional payload of the packet

property key

The key of the packet.

Return type:

int

property payload

The payload of the packet if there is one, or None if there is no payload.

Return type:

int or None

Module contents
spinnman.model package
Subpackages
spinnman.model.enums package
Module contents
class spinnman.model.enums.CPUState(value)[source]

Bases: Enum

SARK CPU States.

CPU_STATE_12 = 12

Spare

CPU_STATE_13 = 13

Spare

CPU_STATE_14 = 14

Spare

C_MAIN = 6

Entered c_main

DEAD = 0

Dead core

FINISHED = 11

Exited application

IDLE = 15

Idle (SARK stub)

INITIALISING = 4

Initialising (transient)

PAUSED = 10

Paused in application

POWERED_DOWN = 1

Powered down

READY = 5

Ready to execute

RUNNING = 7

Running (API/Event)

RUN_TIME_EXCEPTION = 2

Died with Run Time Error

SYNC0 = 8

Waiting for sync 0

SYNC1 = 9

Waiting for sync 1

WATCHDOG = 3

Watchdog expired

class spinnman.model.enums.DiagnosticFilterDefaultRoutingStatus(value)[source]

Bases: Enum

Default routing flags for the diagnostic filters.

Note

Only one has to match for the counter to be incremented.

DEFAULT_ROUTED = 0

Packet is to be default routed

NON_DEFAULT_ROUTED = 1

Packet is not to be default routed

class spinnman.model.enums.DiagnosticFilterDestination(value)[source]

Bases: Enum

Destination flags for the diagnostic filters.

Note

Only one has to match for the counter to be incremented.

DUMP = 0

Destination is to dump the packet

Destination is link 0

Destination is link 1

Destination is link 2

Destination is link 3

Destination is link 4

Destination is link 5

LOCAL = 1

Destination is a local core (but not the monitor core)

LOCAL_MONITOR = 2

Destination is the local monitor core

class spinnman.model.enums.DiagnosticFilterEmergencyRoutingStatus(value)[source]

Bases: Enum

Emergency routing status flags for the diagnostic filters.

Note

Only one has to match for the counter to be incremented.

FIRST_STAGE = 2

Packet is in first hop of emergency route; packet wouldn’t have reached this router without emergency routing

FIRST_STAGE_COMBINED = 1

Packet is in first hop of emergency route; packet should also have been sent here by normal routing

NORMAL = 0

Packet is not emergency routed

SECOND_STAGE = 3

Packet is in last hop of emergency route and should now return to normal routing

class spinnman.model.enums.DiagnosticFilterPacketType(value)[source]

Bases: Enum

Packet type flags for the diagnostic filters.

Note

Only one has to match for the counter to be incremented.

FIXED_ROUTE = 3

Packet is fixed-route

MULTICAST = 0

Packet is multicast

NEAREST_NEIGHBOUR = 2

Packet is nearest-neighbour

POINT_TO_POINT = 1

Packet is point-to-point

class spinnman.model.enums.DiagnosticFilterPayloadStatus(value)[source]

Bases: Enum

Payload flags for the diagnostic filters.

Note

Only one has to match for the counter to be incremented.

WITHOUT_PAYLOAD = 1

Packet doesn’t have a payload

WITH_PAYLOAD = 0

Packet has a payload

class spinnman.model.enums.DiagnosticFilterSource(value)[source]

Bases: Enum

Source flags for the diagnostic filters.

Note

Only one has to match for the counter to be incremented.

LOCAL = 0

Source is a local core

NON_LOCAL = 1

Source is not a local core

class spinnman.model.enums.ExecutableType(value)[source]

Bases: Enum

The different types of executable from the perspective of how they are started and controlled.

NO_APPLICATION = 3

Situation where there user has supplied no application but for some reason still wants to run.

RUNNING = 0

Runs immediately without waiting for barrier and then exits.

SYNC = 1

Calls spin1_start(SYNC_WAIT) and then eventually spin1_exit().

SYSTEM = 4

Runs immediately without waiting for barrier and never ends.

USES_SIMULATION_INTERFACE = 2

Calls simulation_run() and simulation_exit() / simulation_handle_pause_resume().

class spinnman.model.enums.MailboxCommand(value)[source]

Bases: Enum

Commands sent between an application and the monitor processor.

SHM_CMD = 4

The mailbox contains a command

SHM_IDLE = 0

The mailbox is idle

SHM_MSG = 1

The mailbox contains an SDP message

SHM_NOP = 2

The mailbox contains a no-operation (used for watchdog)

SHM_SIGNAL = 3

The mailbox contains a signal

class spinnman.model.enums.P2PTableRoute(value)[source]

Bases: Enum

P2P Routing table routes.

EAST = 0
MONITOR = 7

Route to the monitor on the current chip

NONE = 6

No route to this chip

NORTH = 2
NORTH_EAST = 1
SOUTH = 5
SOUTH_WEST = 4
WEST = 3
class spinnman.model.enums.RouterError(value)[source]

Bases: Enum

Router error flags.

ERROR = 2147483648

Error packet detected (0x80000000)

FRAMING = 268435456

Framing Error (0x10000000)

OVERFLOW = 1073741824

More than one error packet detected (0x40000000)

PARITY = 536870912

Parity Error (0x20000000)

TIMESTAMP = 134217728

Timestamp Error (0x08000000)

class spinnman.model.enums.RunTimeError(value)[source]

Bases: Enum

SARK Run time errors.

ABORT = 9

Generic user abort

API = 19

API startup failure

DABT = 5

Data abort

DIVBY0 = 11

Divide by zero

ENABLE = 15

Bad event enable

EVENT = 12

Event startup failure

FIQ = 7

Unhandled FIQ

IOBUF = 14

Failed to allocate IO buffer

IRQ = 6

Unhandled IRQ

MALLOC = 10

“malloc” failure

NONE = 0

No error

NULL = 16

Generic null pointer error

PABT = 4

Prefetch abort

PKT = 17

Pkt startup failure

RESET = 1

Branch through zero

SARK_VERSRION_INCORRECT = 20

SW version conflict

SVC = 3

Undefined SVC or no handler

SWERR = 13

Fatal SW error

TIMER = 18

Timer startup failure

UNDEF = 2

Undefined instruction

VIC = 8

Unconfigured VIC vector

Module contents
class spinnman.model.ADCInfo(adc_data, offset)[source]

Bases: object

Container for the ADC data that’s been retrieved from an FPGA.

Parameters:

adc_data (bytes) – bytes from an SCP packet containing ADC information

Raises:

SpinnmanInvalidParameterException – If the message does not contain valid ADC information

property fan_0

Fan 0.

Return type:

float or None

property fan_1

Fan 1.

Return type:

float or None

property temp_btm

Temperature bottom.

Return type:

float

property temp_ext_0

Temperature external 0.

Return type:

float or None

property temp_ext_1

Temperature external 1.

Return type:

float or None

property temp_top

Temperature top.

Return type:

float

property voltage_1_2a

Actual voltage of the 1.2V a supply rail.

Return type:

float

property voltage_1_2b

Actual voltage of the 1.2V b supply rail.

Return type:

float

property voltage_1_2c

Actual voltage of the 1.2V c supply rail.

Return type:

float

property voltage_1_8

Actual voltage of the 1.8V supply rail.

Return type:

float

property voltage_3_3

Actual voltage of the 3.3V supply rail.

Return type:

float

property voltage_supply

Actual voltage of the main power supply (nominally 12V).

Return type:

float

class spinnman.model.BMPConnectionData(cabinet, frame, ip_address, boards, port_num)[source]

Bases: object

Contains the details of a BMP connection.

property boards

The boards to be addressed.

Return type:

iterable(int)

property cabinet

The cabinet number.

Return type:

int

property frame

The frame number.

Return type:

int

property ip_address

The IP address of the BMP.

Return type:

str

property port_num

The port number associated with this BMP connection.

Returns:

The port number

class spinnman.model.CPUInfo(x, y, p, cpu_data, offset)[source]

Bases: object

Represents information about the state of a CPU.

Parameters:
  • x (int) – The x-coordinate of a chip

  • y (int) – The y-coordinate of a chip

  • p (int) – The ID of a core on the chip

  • cpu_data (bytes) – A byte-string received from SDRAM on the board

  • offset (int) –

property application_id

The ID of the application running on the core.

Returns:

The ID of the application

Return type:

int

property application_mailbox_command

The command currently in the mailbox being sent from the monitor processor to the application.

Returns:

The command

Return type:

MailboxCommand

property application_mailbox_data_address

The address of the data in SDRAM for the application mailbox.

Returns:

The address of the data

Return type:

int

property application_name

The name of the application running on the core.

Returns:

The name of the application

Return type:

str

property iobuf_address

The address of the IOBUF buffer in SDRAM.

Returns:

The address

Return type:

int

The current link register value (LR).

Returns:

The LR value

Return type:

int

property monitor_mailbox_command

The command currently in the mailbox being sent from the application to the monitor processor.

Returns:

The command

Return type:

MailboxCommand

property monitor_mailbox_data_address

The address of the data in SDRAM of the monitor mailbox.

Returns:

The address of the data

Return type:

int

property p

The ID of the core on the chip.

Returns:

The ID of the core

Return type:

int

property physical_cpu_id

The physical ID of this processor.

Returns:

The physical ID of the processor

Return type:

int

property processor_state_register

The value in the processor state register (PSR).

Returns:

The PSR value

Return type:

int

property registers

The current register values (r0 - r7).

Returns:

An array of 8 values, one for each register

Return type:

list(int)

property run_time_error

The reason for a run time error.

Returns:

The run time error

Return type:

RunTimeError

property software_error_count

The number of software errors counted.

Returns:

The number of software errors

Return type:

int

property software_source_filename_address

The address of the filename of the software source.

Returns:

The filename

Return type:

str

property software_source_line_number

The line number of the software source.

Returns:

The line number

Return type:

int

property software_version

The software version.

Returns:

The software version

Return type:

int

property stack_pointer

The current stack pointer value (SP).

Returns:

The SP value

Return type:

int

property state

The current state of the core.

Returns:

The state of the core

Return type:

CPUState

property time

The time at which the application started.

Returns:

The time in seconds since 00:00:00 on the 1st January 1970

Return type:

int

property user

The current user values (user0 - user3).

Returns:

An array of 4 values, one for each user value

Return type:

list(int)

property x

The x-coordinate of the chip containing the core.

Returns:

The x-coordinate of the chip

Return type:

int

property y

The y-coordinate of the chip containing the core.

Returns:

The y-coordinate of the chip

Return type:

int

class spinnman.model.CPUInfos[source]

Bases: object

A set of CPU information objects.

add_processor(x, y, processor_id, cpu_info)[source]

Add a processor on a given chip to the set.

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

  • y (int) – The y-coordinate of the chip

  • processor_id (int) – A processor ID

  • cpu_info (CPUInfo) – The CPU information for the core

property cpu_infos

The one per core core info.

Returns:

iterable of x,y,p core info

get_cpu_info(x, y, p)[source]

Get the information for the given core on the given chip.

is_core(x, y, p)[source]

Determine if there is a CPU Info for x, y, p.

items()[source]
iteritems()[source]

Get an iterable of (x, y, p), cpu_info.

iterkeys()[source]

Get an iterable of (x, y, p).

itervalues()[source]

Get an iterable of cpu_info.

keys()[source]
values()[source]
class spinnman.model.ChipInfo(system_data, offset)[source]

Bases: object

Represents the system variables for a chip, received from the chip SDRAM.

Parameters:
  • system_data (bytes) – A byte-string retrieved from SDRAM on the board

  • offset (int) – The offset into the byte-string where the actual data starts

Raises:

SpinnmanInvalidParameterException – If the data doesn’t contain valid system data information

property cpu_clock_mhz

The speed of the CPU clock in MHz.

Return type:

int

property cpu_information_base_address

The base address of the CPU information structure.

Return type:

int

property first_free_router_entry

The ID of the first free routing entry on the chip.

Return type:

int

property iobuf_size

The size of the IOBUF buffers in bytes.

Return type:

int

property ip_address

The IP address of the chip, or None if no Ethernet.

Return type:

str

property is_ethernet_available

Whether the Ethernet is running on this chip.

Return type:

bool

The links that are available on the chip.

Return type:

iterable(int)

property nearest_ethernet_x

The X-coordinate of the nearest chip with Ethernet.

Return type:

int

property nearest_ethernet_y

The Y-coordinate of the nearest chip with Ethernet.

Return type:

int

property physical_to_virtual_core_map

The physical core ID to virtual core ID map; entries with a value of 0xFF are non-operational cores.

Return type:

bytearray

router_table_copy_address()[source]

The address of the copy of the router table.

Return type:

int

property sdram_base_address

The base address of the user region of SDRAM on the chip.

Return type:

int

property sdram_heap_address

The address of the base of the heap in SDRAM.

Return type:

int

property system_ram_heap_address

The address of the base of the heap in system RAM.

Return type:

int

property system_sdram_base_address

The base address of the System SDRAM region on the chip.

Return type:

int

property virtual_core_ids

A list of available cores by virtual core ID (including the monitor).

Return type:

iterable(int)

property virtual_to_physical_core_map

The virtual core ID to physical core ID map; entries with a value of 0xFF are non-operational cores.

Return type:

bytearray

property x

The X-coordinate of the chip.

Return type:

int

property x_size

The number of chips in the X-dimension.

Return type:

int

property y

The Y-coordinate of the chip.

Return type:

int

property y_size

The number of chips in the Y-dimension.

Return type:

int

class spinnman.model.ChipSummaryInfo(chip_summary_data, offset, x, y)[source]

Bases: object

Represents the chip summary information read via an SCP command.

Parameters:
  • chip_summary_data (bytes) – The data from the SCP response

  • offset (int) – The offset into the data where the data starts

  • x (int) – The x-coordinate of the chip that this data is from

  • y (int) – The y-coordinate of the chip that this data is from

clear_ethernet_ip_address()[source]

Forces the Ethernet IP address to None, in case of an errant chip.

property core_states

The state of the cores on the chip (list of one per core).

Return type:

list(CPUState)

property ethernet_ip_address

The IP address of the Ethernet if up, or None if not.

Return type:

str

property is_ethernet_available

Whether the Ethernet connection is available on this chip.

Return type:

bool

property largest_free_sdram_block

The size of the largest block of free SDRAM in bytes.

Return type:

int

property largest_free_sram_block

The size of the largest block of free SRAM in bytes.

Return type:

int

property n_cores

The number of cores working on the chip (including monitors).

Return type:

int

property n_free_multicast_routing_entries

The number of multicast routing entries free on this chip.

Return type:

int

property nearest_ethernet_x

The X-coordinate of the nearest Ethernet chip.

Return type:

int

property nearest_ethernet_y

The Y-coordinate of the nearest Ethernet chip.

Return type:

int

The link to the parent of the chip in the tree of chips from root.

Return type:

int

The IDs of the working links outgoing from this chip.

Return type:

list(int)

property x

The X-coordinate of the chip that this data is from.

Return type:

int

property y

The Y-coordinate of the chip that this data is from.

Return type:

int

class spinnman.model.DiagnosticFilter(enable_interrupt_on_counter_event, match_emergency_routing_status_to_incoming_packet, destinations, sources, payload_statuses, default_routing_statuses, emergency_routing_statuses, packet_types)[source]

Bases: object

A router diagnostic counter filter, which counts packets passing through the router with certain properties. The counter will be incremented so long as the packet matches one of the values in each field i.e. one of each of the destinations, sources, payload_statuses, default_routing_statuses, emergency_routing_statuses and packet_types.

Parameters:
  • enable_interrupt_on_counter_event (bool) – Indicates whether an interrupt should be raised when this rule matches

  • match_emergency_routing_status_to_incoming_packet (bool) – Indicates whether the emergency routing statuses should be matched against packets arriving at this router (if True), or if they should be matched against packets leaving this router (if False)

  • destinations (list(DiagnosticFilterDestination)) – Increment the counter if one or more of the given destinations match

  • sources (list(DiagnosticFilterSource)) – Increment the counter if one or more of the given sources match (or None or empty list to match all)

  • payload_statuses (list(DiagnosticFilterPayloadStatus)) – Increment the counter if one or more of the given payload statuses match (or None or empty list to match all)

  • default_routing_statuses (list(DiagnosticFilterDefaultRoutingStatus)) – Increment the counter if one or more of the given default routing statuses match (or None or empty list to match all)

  • emergency_routing_statuses (list(DiagnosticFilterEmergencyRoutingStatus)) – Increment the counter if one or more of the given emergency routing statuses match (or None or empty list to match all)

  • packet_types (list(DiagnosticFilterPacketType)) – Increment the counter if one or more of the given packet types match (or None or empty list to match all)

property default_routing_statuses
property destinations
property emergency_routing_statuses
property enable_interrupt_on_counter_event
property filter_word

A word of data that can be written to the router to set up the filter.

property match_emergency_routing_status_to_incoming_packet
property packet_types
property payload_statuses
static read_from_int(int_value)[source]
property sources
class spinnman.model.ExecutableTargets[source]

Bases: object

Encapsulate the binaries and cores on which to execute them.

add_processor(binary, chip_x, chip_y, chip_p, executable_type=None)[source]

Add a processor to the executable targets

Parameters:
  • binary (str) – the binary path for executable

  • chip_x (int) – the coordinate on the machine in terms of x for the chip

  • chip_y (int) – the coordinate on the machine in terms of y for the chip

  • chip_p (int) – the processor ID to place this executable on

  • executable_type (ExecutableType) – the executable type for locating n cores of

add_subsets(binary, subsets, executable_type=None)[source]

Add core subsets to a binary.

Parameters:
  • binary (str) – the path to the binary needed to be executed

  • subsets (CoreSubsets) – the subset of cores that the binary needs to be loaded on

  • executable_type (ExecutableType) – The type of this executable. None means don’t record it.

property all_core_subsets

All the core subsets for all the binaries.

Return type:

CoreSubsets

property binaries

The binaries of the executables.

Return type:

iterable(str)

executable_types_in_binary_set()[source]

Get the executable types in the set of binaries.

Returns:

iterable of the executable types in this binary set.

Return type:

iterable(ExecutableType)

get_binaries_of_executable_type(executable_type)[source]

Get the binaries of a given a executable type.

Parameters:

executable_type (ExecutableType) – the executable type enum value

Returns:

iterable of binaries with that executable type

Return type:

iterable(str)

get_cores_for_binary(binary)[source]

Get the cores that a binary is to run on.

Parameters:

binary (str) – The binary to find the cores for

get_n_cores_for_executable_type(executable_type)[source]

Get the number of cores that the executable type is using.

Parameters:

executable_type (ExecutableType) –

Returns:

the number of cores using this executable type

Return type:

int

known(binary, chip_x, chip_y, chip_p)[source]
Parameters:
  • binary (str) –

  • chip_x (int) –

  • chip_y (int) –

  • chip_p (int) –

Return type:

bool

property total_processors

The total number of cores to be loaded.

Return type:

int

class spinnman.model.HeapElement(block_address, next_address, free)[source]

Bases: object

An element of one of the heaps on SpiNNaker.

Parameters:
  • block_address (int) – The address of this element on the heap

  • next_address (int) – The address of the next element on the heap

  • free (int) – The “free” element of the block as read from the heap

property app_id

The application ID of the block if allocated, or None if not.

Return type:

int or None

property block_address

The address of the block.

Return type:

int

property is_free

Whether this block is a free block.

Return type:

bool

property next_address

The address of the next block, or 0 if none.

Return type:

int

property size

The usable size of this block (not including the header).

Return type:

int

property tag

The tag of the block if allocated, or None if not.

Return type:

int or None

class spinnman.model.IOBuffer(x, y, p, iobuf)[source]

Bases: object

The contents of IOBUF for a core.

Parameters:
  • x (int) – The x-coordinate of a chip

  • y (int) – The y-coordinate of a chip

  • p (int) – The p-coordinate of a chip

  • iobuf (str) – The contents of the buffer for the chip

property iobuf

The contents of the buffer.

Return type:

str

property p

The ID of the core on the chip.

Return type:

int

property x

The X-coordinate of the chip containing the core.

Return type:

int

property y

The Y-coordinate of the chip containing the core.

Return type:

int

class spinnman.model.MachineDimensions(width, height)[source]

Bases: object

Represents the size of a machine in chips.

Parameters:
  • width (int) – The width of the machine in chips

  • height (int) – The height of the machine in chips

property height

The height of the machine in chips.

Return type:

int

property width

The width of the machine in chips.

Return type:

int

class spinnman.model.P2PTable(width, height, column_data)[source]

Bases: object

Represents a P2P routing table read from the machine.

Parameters:
  • width (int) –

  • height (int) –

  • column_data (bytes) –

static get_column_offset(column)[source]

Get the offset of the next column in the table from the P2P base address.

Parameters:

column (int) – The column to be read

static get_n_column_bytes(height)[source]

Get the number of bytes to be read for each column of the table.

Parameters:

height (int) – The height of the machine

get_route(x, y)[source]

Get the route to follow from this chip to the given chip.

Parameters:
  • x (int) – The x-coordinate of the chip to find the route to

  • y (int) – The y-coordinate of the chip to find the route to

Return type:

P2PTableRoute

property height

The height of the machine that this table represents.

Return type:

int

is_route(x, y)[source]

Determines if there is a route in the P2P table to the given chip.

Parameters:
  • x (int) – The x-coordinate of the chip to look up

  • y (int) – The y-coordinate of the chip to look up

Return type:

bool

iterchips()[source]

Get an iterator of tuples of (x, y) coordinates in the table.

Return type:

iterable(tuple(int,int))

property width

The width of the machine that this table represents.

Return type:

int

class spinnman.model.RouterDiagnostics(control_register, error_status, register_values)[source]

Bases: object

Represents a set of diagnostic information available from a chip router.

Parameters:
  • control_register (int) – The value of the control register

  • error_status (int) – The value of the error_status

  • register_values (list(int)) – The values of the 16 router registers

Raises:

SpinnmanInvalidParameterException – If the number of register values is not 16

property error_count

The count of errors.

Return type:

int

property error_status

The error status.

Return type:

int

property errors_set

A list of errors that have been detected.

Return type:

list(RouterError)

property mon

The “mon” part of the control register.

Return type:

int

property n_dropped_fixed_route_packets

The number of fixed-route packets received that were dropped.

Return type:

int

property n_dropped_multicast_packets

The number of multicast packets received that were dropped.

Return type:

int

property n_dropped_nearest_neighbour_packets

The number of nearest-neighbour packets received that were dropped.

Return type:

int

property n_dropped_peer_to_peer_packets

The number of peer-to-peer packets received that were dropped.

Return type:

int

property n_external_fixed_route_packets

The number of fixed-route packets received from external links.

Return type:

int

property n_external_multicast_packets

The number of multicast packets received from external links.

Return type:

int

property n_external_nearest_neighbour_packets

The number of nearest-neighbour packets received from external links.

Return type:

int

property n_external_peer_to_peer_packets

The number of peer-to-peer packets received from external links.

Return type:

int

property n_local_fixed_route_packets

The number of fixed-route packets received from local cores.

Return type:

int

property n_local_multicast_packets

The number of multicast packets received from local cores.

Return type:

int

property n_local_nearest_neighbour_packets

The number of nearest-neighbour packets received from local cores.

Return type:

int

property n_local_peer_to_peer_packets

The number of peer-to-peer packets received from local cores.

Return type:

int

property registers

The values in all of the registers. Can be used to directly access the registers if they have been programmed to give different values.

Returns:

An array of 16 values

Return type:

array(int)

property user_0

The number of packets counted by the user 0 router diagnostic filter.

Return type:

int

property user_1

The number of packets counted by the user 1 router diagnostic filter.

Return type:

int

property user_2

The number of packets counted by the user 2 router diagnostic filter.

Return type:

int

property user_3

The number of packets counted by the user 3 router diagnostic filter.

Return type:

int

property user_registers

The values in the user control registers.

Returns:

An array of 4 values

Return type:

list(int)

property wait_1

The “wait_1” part of the control register.

Return type:

int

property wait_2

The “wait_2” part of the control register.

Return type:

int

class spinnman.model.VersionInfo(version_data, offset=0)[source]

Bases: object

Decodes SC&MP/SARK version information as returned by the SVER command.

Parameters:
  • version_data (bytes) – bytes from an SCP packet containing version information

  • offset (int) – the offset in the bytes from an SCP packet containing version information

Raises:

SpinnmanInvalidParameterException – If the message does not contain valid version information

property build_date

The build date of the software, in seconds since 1st January 1970.

Return type:

int

property hardware

The hardware being run on.

Return type:

str

property name

The name of the software.

Return type:

str

property p

The processor ID of the processor where the information was obtained.

Return type:

int

property version_number

The version number of the software.

Return type:

tuple(int, int, int)

property version_string

The version information as text.

Return type:

str

property x

The X-coordinate of the chip where the information was obtained.

Return type:

int

property y

The Y-coordinate of the chip where the information was obtained.

Return type:

int

spinnman.processes package
Module contents
class spinnman.processes.AbstractMultiConnectionProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: object

A process for talking to SpiNNaker efficiently that uses multiple connections in communication if relevant.

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

check_for_error(print_exception=False)[source]
property connection_selector

The connection selector of the process.

Return type:

AbstractMultiConnectionProcessConnectionSelector

is_error()[source]
class spinnman.processes.AbstractMultiConnectionProcessConnectionSelector[source]

Bases: object

A connection selector for multi-connection processes.

abstract get_next_connection(message)[source]

Get the index of the next connection for the process from a list of connections.

Parameters:

message (AbstractSCPRequest) – The SCP message to be sent

Return type:

SCAMPConnection

class spinnman.processes.ApplicationCopyRunProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: AbstractMultiConnectionProcess

Process to start a binary on a subset of cores on a subset of chips of a machine, performed by, on each chip, copying the data from an adjacent chip and then starting the binary. This goes to each chip in turn, and so detects failures early on, as well as ensuring that the copy and execution is done in the case of success i.e. this ensures that if all commands are successful, the full binary has been copied and started.

Note

The binary must have been loaded to the boot chip before this is called!

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

run(size, app_id, core_subsets, chksum, wait)[source]

Run the process.

Parameters:
  • size (int) – The size of the binary to copy

  • app_id (int) – The application id to assign to the running binary

  • core_subsets (CoreSubsets) – The cores to load the binary on to

  • chksum (int) – The checksum of the data to test against

  • wait (bool) – Whether to put the binary in “wait” mode or run it straight away

class spinnman.processes.ApplicationRunProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: AbstractMultiConnectionProcess

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

run(app_id, core_subsets, wait)[source]
class spinnman.processes.DeAllocSDRAMProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

Warning

This class is currently deprecated and untested as there is no known use except for Transceiver.free_sdram and free_sdram_by_app_id which are both themselves deprecated.

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

de_alloc_sdram(x, y, app_id, base_address=None)[source]
Parameters:
  • x (int) –

  • y (int) –

  • app_id (int) –

  • base_address (int or None) –

property no_blocks_freed
Return type:

int

class spinnman.processes.FixedConnectionSelector(connection)[source]

Bases: AbstractMultiConnectionProcessConnectionSelector

A connection selector that only uses a single connection.

Parameters:

connection (SCAMPConnection) – The connection to be used

get_next_connection(message)[source]

Get the index of the next connection for the process from a list of connections.

Parameters:

message (AbstractSCPRequest) – The SCP message to be sent

Return type:

SCAMPConnection

class spinnman.processes.GetCPUInfoProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

get_cpu_info(core_subsets)[source]
Parameters:

core_subsets (CoreSubsets) –

Return type:

list(CPUInfo)

class spinnman.processes.GetHeapProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

get_heap(chip_address, pointer=SystemVariableDefinition.sdram_heap_address)[source]
Parameters:
Return type:

list(HeapElement)

class spinnman.processes.GetMachineProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

A process for getting the machine details over a set of connections.

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

get_machine_details(boot_x, boot_y, width, height)[source]
Parameters:
  • boot_x (int) –

  • boot_y (int) –

  • width (int) –

  • height (int) –

Return type:

Machine

class spinnman.processes.GetMultiCastRoutesProcess(connection_selector, app_id=None)[source]

Bases: AbstractMultiConnectionProcess

A process for reading the multicast routing table of a SpiNNaker chip.

Parameters:
get_routes(x, y, base_address)[source]
Parameters:
  • x (int) –

  • y (int) –

  • base_address (int) –

Return type:

list(MulticastRoutingEntry)

class spinnman.processes.GetTagsProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

get_tags(connection)[source]
Parameters:

connection (SCAMPConnection) –

Return type:

list(IPTag or ReverseIPTag)

class spinnman.processes.GetVersionProcess(connection_selector, n_retries=10)[source]

Bases: AbstractMultiConnectionProcess

A process for getting the version of the machine.

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

get_version(x, y, p)[source]
Parameters:
Return type:

VersionInfo

class spinnman.processes.LoadFixedRouteRoutingEntryProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: AbstractMultiConnectionProcess

Load a fixed route routing entry onto a chip.

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

load_fixed_route(x, y, fixed_route, app_id=0)[source]
Parameters:
  • x (int) – The x-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions.

  • y (int) – The y-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions.

  • fixed_route (FixedRouteEntry) – the fixed route entry

  • app_id (int) – The ID of the application with which to associate the routes. If not specified, defaults to 0.

class spinnman.processes.LoadMultiCastRoutesProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

A process for loading the multicast routing table on a SpiNNaker chip.

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

load_routes(x, y, routes, app_id)[source]
Parameters:
class spinnman.processes.MallocSDRAMProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

A process for allocating a block of SDRAM on a SpiNNaker chip.

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

property base_address

The address of the allocated memory block.

Return type:

int

malloc_sdram(x, y, size, app_id, tag)[source]

Allocate space in the SDRAM space.

Parameters:
class spinnman.processes.MostDirectConnectionSelector(connections)[source]

Bases: AbstractMultiConnectionProcessConnectionSelector

A selector that goes for the most direct connection for the message.

Parameters:

connections (list(SCAMPConnection)) – The connections to be used

get_next_connection(message)[source]

Get the index of the next connection for the process from a list of connections.

Parameters:

message (AbstractSCPRequest) – The SCP message to be sent

Return type:

SCAMPConnection

class spinnman.processes.ReadFixedRouteRoutingEntryProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

A process for reading a fixed route routing table entry.

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) – the SC&MP connection selector

read_fixed_route(x, y, app_id=0)[source]

Read the fixed route entry installed on a particular chip’s router.

Parameters:
  • x (int) – The x-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions

  • y (int) – The y-coordinate of the chip, between 0 and 255; this is not checked due to speed restrictions

  • app_id (int) – The ID of the application with which to associate the routes. If not specified, defaults to 0.

Return type:

FixedRouteEntry

class spinnman.processes.ReadIOBufProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

A process for reading IOBUF memory (mostly log messages) from a SpiNNaker core.

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

read_iobuf(iobuf_size, core_subsets)[source]
Parameters:
Return type:

iterable(IOBuffer)

class spinnman.processes.ReadMemoryProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

A process for reading memory on a SpiNNaker chip.

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

Parameters:
  • x (int) –

  • y (int) –

  • p (int) –

  • link (int) –

  • base_address (int) –

  • length (int) –

Return type:

bytearray

read_memory(x, y, p, base_address, length)[source]
Parameters:
  • x (int) –

  • y (int) –

  • p (int) –

  • base_address (int) –

  • length (int) –

Return type:

bytearray

class spinnman.processes.ReadRouterDiagnosticsProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

A process for reading the diagnostic data block from a SpiNNaker router.

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

get_router_diagnostics(x, y)[source]
Parameters:
Return type:

RouterDiagnostics

class spinnman.processes.RoundRobinConnectionSelector(connections)[source]

Bases: AbstractMultiConnectionProcessConnectionSelector

A connection selector that just spreads work as evenly as possible.

Parameters:

connections (list(SCAMPConnection)) – The connections to be used

get_next_connection(message)[source]

Get the index of the next connection for the process from a list of connections.

Parameters:

message (AbstractSCPRequest) – The SCP message to be sent

Return type:

SCAMPConnection

class spinnman.processes.SendSingleCommandProcess(connection_selector, n_retries=3, timeout=1.0)[source]

Bases: AbstractMultiConnectionProcess

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

execute(request)[source]
Parameters:

request (AbstractSCPRequest) –

Return type:

AbstractSCPResponse

class spinnman.processes.WriteMemoryFloodProcess(next_connection_selector)[source]

Bases: AbstractMultiConnectionProcess

A process for writing memory on multiple SpiNNaker chips at once.

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

write_memory_from_bytearray(nearest_neighbour_id, base_address, data, offset, n_bytes=None)[source]
Parameters:
write_memory_from_reader(nearest_neighbour_id, base_address, reader, n_bytes)[source]
Parameters:
class spinnman.processes.WriteMemoryProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: AbstractMultiConnectionProcess

A process for writing memory on a SpiNNaker chip.

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

Writes memory onto a neighbour of a SpiNNaker chip from a bytearray.

Parameters:
  • x (int) – The x-coordinate of the chip where the memory is to be written to

  • y (int) – The y-coordinate of the chip where the memory is to be written to

  • p (int) – The processor of the chip where the memory is to be written to

  • link (int) – Along which link is the neighbour.

  • base_address (int) – the address in SDRAM to start writing

  • data (bytearray or bytes) – the data to write

  • offset (int) – where in the data to start writing from

  • n_bytes (int) – how much data to write

  • get_sum (bool) – whether to return a checksum or 0

Returns:

the data checksum or 0 if get_sum is False

Return type:

int

Writes memory onto a neighbour of a SpiNNaker chip from a reader.

Parameters:
  • x (int) – The x-coordinate of the chip where the memory is to be written to

  • y (int) – The y-coordinate of the chip where the memory is to be written to

  • p (int) – The processor of the chip where the memory is to be written to

  • link (int) – Along which link is the neighbour.

  • base_address (int) – the address in SDRAM to start writing

  • reader (RawIOBase or BufferedIOBase) – the readable object containing the data to write

  • n_bytes (int) – how much data to write

  • get_sum (bool) – whether to return a checksum or 0

Returns:

the data checksum or 0 if get_sum is False

Return type:

int

write_memory_from_bytearray(x, y, p, base_address, data, offset, n_bytes, get_sum=False)[source]

Writes memory onto a SpiNNaker chip from a bytearray.

Parameters:
  • x (int) – The x-coordinate of the chip where the memory is to be written to

  • y (int) – The y-coordinate of the chip where the memory is to be written to

  • p (int) – The processor of the chip where the memory is to be written to

  • base_address (int) – the address in SDRAM to start writing

  • data (bytearray or bytes) – the data to write

  • offset (int) – where in the data to start writing from

  • n_bytes (int) – how much data to write

  • get_sum (bool) – whether to return a checksum or 0

Returns:

the data checksum or 0 if get_sum is False

Return type:

int

write_memory_from_reader(x, y, p, base_address, reader, n_bytes, get_sum=False)[source]

Writes memory onto a SpiNNaker chip from a reader.

Parameters:
  • x (int) – The x-coordinate of the chip where the memory is to be written to

  • y (int) – The y-coordinate of the chip where the memory is to be written to

  • p (int) – The processor of the chip where the memory is to be written to

  • base_address (int) – the address in SDRAM to start writing

  • reader (RawIOBase or BufferedIOBase) – the readable object containing the data to write

  • n_bytes (int) – how much data to write

  • get_sum (bool) – whether to return a checksum or 0

Returns:

the data checksum or 0 if get_sum is False

Return type:

int

spinnman.spalloc package
Submodules
spinnman.spalloc.proxy_protocol module
class spinnman.spalloc.proxy_protocol.ProxyProtocol(value)[source]

Bases: IntEnum

Websocket binary frame type identifiers in the Spalloc Proxy protocol.

CLOSE = 1

Message relating to closing a channel

MSG = 2

Message sent on a channel

MSG_TO = 4

Message sent on an unbound channel to a given board

OPEN = 0

Message relating to opening a channel

OPEN_UNBOUND = 3

Message relating to opening an unbound listen-only channel

spinnman.spalloc.session module
class spinnman.spalloc.session.Session(service_url: str, username: Optional[str] = None, password: Optional[str] = None, token: Optional[str] = None, session_credentials: Optional[Tuple[Dict[str, str], Dict[str, str]]] = None)[source]

Bases: object

Manages session credentials for the Spalloc client.

Warning

This class does not present a stable API for public consumption.

Parameters:
  • service_url (str) – The reference to the service. Should not include a username or password in it.

  • username (str) – The user name to use

  • password (str) – The password to use

  • token (str) – The bearer token to use

delete(url: str, timeout: int = 10, **kwargs) Response[source]

Do an HTTP DELETE in the session.

Parameters:

url (str) –

Return type:

Response

get(url: str, timeout: int = 10, **kwargs) Response[source]

Do an HTTP GET in the session.

Parameters:
  • url (str) –

  • timeout (int) –

Return type:

Response

post(url: str, jsonobj: dict, timeout: int = 10, **kwargs) Response[source]

Do an HTTP POST in the session.

Parameters:
  • url (str) –

  • timeout (int) –

  • jsonobj (dict) –

Return type:

Response

put(url: str, data: str, timeout: int = 10, **kwargs) Response[source]

Do an HTTP PUT in the session. Puts plain text OR JSON!

Parameters:
  • url (str) –

  • data (str) –

  • timeout (int) –

Return type:

Response

renew() dict[source]

Renews the session, logging the user into it so that state modification operations can be performed.

Returns:

Description of the root of the service, without CSRF data

Return type:

dict

Raises:

SpallocException – If the session cannot be renewed.

websocket(url: str, header: Optional[dict] = None, cookie: Optional[str] = None, **kwargs) WebSocket[source]

Create a websocket that uses the session credentials to establish itself.

Parameters:
  • url (str) – Actual location to open websocket at

  • header (dict(str,str)) – Optional HTTP headers

  • cookie (str) – Optional cookies (composed as semicolon-separated string)

  • kwargs – Other options to create_connection()

Return type:

WebSocket

class spinnman.spalloc.session.SessionAware(session: Session, url: str)[source]

Bases: object

Connects to the session.

Warning

This class does not present a stable API for public consumption.

spinnman.spalloc.spalloc_boot_connection module

API of the client for the Spalloc web service.

class spinnman.spalloc.spalloc_boot_connection.SpallocBootConnection(remote_host=None)[source]

Bases: BootConnection, SpallocProxiedConnection

The socket interface supported by proxied boot sockets. The socket will always be talking to the root board of a job. This emulates a BootConnection.

Parameters:

remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

get_receive_method() Callable[source]

Get the method that receives for this connection.

receive_boot_message(timeout=None) SpinnakerBootMessage[source]

Receives a boot message from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed.

Returns:

a boot message

Return type:

SpinnakerBootMessage

Raises:
send_boot_message(boot_message: SpinnakerBootMessage)[source]

Sends a SpiNNaker boot message using this connection.

Parameters:

boot_message (SpinnakerBootMessage) – The message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message

spinnman.spalloc.spalloc_scp_connection module
class spinnman.spalloc.spalloc_scp_connection.SpallocSCPConnection(x, y)[source]

Bases: SCAMPConnection, SpallocProxiedConnection

The socket interface supported by proxied sockets. The socket will always be talking to a specific board. This emulates a SCAMPConnection.

Parameters:
  • chip_x (int) – The x-coordinate of the chip on the board with this remote_host

  • chip_y (int) – The y-coordinate of the chip on the board with this remote_host

  • local_host (str) – The optional IP address or host name of the local interface to listen on

  • local_port (int) – The optional local port to listen on

  • remote_host (str) – The optional remote host name or IP address to send messages to. If not specified, sending will not be possible using this connection

  • remote_port (int) – The optional remote port number to send messages to. If not specified, sending will not be possible using this connection

get_receive_method() Callable[source]

Get the method that receives for this connection.

get_scp_data(scp_request: AbstractSCPRequest, x=None, y=None) bytes[source]

Returns the data of an SCP request as it would be sent down this connection.

Parameters:
  • x (int) – Optional: x-coordinate of where to send to

  • y (int) – Optional: y-coordinate of where to send to

receive_scp_response(timeout=1.0) Tuple[SCPResult, int, bytes, int][source]

Receives an SCP response from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed

Returns:

The SCP result, the sequence number, the data of the response and the offset at which the data starts (i.e., where the SDP header starts).

Return type:

tuple(SCPResult, int, bytes, int)

Raises:
receive_sdp_message(timeout=None) SDPMessage[source]

Receives an SDP message from this connection. Blocks until the message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed.

Returns:

The received SDP message

Return type:

SDPMessage

Raises:
send_scp_request(scp_request: AbstractSCPRequest)[source]

Sends an SCP request down this connection.

Messages must have the following properties:

  • source_port is None or 7

  • source_cpu is None or 31

  • source_chip_x is None or 0

  • source_chip_y is None or 0

tag in the message is optional; if not set, the default set in the constructor will be used. sequence in the message is optional; if not set, (sequence number last assigned + 1) % 65536 will be used

Parameters:

scp_request (AbstractSCPRequest) – message packet to send

Raises:

SpinnmanIOException – If there is an error sending the message

send_sdp_message(sdp_message: SDPMessage)[source]

Sends an SDP message down this connection.

Parameters:

sdp_message (SDPMessage) – The SDP message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message.

Module contents

The new Spalloc client implementation. This has the notable distinction of including a proxying system that allows creating a transceiver with access to the boards of a job despite the client being not within the same firewall/NAT security domain as the Spalloc-managed service.

The main class in here is SpallocClient.

class spinnman.spalloc.AbstractSpallocClient[source]

Bases: object

The API exported by the Spalloc Client.

abstract create_job(num_boards: int = 1, machine_name: Optional[str] = None, keepalive: int = 45) SpallocJob[source]

Create a job with a specified number of boards.

Parameters:
  • num_boards (int) – How many boards to ask for (defaults to 1)

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

abstract create_job_board(triad: Optional[Tuple[int, int, int]] = None, physical: Optional[Tuple[int, int, int]] = None, ip_address: Optional[str] = None, machine_name: Optional[str] = None, keepalive: int = 45) SpallocJob[source]

Create a job with a specific board. At least one of triad, physical and ip_address must be not None.

Parameters:
  • triad (tuple(int,int,int)) – The logical coordinate of the board to request

  • physical (tuple(int,int,int)) – The physical coordinate of the board to request

  • ip_address (str) – The IP address of the board to request

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

abstract create_job_rect(width: int, height: int, machine_name: Optional[str] = None, keepalive: int = 45) SpallocJob[source]

Create a job with a rectangle of boards.

Parameters:
  • width (int) – The width of rectangle to request

  • height (int) – The height of rectangle to request

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

abstract list_jobs(deleted: bool = False) Iterable[SpallocJob][source]

Get the jobs known to the server.

Parameters:

deleted (bool) – Whether to include deleted jobs.

Returns:

The jobs known to the server.

Return type:

Iterable(SpallocJob)

abstract list_machines() Dict[str, SpallocMachine][source]

Get the machines supported by the server.

Returns:

Mapping from machine names to handles for working with a machine.

Return type:

dict(str,SpallocMachine)

class spinnman.spalloc.SpallocClient(service_url, username=None, password=None, bearer_token=None)[source]

Bases: AbstractContextManager, AbstractSpallocClient

Basic client library for talking to new Spalloc.

Parameters:
  • service_url (str) – The reference to the service. May have username and password supplied as part of the network location; if so, the username and password arguments must be None. If username and password are not given, not even within the URL, the bearer_token must be not None.

  • username (str) – The user name to use

  • password (str) – The password to use

  • bearer_token (str) – The bearer token to use

close()[source]

How to actually close the underlying resources.

create_job(num_boards=1, machine_name=None, keepalive=45)[source]

Create a job with a specified number of boards.

Parameters:
  • num_boards (int) – How many boards to ask for (defaults to 1)

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

create_job_board(triad=None, physical=None, ip_address=None, machine_name=None, keepalive=45)[source]

Create a job with a specific board. At least one of triad, physical and ip_address must be not None.

Parameters:
  • triad (tuple(int,int,int)) – The logical coordinate of the board to request

  • physical (tuple(int,int,int)) – The physical coordinate of the board to request

  • ip_address (str) – The IP address of the board to request

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

create_job_rect(width, height, machine_name=None, keepalive=45)[source]

Create a job with a rectangle of boards.

Parameters:
  • width (int) – The width of rectangle to request

  • height (int) – The height of rectangle to request

  • machine_name (str) – Which machine to run on? If omitted, the service’s machine tagged with default will be used.

  • keepalive (int) – After how many seconds of no activity should a job become eligible for automatic pruning?

Returns:

A handle for monitoring and interacting with the job.

Return type:

SpallocJob

list_jobs(deleted=False)[source]

Get the jobs known to the server.

Parameters:

deleted (bool) – Whether to include deleted jobs.

Returns:

The jobs known to the server.

Return type:

Iterable(SpallocJob)

list_machines()[source]

Get the machines supported by the server.

Returns:

Mapping from machine names to handles for working with a machine.

Return type:

dict(str,SpallocMachine)

static open_job_from_database(conn: Cursor) SpallocJob[source]

Create a job from the description in the attached database. This is intended to allow for access to the job’s allocated resources from visualisers and other third party code participating in the SpiNNaker Tools Notification Protocol.

Note

The job is not verified to exist and be running. The session credentials may have expired; if so, the job will be unable to regenerate them.

Parameters:

conn (Cursor) – The database cursor to retrieve the job details from. Assumes the presence of a proxy_configuration table with kind, name and value columns.

Returns:

The job handle, or None if the records in the database are absent or incomplete.

Return type:

SpallocJob

version
class spinnman.spalloc.SpallocEIEIOConnection(local_host=None, local_port=None, remote_host=None, remote_port=None)[source]

Bases: EIEIOConnection, SpallocProxiedConnection

The socket interface supported by proxied EIEIO connected sockets. This emulates an EIEOConnection opened with a remote address specified.

Parameters:
  • local_host (str) – The local host name or IP address to bind to. If not specified defaults to bind to all interfaces, unless remote_host is specified, in which case binding is done to the IP address that will be used to send packets

  • local_port (int) – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

  • remote_port (int) – The remote port to send packets to. If remote_host is None, this is ignored. If remote_host is specified specified, this must also be specified for the connection to allow sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

get_receive_method()[source]

Get the method that receives for this connection.

receive_eieio_message(timeout=None)[source]

Receives an EIEIO message from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed

Returns:

an EIEIO message

Return type:

AbstractEIEIOMessage

Raises:
send_eieio_message(eieio_message)[source]

Sends an EIEIO message down this connection.

Parameters:

eieio_message (AbstractEIEIOMessage) – The EIEIO message to be sent

Raises:

SpinnmanIOException – If there is an error sending the message

send_eieio_message_to_core(eieio_message: AbstractEIEIOMessage, x: int, y: int, p: int)[source]
update_tag(tag: int, do_receive: bool = True)[source]

Update the given tag on the connected Ethernet-enabled chip to send messages to this connection.

Parameters:
  • tag (int) – The tag ID to update

  • do_receive (bool) – Whether to do the reception of the response or not

Raises:
class spinnman.spalloc.SpallocEIEIOListener(local_host=None, local_port=None, remote_host=None, remote_port=None)[source]

Bases: EIEIOConnection, SpallocProxiedConnection

The socket interface supported by proxied EIEIO listener sockets. This emulates an EIEOConnection opened with no address specified.

Parameters:
  • local_host (str) – The local host name or IP address to bind to. If not specified defaults to bind to all interfaces, unless remote_host is specified, in which case binding is done to the IP address that will be used to send packets

  • local_port (int) – The local port to bind to, between 1025 and 65535. If not specified, defaults to a random unused local port

  • remote_host (str) – The remote host name or IP address to send packets to. If not specified, the socket will be available for listening only, and will throw and exception if used for sending

  • remote_port (int) – The remote port to send packets to. If remote_host is None, this is ignored. If remote_host is specified specified, this must also be specified for the connection to allow sending

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

get_receive_method()[source]

Get the method that receives for this connection.

abstract property local_ip_address: str

The IP address on the server to which the connection is bound.

Returns:

The IP address as a dotted string, e.g., 0.0.0.0

Return type:

str

abstract property local_port: int

The port on the server to which the connection is bound.

Returns:

The local port number

Return type:

int

receive_eieio_message(timeout=None)[source]

Receives an EIEIO message from this connection. Blocks until a message has been received, or a timeout occurs.

Parameters:

timeout (int) – The time in seconds to wait for the message to arrive; if not specified, will wait forever, or until the connection is closed

Returns:

an EIEIO message

Return type:

AbstractEIEIOMessage

Raises:
send(data)[source]

Send a message on an open socket.

Parameters:

data – The message to send.

Note

This class does not allow sending.

send_eieio_message_to_core(eieio_message: AbstractEIEIOMessage, x: int, y: int, p: int, ip_address: str)[source]

Send an EIEIO message (one way) to a given core.

Parameters:
  • eieio_message (AbstractEIEIOMessage) – The message to send.

  • x (int) – The X coordinate of the core to send to.

  • y (int) – The Y coordinate of the core to send to.

  • p (int) – The ID of the core to send to.

  • ip_address (str) – The IP address of the Ethernet-enabled chip to route the message via.

send_to(data: bytes, address: Tuple[str, int])[source]

Send a message on an open socket.

Parameters:
  • message (bytes) – The message to send.

  • address (tuple(str,int)) – Where to send it to. Must be the address of an Ethernet-enabled chip on a board allocated to the job. Does not mean that SpiNNaker is listening on that port (but the SCP port is being listened to if the board is booted).

abstract send_to_chip(message: bytes, x: int, y: int, port: int = 17893)[source]

Send a message on an open socket to a particular board.

Parameters:
  • message (bytes) – The message to send.

  • x (int) – The X coordinate of the Ethernet-enabled chip to send the message to.

  • y (int) – The Y coordinate of the Ethernet-enabled chip to send the message to.

  • port (int) – The UDP port on the Ethernet-enabled chip to send the message to. Defaults to the SCP port.

update_tag(x: int, y: int, tag: int, do_receive: bool = True)[source]

Update the given tag on the given Ethernet-enabled chip to send messages to this connection.

Parameters:
  • x (int) – The Ethernet-enabled chip’s X coordinate

  • y (int) – The Ethernet-enabled chip’s Y coordinate

  • tag (int) – The tag ID to update

  • do_receive (bool) – Whether to receive the response or not

Raises:
update_tag_by_ip(ip_address: str, tag: int)[source]

Update a tag on a board at a given IP address to send messages to this connection.

Parameters:
  • ip_address (str) – The address of the Ethernet-enabled chip

  • tag (int) – The ID of the tag

class spinnman.spalloc.SpallocJob[source]

Bases: object

Represents a job in Spalloc.

Don’t make this yourself. Use SpallocClient instead.

abstract connect_for_booting() SpallocBootConnection[source]

Open a connection to a job’s allocation so it can be booted.

Returns:

a boot connection

Return type:

SpallocBootConnection

abstract connect_to_board(x: int, y: int, port: int = 17893) SpallocSCPConnection[source]

Open a connection to a particular board in the job.

Parameters:
  • x (int) – X coordinate of the board’s Ethernet-enabled chip

  • y (int) – Y coordinate of the board’s Ethernet-enabled chip

  • port (int) – UDP port to talk to; defaults to the SCP port

Returns:

A connection that talks to the board.

Return type:

SpallocProxiedConnection

abstract create_transceiver() Transceiver[source]

Create a transceiver that will talk to this job. The transceiver will only be configured to talk to the SCP ports of the boards of the job.

Return type:

Transceiver

abstract destroy(reason: str = 'finished')[source]

Destroy the job.

Parameters:

reason (str) – Why the job is being destroyed.

abstract get_connections() Dict[Tuple[int, int], str][source]

Get the mapping from board coordinates to IP addresses.

Returns:

(x,y)->IP mapping, or None if not allocated

Return type:

dict(tuple(int,int), str) or None

abstract get_root_host() str[source]

Get the IP address for talking to the machine.

Returns:

The IP address, or None if not allocated.

Return type:

str or None

abstract get_state() SpallocState[source]

Get the current state of the machine.

Return type:

SpallocState

abstract keepalive()[source]

Signal the job that we want it to stay alive for a while longer.

abstract launch_keepalive_task(period: int = 30) AbstractContextManager[source]

Starts a periodic task to keep a job alive.

Parameters:
  • job (SpallocJob) – The job to keep alive

  • period (int) – How often to send a keepalive message (in seconds)

Returns:

Some kind of closable task handle; closing it terminates the task. Destroying the job will also terminate the task.

abstract open_eieio_connection(x: int, y: int) SpallocEIEIOConnection[source]

Open an EIEIO connection to a specific board in a job.

Parameters:
  • x (int) – The X coordinate of the Ethernet-enabled chip to connect to

  • y (int) – The Y coordinate of the Ethernet-enabled chip to connect to

Returns:

an EIEIO connection with a board address bound

Return type:

SpallocEIEIOConnection

abstract open_eieio_listener_connection() SpallocEIEIOListener[source]

Open a listening EIEIO connection to the job’s boards. Messages cannot be sent on this connection unless you say which board to send to, but they can be received from all boards. You can also get the server side connection information so you can program that into a tag.

Returns:

an EIEIO connection with no board address bound

Return type:

SpallocEIEIOListener

abstract open_udp_listener_connection() UDPConnection[source]

Open a listening UDP connection to the job’s boards. Messages cannot be sent on this connection unless you say which board to send to, but they can be received from all boards. You can also get the server side connection information so you can program that into a tag.

Returns:

a UDP connection with no board address bound

Return type:

UDPConnection

abstract wait_for_state_change(old_state: SpallocState) SpallocState[source]

Wait until the allocation is not in the given old state.

Parameters:

old_state (SpallocState) – The state that we are looking to change out of.

Returns:

The state that the allocation is now in.

Note

If the machine gets destroyed, this will not wait for it.

Return type:

SpallocState

abstract wait_until_ready()[source]

Wait until the allocation is in the READY state.

Raises:

Exception – If the allocation is destroyed

abstract where_is_machine(x: int, y: int) Tuple[int, int, int][source]

Get the physical coordinates of the board hosting the given chip.

Parameters:
  • x (int) – Chip X coordinate

  • y (int) – Chip Y coordinate

Returns:

physical board coordinates (cabinet, frame, board), or None if there are no boards currently allocated to the job or the chip lies outside the allocation.

Return type:

tuple(int,int,int) or None

class spinnman.spalloc.SpallocMachine[source]

Bases: object

Represents a Spalloc-controlled machine.

Don’t make this yourself. Use SpallocClient instead.

abstract property area: Tuple[int, int]

Area of machine, in boards.

Returns:

width, height

Return type:

tuple(int,int)

abstract property dead_boards: list

The dead or out-of-service boards of the machine.

The dead or out-of-service links of the machine.

abstract property height: int

The height of the machine, in boards.

abstract property name: str

The name of the machine.

abstract property tags: Set[str]

The tags of the machine.

abstract property width: int

The width of the machine, in boards.

class spinnman.spalloc.SpallocProxiedConnection[source]

Bases: Listenable

Base class for connections proxied via Spalloc.

abstract receive(timeout=None) bytes[source]

Receive a message on an open socket. Will block until a message is received.

Parameters:

timeout – How long to wait for a message to be received before timing out. If None, will wait indefinitely (or until the connection is closed).

Returns:

The received message.

Raises:

SpinnmanTimeoutException – If a timeout happens

abstract send(data: bytes)[source]

Send a message on an open socket.

Parameters:

data – The message to send.

class spinnman.spalloc.SpallocState(value)[source]

Bases: IntEnum

The possible states of a Spalloc Job.

Jobs start as QUEUED, then move to POWER once they’ve been allocated. Once the job’s boards have been switched on and the hardware stabilised, the job moves to state READY. (It goes back to POWER if you tell it to switch off or on; this is not recommended.) Finally, it goes to DESTROYED once the job is completed in any way.

The UNKNOWN state is used when something odd is going on. It should normally be ignored.

DESTROYED = 4

The job has been destroyed.

POWER = 2

The job is queued waiting for boards to power on or off.

QUEUED = 1

The job is queued waiting for allocation.

READY = 3

The job is ready for user code to run on it.

UNKNOWN = 0

The job is in an unknown state.

spinnman.spalloc.is_server_address(address: str, additional_schemes: Iterable[str] = ()) bool[source]

Test if the given address is a likely Spalloc server URL.

Parameters:
  • address (str) – The address to check

  • additional_schemes (Iterable(str)) – Any additional URL schemes that should be considered to be successes; typically {"spalloc"} when looser matching is required.

Return type:

bool

spinnman.utilities package
Submodules
spinnman.utilities.appid_tracker module
class spinnman.utilities.appid_tracker.AppIdTracker(app_ids_in_use=None, min_app_id=17, max_app_id=254)[source]

Bases: object

A tracker of application IDs to make it easier to allocate new IDs.

Parameters:
  • app_ids_in_use (list(int) or None) – The IDs that are already in use

  • min_app_id (int) – The smallest application ID to use

  • max_app_id (int) – The largest application ID to use

allocate_id(allocated_id)[source]

Allocate a given ID.

Parameters:

allocated_id (int) – The ID to allocate

Raises:

KeyError – If the ID is not present

free_id(id_to_free)[source]

Free a given ID.

Parameters:

id_to_free (int) – The ID to free

Raises:

KeyError – If the ID is out of range

get_new_id()[source]

Get a new unallocated ID

Return type:

int

spinnman.utilities.locate_connected_machine_ip_address module
spinnman.utilities.locate_connected_machine_ip_address.locate_connected_machine(handler)[source]

Locates any SpiNNaker machines IP addresses from the auto-transmitted packets from non-booted SpiNNaker machines.

Parameters:

handler (Callable) – A callback that decides whether to stop searching. The callback is given two arguments: the IP address found and the current time. It should return True if the search should cease.

spinnman.utilities.reports module
spinnman.utilities.reports.generate_machine_report(report_directory, machine, connections)[source]

Generate report on the physical structure of the target SpiNNaker machine.

Parameters:
  • report_directory (str) – the directory to which reports are stored

  • machine (Machine) – the machine python object

  • connections (list(Connection)) – the list of connections to the machine

Raises:

IOError – when a file cannot be opened for some reason

spinnman.utilities.socket_utils module

Wrappers around socket-related system calls to do exception remapping and apply some consistency to things.

spinnman.utilities.socket_utils.bind_socket(sock, host, port)[source]

Wrapper round bind() system call.

spinnman.utilities.socket_utils.connect_socket(sock, remote_address, remote_port)[source]

Wrapper round connect() system call.

spinnman.utilities.socket_utils.get_socket_address(sock)[source]

Wrapper round getsockname() system call.

spinnman.utilities.socket_utils.get_tcp_socket()[source]

Wrapper round socket() system call to produce TCP/IPv4 sockets.

Note

TCP sockets cannot be used to talk to a SpiNNaker board.

spinnman.utilities.socket_utils.get_udp_socket()[source]

Wrapper round socket() system call to produce UDP/IPv4 sockets.

spinnman.utilities.socket_utils.receive_message(sock, timeout, size)[source]

Wrapper round recv() system call.

spinnman.utilities.socket_utils.receive_message_and_address(sock, timeout, size)[source]

Wrapper round recvfrom() system call.

spinnman.utilities.socket_utils.resolve_host(host)[source]

Wrapper round gethostbyname() system call.

spinnman.utilities.socket_utils.send_message(sock, data)[source]

Wrapper round send() system call.

spinnman.utilities.socket_utils.send_message_to_address(sock, data, address)[source]

Wrapper round sendto() system call.

spinnman.utilities.socket_utils.set_receive_buffer_size(sock, size)[source]

Wrapper round setsockopt() system call.

spinnman.utilities.utility_functions module
spinnman.utilities.utility_functions.get_vcpu_address(p)[source]

Get the address of the vcpu_t structure for the given core.

Parameters:

p (int) – The core

Return type:

int

spinnman.utilities.utility_functions.reprogram_tag(connection: SCAMPConnection, tag: int, strip: bool = True)[source]

Reprogram an IP Tag to send responses to a given SCAMPConnection.

Parameters:
  • connection (SCAMPConnection) – The connection to target the tag at

  • tag (int) – The id of the tag to set

  • strip (bool) – True if the tag should strip SDP headers from outgoing messages

Raises:

SpinnmanTimeoutException – If things time out several times

spinnman.utilities.utility_functions.reprogram_tag_to_listener(connection: UDPConnection, x: int, y: int, ip_address: str, tag: int, strip: bool = True, read_response: bool = True)[source]

Reprogram an IP Tag to send responses to a given connection that is not connected to a specific board. Such connections are normally receive-only connections.

Parameters:
  • connection (UDPConnection) – The connection to target the tag at

  • x (int) – The X coordinate of the Ethernet-enabled chip that should send to the connection

  • y (int) – The Y coordinate of the Ethernet-enabled chip that should send to the connection

  • ip_address (str) – The IP address of the Ethernet-enabled chip that should be given the message

  • tag (int) – The id of the tag to set

  • strip (bool) – True if the tag should strip SDP headers from outgoing messages

  • read_response (bool) – True if the response to the reprogramming should be read

Raises:

SpinnmanTimeoutException – If things time out several times

spinnman.utilities.utility_functions.send_port_trigger_message(connection, board_address)[source]

Sends a port trigger message using a connection to (hopefully) open a port in a NAT and/or firewall to allow incoming packets to be received.

Parameters:
  • connection (UDPConnection) – The UDP connection down which the trigger message should be sent

  • board_address (str) – The IP address of the SpiNNaker board to which the message should be sent

spinnman.utilities.utility_functions.work_out_bmp_from_machine_details(hostname, number_of_boards)[source]

Work out the BMP connection IP address given the machine details. This is assumed to be the IP address of the machine, with 1 subtracted from the final part e.g. if the machine IP address is 192.168.0.5, the BMP IP address is assumed to be 192.168.0.4

Parameters:
  • hostname (str) – the SpiNNaker machine main hostname or IP address

  • number_of_boards (int) – the number of boards in the machine

Returns:

The BMP connection data

Return type:

BMPConnectionData

Module contents
Submodules
spinnman.board_test_configuration module
class spinnman.board_test_configuration.BoardTestConfiguration[source]

Bases: object

set_up_local_virtual_board()[source]
set_up_nonexistent_board()[source]
set_up_remote_board()[source]
spinnman.config_setup module
spinnman.config_setup.add_spinnman_cfg()[source]

Add the local configuration and all dependent configuration files.

spinnman.config_setup.unittest_setup()[source]

Resets the configurations so only the local default configuration is included.

Note

This file should only be called from SpiNNMan/unittests.

spinnman.constants module
spinnman.constants.BMP_ADC_MAX = 4096

The range of values the BMP’s 12-bit ADCs can measure.

spinnman.constants.BMP_MISSING_FAN = -1

Fan speed value returned when a fan is absent.

spinnman.constants.BMP_MISSING_TEMP = -32768

Temperature value returned when a probe is not connected.

spinnman.constants.BMP_POST_POWER_ON_SLEEP_TIME = 5.0

Time to sleep after powering on boards

spinnman.constants.BMP_POWER_ON_TIMEOUT = 10.0

Timeout for BMP power-on commands to reply.

spinnman.constants.BMP_TEMP_SCALE = 0.00390625

Multiplier to convert from temperature probe values to degrees Celsius.

spinnman.constants.BMP_TIMEOUT = 0.5

Timeout for other BMP commands to reply

spinnman.constants.BMP_V_SCALE_12 = 0.003662109375

Multiplier to convert from ADC value to volts for 12 V lines.

spinnman.constants.BMP_V_SCALE_2_5 = 0.0006103515625

Multiplier to convert from ADC value to volts for lines less than 2.5 V.

spinnman.constants.BMP_V_SCALE_3_3 = 0.00091552734375

Multiplier to convert from ADC value to volts for 3.3 V lines.

spinnman.constants.BOOT_RETRIES = 3

This is the number of retries during boot - this is different because otherwise boot takes too long (retrying on a non-booted machine will never work)

spinnman.constants.CPU_INFO_BYTES = 128

How many bytes the CPU info data takes up

spinnman.constants.CPU_INFO_OFFSET = 3842011136

The address of the start of the VCPU structure (copied from sark.h)

spinnman.constants.CPU_IOBUF_ADDRESS_OFFSET = 88

The address at which the iobuf address starts

spinnman.constants.CPU_USER_0_START_ADDRESS = 112

The address at which user0 register starts

spinnman.constants.CPU_USER_1_START_ADDRESS = 116

The address at which user1 register starts

spinnman.constants.CPU_USER_2_START_ADDRESS = 120

The address at which user2 register starts

spinnman.constants.CPU_USER_3_START_ADDRESS = 124

The address at which user3 register starts

class spinnman.constants.EIEIO_COMMAND_IDS(value)[source]

Bases: Enum

A listing of what SpiNNaker specific EIEIO commands there are.

DATABASE = 1

Database handshake with external program; not routed via SpiNNaker

EVENT_PADDING = 2

Fill in buffer area with padding

EVENT_STOP = 3

End of all buffers, stop execution

HOST_DATA_READ = 9

Host confirming data being read form SpiNNaker memory

HOST_DATA_READ_ACK = 12

Host confirming request to read data received

HOST_SEND_SEQUENCED_DATA = 7

Buffers being sent from host to SpiNNaker

SPINNAKER_REQUEST_BUFFERS = 6

Spinnaker requesting new buffers for spike source population

SPINNAKER_REQUEST_READ_DATA = 8

Buffers available to be read from a buffered out vertex

START_RESUME_NOTIFICATION = 11

Command for notifying the external devices that the simulation has started

START_SENDING_REQUESTS = 5

Start complaining that there is SDRAM free space for buffers

STOP_PAUSE_NOTIFICATION = 10

Command for notifying the external devices that the simulation has stopped

STOP_SENDING_REQUESTS = 4

Stop complaining that there is SDRAM free space for buffers

class spinnman.constants.IPTAG_TIME_OUT_WAIT_TIMES(value)[source]

Bases: Enum

The values used by the SCP IP tag time outs. These control how long to wait for any message request which requires a response, before raising an error.

The value is calculated via the following formula:

10ms * 2^(tag_timeout_value - 1)

TIMEOUT_10_ms = 1
TIMEOUT_1280_ms = 8
TIMEOUT_160_ms = 5
TIMEOUT_20_ms = 2
TIMEOUT_2560_ms = 9
TIMEOUT_320_ms = 6
TIMEOUT_40_ms = 3
TIMEOUT_640_ms = 7
TIMEOUT_80_ms = 4
spinnman.constants.MAX_TAG_ID = 7

Max user requested tag value

spinnman.constants.NO_ROUTER_DIAGNOSTIC_FILTERS = 16

Number of router diagnostic filters

spinnman.constants.N_RETRIES = 10

This is the default number of retries when using SCP

class spinnman.constants.READ_TYPES(value)[source]

Bases: Enum

The types of read available from SARK. These values are used to tell SARK how to read the data in a time efficient manner.

BYTE = 0
HALF_WORD = 1
WORD = 2
spinnman.constants.ROUTER_DEFAULT_FILTERS_MAX_POSITION = 11

Point where default filters finish and user set-able ones are available

spinnman.constants.ROUTER_DIAGNOSTIC_FILTER_SIZE = 4

Size of a router diagnostic filter control register in bytes

spinnman.constants.ROUTER_FILTER_CONTROLS_OFFSET = 512

Offset for the router filter controls first register (one word each)

spinnman.constants.ROUTER_REGISTER_BASE_ADDRESS = 3774873600

The base address of a routers diagnostic filter controls

spinnman.constants.ROUTER_REGISTER_P2P_ADDRESS = 3774939136

The base address of a routers p2p routing table

class spinnman.constants.ROUTER_REGISTER_REGISTERS(value)[source]

Bases: Enum

The indices to the router registers.

DUMP_FR = 11
DUMP_MC = 8
DUMP_NN = 10
DUMP_PP = 9
EXT_FR = 7
EXT_MC = 1
EXT_NN = 5
EXT_PP = 3
LOC_FR = 6
LOC_MC = 0
LOC_NN = 4
LOC_PP = 2
USER_0 = 12
USER_1 = 13
USER_2 = 14
USER_3 = 15
spinnman.constants.SCP_SCAMP_PORT = 17893

The default port of the connection

spinnman.constants.SCP_TIMEOUT = 1.0

This is the default timeout when using SCP

spinnman.constants.SYSTEM_VARIABLE_BASE_ADDRESS = 4110450432

The base address of the system variable structure in System ram

spinnman.constants.SYSTEM_VARIABLE_BYTES = 256

The size of the system variable structure in bytes

spinnman.constants.UDP_BOOT_CONNECTION_DEFAULT_PORT = 54321

The default port of the connection

spinnman.constants.UDP_MESSAGE_MAX_SIZE = 256

The max size a UDP packet can be, excluding headers

spinnman.constants.address_length_dtype = {(0, 0): READ_TYPES.WORD, (0, 1): READ_TYPES.BYTE, (0, 2): READ_TYPES.HALF_WORD, (0, 3): READ_TYPES.BYTE, (1, 0): READ_TYPES.BYTE, (1, 1): READ_TYPES.BYTE, (1, 2): READ_TYPES.BYTE, (1, 3): READ_TYPES.BYTE, (2, 0): READ_TYPES.HALF_WORD, (2, 1): READ_TYPES.BYTE, (2, 2): READ_TYPES.HALF_WORD, (2, 3): READ_TYPES.BYTE, (3, 0): READ_TYPES.BYTE, (3, 1): READ_TYPES.BYTE, (3, 2): READ_TYPES.BYTE, (3, 3): READ_TYPES.BYTE}

This is a mapping between read address in the mapping between word byte position, the number of bytes you wish to read, and the type of time efficient way to read said amount of bytes via SARK

spinnman.exceptions module
exception spinnman.exceptions.SpallocException[source]

Bases: SpinnmanException

Raised when there is a problem with the Spalloc session or job.

exception spinnman.exceptions.SpiNNManCoresNotInStateException(timeout, expected_states, failed_core_states)[source]

Bases: SpinnmanTimeoutException

Cores failed to reach a given state within a timeout.

Parameters:
failed_core_states()[source]
Return type:

CPUInfos

exception spinnman.exceptions.SpinnmanEIEIOPacketParsingException(parsing_format, packet)[source]

Bases: SpinnmanException

Unable to complete the parsing of the EIEIO packet received. The routine used is invalid or the content of the packet is invalid.

Parameters:
  • parsing_format (str) –

  • packet (bytes) –

property packet
Return type:

bytes

exception spinnman.exceptions.SpinnmanEOFException[source]

Bases: SpinnmanIOException

An exception that we’re trying to do I/O on a closed socket. That isn’t going to work!

Parameters:

problem (str) – The problem with the IO

exception spinnman.exceptions.SpinnmanException[source]

Bases: Exception

Superclass of exceptions that occur when dealing with communication with SpiNNaker.

exception spinnman.exceptions.SpinnmanGenericProcessException(exception, tb, x, y, p, phys_p, tb2=None)[source]

Bases: SpinnmanException

Encapsulates exceptions from processes which communicate with some core/chip.

Parameters:
property exception
Return type:

Exception

exception spinnman.exceptions.SpinnmanGroupedProcessException(error_requests, exceptions, tracebacks, connections)[source]

Bases: SpinnmanException

Encapsulates exceptions from processes which communicate with a collection of cores/chips.

exception spinnman.exceptions.SpinnmanIOException(problem)[source]

Bases: SpinnmanException

An exception that something went wrong with the underlying IO.

Parameters:

problem (str) – The problem with the IO

property problem

The problem with IO.

Return type:

str

exception spinnman.exceptions.SpinnmanInvalidPacketException(packet_type, problem)[source]

Bases: SpinnmanException

An exception that indicates that a packet was not in the expected format.

Parameters:
  • packet_type (str) – The type of packet expected

  • problem (str) – The problem with the packet

property packet_type

The packet type.

Return type:

str

property problem

The problem with the packet.

Return type:

str

exception spinnman.exceptions.SpinnmanInvalidParameterException(parameter, value, problem)[source]

Bases: SpinnmanException

An exception that indicates that the value of one of the parameters passed was invalid.

Parameters:
  • parameter (str) – The name of the parameter that is invalid

  • value (str) – The value of the parameter that is invalid

  • problem (str) – The problem with the parameter

property parameter

The parameter with an invalid value.

Return type:

str

property problem

The problem with the parameter value.

Return type:

str

property value

The value that is invalid.

exception spinnman.exceptions.SpinnmanInvalidParameterTypeException(parameter, param_type, problem)[source]

Bases: SpinnmanException

An exception that indicates that the type of one of the parameters passed was invalid.

Parameters:
  • parameter (str) – The name of the parameter that is invalid

  • param_type (str) – The type of the parameter that is invalid

  • problem (str) – The problem with the parameter

property parameter

The parameter with an invalid value.

Return type:

str

property problem

The problem with the parameter value.

Return type:

str

property type

The value that is invalid.

exception spinnman.exceptions.SpinnmanTimeoutException(operation, timeout, msg=None)[source]

Bases: SpinnmanException

An exception that indicates that a timeout occurred before an operation could finish.

Parameters:
  • operation (str) – The operation being performed

  • timeout (float) – The timeout value in seconds

property operation

The operation that was performed.

Return type:

str

property timeout

The timeout value in seconds.

Return type:

float

exception spinnman.exceptions.SpinnmanUnexpectedResponseCodeException(operation, command, response)[source]

Bases: SpinnmanException

Indicate that a response code returned from the board was unexpected for the current operation.

Parameters:
  • operation (str) – The operation being performed

  • command (str) – The command being executed

  • response (str) – The response received in error

property command

The command being executed.

property operation

The operation being performed.

Return type:

str

property response

The unexpected response.

Return type:

str

exception spinnman.exceptions.SpinnmanUnsupportedOperationException(operation)[source]

Bases: SpinnmanException

An exception that indicates that the given operation is not supported.

Parameters:

operation (str) – The operation being requested

property operation

The unsupported operation requested.

Return type:

str

spinnman.get_cores_in_run_state module

This is a script used to check the state of a SpiNNaker machine.

spinnman.get_cores_in_run_state.get_cores_in_run_state(txrx, app_id, print_all_chips)[source]
Parameters:
spinnman.get_cores_in_run_state.main(args)[source]

Runs the script.

spinnman.transceiver module
class spinnman.transceiver.Transceiver(version, connections=None)[source]

Bases: AbstractContextManager

An encapsulation of various communications with the SpiNNaker board.

The methods of this class are designed to be thread-safe (provided they do not access a BMP, as access to those is never thread-safe); thus you can make multiple calls to the same (or different) methods from multiple threads and expect each call to work as if it had been called sequentially, although the order of returns is not guaranteed.

Note

With multiple connections to the board, using multiple threads in this way may result in an increase in the overall speed of operation, since the multiple calls may be made separately over the set of given connections.

Parameters:
  • version (int) – The version of the board being connected to

  • connections (list(Connection)) – An iterable of connections to the board. If not specified, no communication will be possible until connections are found.

Raises:
add_scamp_connections(connections)[source]

Check connections to the board and store these for future use.

Note

An exception will be thrown if no initial connections can be found to the board.

Parameters:

connections (dict((int,int),str)) – Dict of (x,`y`) to IP address

Raises:
property bmp_connection

The BMP connections.

Warning

This property is currently deprecated and likely to be removed.

Return type:

dict(tuple(int,int),MostDirectConnectionSelector)

boot_board(number_of_boards=None, width=None, height=None, extra_boot_values=None)[source]

Attempt to boot the board. No check is performed to see if the board is already booted.

Parameters:
  • number_of_boards – this parameter is deprecated

  • width – this parameter is deprecated

  • height – this parameter is deprecated

  • extra_boot_values (dict(SystemVariableDefinition,object)) – extra values to set during boot

Raises:
clear_ip_tag(tag, board_address=None)[source]

Clear the setting of an IP tag.

Parameters:
  • tag (int) – The tag ID

  • board_address (str) – Board address where the tag should be cleared. If not specified, all AbstractSCPConnection connections will send the message to clear the tag

Raises:
clear_multicast_routes(x, y)[source]

Remove all the multicast routes on a chip.

Parameters:
  • x (int) – The x-coordinate of the chip on which to clear the routes

  • y (int) – The y-coordinate of the chip on which to clear the routes

Raises:
clear_router_diagnostic_counters(x, y, enable=True, counter_ids=None)[source]

Clear router diagnostic information on a chip.

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

  • y (int) – The y-coordinate of the chip

  • enable (bool) – True (default) if the counters should be enabled

  • counter_ids (iterable(int)) – The IDs of the counters to reset (all by default) and enable if enable is True; each must be between 0 and 15

Raises:
close()[source]

Close the transceiver and any threads that are running.

control_sync(do_sync)[source]

Control the synchronisation of the chips.

Parameters:

do_sync (bool) – Whether to synchronise or not

discover_scamp_connections()[source]

Find connections to the board and store these for future use.

Note

An exception will be thrown if no initial connections can be found to the board.

Raises:
ensure_board_is_ready(number_of_boards=None, width=None, height=None, n_retries=5, extra_boot_values=None)[source]

Ensure that the board is ready to interact with this version of the transceiver. Boots the board if not already booted and verifies that the version of SCAMP running is compatible with this transceiver.

Parameters:
  • number_of_boards (int or None) – this parameter is deprecated and will be ignored

  • width (int or None) – this parameter is deprecated and will be ignored

  • height (int or None) – this parameter is deprecated and will be ignored

  • n_retries (int) – The number of times to retry booting

  • extra_boot_values (dict(SystemVariableDefinition,object)) – Any additional values to set during boot

Returns:

The version identifier

Return type:

VersionInfo

Raises:

SpinnmanIOException

  • If there is a problem booting the board

  • If the version of software on the board is not compatible with this transceiver

execute(x, y, processors, executable, app_id, n_bytes=None, wait=False, is_filename=False)[source]

Start an executable running on a single chip.

Warning

This method is currently deprecated and likely to be removed.

Parameters:
  • x (int) – The x-coordinate of the chip on which to run the executable

  • y (int) – The y-coordinate of the chip on which to run the executable

  • processors (list(int)) – The cores on the chip on which to run the application

  • executable (RawIOBase or bytes or bytearray or str) –

    The data that is to be executed. Should be one of the following:

    • An instance of RawIOBase

    • A bytearray/bytes

    • A filename of a file containing the executable (in which case is_filename must be set to True)

  • app_id (int) – The ID of the application with which to associate the executable

  • n_bytes (int) –

    The size of the executable data in bytes. If not specified:

    • If executable is an RawIOBase, an error is raised

    • If executable is a bytearray, the length of the bytearray will be used

    • If executable is an int, 4 will be used

    • If executable is a str, the length of the file will be used

  • wait (bool) – True if the binary should enter a “wait” state on loading

  • is_filename (bool) – True if executable is a filename

Raises:
execute_application(executable_targets, app_id)[source]

Execute a set of binaries that make up a complete application on specified cores, wait for them to be ready and then start all of the binaries.

Note

This will get the binaries into c_main but will not signal the barrier.

Parameters:
  • executable_targets (ExecutableTargets) – The binaries to be executed and the cores to execute them on

  • app_id (int) – The app_id to give this application

execute_flood(core_subsets, executable, app_id, n_bytes=None, wait=False, is_filename=False)[source]

Start an executable running on multiple places on the board. This will be optimised based on the selected cores, but it may still require a number of communications with the board to execute.

Parameters:
  • core_subsets (CoreSubsets) – Which cores on which chips to start the executable

  • executable (RawIOBase or bytes or bytearray or str) –

    The data that is to be executed. Should be one of the following:

    • An instance of RawIOBase

    • A bytearray

    • A filename of an executable (in which case is_filename must be set to True)

  • app_id (int) – The ID of the application with which to associate the executable

  • n_bytes (int) –

    The size of the executable data in bytes. If not specified:

    • If executable is an RawIOBase, an error is raised

    • If executable is a bytearray, the length of the bytearray will be used

    • If executable is an int, 4 will be used

    • If executable is a str, the length of the file will be used

  • wait (bool) – True if the processors should enter a “wait” state on loading

  • is_filename (bool) – True if the data is a filename

Raises:
  • SpinnmanIOException

    • If there is an error communicating with the board

    • If there is an error reading the executable

  • SpinnmanInvalidPacketException – If a packet is received that is not in the valid format

  • SpinnmanInvalidParameterException

    • If one of the specified cores is not valid

    • If app_id is an invalid application ID

    • If a packet is received that has invalid parameters

    • If executable is an RawIOBase but n_bytes is not specified

    • If executable is an int and n_bytes is more than 4

    • If n_bytes is less than 0

  • SpinnmanUnexpectedResponseCodeException – If a response indicates an error during the exchange

free_sdram(x, y, base_address, app_id)[source]

Free allocated SDRAM.

Warning

This method is currently deprecated and likely to be removed.

Parameters:
  • x (int) – The x-coordinate of the chip onto which to ask for memory

  • y (int) – The y-coordinate of the chip onto which to ask for memory

  • base_address (int) – The base address of the allocated memory

  • app_id (int) – The app ID of the allocated memory

free_sdram_by_app_id(x, y, app_id)[source]

Free all SDRAM allocated to a given app ID.

Warning

This method is currently deprecated and untested as there is no known use. Same functionality provided by ybug and bmpc. Retained in case needed for hardware debugging.

Parameters:
  • x (int) – The x-coordinate of the chip onto which to ask for memory

  • y (int) – The y-coordinate of the chip onto which to ask for memory

  • app_id (int) – The app ID of the allocated memory

Returns:

The number of blocks freed

Return type:

int

get_connections()[source]

Get the currently known connections to the board, made up of those passed in to the transceiver and those that are discovered during calls to discover_connections. No further discovery is done here.

Returns:

An iterable of connections known to the transceiver

Return type:

list(Connection)

get_core_state_count(app_id, state)[source]

Get a count of the number of cores which have a given state.

Parameters:
  • app_id (int) – The ID of the application from which to get the count.

  • state (CPUState) – The state count to get

Returns:

A count of the cores with the given status

Return type:

int

Raises:
get_core_status_string(cpu_infos)[source]

Get a string indicating the status of the given cores.

Parameters:

cpu_infos (CPUInfos) – A CPUInfos objects

Return type:

str

get_cores_in_state(all_core_subsets, states)[source]

Get all cores that are in a given state or set of states.

Parameters:
Returns:

Core subsets object containing cores in the given state(s)

Return type:

CPUInfos

get_cores_not_in_state(all_core_subsets, states)[source]

Get all cores that are not in a given state or set of states.

Parameters:
Returns:

Core subsets object containing cores not in the given state(s)

Return type:

CoreSubsets

get_cpu_information(core_subsets=None)[source]

Get information about the processors on the board.

Parameters:

core_subsets (CoreSubsets) – A set of chips and cores from which to get the information. If not specified, the information from all of the cores on all of the chips on the board are obtained.

Returns:

An iterable of the CPU information for the selected cores, or all cores if core_subsets is not specified

Return type:

list(CPUInfo)

Raises:
get_cpu_information_from_core(x, y, p)[source]

Get information about a specific processor on the board.

Parameters:
  • x (int) – The x-coordinate of the chip containing the processor

  • y (int) – The y-coordinate of the chip containing the processor

  • p (int) – The ID of the processor to get the information about

Returns:

The CPU information for the selected core

Return type:

CPUInfo

Raises:
get_heap(x, y, heap=SystemVariableDefinition.sdram_heap_address)[source]

Get the contents of the given heap on a given chip.

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

  • y (int) – The y-coordinate of the chip

  • heap (SystemVariableDefinition) – The SystemVariableDefinition which is the heap to read

Return type:

list(HeapElement)

get_iobuf(core_subsets=None)[source]

Get the contents of the IOBUF buffer for a number of processors.

Parameters:

core_subsets (CoreSubsets) – A set of chips and cores from which to get the buffers. If not specified, the buffers from all of the cores on all of the chips on the board are obtained.

Returns:

An iterable of the buffers, which may not be in the order of core_subsets

Return type:

iterable(IOBuffer)

Raises:
get_iobuf_from_core(x, y, p)[source]

Get the contents of IOBUF for a given core.

Warning

This method is currently deprecated and likely to be removed.

Parameters:
  • x (int) – The x-coordinate of the chip containing the processor

  • y (int) – The y-coordinate of the chip containing the processor

  • p (int) – The ID of the processor to get the IOBUF for

Returns:

An IOBUF buffer

Return type:

IOBuffer

Raises:
get_machine_details()[source]

Get the details of the machine made up of chips on a board and how they are connected to each other.

Returns:

A machine description

Return type:

Machine

Raises:
get_machine_dimensions()[source]

Get the maximum chip X-coordinate and maximum chip Y-coordinate of the chips in the machine.

Returns:

The dimensions of the machine

Return type:

MachineDimensions

Raises:
get_multicast_routes(x, y, app_id=None)[source]

Get the current multicast routes set up on a chip.

Parameters:
  • x (int) – The x-coordinate of the chip from which to get the routes

  • y (int) – The y-coordinate of the chip from which to get the routes

  • app_id (int) – The ID of the application to filter the routes for. If not specified, will return all routes

Returns:

An iterable of multicast routes

Return type:

list(MulticastRoutingEntry)

Raises:
get_router_diagnostic_filter(x, y, position)[source]

Gets a router diagnostic filter from a router.

Parameters:
  • x (int) – the X address of the router from which this filter is being retrieved

  • y (int) – the Y address of the router from which this filter is being retrieved

  • position (int) – the position in the list of filters to read the information from

Returns:

The diagnostic filter read

Return type:

DiagnosticFilter

Raises:
get_router_diagnostics(x, y)[source]

Get router diagnostic information from a chip.

Parameters:
  • x (int) – The x-coordinate of the chip from which to get the information

  • y (int) – The y-coordinate of the chip from which to get the information

Returns:

The router diagnostic information

Return type:

RouterDiagnostics

Raises:
get_scamp_version(chip_x=255, chip_y=255, connection_selector=None, n_retries=10)[source]

Get the version of SCAMP which is running on the board.

Parameters:
  • chip_x (int) – the chip’s x coordinate to query for SCAMP version

  • chip_y (int) – the chip’s y coordinate to query for SCAMP version

  • connection_selector (AbstractMultiConnectionProcessConnectionSelector) – the connection to send the SCAMP version or None (if None then a random SCAMP connection is used).

  • n_retries (int) –

Returns:

The version identifier

Return type:

VersionInfo

Raises:
get_tags(connection=None)[source]

Get the current set of tags that have been set on the board.

Parameters:

connection (AbstractSCPConnection) – Connection from which the tags should be received. If not specified, all AbstractSCPConnection connections will be queried and the response will be combined.

Returns:

An iterable of tags

Return type:

iterable(AbstractTag)

Raises:
static get_user_0_register_address_from_core(p)[source]

Get the address of user 0 for a given processor on the board.

Note

Conventionally, user_0 usually holds the address of the table of memory regions.

Parameters:

p (int) – The ID of the processor to get the user 0 address from

Returns:

The address for user 0 register for this processor

Return type:

int

static get_user_1_register_address_from_core(p)[source]

Get the address of user 1 for a given processor on the board.

Parameters:

p (int) – The ID of the processor to get the user 1 address from

Returns:

The address for user 1 register for this processor

Return type:

int

static get_user_2_register_address_from_core(p)[source]

Get the address of user 2 for a given processor on the board.

Parameters:

p (int) – The ID of the processor to get the user 2 address from

Returns:

The address for user 2 register for this processor

Return type:

int

static get_user_3_register_address_from_core(p)[source]

Get the address of user 3 for a given processor on the board.

Parameters:

p (int) – The ID of the processor to get the user 3 address from

Returns:

The address for user 3 register for this processor

Return type:

int

is_connected(connection=None)[source]

Determines if the board can be contacted.

Parameters:

connection (Connection) – The connection which is to be tested. If None, all connections will be tested, and the board will be considered to be connected if any one connection works.

Returns:

True if the board can be contacted, False otherwise

Return type:

bool

static is_scamp_version_compabible(version)[source]

Determine if the version of SCAMP is compatible with this transceiver.

Parameters:

version (tuple(int,int,int)) – The version to test

Return type:

bool

load_fixed_route(x, y, fixed_route, app_id)[source]

Loads a fixed route routing table entry onto a chip’s router.

Parameters:
  • x (int) – The x-coordinate of the chip onto which to load the routes

  • y (int) – The y-coordinate of the chip onto which to load the routes

  • fixed_route (FixedRouteEntry) – the route for the fixed route entry on this chip

  • app_id (int) – The ID of the application with which to associate the routes. If not specified, defaults to 0.

Raises:
load_multicast_routes(x, y, routes, app_id)[source]

Load a set of multicast routes on to a chip.

Parameters:
  • x (int) – The x-coordinate of the chip onto which to load the routes

  • y (int) – The y-coordinate of the chip onto which to load the routes

  • routes (iterable(MulticastRoutingEntry)) – An iterable of multicast routes to load

  • app_id (int) – The ID of the application with which to associate the routes. If not specified, defaults to 0.

Raises:
locate_spinnaker_connection_for_board_address(board_address)[source]

Find a connection that matches the given board IP address.

Parameters:

board_address (str) – The IP address of the Ethernet connection on the board

Returns:

A connection for the given IP address, or None if no such connection exists

Return type:

SCAMPConnection

malloc_sdram(x, y, size, app_id, tag=None)[source]

Allocates a chunk of SDRAM on a chip on the machine.

Parameters:
  • x (int) – The x-coordinate of the chip onto which to ask for memory

  • y (int) – The y-coordinate of the chip onto which to ask for memory

  • size (int) – the amount of memory to allocate in bytes

  • app_id (int) – The ID of the application with which to associate the routes. If not specified, defaults to 0.

  • tag (int) – the tag for the SDRAM, a 8-bit (chip-wide) tag that can be looked up by a SpiNNaker application to discover the address of the allocated block. If 0 then no tag is applied.

Returns:

the base address of the allocated memory

Return type:

int

property number_of_boards_located

The number of boards currently configured.

Warning

This property is currently deprecated and likely to be removed.

Return type:

int

power_off(boards=0, cabinet=0, frame=0)[source]

Power off a set of boards in the machine.

Parameters:
  • boards (int) – The board or boards to power off

  • cabinet (int) – the ID of the cabinet containing the frame, or 0 if the frame is not in a cabinet

  • frame (int) – the ID of the frame in the cabinet containing the board(s), or 0 if the board is not in a frame

power_off_machine()[source]

Power off the whole machine.

:rtype bool :return success or failure to power off the machine

power_on(boards=0, cabinet=0, frame=0)[source]

Power on a set of boards in the machine.

Parameters:
  • boards (int) – The board or boards to power on

  • cabinet (int) – the ID of the cabinet containing the frame, or 0 if the frame is not in a cabinet

  • frame (int) – the ID of the frame in the cabinet containing the board(s), or 0 if the board is not in a frame

power_on_machine()[source]

Power on the whole machine.

:rtype bool :return success of failure to power on machine

read_adc_data(board, cabinet, frame)[source]

Read the BMP ADC data.

Warning

This method is currently deprecated and untested as there is no known use. Same functionality provided by ybug and bmpc. Retained in case needed for hardware debugging.

Parameters:
  • cabinet (int) – cabinet: the cabinet this is targeting

  • frame (int) – the frame this is targeting

  • board (int) – which board to request the ADC data from

Returns:

the FPGA’s ADC data object

Return type:

ADCInfo

read_bmp_version(board, cabinet, frame)[source]

Read the BMP version.

Parameters:
  • cabinet (int) – cabinet: the cabinet this is targeting

  • frame (int) – the frame this is targeting

  • board (int) – which board to request the data from

Returns:

the sver from the BMP

read_fixed_route(x, y, app_id)[source]

Reads a fixed route routing table entry from a chip’s router.

Parameters:
  • x (int) – The x-coordinate of the chip onto which to load the routes

  • y (int) – The y-coordinate of the chip onto which to load the routes

  • app_id (int) – The ID of the application with which to associate the routes. If not specified, defaults to 0.

Returns:

the route as a fixed route entry

read_fpga_register(fpga_num, register, cabinet, frame, board)[source]

Read a register on a FPGA of a board. The meaning of the register’s contents will depend on the FPGA’s configuration.

Parameters:
  • fpga_num (int) – FPGA number (0, 1 or 2) to communicate with.

  • register (int) – Register address to read to (will be rounded down to the nearest 32-bit word boundary).

  • cabinet (int) – cabinet: the cabinet this is targeting

  • frame (int) – the frame this is targeting

  • board (int) – which board to request the FPGA register from

Returns:

the register data

Return type:

int

read_memory(x, y, base_address, length, cpu=0)[source]

Read some areas of memory (usually SDRAM) from the board.

Parameters:
  • x (int) – The x-coordinate of the chip where the memory is to be read from

  • y (int) – The y-coordinate of the chip where the memory is to be read from

  • base_address (int) – The address in SDRAM where the region of memory to be read starts

  • length (int) – The length of the data to be read in bytes

  • cpu (int) – the core ID used to read the memory of; should usually be 0 when reading from SDRAM, but may be other values when reading from DTCM.

Returns:

A bytearray of data read

Return type:

bytes

Raises:
read_neighbour_memory(x, y, link, base_address, length, cpu=0)[source]

Read some areas of memory on a neighbouring chip using a LINK_READ SCP command. If sent to a BMP, this command can be used to communicate with the FPGAs’ debug registers.

Warning

This method is currently deprecated and untested as there is no known use. Same functionality provided by ybug and bmpc. Retained in case needed for hardware debugging.

Parameters:
  • x (int) – The x-coordinate of the chip whose neighbour is to be read from

  • y (int) – The y-coordinate of the chip whose neighbour is to be read from

  • cpu (int) – The CPU to use, typically 0 (or if a BMP, the slot number)

  • link (int) – The link index to send the request to (or if BMP, the FPGA number)

  • base_address (int) – The address in SDRAM where the region of memory to be read starts

  • length (int) – The length of the data to be read in bytes

Returns:

An iterable of chunks of data read in order

Return type:

bytes

Raises:
read_user_0(x, y, p)[source]

Get the contents of the user_0 register for the given processor.

Note

Conventionally, user_0 usually holds the address of the table of memory regions.

Parameters:
  • x (int) – X coordinate of the chip

  • y (int) – Y coordinate of the chip

  • p (int) – Virtual processor identifier on the chip

Return type:

int

Raises:
read_user_1(x, y, p)[source]

Get the contents of the user_1 register for the given processor.

Parameters:
  • x (int) – X coordinate of the chip

  • y (int) – Y coordinate of the chip

  • p (int) – Virtual processor identifier on the chip

Return type:

int

Raises:
read_word(x, y, base_address, cpu=0)[source]

Read a word (usually of SDRAM) from the board.

Parameters:
  • x (int) – The x-coordinate of the chip where the word is to be read from

  • y (int) – The y-coordinate of the chip where the word is to be read from

  • base_address (int) – The address (usually in SDRAM) where the word to be read starts

  • cpu (int) – the core ID used to read the word; should usually be 0 when reading from SDRAM, but may be other values when reading from DTCM.

Returns:

The unsigned integer value at base_address

Return type:

int

Raises:
send_scp_message(message, connection=None)[source]

Sends an SCP message, without expecting a response.

Parameters:
Raises:
send_sdp_message(message, connection=None)[source]

Sends an SDP message using one of the connections.

Parameters:
send_signal(app_id, signal)[source]

Send a signal to an application.

Parameters:
  • app_id (int) – The ID of the application to send to

  • signal (Signal) – The signal to send

Raises:
set_ip_tag(ip_tag, use_sender=False)[source]

Set up an IP tag.

Parameters:
  • ip_tag (IPTag) –

    The tag to set up.

    Note

    board_address can be None, in which case, the tag will be assigned to all boards.

  • use_sender (bool) – Optionally use the sender host and port instead of the given host and port in the tag

Raises:
set_led(led, action, board, cabinet, frame)[source]

Set the LED state of a board in the machine.

Warning

This method is currently deprecated and untested as there is no known use. Same functionality provided by ybug and bmpc. Retained in case needed for hardware debugging.

Parameters:
  • led (int or iterable(int)) – Number of the LED or an iterable of LEDs to set the state of (0-7)

  • action (LEDAction) – State to set the LED to, either on, off or toggle

  • board (int or iterable(int)) – Specifies the board to control the LEDs of. This may also be an iterable of multiple boards (in the same frame). The command will actually be sent to the first board in the iterable.

  • cabinet (int) – the cabinet this is targeting

  • frame (int) – the frame this is targeting

set_leds(x, y, cpu, led_states)[source]

Set LED states.

Warning

The set_leds is deprecated and untested due to no known use.

Parameters:
  • x (int) – The x-coordinate of the chip on which to set the LEDs

  • y (int) – The x-coordinate of the chip on which to set the LEDs

  • cpu (int) – The CPU of the chip on which to set the LEDs

  • led_states (dict(int,int)) – A dictionary mapping SetLED index to state with 0 being off, 1 on and 2 inverted.

Raises:
set_reverse_ip_tag(reverse_ip_tag)[source]

Set up a reverse IP tag.

Parameters:

reverse_ip_tag (ReverseIPTag) –

The reverse tag to set up.

Note

The board_address field can be None, in which case, the tag will be assigned to all boards.

Raises:
set_router_diagnostic_filter(x, y, position, diagnostic_filter)[source]

Sets a router diagnostic filter in a router.

Parameters:
  • x (int) – The X address of the router in which this filter is being set.

  • y (int) – The Y address of the router in which this filter is being set.

  • position (int) – The position in the list of filters where this filter is to be added.

  • diagnostic_filter (DiagnosticFilter) –

    The diagnostic filter being set in the placed, between 0 and 15.

    Note

    Positions 0 to 11 are used by the default filters, and setting these positions will result in a warning.

Raises:
set_watch_dog(watch_dog)[source]

Enable, disable or set the value of the watch dog timer.

Warning

This method is currently deprecated and untested as there is no known use. Same functionality provided by ybug and bmpc. Retained in case needed for hardware debugging.

Parameters:

watch_dog (bool or int) – Either a boolean indicating whether to enable (True) or disable (False) the watch dog timer, or an int value to set the timer count to.

set_watch_dog_on_chip(x, y, watch_dog)[source]

Enable, disable or set the value of the watch dog timer on a specific chip.

Warning

This method is currently deprecated and untested as there is no known use. Same functionality provided by ybug and bmpc. Retained in case needed for hardware debugging.

Parameters:
  • x (int) – chip X coordinate to write new watchdog parameter to

  • y (int) – chip Y coordinate to write new watchdog parameter to

  • watch_dog (bool or int) – Either a boolean indicating whether to enable (True) or disable (False) the watchdog timer, or an int value to set the timer count to

stop_application(app_id)[source]

Sends a stop request for an app_id.

Parameters:

app_id (int) – The ID of the application to send to

Raises:
wait_for_cores_to_be_in_state(all_core_subsets, app_id, cpu_states, timeout=None, time_between_polls=0.1, error_states=frozenset({<CPUState.WATCHDOG: 3>, <CPUState.RUN_TIME_EXCEPTION: 2>}), counts_between_full_check=100, progress_bar=None)[source]

Waits for the specified cores running the given application to be in some target state or states. Handles failures.

Parameters:
  • all_core_subsets (CoreSubsets) – the cores to check are in a given sync state

  • app_id (int) – the application ID that being used by the simulation

  • cpu_states (set(CPUState)) – The expected states once the applications are ready; success is when each application is in one of these states

  • timeout (float) – The amount of time to wait in seconds for the cores to reach one of the states

  • time_between_polls (float) – Time between checking the state

  • error_states (set(CPUState)) – Set of states that the application can be in that indicate an error, and so should raise an exception

  • counts_between_full_check (int) – The number of times to use the count signal before instead using the full CPU state check

  • progress_bar (ProgressBar or None) – Possible progress bar to update.

Raises:

SpinnmanTimeoutException – If a timeout is specified and exceeded.

write_fpga_register(fpga_num, register, value, cabinet, frame, board)[source]

Write a register on a FPGA of a board. The meaning of setting the register’s contents will depend on the FPGA’s configuration.

Parameters:
  • fpga_num (int) – FPGA number (0, 1 or 2) to communicate with.

  • register (int) – Register address to read to (will be rounded down to the nearest 32-bit word boundary).

  • value (int) – the value to write into the FPGA register

  • cabinet (int) – cabinet: the cabinet this is targeting

  • frame (int) – the frame this is targeting

  • board (int) – which board to write the FPGA register to

write_memory(x, y, base_address, data, n_bytes=None, offset=0, cpu=0, is_filename=False, get_sum=False)[source]

Write to the SDRAM on the board.

Parameters:
  • x (int) – The x-coordinate of the chip where the memory is to be written to

  • y (int) – The y-coordinate of the chip where the memory is to be written to

  • base_address (int) – The address in SDRAM where the region of memory is to be written

  • data (RawIOBase or bytes or bytearray or int or str) –

    The data to write. Should be one of the following:

    • An instance of RawIOBase

    • A bytearray/bytes

    • A single integer - will be written in little-endian byte order

    • A filename of a data file (in which case is_filename must be set to True)

  • n_bytes (int) –

    The amount of data to be written in bytes. If not specified:

    • If data is an RawIOBase, an error is raised

    • If data is a bytearray, the length of the bytearray will be used

    • If data is an int, 4 will be used

    • If data is a str, the length of the file will be used

  • offset (int) – The offset from which the valid data begins

  • cpu (int) – The optional CPU to write to

  • is_filename (bool) – True if data is a filename

  • get_sum (bool) – whether to return a checksum or 0

Returns:

The number of bytes written, the checksum (0 if get_sum=False)

Return type:

int, int

Raises:
write_memory_flood(base_address, data, n_bytes=None, offset=0, is_filename=False)[source]

Write to the SDRAM of all chips.

Parameters:
  • base_address (int) – The address in SDRAM where the region of memory is to be written

  • data (RawIOBase or bytes or bytearray or int or str) –

    The data that is to be written. Should be one of the following:

    • An instance of RawIOBase

    • A byte-string

    • A single integer

    • A file name of a file to read (in which case is_filename should be set to True)

  • n_bytes (int) –

    The amount of data to be written in bytes. If not specified:

    • If data is an RawIOBase, an error is raised

    • If data is a bytearray or bytes, the length of the bytearray will be used

    • If data is an int, 4 will be used

    • If data is a str, the size of the file will be used

  • offset (int) – The offset where the valid data starts; if data is an int, then the offset will be ignored and 0 is used.

  • is_filename (bool) – True if data should be interpreted as a file name

Raises:
write_neighbour_memory(x, y, link, base_address, data, n_bytes=None, offset=0, cpu=0)[source]

Write to the memory of a neighbouring chip using a LINK_READ SCP command. If sent to a BMP, this command can be used to communicate with the FPGAs’ debug registers.

Warning

This method is deprecated and untested due to no known use.

Parameters:
  • x (int) – The x-coordinate of the chip whose neighbour is to be written to

  • y (int) – The y-coordinate of the chip whose neighbour is to be written to

  • link (int) – The link index to send the request to (or if BMP, the FPGA number)

  • base_address (int) – The address in SDRAM where the region of memory is to be written

  • data (RawIOBase or bytes or bytearray or int) –

    The data to write. Should be one of the following:

    • An instance of RawIOBase

    • A bytearray/bytes

    • A single integer; will be written in little-endian byte order

  • n_bytes (int) –

    The amount of data to be written in bytes. If not specified:

    • If data is an RawIOBase, an error is raised

    • If data is a bytearray, the length of the bytearray will be used

    • If data is an int, 4 will be used

  • offset (int) – The offset where the valid data starts (if data is an int then offset will be ignored and used 0)

  • cpu (int) – The CPU to use, typically 0 (or if a BMP, the slot number)

Raises:
write_user_0(x, y, p, value)[source]

Write to the user_0 register for the given processor.

Note

Conventionally, user_0 usually holds the address of the table of memory regions.

Parameters:
  • x (int) – X coordinate of the chip

  • y (int) – Y coordinate of the chip

  • p (int) – Virtual processor identifier on the chip

  • value (int) – The value to write

Raises:
write_user_1(x, y, p, value)[source]

Write to the user_1 register for the given processor.

Parameters:
  • x (int) – X coordinate of the chip

  • y (int) – Y coordinate of the chip

  • p (int) – Virtual processor identifier on the chip

  • value (int) – The value to write

Raises:
spinnman.transceiver.create_transceiver_from_hostname(hostname, version, bmp_connection_data=None, number_of_boards=None, auto_detect_bmp=False)[source]

Create a Transceiver by creating a UDPConnection to the given hostname on port 17893 (the default SCAMP port), and a BootConnection on port 54321 (the default boot port), optionally discovering any additional links using the UDPConnection, and then returning the transceiver created with the conjunction of the created UDPConnection and the discovered connections.

Parameters:
  • hostname (str or None) – The hostname or IP address of the board or None if only the BMP connections are of interest

  • number_of_boards (int or None) – a number of boards expected to be supported, or None, which defaults to a single board

  • version (int) – the type of SpiNNaker board used within the SpiNNaker machine being used. If a Spinn-5 board, then the version will be 5, Spinn-3 would equal 3 and so on.

  • bmp_connection_data (list(BMPConnectionData)) – the details of the BMP connections used to boot multi-board systems

  • auto_detect_bmp (bool) – True if the BMP of version 4 or 5 boards should be automatically determined from the board IP address

  • scamp_connections – the list of connections used for SCAMP communications

Returns:

The created transceiver

Return type:

Transceiver

Raises:
Module contents

Used to communicate with a SpiNNaker Board. The main part of this package is the Transceiver class. This can be used to send and receive packets in various SpiNNaker formats, depending on what connections are available.

Functional Requirements
  1. Connect to and communicate with a machine using a number of different connections.

  2. Boot a machine with the expected version of the software.

    • If the machine is already booted but the version is not the version expected, an exception will be thrown.

  3. Check the version of the software which the machine is booted with.

  4. Query the state of the machine to determine:

    • What the current state of the machine is in terms of the chips and cores available, the SDRAM available on the chips and which links are available between which chips.

    • What external links to the host exist (and separately add the discovered links to the set of links used to communicate with the machine).

    • What is running on the machine and where, and what the current status of those processes are.

    • How many cores are in a given state.

    • What is in the IOBUF buffers.

    • What the current routing entries for a given router are.

    • What the routing status counter values are.

  5. Load application binaries on to the machine, either to individual cores or via a “flood-fill” mechanism to multiple cores simultaneously (which may be a subset of the cores on a subset of the chips).

  6. Write data to SDRAM, either on an individual chip, or via a “flood-fill” mechanism to multiple chips simultaneously.

  7. Send a signal to an application.

  8. Read data from SDRAM on an individual chip.

  9. Send and receive SpiNNaker packets where the connections allow this.

    • If no connection supports this packet type, an exception is thrown.

    • The user should be able to select which connection is used. Selection of a connection which does not support the traffic type will also result in an exception.

  10. Send and receive SCP and SDP packets where the connections allow this.

    • If no connection supports the packet type, an exception is thrown.

    • The user should be able to select which connection is used. Selection of a connection which does not support the traffic type will also result in an exception.

  11. It should be possible to call any of the functions simultaneously, including the same function more than once.

    • Where possible, multiple connections should be used to overlap calls.

    • The functions should not return until they have confirmed that any messages sent have been received, and any responses have been received.

    • Functions should not respond with the result of a different function.

    • Functions can further sub-divide the call into a number of separate calls that can be divided across the available connections, so long as the other requirements are met.

  12. More than one machine can be connected to the same host.

    • Once the subset of connections has been worked out for each machine, the operation of these machines should be independent.

Use Cases

Indices and tables

SpiNNMan_github

SpiNNMan_individual_docs

DataSpecification

This package provides utilities for specifying binary data algorithmically, and executing the specifications to produce the data.

DataSpecification

Used to generate memory images for a SpiNNaker CPU core from a set of instructions.

The main part of this package is the DataSpecificationGenerator class. This is used to generate a “Data Specification”, which can then be executed to produce a memory image. This package also handles this function if required, through the DataSpecificationExecutor class.

Functional Requirements

Creation of a Data Specification Language file which can be executed to produce a memory image.

  • Any errors that can be checked during the creation of the specification should throw an exception.

  • It will be impossible to detect all errors at creation time.

  • There should be no assumption of where the data specification will be stored, although a default provision of a way to write the specification to a file is acceptable.

Execution of a Data Specification Language file, producing a memory image.

  • This should detect any errors during execution and report them, halting the execution.

  • There should be no assumption of where the data specification is read from, although a default provision of a way to read the specification from a file is acceptable.

Use Cases

There are a number of use-cases of this library:

  • DataSpecificationGenerator is used to create a compressed memory image which can be expanded later, to reduce the amount of data that needs to be transferred over a slow connection.

  • DataSpecificationExecutor is used to execute a previously generated specification at the receiving end of a slow connection.

Main API

class data_specification.AbstractMemoryRegion[source]

Identifies something as a Memory region

class data_specification.DataSpecificationExecutor(spec_reader, memory_space)[source]

Used to execute a SpiNNaker data specification language file to produce a memory image.

Parameters:
  • spec_reader (RawIOBase) – The object to read the specification language file from

  • memory_space (int) – memory available on the destination architecture

Raises:

IOError – If a read or write fails

dsef

The executor functions themselves.

execute()[source]

Executes the specification. This will result in a configuration of memory regions being created (but not actually uploaded to SpiNNaker).

Raises:
get_constructed_data_size()[source]

Return the size of the data that will be written to memory.

Returns:

size of the data that will be written to memory

Return type:

int

get_header()[source]

Get the header of the data as a numpy array.

Return type:

numpy.ndarray

get_pointer_table(start_address)[source]

Get the pointer table as a numpy array.

Parameters:

start_address (int) – The base address of the data to be written

Return type:

numpy.ndarray

get_region(region_id)[source]

Get a region with a given ID.

Parameters:

region_id (int) – The ID of the region to get

Returns:

The region, or None if the region was not allocated

Return type:

MemoryRegionReal or None

property mem_regions

An enumeration of the mapping from region ID to region holder.

Return type:

iterable(tuple(int, AbstractMemoryRegion or None))

property referenceable_regions

The regions that can be referenced by others.

Return type:

list(int)

property references_to_fill

The references that need to be filled.

Return type:

list(int)

class data_specification.DataSpecificationExecutorFunctions(spec_reader, memory_space)[source]

This class includes the function related to each of the commands of the data specification file.

Note

DSG operations not mentioned in this class will cause an error during DSE if used.

Parameters:
  • spec_reader (RawIOBase) – The object to read the specification language file from

  • memory_space (int) – Memory space available for the data to be generated per region

execute_break(cmd)[source]

This command raises an exception to stop the execution of the data spec executor (DSE).

Implements BREAK

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_end_spec(cmd)[source]

This command marks the end of the specification program.

Implements END_SPEC

Parameters:

cmd (int) – the command which triggered the function call

Returns:

A special marker to signal the end.

Raises:
execute_mv(cmd)[source]

This command moves an immediate value to a register or copies the value of a register to another register.

Implements MV

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_reference(cmd)[source]

This command reserves a region and sets it to reference another.

Implements REFERENCE

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_reserve(cmd)[source]

This command reserves a region and assigns some memory space to it.

Implements RESERVE

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_set_wr_ptr(cmd)[source]

This command sets the current write pointer.

Implements SET_WR_PTR

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_switch_focus(cmd)[source]

This command switches the focus to the desired, already allocated, memory region.

Implements SWITCH_FOCUS

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_write(cmd)[source]

This command writes the given value in the specified region a number of times as identified by either a value in the command or a register value.

Implements WRITE

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_write_array(cmd)[source]

This command writes an array of values in the specified region.

Implements WRITE_ARRAY

Parameters:

cmd (int) – the command which triggered the function call

Raises:
property mem_regions

The collection of memory regions that can be written to.

Return type:

MemoryRegionCollection

property referenceable_regions

The regions that can be referenced by others.

Return type:

list(int)

property references_to_fill

The references that need to be filled.

Return type:

list(int)

class data_specification.DataSpecificationGenerator(spec_writer, report_writer=None)[source]

Used to generate a SpiNNaker data specification language file that can be executed to produce a memory image.

Parameters:
  • spec_writer (RawIOBase) – The object to write the specification to

  • 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:

IOError – If a write to external storage fails

align_write_pointer(log_block_size, log_block_size_is_register=False, return_register_id=None)[source]

Insert command to align the write pointer against a power-of-2 block size in bytes. Zeros are inserted in the intervening space

Parameters:
  • log_block_size (int) –

    • If log_block_size_is_register is False, log to base 2 of the block size (e.g. The write pointer will be moved so that it is a multiple of 2log_block_size), between 0 and 32

    • If log_block_size_is_register is True, the ID of the register containing log to the base 2 of the block size, between 0 and 15

  • log_block_size_is_register (bool) – Indicates if log_block_size is a register ID

  • return_register_id (int or None) – The ID of a register where the write pointer will be written to once it has been updated, between 0 and 15, or None if no such writing is to be done

Raises:
break_loop()[source]

Insert command to break out of a loop before it has completed.

Raises:
call_arithmetic_operation(register_id, operand_1, operation, operand_2, signed, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform an arithmetic operation on two signed or unsigned values and store the result in a register

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operation (ArithmeticOperation) – The operation to perform

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found, between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • signed (bool) – Indicates if the values should be considered signed

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
call_function(function_id, structure_ids)[source]

Insert command to call a function.

Parameters:
  • function_id (int) – The ID of a previously defined function, between 0 and 31

  • structure_ids (list(int)) – A list of structure IDs that will be passed into the function, each between 0 and 15

Raises:
call_random_distribution(distribution_id, register_id)[source]

Insert command to get the next random number from a random distribution, placing the result in a register to be used in a future call.

Parameters:
  • distribution_id (int) – The ID of the random distribution to call between 0 and 63

  • register_id (int) – The ID of the register to store the result in between 0 and 15

Raises:
comment(comment)[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

Raises:
copy_structure(source_structure_id, destination_structure_id, source_id_is_register=False, destination_id_is_register=False)[source]

Insert command to copy a structure, possibly overwriting another structure.

Parameters:
  • source_structure_id (int) –

    • If source_id_is_register is True, the ID of the register holding the source structure ID, between 0 and 15

    • Otherwise, the ID of the source structure, between 0 and 15

  • destination_structure_id (int) –

    • If destination_id_is_register is True, the ID of the register holding the destination structure ID, between 0 and 15

    • If destination_id_is_register is False, the ID of the destination structure, between 0 and 15

  • source_id_is_register (bool) – Indicates if source_structure_id is a register ID

  • destination_id_is_register (bool) – Indicates if destination_structure_id is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If source_id_is_register is True and source_structure_id is not a valid register ID

    • If destination_id_is_register is True and destination_structure_id is not a valid register ID

    • If source_id_is_register is False and source_structure_id is not a valid structure ID

    • If destination_id_is_register is False and destination_structure_id is not a valid structure ID

  • NotAllocatedException

    • If no structure with ID source_structure_id has been allocated

copy_structure_parameter(source_structure_id, source_parameter_index, destination_id, destination_parameter_index=None, destination_is_register=False)[source]

Insert command to copy the value of a parameter from one structure to another.

Parameters:
  • source_structure_id (int) – The ID of the source structure, between 0 and 15

  • source_parameter_index (int) – The index of the parameter in the source structure

  • destination_id (int) – The ID of the destination structure, or the ID of the destination register, between 0 and 15

  • destination_parameter_index (int) – The index of the parameter in the destination structure. Ignored when writing to a register.

  • destination_is_register (bool) – Indicates whether the destination is a structure or a register.

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If source_structure_id is not a valid structure ID

    • If destination_id is not a valid structure ID

    • If source_parameter_index is not a valid parameter index in the source structure

    • If destination_parameter_index is not a valid parameter index in the destination structure

  • NotAllocatedException

    • If no structure with ID destination_id has been allocated

    • If no structure with ID source_structure_id has been allocated

create_cmd(data, data_type=DataType.UINT32)[source]

Creates command to write a value 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 does not actually insert the WRITE command in the spec; that is done by write_cmd().

Parameters:
  • data (int or float) – the data to write.

  • data_type (DataType) – the type to convert data to

Returns:

cmd_word_list (binary data to be added to the binary data specification file), and cmd_string (string describing the command to be added to the report for the data specification file)

Return type:

tuple(bytearray, str)

Raises:
property current_region

The ID of the current DSG region we’re writing to. If not yet writing to any region, None.

Return type:

int or None

declare_random_number_generator(rng_id, rng_type, seed)[source]

Insert command to declare a random number generator.

Parameters:
  • rng_id (int) – The ID of the random number generator

  • rng_type (RandomNumberGenerator) – The type of the random number generator

  • seed (int) – The seed of the random number generator >= 0

Raises:
declare_uniform_random_distribution(distribution_id, structure_id, rng_id, min_value, max_value)[source]

Insert commands to declare a uniform random distribution.

Parameters:
  • distribution_id (int) – ID of the distribution being set up

  • structure_id (int) – ID of an empty structure slot to fill with the uniform random distribution data

  • rng_id (int) – The ID of the random number generator, between 0 and 15

  • min_value (float) – The minimum value that should be returned from the distribution between -32768.0 and max_value

  • max_value (float) – The maximum value that should be returned from the distribution between min_value and 32767.9999847

Raises:
define_break()[source]

Insert command to stop execution with an exception (for debugging).

Raises:
define_structure(structure_id, parameters)[source]

Insert commands to define a data structure.

Parameters:
  • structure_id (int) – the ID of the structure to create, between 0 and 15

  • parameters (list(tuple(str, DataType, float))) –

    A list of between 1 and 255 tuples of (label, data_type, value) where:

    • label is the label of the element (for debugging)

    • data_type is the data type of the element

    • value is the value of the element, or None if no value is to

      be assigned

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • NoMoreException – If there are no more spaces for new structures

  • ParameterOutOfBoundsException

    • If there are an incorrect number of parameters

    • If the size of one of the tuples is incorrect

    • If one of the values to be assigned has an integer data_type but has a fractional part

    • If one of the values to be assigned would overflow its data_type

  • UnknownTypeException – If one of the data types in the structure is unknown

else_conditional()[source]

Insert command for the else of an if…then…else construct. If the condition of the conditional evaluates to false, the statements up between the conditional and the insertion of this “else” are skipped, and the statements from this point until the end of the conditional are executed.

Raises:
end_conditional()[source]

Insert command to mark the end of an if…then…else construct

Raises:
end_function()[source]

Insert command to mark the end of a function definition.

Raises:

InvalidCommandException – If there is no function being defined at this point

end_loop()[source]

Insert command to indicate that this is the end of the loop. Commands between the start of the loop and this command will be repeated.

Raises:
end_specification(close_writer=True)[source]

Insert a command to indicate that the specification has finished and finish writing.

Parameters:

close_writer (bool) – Indicates whether to close the underlying writer(s)

Raises:
free_memory_region(region)[source]

Insert command to free a previously reserved memory region.

Parameters:

region (int) – The number of the region to free, from 0 to 15

Raises:
get_structure_value(destination_id, structure_id, parameter_index, parameter_index_is_register=False)[source]

Insert command to get a value from a structure. The value is copied in a register.

Parameters:
  • destination_id (int) – The ID of the destination register

  • structure_id (int) – The ID of the source structure

  • parameter_index (int) – The ID of the parameter/element to copy

  • parameter_index_is_register (bool) – True if parameter_index is a register ID containing the ID of the parameter/element to copy

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If structure_id is not in the allowed range

    • If parameter_index is larger than the number of parameters declared in the original structure

    • If destination_id is not the ID of a valid register

    • If parameter_index_is_register is True and parameter_index is not a valid register ID

  • NotAllocatedException – If the structure requested has not been declared

logical_and(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical AND operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found. between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If operand_1_is_register is True and operand_1 is not a valid register ID

    • If operand_2_is_register is True and operand_2 is not a valid register ID

logical_left_shift(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical left shift operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found. between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If operand_1_is_register is True and operand_1 is not a valid register ID

    • If operand_2_is_register is True and operand_2 is not a valid register ID

logical_not(register_id, operand, operand_is_register=False)[source]

Insert command to perform a logical NOT operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand (int) –

    • If operand_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_is_register is False, a 32-bit value

  • operand_is_register (bool) – Indicates if operand is a register ID

Raises:
logical_or(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical OR operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found. between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If operand_1_is_register is True and operand_1 is not a valid register ID

    • If operand_2_is_register is True and operand_2 is not a valid register ID

logical_right_shift(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical right shift operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found. between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If operand_1_is_register is True and operand_1 is not a valid register ID

    • If operand_2_is_register is True and operand_2 is not a valid register ID

logical_xor(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical XOR operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found. between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If operand_1_is_register is True and operand_1 is not a valid register ID

    • If operand_2_is_register is True and operand_2 is not a valid register ID

no_operation()[source]

Insert command to execute nothing.

Raises:
print_struct(structure_id, structure_id_is_register=False)[source]

Insert command to print out a structure (for debugging).

Parameters:
  • structure_id (int) –

    • If structure_id_is_register is True, the ID of the register containing the ID of the structure to print, between 0 and 15

    • If structure_id_is_register is False, the ID of the structure to print, between 0 and 15

  • structure_id_is_register (bool) – Indicates if the structure_id is a register

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If structure_id_is_register is True and structure_id is not a valid register ID

    • If structure_id_is_register is False and structure_id is not a valid structure ID

  • NotAllocatedException – If structure_id_is_register is False and structure_id is the ID of a structure that has not been allocated

print_text(text, encoding='ASCII')[source]

Insert command to print some text (for debugging).

Parameters:
  • text (str) – The text to write (max 12 bytes once encoded)

  • encoding (str) – The character encoding to use for the string. Defaults to ASCII.

Raises:
print_value(value, value_is_register=False, data_type=DataType.UINT32)[source]

Insert command to print out a value (for debugging).

Parameters:
  • value (float or int) –

    • If value_is_register is True, the ID of the register containing the value to print

    • If value_is_register is False, the value to print as a value of type given by data_type

  • value_is_register (bool) – Indicates if value is a register

  • data_type (DataType) – The type of the data to be printed

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If value_is_register is True and value is not a valid register ID

    • If value_is_register is False, the data_type is an integer type and value has a fractional part

    • If value_is_register is False and the value would overflow the data type

  • UnknownTypeException – If data_type is not a valid data type

read_value(dest_id, data_type)[source]

Insert command to read a value from the current write pointer, causing the write pointer to move by the number of bytes read. The data is stored in a register passed as argument.

Parameters:
  • dest_id (int) – The ID of the destination register.

  • data_type (DataType) – The type of the data to be read.

Raises:

ParameterOutOfBoundsException – If dest_id is out of range for a register ID

reference_memory_region(region, ref, label=None)[source]

Insert command to reference another memory region.

Parameters:
  • region (int) – The number of the region to reserve, from 0 to 15

  • ref (int) – The identifier of the region to reference

  • label (str or None) – An optional label for the region

Raises:
property region_sizes

A list of sizes of each region that has been reserved.

Note

The list will include 0 for each non-reserved region.

Return type:

list(int)

reserve_memory_region(region, size, label=None, empty=False, reference=None)[source]

Insert command to reserve a memory region.

Parameters:
  • region (int) – The number of the region to reserve, from 0 to 15

  • size (int) – The size to reserve for the region, in bytes

  • label (str or None) – An optional label for the region

  • empty (bool) – Specifies if the region will be left empty

  • reference (int or None) – A globally unique reference for this region

Raises:
save_write_pointer(register_id)[source]

Insert command to save the write pointer to a register.

Parameters:

register_id (int) – The ID of the register to assign, between 0 and 15

Raises:
set_register_value(register_id, data, data_is_register=False, data_type=DataType.UINT32)[source]

Insert command to set the value of a register.

Parameters:
  • register_id (int) – The ID of the register to assign, between 0 and 15

  • data (int or float) –

    • If data_is_register is True, the register ID containing the data to set, between 0 and 15

    • If data_is_register is False, the data is a value of the type given by data_type

  • data_is_register (bool) – Indicates if data is a register ID

  • data_type (DataType) – The type of the data to be assigned

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If data_is_register is True, and data is not a valid register ID

    • If data_is_register is False, data_type is an integer type and data has a fractional part

    • If data_is_register if False, and data would overflow the data type

  • UnknownTypeException – If the data type is not known

set_structure_value(structure_id, parameter_index, value, data_type, value_is_register=False)[source]

Insert command to set a value in a structure.

Parameters:
  • structure_id (int) –

    • If called outside of a function, the ID of the structure, between 0 and 15

    • If called within a function, the ID of the structure argument, between 0 and 4

  • parameter_index (int) – The index of the value to assign in the structure, between 0 and the number of parameters declared in the structure

  • value (float) –

    • If value_is_register is False, the value to assign at the selected position as a float or int

    • If value_is_register is True, the ID of the register containing the value to assign to the position, between 0 and 15

  • data_type (DataType) – type of the data to be stored in the structure. If parameter value_is_register is set to true, this variable is disregarded

  • value_is_register (bool) – Identifies if value identifies a register

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If structure_id is not in the allowed range

    • If parameter_index is larger than the number of parameters declared in the original structure

    • If value_is_register is False, and the data type of the structure value is an integer, and value has a fractional part

    • If value_is_register is False, and value would overflow the position in the structure

    • If value_is_register is True, and value is not a valid register ID

  • NotAllocatedException – If the structure requested has not been declared

  • UnknownTypeException – If the data type is unknown

set_write_pointer(address, address_is_register=False, relative_to_current=False)[source]

Insert command to set the position of the write pointer within the current region.

Parameters:
  • address (int) –

    • If address_is_register is True, the ID of the register containing the address to move to

    • If address_is_register is False, the address to move the write pointer to

  • address_is_register (bool) – Indicates if address is a register ID

  • relative_to_current (bool) – Indicates if address (or the value read from that register when address_is_register is True) is to be added to the current address, or used as an absolute address from the start of the current region

Raises:
start_conditional(register_id, condition, value, value_is_register=False)[source]

Insert command to start a conditional if…then…else construct. If the condition evaluates to true, the statement is executed up to the next else statement, or the end of the conditional, whichever comes first.

Parameters:
  • register_id (int) – The ID of a register to compare the value of

  • condition (Condition) – The condition which must be true to execute the following commands

  • value (int) –

    • If value_is_register is False, the value to compare to the value in the register

    • If value_is_register is True, the ID of the register containing the value to compare, between 0 and 15

  • value_is_register (bool) – Indicates if value is a register ID

Raises:
start_function(function_id, argument_by_value)[source]

Insert command to start a function definition, with up to 5 arguments, which are the IDs of structures to be used within the function, each of which can be passed by reference or by value. In the commands following this command up to the end_function() command, structures can only be referenced using the numbers 1 to 5 which address the arguments, rather than the original structure IDs.

Parameters:
  • function_id (int) – The ID of the function currently defined.

  • argument_by_value (list(bool)) – A list of up to 5 booleans indicating if the structure to be passed as an argument is to be passed by reference (i.e., changes made within the function are persisted) or by value (i.e., changes made within the function are lost when the function exits. The number of arguments is determined by the length of this list.

Raises:
start_loop(counter_register_id, start, end, increment=1, start_is_register=False, end_is_register=False, increment_is_register=False)[source]

Insert command to start a loop.

Parameters:
  • counter_register_id (int) – The ID of the register to use as the loop counter, between 0 and 15

  • start (int) –

    • If start_is_register is False, the number at which to start the loop counter, >= 0

    • If start_is_register is True, the ID of the register containing the number at which to start the loop counter, between 0 and 15

  • end (int) –

    • If end_is_register is False, the number which the loop counter must reach to stop the loop i.e. the loop will run while the contents of counter_register < end, >= 0

    • If end_is_register is True, the ID of the register containing the number at which to stop the loop, between 0 and 15

  • increment (int) –

    • If increment_is_register is False, the amount by which to increment the loop counter on each run of the loop, >= 0

    • If increment_is_register is True, the ID of the register containing the amount by which to increment the loop counter on each run of the loop, between 0 and 15

  • start_is_register (bool) – Indicates if start is a register ID

  • end_is_register (bool) – Indicates if end is a register ID

  • increment_is_register (bool) – Indicates if increment is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If counter_register_id is not a valid register ID

    • If start_is_register is True and start is not a valid register ID

    • If end_is_register is True and end is not a valid register ID

    • If increment_is_register is True, and increment is not a valid register ID

    • If start_is_register is False and ``start is not in the allowed range

    • If end_is_register is False and ``end is not in the allowed range

    • If increment_is_register is False and increment is not in the allowed range

switch_write_focus(region)[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:
write_array(array_values, data_type=DataType.UINT32)[source]

Insert command to write an array, causing the write pointer to move on by (data type size * the array size), in bytes.

Parameters:
Raises:
write_cmd(cmd_word_list, cmd_string)[source]

Applies write commands created previously created (and cached).

Note

See create_cmd() for how to create the arguments to this method.

Parameters:
  • cmd_word_list (bytearray) – list of binary words to be added to the binary data specification file

  • cmd_string (str) – string describing the command to be added to the report for the data specification file

Raises:
write_repeated_value(data, repeats=1, repeats_is_register=False, data_type=DataType.UINT32)[source]

Insert command to write a value one or more times 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

Parameters:
  • data (float or int) – the data to write as a float.

  • repeats (int) –

    • If repeats_is_register is False, this parameter identifies the number of times to repeat the data, between 1 and 255 (default 1)

    • If repeats_is_register is True, this parameter identifies the register that contains the number of repeats.

  • repeats_is_register (bool) – Indicates if the parameter repeats identifies the register containing the number of repeats of the value to write

  • data_type (DataType) – the type to convert data to

Raises:
write_structure(structure_id, repeats=1, repeats_is_register=False)[source]

Insert command to write a structure to the current write pointer, causing the current write pointer to move on by the number of bytes needed to represent the structure.

Parameters:
  • structure_id (int) –

    • If called within a function, the ID of the structure to write, between 0 and 15

    • If called outside of a function, the ID of the structure argument, between 0 and 5

  • repeats (int) –

    • If repeats_is_register is True, the ID of the register containing the number of repeats, between 0 and 15

    • If repeats_is_register is False, the number of repeats to write, between 0 and 255

  • repeats_is_register (bool) – Whether repeats identifies a register

Raises:
write_value(data, data_type=DataType.UINT32)[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 and repeats_is_register. They have been removed here. If you need them, use write_repeated_value()

Parameters:
  • data (int or float) – the data to write as a float.

  • data_type (DataType) – the type to convert data to

Raises:
write_value_from_register(data_register, repeats=1, repeats_is_register=False, data_type=DataType.UINT32)[source]

Insert command to write a value one or more times at the write pointer of the current memory region, causing it to move. The data is contained in a register whose ID is passed to the function.

Parameters:
  • data_register (int) – Identifies the register in which the data is stored.

  • repeats (int) –

    • If repeats_is_register is None, this parameter identifies the number of times to repeat the data, between 1 and 255 (default 1)

    • If repeats_is_register is not None (i.e. has an integer value), the content of this parameter is disregarded

  • repeats_is_register (bool) – Identifies if repeats is the register containing the number of repeats of the value to write

  • data_type (DataType) – the type of the data held in the register

Raises:
class data_specification.MemoryRegionCollection(n_regions)[source]

Collection of memory regions (AbstractMemoryRegion).

Parameters:

n_regions (int) – The number of regions in the collection.

is_empty(region)[source]
Parameters:

region (int) – The ID of the region

Return type:

bool

class data_specification.MemoryRegionReal(unfilled, size, reference=None)[source]

Memory region storage object.

Parameters:
  • unfilled (bool) – if the region should not be written to by the data specification (i.e., because the vertex uses it as a working data region or an output region)

  • size (int) – the size of the region, in bytes

  • reference (int or None) – An optional globally unique reference for the region

property allocated_size

The size of the region.

Return type:

int

increment_write_pointer(n_bytes)[source]

Advance the write pointer.

Parameters:

n_bytes (int) – The number of bytes to advance the pointer by.

property max_write_pointer

The max point where if written over, it will cause an error.

Return type:

int

property reference

The globally unique reference of this region, or None if none.

Return type:

int or None

property region_data

The buffer which holds the data written in this region.

Return type:

bytearray

property remaining_space

The space between the current write pointer and the end of the region, which is the number of bytes remaining in the region that can be written.

Return type:

int

property unfilled

Whether the region is marked as not fillable; unfilled regions will not contain any data at write time.

Return type:

bool

property write_pointer

The position in the buffer where data will be written to next.

Return type:

int

class data_specification.MemoryRegionReference(ref)[source]

A reference to another memory region.

Parameters:

ref (int) – Identifies what this refers to

property ref

Identifies what this references.

Return type:

int

class data_specification.ReferenceContext[source]

Allows the generation of unique references within a context.

classmethod next()[source]

Get the next reference ID in the current context.

Return type:

int

Contents

data_specification
data_specification package
Subpackages
data_specification.enums package
Module contents
class data_specification.enums.ArithmeticOperation(value)[source]

Bases: Enum

Arithmetic Operations.

ADD = 0

Addition operation

MULTIPLY = 2

Multiplication operation

SUBTRACT = 1

Subtraction operation

class data_specification.enums.Commands(value)[source]

Bases: Enum

Set of opcodes for the spec executor.

ALIGN_WR_PTR = 101
ARITH_OP = 103
BLOCK_COPY = 69
BREAK = 0

Halts spec execution with an error.

BREAK_LOOP = 82
CONSTRUCT = 64
COPY_PARAM = 113
COPY_STRUCT = 112
DECLARE_RANDOM_DIST = 6
DECLARE_RNG = 5
ELSE = 86
END_CONSTRUCTOR = 37
END_IF = 87
END_LOOP = 83
END_SPEC = 255
END_STRUCT = 18
FREE = 3
GET_RANDOM_NUMBER = 7
GET_WR_PTR = 99
IF = 85
LOGIC_OP = 104
LOOP = 81
MV = 96

Place a value in a register, from an immediate or another register.

NOP = 1

No operation. Can be used as a filler.

PRINT_STRUCT = 130
PRINT_TXT = 129
PRINT_VAL = 128
READ = 65
READ_PARAM = 115
REFERENCE = 4
REFORMAT = 106
RESERVE = 2

Reserves a block of memory ready for filling.

SET_WR_PTR = 100

Move the write pointer to a new location, either relative to the start of this reserved memory area or relative to the current write pointer.

START_CONSTRUCTOR = 32
START_STRUCT = 16
STRUCT_ELEM = 17
SWITCH_FOCUS = 80

Swap between different reserved memory regions to work on several at the same time.

WRITE = 66

Performs a simple write or block write operation.

WRITE_ARRAY = 67

Performs a write from an array.

WRITE_PARAM = 114
WRITE_PARAM_COMPONENT = 116
WRITE_STRUCT = 68
class data_specification.enums.Condition(value)[source]

Bases: Enum

Comparison Operations.

EQUAL = 0

Compare the operands for equality

GREATER_THAN = 5

True if the first operand is > the second

GREATER_THAN_OR_EQUAL = 4

True if the first operand is >= the second

LESS_THAN = 3

True if the first operand is < the second

LESS_THAN_OR_EQUAL = 2

True if the first operand is <= the second

NOT_EQUAL = 1

Compare the operands for inequality

class data_specification.enums.DataType(value)[source]

Bases: Enum

Supported data types. Internally, these are actually tuples.

  1. an identifier for the enum class;

  2. the size in bytes of the type;

  3. the minimum possible value for the type;

  4. the maximum possible value for the type;

  5. the scale of the input value to convert it in integer;

  6. the pattern to use following the struct package encodings to convert the data in binary format;

  7. is whether to apply the scaling when converting to SpiNNaker’s binary format.

  8. the corresponding numpy type (or None to inhibit direct conversion via numpy, scaled conversion still supported);

  9. 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 representability and lack of hardware/library support.

FLOAT_32 = 14

32-bit floating point number

FLOAT_64 = 15

64-bit floating point number (use not recommended: hardware/library support inadequate)

INT16 = 5

16-bit signed integer

INT32 = 6

32-bit signed integer

INT64 = 7

64-bit signed integer

INT8 = 4

8-bit signed integer

S015 = 21

0.15 signed fixed point number

S031 = 22

0.32 signed fixed point number

S063 = 23

0.63 signed fixed point number (use not recommended: representability)

S07 = 20

0.7 signed fixed point number

S1615 = 12

16.15 signed fixed point number

S3231 = 13

32.31 signed fixed point number (use not recommended: representability)

S87 = 11

8.7 signed fixed point number

U016 = 17

0.16 unsigned fixed point number

U032 = 18

0.32 unsigned fixed point number

U064 = 19

0.64 unsigned fixed point number (use not recommended: representability)

U08 = 16

0.8 unsigned fixed point number

U1616 = 9

16.16 unsigned fixed point number

U3232 = 10

32.32 unsigned fixed point number (use not recommended: representability)

U88 = 8

8.8 unsigned fixed point number

UINT16 = 1

16-bit unsigned integer

UINT32 = 2

32-bit unsigned integer

UINT64 = 3

64-bit unsigned integer

UINT8 = 0

8-bit unsigned integer

decode_array(values)[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)[source]

Decode the numpy array of SpiNNaker values according to this type.

Parameters:

array (ndarray(uint32)) –

Return type:

ndarray(uint32 or float64)

encode(value)[source]

Encode the Python value for SpiNNaker according to this type.

Parameters:

value (float or int) –

Return type:

bytes

encode_as_int(value)[source]

Returns the value as an integer, according to this type.

Parameters:

value (float or int) –

Return type:

int

encode_as_numpy_int(value)[source]

Returns the value as a numpy integer, according to this type.

Note

Only works with integer and fixed point data types.

Parameters:

value (float or int) –

Return type:

uint32

encode_as_numpy_int_array(array)[source]

Returns the numpy array as an integer numpy array, according to this type.

Parameters:

array (ndarray) –

Return type:

ndarray

property max

The maximum possible value for the type.

Return type:

Decimal

property min

The minimum possible value for the type.

Return type:

Decimal

property numpy_typename

The corresponding numpy type, if one exists.

property scale

The scale of the input value to convert it in integer.

Return type:

Decimal

property size

The size in bytes of the type.

Return type:

int

property struct_encoding

The encoding string used for struct. Scaling may also be required.

Return type:

str

class data_specification.enums.LogicOperation(value)[source]

Bases: Enum

Logic Operations

AND = 3

Logical AND

LEFT_SHIFT = 0

Shift left (with zero extension)

NOT = 5

Logical NOT (single argument)

OR = 2

Logical OR

RIGHT_SHIFT = 1

Shift right (with zero extension)

XOR = 4

Logical XOR

class data_specification.enums.RandomNumberGenerator(value)[source]

Bases: Enum

Random number generator types.

MERSENNE_TWISTER = 0

The well-known Mersenne Twister PRNG

data_specification.spi package
Module contents

The interface used by implementations of the executor.

class data_specification.spi.AbstractExecutorFunctions[source]

Bases: object

This class defines a function related to each of the commands of the data specification file. Subclasses need to provide implementations that work for the operations they wish to support.

execute_align_wr_ptr(cmd)[source]

This command moves the write pointer to be at the start of the next word if it isn’t already at the start of a word.

Implements ALIGN_WR_PTR

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_arith_op(cmd)[source]

This command performs an arithmetic operation.

Implements ARITH_OP

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_block_copy(cmd)[source]

This command copies a block of memory from one location to another.

Implements BLOCK_COPY

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_break(cmd)[source]

This command raises an exception to stop the execution of the data spec executor (DSE).

Implements BREAK

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_break_loop(cmd)[source]

This command stops a loop early.

Implements BREAK_LOOP

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_construct(cmd)[source]

This command calls a function.

Implements CONSTRUCT

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_copy_param(cmd)[source]

This command copies a field of a structure to another field of a possibly-different structure.

Implements COPY_PARAM

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_copy_struct(cmd)[source]

This command copies a structure from one slot to another.

Implements COPY_STRUCT

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_declare_rng(cmd)[source]

This command declares a random number generator.

Implements DECLARE_RNG

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_else(cmd)[source]

This command handles the other branch of a conditional.

Implements ELSE

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_end_constructor(cmd)[source]

This command ends the definition of a function.

Implements END_CONSTRUCTOR

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_end_if(cmd)[source]

This command ends a conditional.

Implements END_IF

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_end_loop(cmd)[source]

This command finishes a loop.

Implements END_LOOP

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_end_spec(cmd)[source]

This command marks the end of the specification program.

Implements END_SPEC

Parameters:

cmd (int) – the command which triggered the function call

Returns:

A special marker to signal the end.

Raises:
execute_end_struct(cmd)[source]

This command completes the definition of a structure.

Implements END_STRUCT

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_free(cmd)[source]

This command frees some memory.

Implements FREE

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_get_random_rumber(cmd)[source]

This command obtains a random number from a distribution.

Implements GET_RANDOM_NUMBER

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_get_wr_ptr(cmd)[source]

This command gets the current write pointer.

Implements GET_WR_PTR

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_if(cmd)[source]

This command does a conditional branch.

Implements IF

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_logic_op(cmd)[source]

This command performs a logical operation.

Implements LOGIC_OP

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_loop(cmd)[source]

This command starts a loop.

Implements LOOP

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_mv(cmd)[source]

This command moves an immediate value to a register or copies the value of a register to another register.

Implements MV

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_nop(cmd)[source]

This command executes no operation.

Implements NOP

Parameters:

cmd (int) – the command which triggered the function call

Raises:

DataSpecificationSyntaxError – If there is an error in the command syntax

execute_print_struct(cmd)[source]

This command prints a structure to the log.

Implements PRINT_STRUCT

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_print_txt(cmd)[source]

This command prints a short string to the log.

Implements PRINT_TXT

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_print_val(cmd)[source]

This command prints a value to the log.

Implements PRINT_VAL

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_random_dist(cmd)[source]

This command defines a random distribution.

Implements DECLARE_RANDOM_DIST

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_read(cmd)[source]

This command reads a word from memory.

Implements READ

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_read_param(cmd)[source]

This command extracts an element from a structure.

Implements READ_PARAM

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_reference(cmd)[source]

This command reserves a region and sets it to reference another.

Implements REFERENCE

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_reformat(cmd)[source]

This command is never generated!

Implements REFORMAT

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_reserve(cmd)[source]

This command reserves a region and assigns some memory space to it.

Implements RESERVE

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_reset_wr_ptr(cmd)[source]

This command resets the current write pointer to the beginning of the memory region.

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_set_wr_ptr(cmd)[source]

This command sets the current write pointer.

Implements SET_WR_PTR

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_start_constructor(cmd)[source]

This command starts the definition of a function.

Implements START_CONSTRUCTOR

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_start_struct(cmd)[source]

This command starts to define a structure.

Implements START_STRUCT

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_struct_elem(cmd)[source]

This command adds an element to a structure.

Implements STRUCT_ELEM

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_switch_focus(cmd)[source]

This command switches the focus to the desired, already allocated, memory region.

Implements SWITCH_FOCUS

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_write(cmd)[source]

This command writes the given value in the specified region a number of times as identified by either a value in the command or a register value.

Implements WRITE

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_write_array(cmd)[source]

This command writes an array of values in the specified region.

Implements WRITE_ARRAY

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_write_param(cmd)[source]

This command handles a single element of a structure.

Implements WRITE_PARAM

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_write_param_component(cmd)[source]

This command is never generated!

Implements WRITE_PARAM_COMPONENT

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_write_struct(cmd)[source]

This command writes a structure to memory.

Implements WRITE_STRUCT

Parameters:

cmd (int) – the command which triggered the function call

Raises:
Submodules
data_specification.config_setup module

Note

This file should only be called from PACMAN/unit tests.

data_specification.config_setup.add_data_specification_cfg()[source]

Add the local configuration and all dependent configuration files.

data_specification.config_setup.unittest_setup()[source]

Resets the configuration so only the local default configuration is included.

data_specification.constants module

Constants used by the Data Structure Generator (DSG) and the Specification Executor.

data_specification.constants.APPDATA_MAGIC_NUM = 2903706326

Application data magic number.

data_specification.constants.APP_PTR_TABLE_BYTE_SIZE = 392

Size of data spec pointer table produced by DSE, in bytes.

data_specification.constants.APP_PTR_TABLE_HEADER_BYTE_SIZE = 8

Size of header of data spec pointer table produced by DSE, in bytes. Note that the header consists of 2 uint32_t variables (magic_number, version)

data_specification.constants.APP_PTR_TABLE_REGION_BYTE_SIZE = 12

Size of a region description in the pointer table. Note that the description consists of a pointer and 2 uint32_t variables: (pointer, checksum, n_words)

data_specification.constants.DSE_VERSION = 65536

Version of the file produced by the DSE.

data_specification.constants.DSG_MAGIC_NUM = 1534894462

Data spec magic number.

data_specification.constants.MAX_CONSTRUCTORS = 16

Maximum number of functions in DSG virtual machine.

data_specification.constants.MAX_MEM_REGIONS = 32

Maximum number of memory regions in DSG virtual machine.

data_specification.constants.MAX_PACKSPEC_SLOTS = 16

Maximum number of packing specification slots in DSG virtual machine.

data_specification.constants.MAX_PARAM_LISTS = 16

Maximum number of parameter lists in DSG virtual machine.

data_specification.constants.MAX_RANDOM_DISTS = 16

Maximum number of random distributions in DSG virtual machine.

data_specification.constants.MAX_REGISTERS = 16

Maximum number of registers in DSG virtual machine.

data_specification.constants.MAX_RNGS = 16

Maximum number of random number generators in DSG virtual machine.

data_specification.constants.MAX_STRUCT_ELEMENTS = 255

Maximum number of structure elements in DSG virtual machine.

data_specification.constants.MAX_STRUCT_SLOTS = 16

Maximum number of structure slots in DSG virtual machine.

data_specification.exceptions module
exception data_specification.exceptions.DataSpecificationException[source]

Bases: Exception

A general purpose exception indicating that something went wrong when interacting with a Data Specification.

exception data_specification.exceptions.DataSpecificationSyntaxError[source]

Bases: DataSpecificationException

An exception which occurs when a command read from the data specification file shows an inconsistency in the binary content.

exception data_specification.exceptions.DataUndefinedWriterException[source]

Bases: Exception

An exception that indicates that the file data writer has not been initialised.

exception data_specification.exceptions.DuplicateParameterException(command, parameters)[source]

Bases: DataSpecificationException

An exception that indicates that a command has been called with a duplicate parameter, which shouldn’t be allowed.

Parameters:
  • command (int) – The command called with duplicate parameters

  • parameters (list) – The parameters used to call the function

exception data_specification.exceptions.ExecuteBreakInstruction(address, filename)[source]

Bases: DataSpecificationException

An exception which occurs when a BREAK instruction is found in the data specification.

Parameters:
  • address (int) – address of the data specification being executed at the time of breakpoint

  • filename (str) – file being parsed

exception data_specification.exceptions.FunctionInUseException(function_id)[source]

Bases: DataSpecificationException

An exception that indicates that a function is already defined.

Parameters:

function_id (int) – The ID of the function

exception data_specification.exceptions.InvalidCommandException(command)[source]

Bases: DataSpecificationException

An exception that indicates that the command being requested cannot be executed at this point in the specification.

Parameters:

command (str) – The command being executed

exception data_specification.exceptions.InvalidOperationException(operation_type, requested_operation_id, command)[source]

Bases: DataSpecificationException

An exception that indicates that the operation of the type given type is not available.

Parameters:
  • operation_type (str) – The type of operation requested (i.e. arithmetic or logic)

  • requested_operation_id (int) – The ID of the requested operation

  • command (str) – The command being executed

exception data_specification.exceptions.InvalidSizeException(type_name, type_size, command)[source]

Bases: DataSpecificationException

An exception that indicates that the size of the requested type is invalid.

Parameters:
  • type_name (str) – The name of the requested type

  • type_size (int) – The size of the requested variable

  • command (str) – The command being executed

exception data_specification.exceptions.NestedFunctionException[source]

Bases: DataSpecificationException

An exception that indicates that a function is being defined within the context of another function definition.

exception data_specification.exceptions.NoMoreException(space_available, space_required, region)[source]

Bases: DataSpecificationException

An exception that indicates that there is no more space for the requested item.

Parameters:
  • space_available (int) – The space available in the region

  • space_required (int) – The space requested by the write command

exception data_specification.exceptions.NoRegionSelectedException(command)[source]

Bases: DataSpecificationException

An exception that indicates that a memory region has not been selected.

Parameters:

command (str) – The command being executed

exception data_specification.exceptions.NotAllocatedException(item_type, item_id, command)[source]

Bases: DataSpecificationException

An exception that indicates that an item is being used that has not been allocated.

Parameters:
  • item_type (str) – The type of the item being used

  • item_id (int) – The ID of the item being used

  • command (str) – The command being executed

exception data_specification.exceptions.ParameterOutOfBoundsException(parameter, value, range_min, range_max, command)[source]

Bases: DataSpecificationException

An exception that indicates that a parameter value was outside of the allowed bounds.

Parameters:
  • parameter (str) – The parameter that is out of bounds

  • value (float or int) – The value specified

  • range_min (float or int) – The minimum allowed value

  • range_max (float or int) – The maximum allowed value

  • command (str) – The command being executed

exception data_specification.exceptions.RNGInUseException(rng_id)[source]

Bases: DataSpecificationException

An exception that indicates that a random number generator is already defined.

Parameters:

rng_id (int) – The ID of the RNG

exception data_specification.exceptions.RandomNumberDistributionInUseException(rng_id)[source]

Bases: DataSpecificationException

An exception that indicates that a random number distribution is already defined.

Parameters:

rng_id (int) – The ID of the random number distribution

exception data_specification.exceptions.RegionExhaustedException(region, region_size, allocated_size, command)[source]

Bases: DataSpecificationException

An exception that indicates that a region has run out of memory whilst some data is being written.

Parameters:
  • region (int) – The region that was being written to

  • region_size (int) – The originally requested size of the region that has run out of space, in bytes

  • allocated_size (int) – The amount of the originally requested space that has already been allocated, in bytes

  • command (str) – The command being executed

exception data_specification.exceptions.RegionInUseException(region, label=None)[source]

Bases: DataSpecificationException

An exception that indicates that a region has already been allocated.

Parameters:
  • region (int) – The region that was already allocated

  • label (str or None) – What label is known for the region

exception data_specification.exceptions.RegionNotAllocatedException(region, command)[source]

Bases: DataSpecificationException

An exception which occurs when trying to write to an unallocated region of memory.

Parameters:
  • region (int) – The ID of the region that was not allocated.

  • command (str) – The name of the command that was being handled.

exception data_specification.exceptions.RegionOutOfBoundsException(region, region_size, requested_offset, command)[source]

Bases: DataSpecificationException

An exception that indicates that an offset into a region is out of bounds for that region.

Parameters:
  • region (int) – The region that was being offset into

  • region_size (int) – The originally requested size of the region in question, in bytes

  • requested_offset (int) – The offset being requested, in bytes

  • command (str) – The command being executed

exception data_specification.exceptions.RegionUnfilledException(region, command)[source]

Bases: DataSpecificationException

An exception that indicates that a memory region is being used that was originally requested to be unfilled.

Parameters:
  • region (int) – The region that was requested as unfilled

  • command (str) – The command being executed

exception data_specification.exceptions.StructureInUseException(structure)[source]

Bases: DataSpecificationException

An exception that indicates that a structure has already been defined.

Parameters:

structure (int) – The structure that was already allocated

exception data_specification.exceptions.TablePointerOutOfMemoryException(memory_available, memory_required)[source]

Bases: DataSpecificationException

An exception which occurs when building the table pointer as header of the data generated by the spec executor. This message is printed in case the memory available is not enough to contain the pointer table for each of the allocated regions.

Parameters:
  • memory_available (int) – on-chip memory available

  • memory_required (int) – on-chip memory required to complete the execution of the specification file

exception data_specification.exceptions.TypeMismatchException(command)[source]

Bases: DataSpecificationException

An exception that indicates that a type mismatch has occurred.

Parameters:

command (str) – The command that generated the exception

exception data_specification.exceptions.UnimplementedDSECommandError(command)[source]

Bases: DataSpecificationException

An exception which occurs when trying to execute an unimplemented command.

Parameters:

command (str) – Command attempted to be executed by the DSE

exception data_specification.exceptions.UnimplementedDSGCommandError(command)[source]

Bases: DataSpecificationException

An exception which occurs when trying to write an unimplemented command.

Parameters:

command (str) – Command attempted to be generated by the DSG

exception data_specification.exceptions.UnknownConditionException(condition_id, command)[source]

Bases: DataSpecificationException

An exception which is triggered in case the condition in an IF test does not exist in the list of possible conditions.

Parameters:
  • condition_id (int) – ID of the condition being requested

  • command (str) – The command being executed

exception data_specification.exceptions.UnknownTypeException(type_id, command)[source]

Bases: DataSpecificationException

An exception that indicates that the value of the requested type is unknown.

Parameters:
  • type_id (int) – The ID of the requested type

  • command (str) – The command being executed

exception data_specification.exceptions.UnknownTypeLengthException(data_length, command)[source]

Bases: DataSpecificationException

An exception that indicates that the value of the requested type is unknown.

Parameters:
  • data_length (int) – the length of the requested type

  • command (str) – The command being executed

exception data_specification.exceptions.WrongParameterNumberException(function_id, no_of_parameters_required, parameters)[source]

Bases: DataSpecificationException

An exception that indicates that a function has been called with a wrong number of parameters.

Parameters:
  • function_id (int) – The ID of the function

  • parameters (list) – The parameters used in the function call

  • no_of_parameters_required (int) – The number of parameters required by the function

Module contents

Used to generate memory images for a SpiNNaker CPU core from a set of instructions.

The main part of this package is the DataSpecificationGenerator class. This is used to generate a “Data Specification”, which can then be executed to produce a memory image. This package also handles this function if required, through the DataSpecificationExecutor class.

Functional Requirements

Creation of a Data Specification Language file which can be executed to produce a memory image.

  • Any errors that can be checked during the creation of the specification should throw an exception.

  • It will be impossible to detect all errors at creation time.

  • There should be no assumption of where the data specification will be stored, although a default provision of a way to write the specification to a file is acceptable.

Execution of a Data Specification Language file, producing a memory image.

  • This should detect any errors during execution and report them, halting the execution.

  • There should be no assumption of where the data specification is read from, although a default provision of a way to read the specification from a file is acceptable.

Use Cases

There are a number of use-cases of this library:

  • DataSpecificationGenerator is used to create a compressed memory image which can be expanded later, to reduce the amount of data that needs to be transferred over a slow connection.

  • DataSpecificationExecutor is used to execute a previously generated specification at the receiving end of a slow connection.

Main API
class data_specification.AbstractMemoryRegion[source]

Bases: object

Identifies something as a Memory region

class data_specification.DataSpecificationExecutor(spec_reader, memory_space)[source]

Bases: object

Used to execute a SpiNNaker data specification language file to produce a memory image.

Parameters:
  • spec_reader (RawIOBase) – The object to read the specification language file from

  • memory_space (int) – memory available on the destination architecture

Raises:

IOError – If a read or write fails

TABLE_TYPE = dtype([('pointer', '<u4'), ('checksum', '<u4'), ('n_words', '<u4')])
dsef

The executor functions themselves.

execute()[source]

Executes the specification. This will result in a configuration of memory regions being created (but not actually uploaded to SpiNNaker).

Raises:
get_constructed_data_size()[source]

Return the size of the data that will be written to memory.

Returns:

size of the data that will be written to memory

Return type:

int

get_header()[source]

Get the header of the data as a numpy array.

Return type:

numpy.ndarray

get_pointer_table(start_address)[source]

Get the pointer table as a numpy array.

Parameters:

start_address (int) – The base address of the data to be written

Return type:

numpy.ndarray

get_region(region_id)[source]

Get a region with a given ID.

Parameters:

region_id (int) – The ID of the region to get

Returns:

The region, or None if the region was not allocated

Return type:

MemoryRegionReal or None

property mem_regions

An enumeration of the mapping from region ID to region holder.

Return type:

iterable(tuple(int, AbstractMemoryRegion or None))

property referenceable_regions

The regions that can be referenced by others.

Return type:

list(int)

property references_to_fill

The references that need to be filled.

Return type:

list(int)

class data_specification.DataSpecificationExecutorFunctions(spec_reader, memory_space)[source]

Bases: AbstractExecutorFunctions

This class includes the function related to each of the commands of the data specification file.

Note

DSG operations not mentioned in this class will cause an error during DSE if used.

Parameters:
  • spec_reader (RawIOBase) – The object to read the specification language file from

  • memory_space (int) – Memory space available for the data to be generated per region

execute_break(cmd)[source]

This command raises an exception to stop the execution of the data spec executor (DSE).

Implements BREAK

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_end_spec(cmd)[source]

This command marks the end of the specification program.

Implements END_SPEC

Parameters:

cmd (int) – the command which triggered the function call

Returns:

A special marker to signal the end.

Raises:
execute_mv(cmd)[source]

This command moves an immediate value to a register or copies the value of a register to another register.

Implements MV

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_reference(cmd)[source]

This command reserves a region and sets it to reference another.

Implements REFERENCE

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_reserve(cmd)[source]

This command reserves a region and assigns some memory space to it.

Implements RESERVE

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_set_wr_ptr(cmd)[source]

This command sets the current write pointer.

Implements SET_WR_PTR

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_switch_focus(cmd)[source]

This command switches the focus to the desired, already allocated, memory region.

Implements SWITCH_FOCUS

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_write(cmd)[source]

This command writes the given value in the specified region a number of times as identified by either a value in the command or a register value.

Implements WRITE

Parameters:

cmd (int) – the command which triggered the function call

Raises:
execute_write_array(cmd)[source]

This command writes an array of values in the specified region.

Implements WRITE_ARRAY

Parameters:

cmd (int) – the command which triggered the function call

Raises:
property mem_regions

The collection of memory regions that can be written to.

Return type:

MemoryRegionCollection

property referenceable_regions

The regions that can be referenced by others.

Return type:

list(int)

property references_to_fill

The references that need to be filled.

Return type:

list(int)

class data_specification.DataSpecificationGenerator(spec_writer, report_writer=None)[source]

Bases: object

Used to generate a SpiNNaker data specification language file that can be executed to produce a memory image.

Parameters:
  • spec_writer (RawIOBase) – The object to write the specification to

  • 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:

IOError – If a write to external storage fails

align_write_pointer(log_block_size, log_block_size_is_register=False, return_register_id=None)[source]

Insert command to align the write pointer against a power-of-2 block size in bytes. Zeros are inserted in the intervening space

Parameters:
  • log_block_size (int) –

    • If log_block_size_is_register is False, log to base 2 of the block size (e.g. The write pointer will be moved so that it is a multiple of 2log_block_size), between 0 and 32

    • If log_block_size_is_register is True, the ID of the register containing log to the base 2 of the block size, between 0 and 15

  • log_block_size_is_register (bool) – Indicates if log_block_size is a register ID

  • return_register_id (int or None) – The ID of a register where the write pointer will be written to once it has been updated, between 0 and 15, or None if no such writing is to be done

Raises:
break_loop()[source]

Insert command to break out of a loop before it has completed.

Raises:
call_arithmetic_operation(register_id, operand_1, operation, operand_2, signed, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform an arithmetic operation on two signed or unsigned values and store the result in a register

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operation (ArithmeticOperation) – The operation to perform

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found, between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • signed (bool) – Indicates if the values should be considered signed

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
call_function(function_id, structure_ids)[source]

Insert command to call a function.

Parameters:
  • function_id (int) – The ID of a previously defined function, between 0 and 31

  • structure_ids (list(int)) – A list of structure IDs that will be passed into the function, each between 0 and 15

Raises:
call_random_distribution(distribution_id, register_id)[source]

Insert command to get the next random number from a random distribution, placing the result in a register to be used in a future call.

Parameters:
  • distribution_id (int) – The ID of the random distribution to call between 0 and 63

  • register_id (int) – The ID of the register to store the result in between 0 and 15

Raises:
comment(comment)[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

Raises:
copy_structure(source_structure_id, destination_structure_id, source_id_is_register=False, destination_id_is_register=False)[source]

Insert command to copy a structure, possibly overwriting another structure.

Parameters:
  • source_structure_id (int) –

    • If source_id_is_register is True, the ID of the register holding the source structure ID, between 0 and 15

    • Otherwise, the ID of the source structure, between 0 and 15

  • destination_structure_id (int) –

    • If destination_id_is_register is True, the ID of the register holding the destination structure ID, between 0 and 15

    • If destination_id_is_register is False, the ID of the destination structure, between 0 and 15

  • source_id_is_register (bool) – Indicates if source_structure_id is a register ID

  • destination_id_is_register (bool) – Indicates if destination_structure_id is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If source_id_is_register is True and source_structure_id is not a valid register ID

    • If destination_id_is_register is True and destination_structure_id is not a valid register ID

    • If source_id_is_register is False and source_structure_id is not a valid structure ID

    • If destination_id_is_register is False and destination_structure_id is not a valid structure ID

  • NotAllocatedException

    • If no structure with ID source_structure_id has been allocated

copy_structure_parameter(source_structure_id, source_parameter_index, destination_id, destination_parameter_index=None, destination_is_register=False)[source]

Insert command to copy the value of a parameter from one structure to another.

Parameters:
  • source_structure_id (int) – The ID of the source structure, between 0 and 15

  • source_parameter_index (int) – The index of the parameter in the source structure

  • destination_id (int) – The ID of the destination structure, or the ID of the destination register, between 0 and 15

  • destination_parameter_index (int) – The index of the parameter in the destination structure. Ignored when writing to a register.

  • destination_is_register (bool) – Indicates whether the destination is a structure or a register.

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If source_structure_id is not a valid structure ID

    • If destination_id is not a valid structure ID

    • If source_parameter_index is not a valid parameter index in the source structure

    • If destination_parameter_index is not a valid parameter index in the destination structure

  • NotAllocatedException

    • If no structure with ID destination_id has been allocated

    • If no structure with ID source_structure_id has been allocated

create_cmd(data, data_type=DataType.UINT32)[source]

Creates command to write a value 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 does not actually insert the WRITE command in the spec; that is done by write_cmd().

Parameters:
  • data (int or float) – the data to write.

  • data_type (DataType) – the type to convert data to

Returns:

cmd_word_list (binary data to be added to the binary data specification file), and cmd_string (string describing the command to be added to the report for the data specification file)

Return type:

tuple(bytearray, str)

Raises:
property current_region

The ID of the current DSG region we’re writing to. If not yet writing to any region, None.

Return type:

int or None

declare_random_number_generator(rng_id, rng_type, seed)[source]

Insert command to declare a random number generator.

Parameters:
  • rng_id (int) – The ID of the random number generator

  • rng_type (RandomNumberGenerator) – The type of the random number generator

  • seed (int) – The seed of the random number generator >= 0

Raises:
declare_uniform_random_distribution(distribution_id, structure_id, rng_id, min_value, max_value)[source]

Insert commands to declare a uniform random distribution.

Parameters:
  • distribution_id (int) – ID of the distribution being set up

  • structure_id (int) – ID of an empty structure slot to fill with the uniform random distribution data

  • rng_id (int) – The ID of the random number generator, between 0 and 15

  • min_value (float) – The minimum value that should be returned from the distribution between -32768.0 and max_value

  • max_value (float) – The maximum value that should be returned from the distribution between min_value and 32767.9999847

Raises:
define_break()[source]

Insert command to stop execution with an exception (for debugging).

Raises:
define_structure(structure_id, parameters)[source]

Insert commands to define a data structure.

Parameters:
  • structure_id (int) – the ID of the structure to create, between 0 and 15

  • parameters (list(tuple(str, DataType, float))) –

    A list of between 1 and 255 tuples of (label, data_type, value) where:

    • label is the label of the element (for debugging)

    • data_type is the data type of the element

    • value is the value of the element, or None if no value is to

      be assigned

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • NoMoreException – If there are no more spaces for new structures

  • ParameterOutOfBoundsException

    • If there are an incorrect number of parameters

    • If the size of one of the tuples is incorrect

    • If one of the values to be assigned has an integer data_type but has a fractional part

    • If one of the values to be assigned would overflow its data_type

  • UnknownTypeException – If one of the data types in the structure is unknown

else_conditional()[source]

Insert command for the else of an if…then…else construct. If the condition of the conditional evaluates to false, the statements up between the conditional and the insertion of this “else” are skipped, and the statements from this point until the end of the conditional are executed.

Raises:
end_conditional()[source]

Insert command to mark the end of an if…then…else construct

Raises:
end_function()[source]

Insert command to mark the end of a function definition.

Raises:

InvalidCommandException – If there is no function being defined at this point

end_loop()[source]

Insert command to indicate that this is the end of the loop. Commands between the start of the loop and this command will be repeated.

Raises:
end_specification(close_writer=True)[source]

Insert a command to indicate that the specification has finished and finish writing.

Parameters:

close_writer (bool) – Indicates whether to close the underlying writer(s)

Raises:
free_memory_region(region)[source]

Insert command to free a previously reserved memory region.

Parameters:

region (int) – The number of the region to free, from 0 to 15

Raises:
get_structure_value(destination_id, structure_id, parameter_index, parameter_index_is_register=False)[source]

Insert command to get a value from a structure. The value is copied in a register.

Parameters:
  • destination_id (int) – The ID of the destination register

  • structure_id (int) – The ID of the source structure

  • parameter_index (int) – The ID of the parameter/element to copy

  • parameter_index_is_register (bool) – True if parameter_index is a register ID containing the ID of the parameter/element to copy

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If structure_id is not in the allowed range

    • If parameter_index is larger than the number of parameters declared in the original structure

    • If destination_id is not the ID of a valid register

    • If parameter_index_is_register is True and parameter_index is not a valid register ID

  • NotAllocatedException – If the structure requested has not been declared

logical_and(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical AND operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found. between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If operand_1_is_register is True and operand_1 is not a valid register ID

    • If operand_2_is_register is True and operand_2 is not a valid register ID

logical_left_shift(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical left shift operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found. between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If operand_1_is_register is True and operand_1 is not a valid register ID

    • If operand_2_is_register is True and operand_2 is not a valid register ID

logical_not(register_id, operand, operand_is_register=False)[source]

Insert command to perform a logical NOT operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand (int) –

    • If operand_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_is_register is False, a 32-bit value

  • operand_is_register (bool) – Indicates if operand is a register ID

Raises:
logical_or(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical OR operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found. between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If operand_1_is_register is True and operand_1 is not a valid register ID

    • If operand_2_is_register is True and operand_2 is not a valid register ID

logical_right_shift(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical right shift operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found. between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If operand_1_is_register is True and operand_1 is not a valid register ID

    • If operand_2_is_register is True and operand_2 is not a valid register ID

logical_xor(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical XOR operation.

Parameters:
  • register_id (int) – The ID of the register to store the result in

  • operand_1 (int) –

    • If operand_1_is_register is True, the ID of a register where the first operand can be found, between 0 and 15

    • If operand_1_is_register is False, a 32-bit value

  • operand_2 (int) –

    • If operand_2_is_register is True, the ID of a register where the second operand can be found. between 0 and 15

    • If operand_2_is_register is False, a 32-bit value

  • operand_1_is_register (bool) – Indicates if operand_1 is a register ID

  • operand_2_is_register (bool) – Indicates if operand_2 is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If operand_1_is_register is True and operand_1 is not a valid register ID

    • If operand_2_is_register is True and operand_2 is not a valid register ID

no_operation()[source]

Insert command to execute nothing.

Raises:
print_struct(structure_id, structure_id_is_register=False)[source]

Insert command to print out a structure (for debugging).

Parameters:
  • structure_id (int) –

    • If structure_id_is_register is True, the ID of the register containing the ID of the structure to print, between 0 and 15

    • If structure_id_is_register is False, the ID of the structure to print, between 0 and 15

  • structure_id_is_register (bool) – Indicates if the structure_id is a register

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If structure_id_is_register is True and structure_id is not a valid register ID

    • If structure_id_is_register is False and structure_id is not a valid structure ID

  • NotAllocatedException – If structure_id_is_register is False and structure_id is the ID of a structure that has not been allocated

print_text(text, encoding='ASCII')[source]

Insert command to print some text (for debugging).

Parameters:
  • text (str) – The text to write (max 12 bytes once encoded)

  • encoding (str) – The character encoding to use for the string. Defaults to ASCII.

Raises:
print_value(value, value_is_register=False, data_type=DataType.UINT32)[source]

Insert command to print out a value (for debugging).

Parameters:
  • value (float or int) –

    • If value_is_register is True, the ID of the register containing the value to print

    • If value_is_register is False, the value to print as a value of type given by data_type

  • value_is_register (bool) – Indicates if value is a register

  • data_type (DataType) – The type of the data to be printed

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If value_is_register is True and value is not a valid register ID

    • If value_is_register is False, the data_type is an integer type and value has a fractional part

    • If value_is_register is False and the value would overflow the data type

  • UnknownTypeException – If data_type is not a valid data type

read_value(dest_id, data_type)[source]

Insert command to read a value from the current write pointer, causing the write pointer to move by the number of bytes read. The data is stored in a register passed as argument.

Parameters:
  • dest_id (int) – The ID of the destination register.

  • data_type (DataType) – The type of the data to be read.

Raises:

ParameterOutOfBoundsException – If dest_id is out of range for a register ID

reference_memory_region(region, ref, label=None)[source]

Insert command to reference another memory region.

Parameters:
  • region (int) – The number of the region to reserve, from 0 to 15

  • ref (int) – The identifier of the region to reference

  • label (str or None) – An optional label for the region

Raises:
property region_sizes

A list of sizes of each region that has been reserved.

Note

The list will include 0 for each non-reserved region.

Return type:

list(int)

reserve_memory_region(region, size, label=None, empty=False, reference=None)[source]

Insert command to reserve a memory region.

Parameters:
  • region (int) – The number of the region to reserve, from 0 to 15

  • size (int) – The size to reserve for the region, in bytes

  • label (str or None) – An optional label for the region

  • empty (bool) – Specifies if the region will be left empty

  • reference (int or None) – A globally unique reference for this region

Raises:
save_write_pointer(register_id)[source]

Insert command to save the write pointer to a register.

Parameters:

register_id (int) – The ID of the register to assign, between 0 and 15

Raises:
set_register_value(register_id, data, data_is_register=False, data_type=DataType.UINT32)[source]

Insert command to set the value of a register.

Parameters:
  • register_id (int) – The ID of the register to assign, between 0 and 15

  • data (int or float) –

    • If data_is_register is True, the register ID containing the data to set, between 0 and 15

    • If data_is_register is False, the data is a value of the type given by data_type

  • data_is_register (bool) – Indicates if data is a register ID

  • data_type (DataType) – The type of the data to be assigned

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If register_id is not a valid register ID

    • If data_is_register is True, and data is not a valid register ID

    • If data_is_register is False, data_type is an integer type and data has a fractional part

    • If data_is_register if False, and data would overflow the data type

  • UnknownTypeException – If the data type is not known

set_structure_value(structure_id, parameter_index, value, data_type, value_is_register=False)[source]

Insert command to set a value in a structure.

Parameters:
  • structure_id (int) –

    • If called outside of a function, the ID of the structure, between 0 and 15

    • If called within a function, the ID of the structure argument, between 0 and 4

  • parameter_index (int) – The index of the value to assign in the structure, between 0 and the number of parameters declared in the structure

  • value (float) –

    • If value_is_register is False, the value to assign at the selected position as a float or int

    • If value_is_register is True, the ID of the register containing the value to assign to the position, between 0 and 15

  • data_type (DataType) – type of the data to be stored in the structure. If parameter value_is_register is set to true, this variable is disregarded

  • value_is_register (bool) – Identifies if value identifies a register

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If structure_id is not in the allowed range

    • If parameter_index is larger than the number of parameters declared in the original structure

    • If value_is_register is False, and the data type of the structure value is an integer, and value has a fractional part

    • If value_is_register is False, and value would overflow the position in the structure

    • If value_is_register is True, and value is not a valid register ID

  • NotAllocatedException – If the structure requested has not been declared

  • UnknownTypeException – If the data type is unknown

set_write_pointer(address, address_is_register=False, relative_to_current=False)[source]

Insert command to set the position of the write pointer within the current region.

Parameters:
  • address (int) –

    • If address_is_register is True, the ID of the register containing the address to move to

    • If address_is_register is False, the address to move the write pointer to

  • address_is_register (bool) – Indicates if address is a register ID

  • relative_to_current (bool) – Indicates if address (or the value read from that register when address_is_register is True) is to be added to the current address, or used as an absolute address from the start of the current region

Raises:
start_conditional(register_id, condition, value, value_is_register=False)[source]

Insert command to start a conditional if…then…else construct. If the condition evaluates to true, the statement is executed up to the next else statement, or the end of the conditional, whichever comes first.

Parameters:
  • register_id (int) – The ID of a register to compare the value of

  • condition (Condition) – The condition which must be true to execute the following commands

  • value (int) –

    • If value_is_register is False, the value to compare to the value in the register

    • If value_is_register is True, the ID of the register containing the value to compare, between 0 and 15

  • value_is_register (bool) – Indicates if value is a register ID

Raises:
start_function(function_id, argument_by_value)[source]

Insert command to start a function definition, with up to 5 arguments, which are the IDs of structures to be used within the function, each of which can be passed by reference or by value. In the commands following this command up to the end_function() command, structures can only be referenced using the numbers 1 to 5 which address the arguments, rather than the original structure IDs.

Parameters:
  • function_id (int) – The ID of the function currently defined.

  • argument_by_value (list(bool)) – A list of up to 5 booleans indicating if the structure to be passed as an argument is to be passed by reference (i.e., changes made within the function are persisted) or by value (i.e., changes made within the function are lost when the function exits. The number of arguments is determined by the length of this list.

Raises:
start_loop(counter_register_id, start, end, increment=1, start_is_register=False, end_is_register=False, increment_is_register=False)[source]

Insert command to start a loop.

Parameters:
  • counter_register_id (int) – The ID of the register to use as the loop counter, between 0 and 15

  • start (int) –

    • If start_is_register is False, the number at which to start the loop counter, >= 0

    • If start_is_register is True, the ID of the register containing the number at which to start the loop counter, between 0 and 15

  • end (int) –

    • If end_is_register is False, the number which the loop counter must reach to stop the loop i.e. the loop will run while the contents of counter_register < end, >= 0

    • If end_is_register is True, the ID of the register containing the number at which to stop the loop, between 0 and 15

  • increment (int) –

    • If increment_is_register is False, the amount by which to increment the loop counter on each run of the loop, >= 0

    • If increment_is_register is True, the ID of the register containing the amount by which to increment the loop counter on each run of the loop, between 0 and 15

  • start_is_register (bool) – Indicates if start is a register ID

  • end_is_register (bool) – Indicates if end is a register ID

  • increment_is_register (bool) – Indicates if increment is a register ID

Raises:
  • DataUndefinedWriterException – If the binary specification file writer has not been initialised

  • IOError – If a write to external storage fails

  • ParameterOutOfBoundsException

    • If counter_register_id is not a valid register ID

    • If start_is_register is True and start is not a valid register ID

    • If end_is_register is True and end is not a valid register ID

    • If increment_is_register is True, and increment is not a valid register ID

    • If start_is_register is False and ``start is not in the allowed range

    • If end_is_register is False and ``end is not in the allowed range

    • If increment_is_register is False and increment is not in the allowed range

switch_write_focus(region)[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:
write_array(array_values, data_type=DataType.UINT32)[source]

Insert command to write an array, causing the write pointer to move on by (data type size * the array size), in bytes.

Parameters:
Raises:
write_cmd(cmd_word_list, cmd_string)[source]

Applies write commands created previously created (and cached).

Note

See create_cmd() for how to create the arguments to this method.

Parameters:
  • cmd_word_list (bytearray) – list of binary words to be added to the binary data specification file

  • cmd_string (str) – string describing the command to be added to the report for the data specification file

Raises:
write_repeated_value(data, repeats=1, repeats_is_register=False, data_type=DataType.UINT32)[source]

Insert command to write a value one or more times 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

Parameters:
  • data (float or int) – the data to write as a float.

  • repeats (int) –

    • If repeats_is_register is False, this parameter identifies the number of times to repeat the data, between 1 and 255 (default 1)

    • If repeats_is_register is True, this parameter identifies the register that contains the number of repeats.

  • repeats_is_register (bool) – Indicates if the parameter repeats identifies the register containing the number of repeats of the value to write

  • data_type (DataType) – the type to convert data to

Raises:
write_structure(structure_id, repeats=1, repeats_is_register=False)[source]

Insert command to write a structure to the current write pointer, causing the current write pointer to move on by the number of bytes needed to represent the structure.

Parameters:
  • structure_id (int) –

    • If called within a function, the ID of the structure to write, between 0 and 15

    • If called outside of a function, the ID of the structure argument, between 0 and 5

  • repeats (int) –

    • If repeats_is_register is True, the ID of the register containing the number of repeats, between 0 and 15

    • If repeats_is_register is False, the number of repeats to write, between 0 and 255

  • repeats_is_register (bool) – Whether repeats identifies a register

Raises:
write_value(data, data_type=DataType.UINT32)[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 and repeats_is_register. They have been removed here. If you need them, use write_repeated_value()

Parameters:
  • data (int or float) – the data to write as a float.

  • data_type (DataType) – the type to convert data to

Raises:
write_value_from_register(data_register, repeats=1, repeats_is_register=False, data_type=DataType.UINT32)[source]

Insert command to write a value one or more times at the write pointer of the current memory region, causing it to move. The data is contained in a register whose ID is passed to the function.

Parameters:
  • data_register (int) – Identifies the register in which the data is stored.

  • repeats (int) –

    • If repeats_is_register is None, this parameter identifies the number of times to repeat the data, between 1 and 255 (default 1)

    • If repeats_is_register is not None (i.e. has an integer value), the content of this parameter is disregarded

  • repeats_is_register (bool) – Identifies if repeats is the register containing the number of repeats of the value to write

  • data_type (DataType) – the type of the data held in the register

Raises:
class data_specification.MemoryRegionCollection(n_regions)[source]

Bases: object

Collection of memory regions (AbstractMemoryRegion).

Parameters:

n_regions (int) – The number of regions in the collection.

is_empty(region)[source]
Parameters:

region (int) – The ID of the region

Return type:

bool

class data_specification.MemoryRegionReal(unfilled, size, reference=None)[source]

Bases: AbstractMemoryRegion

Memory region storage object.

Parameters:
  • unfilled (bool) – if the region should not be written to by the data specification (i.e., because the vertex uses it as a working data region or an output region)

  • size (int) – the size of the region, in bytes

  • reference (int or None) – An optional globally unique reference for the region

property allocated_size

The size of the region.

Return type:

int

increment_write_pointer(n_bytes)[source]

Advance the write pointer.

Parameters:

n_bytes (int) – The number of bytes to advance the pointer by.

property max_write_pointer

The max point where if written over, it will cause an error.

Return type:

int

property reference

The globally unique reference of this region, or None if none.

Return type:

int or None

property region_data

The buffer which holds the data written in this region.

Return type:

bytearray

property remaining_space

The space between the current write pointer and the end of the region, which is the number of bytes remaining in the region that can be written.

Return type:

int

property unfilled

Whether the region is marked as not fillable; unfilled regions will not contain any data at write time.

Return type:

bool

property write_pointer

The position in the buffer where data will be written to next.

Return type:

int

class data_specification.MemoryRegionReference(ref)[source]

Bases: AbstractMemoryRegion

A reference to another memory region.

Parameters:

ref (int) – Identifies what this refers to

property ref

Identifies what this references.

Return type:

int

class data_specification.ReferenceContext[source]

Bases: object

Allows the generation of unique references within a context.

classmethod next()[source]

Get the next reference ID in the current context.

Return type:

int

Indices and tables

DataSpecification_github

DataSpecification_individual_docs

SpiNNFrontEndCommon

This package provides functionality which are common to all front ends that translate application level programs into executables which run on a SpiNNaker machine.

SpiNNFrontEndCommon

Contents

spinn_front_end_common
spinn_front_end_common package
Subpackages
spinn_front_end_common.abstract_models package
Subpackages
spinn_front_end_common.abstract_models.impl package
Module contents
class spinn_front_end_common.abstract_models.impl.MachineAllocationController(thread_name, hostname=None, connection_data=None)[source]

Bases: AbstractMachineAllocationController

How to manage the allocation of a machine so that it gets cleaned up neatly when the script dies.

Parameters:

thread_name (str) –

close()[source]

Indicate that the use of the machine is complete.

create_transceiver()[source]

Create a transceiver for talking to the allocated machine, and make sure everything is ready for use (i.e. boot and discover connections if needed).

Return type:

Transceiver

open_eieio_connection(chip_x, chip_y)[source]

Open a connection to a specific Ethernet-enabled chip for EIEIO. Caller will have to arrange for SpiNNaker to pay attention to the connection.

The coordinates will be job-relative.

Parameters:
  • chip_x (int) – Ethernet-enabled chip X coordinate

  • chip_y (int) – Ethernet-enabled chip Y coordinate

Return type:

EIEIOConnection

open_eieio_listener()[source]

Open an unbound EIEIO connection. This may be used to communicate with any board of the job.

Return type:

EIEIOConnection

open_sdp_connection(chip_x, chip_y, udp_port=17893)[source]

Open a connection to a specific Ethernet-enabled SpiNNaker chip. Caller will have to arrange for SpiNNaker to pay attention to the connection.

The coordinates will be job-relative.

Parameters:
  • chip_x (int) – Ethernet-enabled chip X coordinate

  • chip_y (int) – Ethernet-enabled chip Y coordinate

  • udp_port (int) – the UDP port on the chip to connect to; connecting to a non-SCP port will result in a connection that can’t easily be configured.

Return type:

SDPConnection

class spinn_front_end_common.abstract_models.impl.MachineDataSpecableVertex[source]

Bases: AbstractGeneratesDataSpecification

Support for a vertex that simplifies generating a data specification.

generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
abstract generate_machine_data_specification(spec, placement, iptags, reverse_iptags)[source]
Parameters:
  • spec (DataSpecificationGenerator) – The data specification to write into.

  • placement (Placement) – Where this node is on the SpiNNaker machine.

  • iptags (iterable(IPTag) or None) – The (forward) IP tags for the vertex, if any

  • reverse_iptags (iterable(ReverseIPTag) or None) – The reverse IP tags for the vertex, if any

class spinn_front_end_common.abstract_models.impl.TDMAAwareApplicationVertex(label, max_atoms_per_core, splitter=None)[source]

Bases: ApplicationVertex

An application vertex that contains the code for using TDMA to spread packet transmission to try to avoid overloading any SpiNNaker routers.

Parameters:
  • label (str or None) – The name of the vertex.

  • max_atoms_per_core (int) – The max number of atoms that can be placed on a core, used in partitioning.

generate_tdma_data_specification_data(vertex_index)[source]

Generates the TDMA configuration data needed for the data spec.

Parameters:

vertex_index (int) – the machine vertex index in the pop

Returns:

array of data to write.

Return type:

list(int)

abstract get_n_cores()[source]

Get the number of cores this application vertex is using in the TDMA.

Returns:

the number of cores to use in the TDMA

Return type:

int

get_n_phases()[source]

Compute the number of phases needed for this application vertex. This is the maximum number of packets any machine vertex created by this application vertex can send in one simulation time step, which defaults to the number of atoms in the graph.

Return type:

int

get_tdma_provenance_item(x, y, p, desc_label, tdma_slots_missed)[source]

Get the provenance item used for the TDMA provenance.

Parameters:
  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • desc_label (str) – a descriptive label for the vertex

  • tdma_slots_missed (int) – the number of TDMA slots missed

set_initial_offset(new_value)[source]

Sets the initial offset.

Parameters:

new_value (int) – the new initial offset, in clock ticks

set_other_timings(clocks_between_cores, n_slots, clocks_between_spikes, n_phases, clocks_per_cycle)[source]

Sets the other timings needed for the TDMA.

Parameters:
  • clocks_between_cores (int) – clock cycles between cores

  • n_slots (int) – the number of slots

  • clocks_between_spikes (int) – the clock cycles to wait between spikes

  • n_phases (int) – the number of phases

  • clocks_per_cycle (int) – the number of clock cycles per TDMA cycle

property tdma_sdram_size_in_bytes

The number of bytes needed by the TDMA data.

Return type:

int

Module contents
class spinn_front_end_common.abstract_models.AbstractCanReset[source]

Bases: object

Indicates an object that can be reset to time 0.

This is used when AbstractSpinnakerBase.reset is called. All Vertices and all edges in the original graph (the one added to by the user) will be checked and reset.

abstract reset_to_first_timestep()[source]

Reset the object to first time step.

class spinn_front_end_common.abstract_models.AbstractGeneratesDataSpecification[source]

Bases: object

abstract generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
class spinn_front_end_common.abstract_models.AbstractHasAssociatedBinary[source]

Bases: object

Marks a machine graph vertex that can be launched on a SpiNNaker core.

abstract get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

abstract get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

class spinn_front_end_common.abstract_models.AbstractMachineAllocationController[source]

Bases: object

An object that controls the allocation of a machine

abstract close()[source]

Indicate that the use of the machine is complete.

abstract create_transceiver()[source]

Create a transceiver for talking to the allocated machine, and make sure everything is ready for use (i.e. boot and discover connections if needed).

Return type:

Transceiver

abstract extend_allocation(new_total_run_time)[source]

Extend the allocation of the machine from the original run time.

Parameters:

new_total_run_time (float) – The total run time that is now required starting from when the machine was first allocated

make_report(filename)[source]

Asks the controller to make a report of details of allocations. By default, this does nothing.

abstract open_eieio_connection(chip_x, chip_y)[source]

Open a connection to a specific Ethernet-enabled chip for EIEIO. Caller will have to arrange for SpiNNaker to pay attention to the connection.

The coordinates will be job-relative.

Parameters:
  • chip_x (int) – Ethernet-enabled chip X coordinate

  • chip_y (int) – Ethernet-enabled chip Y coordinate

Return type:

EIEIOConnection

abstract open_eieio_listener()[source]

Open an unbound EIEIO connection. This may be used to communicate with any board of the job.

Return type:

EIEIOConnection

abstract open_sdp_connection(chip_x, chip_y, udp_port=17893)[source]

Open a connection to a specific Ethernet-enabled SpiNNaker chip. Caller will have to arrange for SpiNNaker to pay attention to the connection.

The coordinates will be job-relative.

Parameters:
  • chip_x (int) – Ethernet-enabled chip X coordinate

  • chip_y (int) – Ethernet-enabled chip Y coordinate

  • udp_port (int) – the UDP port on the chip to connect to; connecting to a non-SCP port will result in a connection that can’t easily be configured.

Return type:

SDPConnection

property proxying

Whether this is a proxying connection. False unless overridden.

Return type:

bool

abstract where_is_machine(chip_x, chip_y)[source]

Locates and returns cabinet, frame, board for a given chip in a machine allocated to this job.

Parameters:
  • chip_x (int) – chip x location

  • chip_y (int) – chip y location

Returns:

(cabinet, frame, board)

Return type:

tuple(int,int,int)

class spinn_front_end_common.abstract_models.AbstractRewritesDataSpecification[source]

Bases: object

Indicates an object that allows data to be changed after run, and so can rewrite the data specification.

abstract regenerate_data_specification(spec, placement)[source]

Regenerate the data specification, only generating regions that have changed and need to be reloaded.

Parameters:
abstract reload_required()[source]

Return true if any data region needs to be reloaded.

Return type:

bool

abstract set_reload_required(new_value)[source]

Indicate that the regions have been reloaded.

Parameters:

new_value – the new value

class spinn_front_end_common.abstract_models.AbstractSendMeMulticastCommandsVertex[source]

Bases: object

A device that may be a virtual vertex which wants to commands to be sent to it as multicast packets at fixed points in the simulation.

Note

The device might not be a vertex at all. It could instead be instantiated entirely host side, in which case these methods will never be called.

abstract property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

abstract property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

abstract property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spinn_front_end_common.abstract_models.AbstractSupportsBitFieldGeneration[source]

Bases: object

Marks a vertex that can provide information about bitfields it wants generated on-chip.

abstract bit_field_base_address(placement)[source]

Returns the SDRAM address for the bit field table data.

Parameters:

placement (Placement) –

Returns:

the SDRAM address for the bitfield address

Return type:

int

abstract bit_field_builder_region(placement)[source]

Returns the SDRAM address for the bit field builder data.

Parameters:

placement (Placement) –

Returns:

the SDRAM address for the bitfield builder data

Return type:

int

class spinn_front_end_common.abstract_models.AbstractSupportsBitFieldRoutingCompression[source]

Bases: object

Marks a machine vertex that can support having the on-chip bitfield compressor running on its core.

abstract bit_field_base_address(placement)[source]

Returns the SDRAM address for the bit-field table data.

Parameters:

placement (Placement) –

Returns:

the SDRAM address for the bitfield address

Return type:

int

abstract regeneratable_sdram_blocks_and_sizes(placement)[source]

Returns the SDRAM addresses and sizes for the cores’ SDRAM that are available (borrowed) for generating bitfield tables.

Parameters:

placement (Placement) –

Returns:

list of tuples containing (the SDRAM address for the cores SDRAM address’s for the core’s SDRAM that can be used to generate bitfield tables loaded, and the size of memory chunks located there)

Return type:

list(tuple(int,int))

class spinn_front_end_common.abstract_models.AbstractSupportsDatabaseInjection[source]

Bases: object

Marks a machine vertex as supporting injection of information via a database running on the controlling host.

abstract property injection_partition_id

The partition that packets are being injected with.

Return type:

str

abstract property is_in_injection_mode

Whether this vertex is actually in injection mode.

Return type:

bool

class spinn_front_end_common.abstract_models.AbstractVertexWithEdgeToDependentVertices[source]

Bases: object

A vertex with a dependent vertices, which should be connected to this vertex by an edge directly to each of them.

abstract dependent_vertices()[source]

Return the vertices which this vertex depends upon.

Return type:

iterable(ApplicationVertex)

abstract edge_partition_identifiers_for_dependent_vertex(vertex)[source]

Return the dependent edge identifiers for a particular dependent vertex.

Parameters:

vertex (ApplicationVertex) –

Return type:

iterable(str)

class spinn_front_end_common.abstract_models.HasCustomAtomKeyMap[source]

Bases: object

An object that can provide a custom atom-key mapping for a partition. Useful when there isn’t a one-to-one correspondence between atoms and keys for a given partition.

abstract get_atom_key_map(pre_vertex, partition_id, routing_info)[source]

Get the mapping between atoms and keys for the given partition id, and for the given machine pre-vertex.

Parameters:
  • pre_vertex (MachineVertex) – The machine vertex to get the map for

  • partition_id (str) – The partition to get the map for

  • routing_info (RoutingInfo) – Routing information

Returns:

A list of (atom_id, key)

Return type:

list(tuple(int,int))

spinn_front_end_common.common_model_binaries package
Module contents

This module contains no python code

spinn_front_end_common.data package
Submodules
spinn_front_end_common.data.fec_data_writer module
class spinn_front_end_common.data.fec_data_writer.FecDataWriter(state)[source]

Bases: PacmanDataWriter, SpiNNManDataWriter, FecDataView

See UtilsDataWriter.

This class is designed to only be used directly by AbstractSpinnakerBase and within the Non-PyNN repositories unit tests as all methods are available to subclasses.

Parameters:

state (DataStatus) – State writer should be in

classmethod add_vertex(vertex)[source]

Adds an Application vertex to the user graph.

Syntactic sugar for get_graph().add_vertex()

Parameters:

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

Raises:
clear_notification_protocol()[source]

Closes an existing notification_protocol and sets the value to None.

If no notification_protocol exist this method silently returns.

If the close causes an Exception it is logged and ignored

clear_run_steps()[source]

Clears the run step.

get_run_step will go back to returning None

next_run_step will restart at 1

finish_run()[source]

Puts all data into the state expected after sim.run ends.

increment_current_run_timesteps(increment)[source]

Increment the current_run_timesteps and sets first_machine_time_step.

A None increment signals run_forever

Parameters:

increment (int or None) – The timesteps for this do_run loop

next_run_step()[source]

Starts or increases the run step count.

Run steps start at 1

Returns:

The next step number

Return type:

int

reset_sync_signal()[source]

Returns the sync signal to the default value.

set_allocation_controller(allocation_controller)[source]

Sets the allocation controller variable.

Parameters:

allocation_controller (AbstractMachineAllocationController) –

set_buffer_manager(buffer_manager)[source]

Sets the Buffer manager variable.

Parameters:

buffer_manager (BufferManager) –

set_database_file_path(database_file_path)[source]

Sets the database_file_path variable. Possibly to None.

Parameters:

database_file_path (str or None) –

set_dsg_targets(dsg_targets)[source]

Sets the Data Spec targets database.

Parameters:

dsg_targets (ExecutableTargets) –

set_executable_targets(executable_targets)[source]

Sets the executable_targets

Parameters:

executable_targets (ExecutableTargets) –

set_executable_types(executable_types)[source]
Parameters:

executable_types (dict( ExecutableType, CoreSubsets or None)) –

set_fixed_routes(fixed_routes)[source]
Parameters:

fixed_routes (dict(tuple(int,int), FixedRouteEntry)) –

set_gatherer_map(gatherer_map)[source]

Sets the map of (x,y) to Gatherer Vertices.

Parameters:

gatherer_map (dict((int, int), DataSpeedUpPacketGatherMachineVertex)) –

set_ipaddress(ip_address)[source]
Parameters:

ip_address (str) –

set_java_caller(java_caller)[source]
Parameters:

java_caller (JavaCaller) –

set_live_packet_gatherer_parameters(params)[source]

testing method will not work outside of mock

set_max_run_time_steps(max_run_time_steps)[source]

Sets the max_run_time_steps value

Parameters:

max_run_time_steps (int) – new value

set_monitor_map(monitor_map)[source]

Sets the map of (x,y) to Monitor Vertices.

Parameters:

monitor_map (dict((int, int), ExtraMonitorSupportMachineVertex)) –

set_n_chips_in_graph(n_chips_in_graph)[source]

Sets the number of chips needed by the graph.

Parameters:

n_chips_in_graph (int) –

set_n_required(n_boards_required, n_chips_required)[source]

Sets (if not None) the number of boards/chips requested by the user.

Parameters:
  • n_boards_required (int or None) – None or the number of boards requested by the user

  • n_chips_required (int or None) – None or the number of chips requested by the user

set_notification_protocol(notification_protocol)[source]

Sets the notification_protocol.

Parameters:

notification_protocol (NotificationProtocol) –

set_system_multicast_routing_data(data)[source]

Sets the system_multicast_routing_data.

These are: data_in_multicast_routing_tables, data_in_multicast_key_to_chip_map, system_multicast_router_timeout_keys

Parameters:

data (tuple(MulticastRoutingTables, dict, dict)) – new value

set_up_timings(simulation_time_step_us, time_scale_factor, default_time_scale_factor=None)[source]

Set up timings for the simulation.

Parameters:
  • simulation_time_step_us (int or None) – An explicitly specified time step for the simulation in . If None, the value is read from the configuration

  • time_scale_factor (float or None) – An explicitly specified time scale factor for the simulation. If None, the value is read from the configuration

  • default_time_scale_factor (float or None) – A back up time scale factor for the simulation. Only used if time_scale_factor parameter and configuration are both None. If None, the value is based on simulation_time_step

Module contents
class spinn_front_end_common.data.FecDataView[source]

Bases: PacmanDataView, SpiNNManDataView

Adds the extra Methods to the View for spinn_front_end_commom level.

See UtilsDataView for a more detailed description.

This class is designed to only be used directly within non-PyNN repositories as all methods are available to subclasses

classmethod add_database_socket_address(database_socket_address)[source]

Adds a socket address to the list of known addresses.

Parameters:

database_socket_address (SocketAddress) –

Raises:

TypeError – if database_socket_address is not a SocketAddress

classmethod add_database_socket_addresses(database_socket_addresses)[source]

Adds all socket addresses to the list of known addresses.

Parameters:

database_socket_addresses (iterable(SocketAddress)) – The addresses to add

Raises:

TypeError – if database_socket_address is not a iterable of SocketAddress

classmethod add_live_output_vertex(vertex, partition_id)[source]

Add a vertex that is to be output live, and so wants its atom IDs recorded in the database.

Parameters:
  • vertex (ApplicationVertex) – The vertex to add

  • partition_id (str) – The partition to get the IDs of

classmethod 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

If the ApplicationGraph is used, the vertex must be an ApplicationVertex. If not, it must be a MachineVertex.

Parameters:
  • live_packet_gatherer_params (LivePacketGatherParameters) – parameters for an LPG to look for or create

  • vertex_to_record_from (AbstractVertex) – the vertex that needs to send to a given LPG

  • partition_ids (iterable(str)) – the IDs of the partitions to connect from the vertex

classmethod get_allocation_controller()[source]

Returns the allocation controller if known.

Return type:

AbstractMachineAllocationController

Raises:

SpiNNUtilsException – If the buffer manager unavailable

classmethod get_app_provenance_dir_path()[source]

Returns the path to the directory that holds all application provenance files.

This will be the path used by the last run call or to be used by the next run if it has not yet been called.

Note

In unit-test mode this returns a temporary directory shared by all path methods.

Return type:

str

Raises:

SimulatorNotSetupException – If the simulator has not been setup

classmethod get_buffer_manager()[source]

Returns the buffer manager if known.

Return type:

BufferManager

Raises:

SpiNNUtilsException – If the buffer manager unavailable

classmethod get_current_run_time_ms()[source]

The end of this or the previous do__run loop time in ms.

Syntactic sugar for current_run_timesteps * simulation_time_step_ms

Will be zero if not yet run and not yet in the do_run_loop

Will be zero if in run forever mode

Return type:

float

classmethod get_current_run_timesteps()[source]

The end of this or the previous do__run loop time in steps.

Will be zero if not yet run and not yet in the do_run_loop

Will be None if in run forever mode

Return type:

int or None

classmethod get_data_in_multicast_key_to_chip_map()[source]

Retrieve the data_in_multicast_key_to_chip_map if known.

Return type:

dict

Raises:

SpiNNUtilsException – If the data_in_multicast_key_to_chip_map is currently unavailable

classmethod get_data_in_multicast_routing_tables()[source]

Retrieve the data_in_multicast_routing_tables if known

Return type:

MulticastRoutingTables

Raises:

SpiNNUtilsException – If the data_in_multicast_routing_tables is currently unavailable

classmethod get_database_file_path()[source]

Will return the database_file_path if set or None if not set or set to None

Return type:

str or None

classmethod get_dsg_targets()[source]

Data Spec targets database.

Return type:

DsSqlliteDatabase

Raises:

SpiNNUtilsException – If the dsg_targets is currently unavailable

classmethod get_executable_targets()[source]

Binaries to be executed.

Return type:

ExecutableTargets

Raises:

SpiNNUtilsException – If the executable_targets is currently unavailable

classmethod get_executable_types()[source]

Gets the _executable_types if they have been created.

Return type:

dict( ExecutableType, CoreSubsets)

Raises:

SpiNNUtilsException – If the executable_types is currently unavailable

classmethod get_first_machine_time_step()[source]

The start of this or the next do_run loop time in steps.

Will be None if in run forever mode

Return type:

int or None

classmethod get_fixed_routes()[source]

Gets the fixed routes if they have been created.

Return type:

dict(tuple(int,int), FixedRouteEntry)

Raises:

SpiNNUtilsException – If the fixed_routes is currently unavailable

classmethod get_gatherer_by_xy(x, y)[source]

The DataSpeedUpPacketGatherMachineVertex for chip (x,y).

Parameters:
  • x (int) – X coordinate of chip

  • y (int) – Y coordinate of chip

Return type:

DataSpeedUpPacketGatherMachineVertex

Raises:
classmethod get_hardware_time_step_ms()[source]

The hardware timestep, in milliseconds.

Syntactic sugar for simulation_time_step_ms * time_scale_factor

Return type:

float

Raises:

SpiNNUtilsException – If the hardware_time_step is currently unavailable

classmethod get_hardware_time_step_us()[source]

The hardware timestep, in microseconds.

Syntactic sugar for simulation_time_step_us * time_scale_factor

Return type:

int

Raises:

SpiNNUtilsException – If the hardware_time_step is currently unavailable

classmethod get_ipaddress()[source]

Gets the IP address of the board with chip 0,0 if it has been set.

Return type:

str

Raises:

SpiNNUtilsException – If the IP address is currently unavailable

classmethod get_java_caller()[source]

Gets the Java_caller.

Return type:

str

Raises:

SpiNNUtilsException – If the java_caller is currently unavailable

classmethod get_json_dir_path()[source]

Returns the path to the directory that holds all JSON files.

This will be the path used by the last run call or to be used by the next run if it has not yet been called.

Note

In unit-test mode this returns a temporary directory shared by all path methods.

Return type:

str

Raises:

SpiNNUtilsException – If the simulation_time_step is currently unavailable

classmethod get_live_packet_recorder_params()[source]

Mapping of live_packet_gatherer_params to a list of tuples (vertex and list of ids)).

Return type:

dict(LivePacketGatherParameters, tuple(AbstractVertex, list(str))

Raises:

SpiNNUtilsException – If the _live_packet_recorder_params is currently unavailable

classmethod get_max_run_time_steps()[source]

Returns the calculated longest time this or a future run loop could be.

Mainly used to indicate the number of timesteps the vertex can and therefore should reserve memory for

Guaranteed to be positive int if available

Return type:

int

Raises:

SpiNNUtilsException – If the max run time is currently unavailable

classmethod get_monitor_by_xy(x, y)[source]

The ExtraMonitorSupportMachineVertex for chip (x,y).

Parameters:
  • x (int) – X coordinate of chip

  • y (int) – Y coordinate of chip

Return type:

ExtraMonitorSupportMachineVertex

Raises:
classmethod get_n_boards_required()[source]

Gets the number of boards requested by the user during setup if known.

Guaranteed to be positive

Return type:

int

Raises:

SpiNNUtilsException – If the n_boards_required is currently unavailable

classmethod get_n_chips_needed()[source]

Gets the number of chips needed, if set.

This will be the number of chips requested by the user during setup, even if this is less that what the partitioner reported.

If the partitioner has run and the user has not specified a number, this will be what the partitioner requested.

Guaranteed to be positive if set

Return type:

int

Raises:

SpiNNUtilsException – If data for n_chips_needed is not available

classmethod get_n_database_socket_addresses()[source]

Number of registered database_socket_addresses.

Return type:

int

classmethod get_n_gathers()[source]

Number of DataSpeedUpPacketGatherMachineVertex(s).

Return type:

int

Raises:

SpiNNUtilsException – If the gathers are currently unavailable

classmethod get_n_monitors()[source]

Number of ExtraMonitorSupportMachineVertexs.

Return type:

int

Raises:

SpiNNUtilsException – If the monitors are currently unavailable

classmethod get_next_none_labelled_edge_number()[source]

Returns an unused number for labelling an unlabelled edge.

Return type:

int

classmethod get_next_sync_signal()[source]

Returns alternately Signal.SYNC0 and Signal.SYNC1.

Return type:

Signal

classmethod get_notification_protocol()[source]

The notification protocol handler.

Return type:

NotificationProtocol

Raises:

SpiNNUtilsException – If the notification_protocol is currently unavailable

classmethod get_provenance_dir_path()[source]

Returns the path to the directory that holds all provenance files.

This will be the path used by the last run call or to be used by the next run if it has not yet been called.

Note

In unit-test mode this returns a temporary directory shared by all path methods.

Return type:

str

Raises:

SpiNNUtilsException – If the simulation_time_step is currently unavailable

classmethod get_reset_number()[source]

Get the number of times a reset has happened.

Only counts the first reset after each run.

So resets that are first soft then hard are ignored. Double reset calls without a run and resets before run are ignored.

Reset numbers start at zero

Return type:

int

Raises:

SpiNNUtilsException – If the run_number is currently unavailable

classmethod get_reset_str()[source]

Get the number of times a reset has happened as a string.

An empty string is returned if the system has never been reset (i.e., the reset number is 0)

Only counts the first reset after each run.

So resets that are first soft then hard are ignored. Double reset calls without a run and resets before run are ignored.

Reset numbers start at zero

Raises:

SpiNNUtilsException – If the run_number is currently unavailable

Return type:

str

classmethod get_run_number()[source]

Get the number of this or the next run.

Run numbers start at 1

Return type:

int

Raises:

SpiNNUtilsException – If the run_number is currently unavailable

classmethod get_run_step()[source]

Get the auto pause and resume step currently running if any.

If and only if currently in an auto pause and resume loop this will report the number of the step. Starting at 1

In most cases this will return None, including when running without steps.

Return type:

None or int

classmethod get_simulation_time_step_ms()[source]

The simulation time step, in milliseconds.

Syntactic sugar for simulation_time_step_us / 1000.

Return type:

float

Raises:

SpiNNUtilsException – If the simulation_time_step_ms is currently unavailable

classmethod get_simulation_time_step_per_ms()[source]

The number of simulation time steps in a millisecond.

Syntactic sugar for 1000 / simulation_time_step_us

Return type:

float

Raises:

SpiNNUtilsException – If the simulation_time_step is currently unavailable

classmethod get_simulation_time_step_per_s()[source]

The number of simulation time steps in a seconds.

Syntactic sugar for 1,000,000 / simulation_time_step_us

Return type:

float

Raises:

SpiNNUtilsException – If the simulation_time_step is currently unavailable

classmethod get_simulation_time_step_s()[source]

The simulation timestep, in seconds.

Syntactic sugar for simulation_time_step() / 1,000,000.

Return type:

float

Raises:

SpiNNUtilsException – If the simulation_time_step_ms is currently unavailable

classmethod get_simulation_time_step_us()[source]

The simulation timestep, in microseconds.

Previously known as “machine_time_step”

Return type:

int

Raises:

SpiNNUtilsException – If the simulation_time_step_us is currently unavailable

classmethod get_system_multicast_router_timeout_keys()[source]

Retrieve the system_multicast_router_timeout_keys if known.

Return type:

dict

Raises:

SpiNNUtilsException – If the system_multicast_router_timeout_keys is currently unavailable

classmethod get_system_provenance_dir_path()[source]

Returns the path to the directory that holds system provenance files.

This will be the path used by the last run call or to be used by the next run if it has not yet been called.

Note

In unit-test mode this returns a temporary directory shared by all path methods.

Return type:

str

Raises:

SpiNNUtilsException – If the simulation_time_step is currently unavailable

classmethod get_time_scale_factor()[source]
Return type:

int or float

Raises:
classmethod get_timestamp_dir_path()[source]

Returns path to existing time-stamped directory in the reports directory.

Note

In unit-test mode this returns a temporary directory shared by all path methods.

Return type:

str

Raises:

SpiNNUtilsException – If the simulation_time_step is currently unavailable

classmethod has_allocation_controller()[source]

Reports if an AllocationController object has already been set.

Returns:

True if and only if an AllocationController has been added and not reset.

Return type:

bool

classmethod has_buffer_manager()[source]

Reports if a BufferManager object has already been set.

Returns:

True if and only if a BufferManager has been added and not reset

Return type:

bool

classmethod has_ipaddress()[source]

Detects if the IP address of the board with chip 0,0 is known.

Return type:

bool

classmethod has_java_caller()[source]

Reports if there is a Java called that can be used.

Equivalent to get_config_bool(“Java”, “use_java”) as the writer will have created the caller during setup

The behaviour when Mocked is currently to always return False.

Return type:

bool

classmethod has_live_packet_recorder_params()[source]

Reports if there are live_packet_recorder_params.

If True the live_packet_recorder_params not be empty

Return type:

bool

classmethod has_max_run_time_steps()[source]

Indicates if max_run_time_steps is currently available.

Return type:

bool

classmethod has_monitors()[source]

Detect is ExtraMonitorSupportMachineVertex(s) have been created.

Return type:

bool

classmethod has_n_boards_required()[source]

Reports if a user has sets the number of boards requested during setup.

Return type:

bool

Raises:

SpiNNUtilsException – If n_boards_required is not set or set to None

classmethod has_n_chips_needed()[source]

Detects if the number of chips needed has been set.

This will be the number of chips requested by the use during setup or what the partitioner requested.

Return type:

bool

classmethod has_time_scale_factor()[source]
Return type:

bool

classmethod has_time_step()[source]

Check if any/all of the time_step values are known.

True When all simulation/hardware_time_step methods are known False when none of the simulation/hardware_time_step values are known. There is never a case when some are known and others not

Return type:

bool

classmethod iterate_database_socket_addresses()[source]

Iterates over the registered database_socket_addresses.

Return type:

iterable(SocketAddress)

classmethod iterate_gather_items()[source]

Iterates over the (x,y) and DataSpeedUpPacketGatherMachineVertex.

get_n_gathers returns the number of items this iterable will provide

Return type:

iterable(tuple(tuple(int,int), DataSpeedUpPacketGatherMachineVertex))

Raises:

SpiNNUtilsException – If the gathers are currently unavailable

classmethod iterate_gathers()[source]

Iterates over the DataSpeedUpPacketGatherMachineVertex(s).

Return type:

iterable(DataSpeedUpPacketGatherMachineVertex)

Raises:

SpiNNUtilsException – If the gathers are currently unavailable

classmethod iterate_live_output_vertices()[source]

Get an iterator over the live output vertices and partition IDs.

Return type:

iterable(tuple(ApplicationVertex, str))

classmethod iterate_monitor_items()[source]

Iterates over the (x,y) and ExtraMonitorSupportMachineVertex.

get_n_monitors returns the number of items this iterable will provide.

Return type:

iterable(tuple(tuple(int,int), ExtraMonitorSupportMachineVertex))

Raises:

SpiNNUtilsException – If the monitors are currently unavailable

classmethod iterate_monitors()[source]

Iterates over the ExtraMonitorSupportMachineVertex(s).

Return type:

iterable(ExtraMonitorSupportMachineVertex)

Raises:

SpiNNUtilsException – If the monitors are currently unavailable

spinn_front_end_common.interface package
Subpackages
spinn_front_end_common.interface.buffer_management package
Subpackages
spinn_front_end_common.interface.buffer_management.buffer_models package
Module contents
class spinn_front_end_common.interface.buffer_management.buffer_models.AbstractReceiveBuffersToHost[source]

Bases: object

Indicates that this MachineVertex can receive buffers.

abstract get_recorded_region_ids()[source]

Get the recording region IDs that have been recorded using buffering.

Returns:

The region numbers that have active recording

Return type:

iterable(int)

abstract get_recording_region_base_address(placement)[source]

Get the recording region base address.

Parameters:

placement (Placement) – the placement object of the core to find the address of

Returns:

the base address of the recording region

Return type:

int

class spinn_front_end_common.interface.buffer_management.buffer_models.AbstractSendsBuffersFromHost[source]

Bases: object

A vertex that sends buffers of keys to be transmitted at given timestamps in the simulation.

abstract buffering_input()[source]

Return True if the input of this vertex is to be buffered.

Return type:

bool

abstract get_next_key(region)[source]

Get the next key in the given region.

Parameters:

region (int) – The region to get the next key from

Returns:

The next key, or None if there are no more keys

Return type:

int

abstract get_next_timestamp(region)[source]

Get the next timestamp at which there are still keys to be sent for the given region.

Parameters:

region (int) – The region to get the timestamp for

Returns:

The timestamp of the next available keys

Return type:

int

abstract get_region_buffer_size(region)[source]

Get the size of the buffer to be used in SDRAM on the machine for the region in bytes.

Parameters:

region (int) – The region to get the buffer size of

Returns:

The size of the buffer space in bytes

Return type:

int

abstract get_regions()[source]

Get the set of regions for which there are keys to be sent.

Returns:

Iterable of region IDs

Return type:

iterable(int)

abstract is_empty(region)[source]

Return true if there are no spikes to be buffered for the specified region.

Parameters:

region (int) – The region to get the next key from

Returns:

Whether there are no keys to send for the region

Return type:

bool

abstract is_next_key(region, timestamp)[source]

Determine if there are still keys to be sent at the given timestamp for the given region.

Parameters:
  • region (int) – The region to determine if there are keys for

  • timestamp (int) – The timestamp to determine if there are more keys for

Returns:

Whether there are more keys to send for the parameters

Return type:

bool

abstract is_next_timestamp(region)[source]

Determine if there is another timestamp with data to be sent.

Parameters:

region (int) – The region to determine if there is more data for

Returns:

Whether there is more data

Return type:

bool

abstract rewind(region)[source]

Rewinds the internal buffer in preparation of re-sending the spikes.

Parameters:

region (int) – The region to rewind

class spinn_front_end_common.interface.buffer_management.buffer_models.SendsBuffersFromHostPreBufferedImpl[source]

Bases: AbstractSendsBuffersFromHost

Implementation of AbstractReceiveBuffersToHost that uses an existing set of buffers for the details.

buffering_input()[source]

Return True if the input of this vertex is to be buffered.

Return type:

bool

get_next_key(region)[source]

Get the next key in the given region.

Parameters:

region (int) – The region to get the next key from

Returns:

The next key, or None if there are no more keys

Return type:

int

get_next_timestamp(region)[source]

Get the next timestamp at which there are still keys to be sent for the given region.

Parameters:

region (int) – The region to get the timestamp for

Returns:

The timestamp of the next available keys

Return type:

int

get_regions()[source]

Get the set of regions for which there are keys to be sent.

Returns:

Iterable of region IDs

Return type:

iterable(int)

is_empty(region)[source]

Return true if there are no spikes to be buffered for the specified region.

Parameters:

region (int) – The region to get the next key from

Returns:

Whether there are no keys to send for the region

Return type:

bool

is_next_key(region, timestamp)[source]

Determine if there are still keys to be sent at the given timestamp for the given region.

Parameters:
  • region (int) – The region to determine if there are keys for

  • timestamp (int) – The timestamp to determine if there are more keys for

Returns:

Whether there are more keys to send for the parameters

Return type:

bool

is_next_timestamp(region)[source]

Determine if there is another timestamp with data to be sent.

Parameters:

region (int) – The region to determine if there is more data for

Returns:

Whether there is more data

Return type:

bool

rewind(region)[source]

Rewinds the internal buffer in preparation of re-sending the spikes.

Parameters:

region (int) – The region to rewind

abstract property send_buffers

The buffer for each region that has keys to send.

Return type:

dict(int, BufferedSendingRegion)

spinn_front_end_common.interface.buffer_management.storage_objects package
Module contents
class spinn_front_end_common.interface.buffer_management.storage_objects.BufferDatabase(database_file=None, *, read_only=False, row_factory=<class 'sqlite3.Row'>, text_factory=<class 'memoryview'>)[source]

Bases: BaseDatabase

Specific implementation of the Database for SQLite 3.

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.

If 2 database objects where opened with the database_file they hold the same data. Unless someone else deletes that file.

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 the default location will be used.

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_core_name(x, y, p)[source]
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

    Must be shorter than 1GB

store_vertex_labels()[source]
write_session_credentials_to_db()[source]

Write Spalloc session credentials to the database if in use.

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

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.

property current_timestamp

The current timestamp in the iterator.

Return type:

int

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

property is_next_timestamp

Whether the region is empty.

Returns:

True if the region is empty, false otherwise.

Return type:

bool

property n_timestamps

The number of timestamps available.

Return type:

int

property next_key

The next key to be sent.

Return type:

int

property 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.

property 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

property is_full

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

Return type:

bool

property 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

Submodules
spinn_front_end_common.interface.buffer_management.recording_utilities module
spinn_front_end_common.interface.buffer_management.recording_utilities.get_recording_data_constant_size(n_recording_regions)[source]

Get the size of the headers that are stored in the SDRAM spaces allocated during recording_initialise, and so do not need to be reserved with DSG (but need to be accounted for in SDRAM calculations).

Parameters:

n_recording_regions (int) – The number of regions that can be recorded

Return type:

int

spinn_front_end_common.interface.buffer_management.recording_utilities.get_recording_header_array(recorded_region_sizes)[source]

Get data to be written for the recording header.

Parameters:

recorded_region_sizes (list(int)) – A list of sizes of each region to be recorded. A size of 0 is acceptable.

Return type:

list(int)

spinn_front_end_common.interface.buffer_management.recording_utilities.get_recording_header_size(n_recording_regions)[source]

Get the size of the data to be written for the recording header.

This is the data that sets up how recording will be done, and indicates the sizes of the regions to be stored.

Parameters:

n_recording_regions (int) – The number of regions that can be recorded

Return type:

int

Module contents
class spinn_front_end_common.interface.buffer_management.BufferManager[source]

Bases: object

Manager of send buffers.

clear_recorded_data(x, y, p, recording_region_id)[source]

Removes the recorded data stored in memory.

Parameters:
  • x (int) – placement X coordinate

  • y (int) – placement Y coordinate

  • p (int) – placement processor ID

  • recording_region_id (int) – the recording region ID

get_data_by_placement(placement, recording_region_id)[source]

Get the data container for all the data retrieved during the simulation from a specific region area of a core.

Parameters:
  • placement (Placement) – the placement to get the data from

  • recording_region_id (int) – desired recording data region

Returns:

an array contained all the data received during the simulation, and a flag indicating if any data was missing

Return type:

tuple(bytearray, bool)

get_placement_data()[source]
load_initial_buffers()[source]

Load the initial buffers for the senders using memory writes.

reset()[source]

Resets the buffered regions to start transmitting from the beginning of its expected regions and clears the buffered out data files.

resume()[source]

Resets any data structures needed before starting running again.

property sender_vertices

The vertices which are buffered.

Return type:

iterable(AbstractSendsBuffersFromHost)

spinn_front_end_common.interface.ds package
Module contents
class spinn_front_end_common.interface.ds.DataRowWriter(x, y, p, targets)[source]

Bases: RawIOBase

close()[source]

Closes the writer if not already closed.

fileno()[source]

Returns underlying file descriptor if one exists.

OSError is raised if the IO object does not use a file descriptor.

readable()[source]

Return whether object was opened for reading.

If False, read() will raise OSError.

seekable()[source]

Return whether object supports random access.

If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().

truncate(size=None)[source]

Truncate file to size bytes.

File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Returns the new size.

writable()[source]

Return whether object was opened for writing.

If False, write() will raise OSError.

write(data)[source]
class spinn_front_end_common.interface.ds.DsSqlliteDatabase(init_file=None)[source]

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.

app_items()[source]

Yields the keys and values for the data specification data for application cores.

Note

Do not use the database for anything else while iterating.

Returns:

Yields the (x, y, p) and saved data specification byte-code pairs

Return type:

iterable(tuple(tuple(int,int,int),RawIOBase, int))

clear_write_info()[source]

Clears the provenance for all rows.

create_data_spec(x, y, p)[source]

Get a stream that will write the data specification for a particular core to this database.

Parameters:
  • x (int) – X coordinate of the core

  • y (int) – Y coordinate of the core

  • p (int) – Processor ID of the core

Returns:

the stream; the write only happens when the stream is closed

Return type:

DataRowWriter

classmethod default_database_file()[source]
ds_n_app_cores()[source]

Returns the number for application cores there is a data specification saved for.

Return type:

int

Raises:

DsDatabaseException

ds_n_cores()[source]

Returns the number for cores there is a data specification saved for.

Return type:

int

Raises:

DsDatabaseException

ds_n_system_cores()[source]

Returns the number for system cores there is a data specification saved for.

Return type:

int

Raises:

DsDatabaseException

get_app_id(x, y, p)[source]

Gets the app_id set for this core.

Parameters:
  • x (int) – core X coordinate

  • y (int) – core Y coordinate

  • p (int) – core processor ID

Return type:

int

get_ds(x, y, p)[source]

Retrieves the data specification as byte-code for this core.

Parameters:
  • x (int) – core X coordinate

  • y (int) – core Y coordinate

  • p (int) – core processor ID

Returns:

data specification as byte code

Return type:

bytes

get_write_info(x, y, p)[source]

Gets the provenance returned by the data specification executor.

Parameters:
  • x (int) – core X coordinate

  • y (int) – core Y coordinate

  • p (int) – core processor ID

Returns:

start_address, memory_used, memory_written

Return type:

DataWritten

info_iteritems()[source]

Yields the keys and values for the Info data.

Note

A DB transaction may be held while this iterator is processing. Reentrant use of this class is not supported.

Returns:

Yields the (x, y, p), start_address, memory_used and memory_written

Return type:

iterable(tuple(tuple(int, int, int), int, int, int))

info_n_cores()[source]

Returns the number for cores there is a info saved for.

Return type:

int

Raises:

DsDatabaseException

items()[source]

Yields the keys and values for the data specification data.

Note

Do not use the database for anything else while iterating.

Returns:

Yields the (x, y, p) and saved data specification byte-code pairs

Return type:

iterable(tuple(tuple(int,int,int),RawIOBase))

keys()[source]

Yields the keys.

Note

Do not use the database for anything else while iterating.

Returns:

Yields the (x, y, p)

Return type:

iterable(tuple(int,int,int))

mark_system_cores(core_subsets)[source]

Flags a set of processors as running system binaries.

Parameters:

core_subsets (CoreSubsets) – Which cores to mark.

set_app_id(app_id)[source]

Sets the same app_id for all rows that have data specification content.

Parameters:

app_id (int) – value to set

set_size_info(x, y, p, memory_used)[source]
set_write_info(x, y, p, start, used, written)[source]

Sets the provenance returned by the data specification executor.

Parameters:
  • x (int) – core X coordinate

  • y (int) – core Y coordinate

  • p (int) – core processor ID

  • start (int) – base address

  • used (int) – size allocated

  • written (int) – bytes written

system_items()[source]

Yields the keys and values for the data specification data for system cores.

Note

Do not use the database for anything else while iterating.

Returns:

Yields the (x, y, p), saved data specification byte-code, and region_size triples

Return type:

iterable(tuple(tuple(int,int,int),RawIOBase, int))

write_data_spec(core_x, core_y, core_p, spec_bytes)[source]
Parameters:
  • core_x (int) – X coordinate of the core that spec_bytes applies to

  • core_y (int) – Y coordinate of the core that spec_bytes applies to

  • p (int) – Processor ID of the core that spec_bytes applies to

  • spec_bytes (bytes) – the data specification byte-code

write_session_credentials_to_db()[source]

Write Spalloc session credentials to the database, if in use.

spinn_front_end_common.interface.interface_functions package
Submodules
spinn_front_end_common.interface.interface_functions.host_no_bitfield_router_compression module
class spinn_front_end_common.interface.interface_functions.host_no_bitfield_router_compression.Compression(binary_path, progress_text, result_register)[source]

Bases: object

Compression algorithm implementation that uses a on-chip router compressor in order to parallelise.

Parameters:
  • binary_path (str) – What binary to run

  • machine (Machine) – The machine model

  • progress_text (str) – Text to use in progress bar

  • result_register (int) – number of the user register to check for the result code

compress()[source]

Apply the on-machine compression algorithm.

Raises:

SpinnFrontEndException – If compression fails

spinn_front_end_common.interface.interface_functions.host_no_bitfield_router_compression.ordered_covering_compression()[source]

Load routing tables and compress then using the unordered Algorithm.

To the best of our knowledge this is the same algorithm as mundy_on_chip_router_compression(), except this one is still buildable and can be maintained.

Raises:

SpinnFrontEndException – If compression fails

spinn_front_end_common.interface.interface_functions.host_no_bitfield_router_compression.pair_compression()[source]

Load routing tables and compress then using the Pair Algorithm.

See pacman/operations/router_compressors/pair_compressor.py which is the exact same algorithm implemented in Python.

Raises:

SpinnFrontEndException – If compression fails

spinn_front_end_common.interface.interface_functions.machine_bit_field_router_compressor module
spinn_front_end_common.interface.interface_functions.machine_bit_field_router_compressor.SIZE_OF_SDRAM_ADDRESS_IN_BYTES = 148

Size of SDRAM allocation for addresses

spinn_front_end_common.interface.interface_functions.machine_bit_field_router_compressor.machine_bit_field_ordered_covering_compressor(compress_as_much_as_possible=False)[source]

Compression with bit field and ordered covering.

Parameters:

compress_as_much_as_possible (bool) – whether to compress as much as possible

Returns:

where the compressors ran

spinn_front_end_common.interface.interface_functions.machine_bit_field_router_compressor.machine_bit_field_pair_router_compressor(compress_as_much_as_possible=False)[source]

Compression with bit field pairing.

Parameters:

compress_as_much_as_possible (bool) – whether to compress as much as possible

Returns:

where the compressors ran

Module contents
class spinn_front_end_common.interface.interface_functions.FindApplicationChipsUsed[source]

Bases: object

Builds a set of stats on how many chips were used for application cores.

__call__(placements)[source]

Finds how many application chips there were and the cost on each chip

Parameters:

placements (Placements) – placements

Returns:

a tuple with 4 elements.

  1. how many chips were used

  2. the max application cores on any given chip

  3. the lowest number of application cores on any given chip

  4. the average number of application cores on any given chip

Return type:

tuple(int,int,int,float)

spinn_front_end_common.interface.interface_functions.add_command_senders(system_placements)[source]

Add command senders

spinn_front_end_common.interface.interface_functions.application_finisher()[source]

Handles finishing the running of an application, collecting the status of the cores that the application was running on.

Raises:

ExecutableFailedToStopException

spinn_front_end_common.interface.interface_functions.application_runner(runtime, time_threshold, run_until_complete)[source]

Ensures all cores are initialised correctly, ran, and completed successfully.

Parameters:
  • runtime (int) –

  • time_threshold (int) –

  • run_until_complete (bool) –

Raises:

ConfigurationException

spinn_front_end_common.interface.interface_functions.chip_io_buf_clearer()[source]

Clears the logging output buffer of an application running on a SpiNNaker machine.

spinn_front_end_common.interface.interface_functions.chip_io_buf_extractor()[source]

Extract the logging output buffers from the machine, and separates lines based on their prefix.

Returns:

error_entries, warn_entries

Return type:

tuple(list(str),list(str))

spinn_front_end_common.interface.interface_functions.chip_provenance_updater(all_core_subsets)[source]
spinn_front_end_common.interface.interface_functions.chip_runtime_updater(n_sync_steps)[source]

Updates the runtime of an application running on a SpiNNaker machine.

Parameters:

n_sync_steps (int or None) –

spinn_front_end_common.interface.interface_functions.compute_energy_used()[source]

This algorithm does the actual work of computing energy used by a simulation (or other application) running on SpiNNaker.

Return type:

PowerUsed

spinn_front_end_common.interface.interface_functions.create_notification_protocol()[source]

Builds the notification protocol for GUI and external device interaction.

spinn_front_end_common.interface.interface_functions.database_interface(runtime)[source]
Parameters:

runtime (int) –

Returns:

where the database is located

Return type:

str

spinn_front_end_common.interface.interface_functions.energy_provenance_reporter(power_used)[source]

Converts the power usage information into provenance data.

Parameters:

power_used (PowerUsed) – The computed basic power consumption information

spinn_front_end_common.interface.interface_functions.execute_application_data_specs()[source]

Execute the data specs for all non-system targets.

spinn_front_end_common.interface.interface_functions.execute_system_data_specs()[source]

Execute the data specs for all system targets.

spinn_front_end_common.interface.interface_functions.graph_binary_gatherer()[source]

Extracts binaries to be executed.

Return type:

ExecutableTargets

spinn_front_end_common.interface.interface_functions.graph_data_specification_writer(placement_order=None)[source]
Parameters:

placement_order (list(Placement)) – the optional order in which placements should be examined

Return type:

DsSqlliteDatabase

Raises:

ConfigurationException – If the DSG asks to use more SDRAM than is available.

spinn_front_end_common.interface.interface_functions.graph_provenance_gatherer()[source]

Gets provenance information from the graph.

spinn_front_end_common.interface.interface_functions.hbp_allocator(total_run_time)[source]

Request a machine from the HBP remote access server that will fit a number of chips.

Parameters:

total_run_time (int) – The total run time to request

Returns:

machine name, machine version, BMP details (if any), reset on startup flag, auto-detect BMP, SCAMP connection details, boot port, allocation controller

Return type:

tuple(str, int, object, bool, bool, object, object, MachineAllocationController)

Raises:

PacmanConfigurationException – If neither n_chips or n_boards provided

spinn_front_end_common.interface.interface_functions.host_based_bit_field_router_compressor()[source]

Entry point when using the PACMANAlgorithmExecutor.

Returns:

compressed routing table entries

Return type:

MulticastRoutingTables

spinn_front_end_common.interface.interface_functions.insert_chip_power_monitors_to_graphs(placements)[source]

Adds chip power monitors into a given graph.

Parameters:

placements (Placements) –

Returns:

One of the Vertices added

Return type:

ChipPowerMonitorMachineVertex

spinn_front_end_common.interface.interface_functions.insert_extra_monitor_vertices_to_graphs(placements)[source]

Inserts the extra monitor vertices into the graph that correspond to the extra monitor cores required.

Returns:

vertex to Ethernet connection map, list of extra_monitor_vertices, vertex_to_chip_map

Return type:

tuple( dict(tuple(int,int),DataSpeedUpPacketGatherMachineVertex), list(ExtraMonitorSupportMachineVertex), dict(tuple(int,int),ExtraMonitorSupportMachineVertex))

spinn_front_end_common.interface.interface_functions.load_app_images()[source]

Go through the executable targets and load each binary to everywhere and then send a start request to the cores that actually use it.

spinn_front_end_common.interface.interface_functions.load_fixed_routes()[source]

Load a set of fixed routes onto a SpiNNaker machine.

Parameters:

transceiver (Transceiver) –

spinn_front_end_common.interface.interface_functions.load_sys_images()[source]

Go through the executable targets and load each binary to everywhere and then send a start request to the cores that actually use it.

spinn_front_end_common.interface.interface_functions.local_tdma_builder()[source]

Builds a localised TDMA.

Builds a localised TDMA which allows a number of machine vertices of the same application vertex to fire at the same time. Ensures that other application vertices are not firing at the same time. Verifies if the total time required fits into the time scale factor and machine time step. Below are text diagrams to show how this works in principle.

Figure 1: bits needed to figure out time between spikes. Cores 0-4 have 2 atoms, core 5 has 1 atom:

#        0     1       2      3       4      5
# T2-[   X                    X
#    |         X                      X
#    |                 X                     X
#    [  X                     X
#       |------| T
#              X                      X
#                      X <- T3

T = time_between_cores
T2 = time_between_phases
T3 = end of TDMA (equiv of ((n_phases + 1) * T2))
cutoff = 2. n_phases = 3 max_atoms = 2

Constants etc just to get into head:

  • clock cycles = 200 MHz = 200 = sv->cpu_clk

  • 1ms = 200000 for timer 1. = clock cycles

  • 200 per microsecond

  • machine time step = microseconds already.

  • __time_between_cores = microseconds.

Figure 2: initial offset (used to try to interleave packets from other application vertices into the TDMA without extending the overall time, and trying to stop multiple packets in flight at same time).

Figure 3: bits needed to figure out time between spikes. Cores 0-4 have 2 atoms, core 5 has 1 atom:

#        0  .5   1   .5    2   .5   3    .5   4   .5   5  .5
# T2-[   X   Y                      X     Y
#    |           X   Y                        X    Y
#    |                     X    Y                      X   Y
#    [  X    Y                      X     Y
#       |-------| T
#               X    Y                        X    Y
#               |----| T4
#                   T3 ->  X    Y

T4 is the spreader between populations.
X is pop0 firing,
Y is pop1 firing
spinn_front_end_common.interface.interface_functions.locate_executable_start_type()[source]

Discovers where applications of particular types need to be launched.

spinn_front_end_common.interface.interface_functions.machine_generator(bmp_details, board_version, auto_detect_bmp, scamp_connection_data, reset_machine_on_start_up)[source]

Makes a transceiver and a machine object.

Parameters:
  • bmp_details (str) – the details of the BMP connections

  • board_version (int) – the version of the boards being used within the machine (1, 2, 3, 4 or 5)

  • auto_detect_bmp (bool) – Whether the BMP should be automatically determined

  • scamp_connection_data (dict((int,int), str) or None) – Job.connection dict, a String SC&MP connection data or None

  • reset_machine_on_start_up (bool) –

  • allocation_controller (MachineAllocationController) – The allocation controller; in some cases, we delegate the creation of the transceiver to it.

Returns:

Transceiver, and description of machine it is connected to

Return type:

tuple(Machine, Transceiver)

spinn_front_end_common.interface.interface_functions.placements_provenance_gatherer(n_placements, placements)[source]

Gets provenance information from placements.

Parameters:
  • n_placements (int) – Number of placements to gather

  • placements (iterator(Placement)) – The placements of the vertices to gather data form. May not be all placements so don’t use View

spinn_front_end_common.interface.interface_functions.profile_data_gatherer()[source]

Gets all the profiling data recorded by vertices and writes it to files.

spinn_front_end_common.interface.interface_functions.read_routing_tables_from_machine()[source]

Reads compressed routing tables from a SpiNNaker machine.

Return type:

MulticastRoutingTables

spinn_front_end_common.interface.interface_functions.reload_dsg_regions()[source]

Reloads DSG regions where needed.

spinn_front_end_common.interface.interface_functions.router_provenance_gatherer()[source]
spinn_front_end_common.interface.interface_functions.routing_setup()[source]

Initialises the routers.

Note

This does not load any routes into them.

Parameters:

transceiver (Transceiver) –

spinn_front_end_common.interface.interface_functions.routing_table_loader(router_tables)[source]

Loads routes into initialised routers.

Parameters:

router_tables (MulticastRoutingTables) –

spinn_front_end_common.interface.interface_functions.sdram_outgoing_partition_allocator()[source]
spinn_front_end_common.interface.interface_functions.spalloc_allocator(bearer_token: Optional[str] = None) Tuple[str, int, None, bool, bool, Dict[Tuple[int, int], str], None, MachineAllocationController][source]

Request a machine from a SPALLOC server that will fit the given number of chips.

Parameters:

bearer_token (str or None) – The bearer token to use

Returns:

host, board version, BMP details, reset on startup flag, auto-detect BMP flag, board address map, allocation controller

Return type:

tuple(str, int, object, bool, bool, dict(tuple(int,int),str), MachineAllocationController)

spinn_front_end_common.interface.interface_functions.split_lpg_vertices(system_placements)[source]

Split any LPG vertices found.

Parameters:
  • app_graph (ApplicationGraph) – The application graph

  • machine (Machine) – the SpiNNaker machine as discovered

  • system_placements (Placements) – existing placements to be added to

spinn_front_end_common.interface.interface_functions.system_multicast_routing_generator()[source]

Generates routing table entries used by the data-in processes with the extra monitor cores.

Returns:

routing tables, destination-to-key map, board-location-to-timeout-key map

Return type:

tuple(MulticastRoutingTables, dict(tuple(int,int),int), dict(tuple(int,int),int))

spinn_front_end_common.interface.interface_functions.tags_loader()[source]

Loads tags onto the machine.

spinn_front_end_common.interface.interface_functions.virtual_machine_generator()[source]

Generates a virtual machine with given dimensions and configuration.

Returns:

The virtual machine.

Return type:

Machine

Raises:

Exception – If given bad arguments

spinn_front_end_common.interface.profiling package
Submodules
spinn_front_end_common.interface.profiling.profile_utils module
spinn_front_end_common.interface.profiling.profile_utils.get_profile_region_size(n_samples)[source]

Get the size of the region of the profile data.

Parameters:

n_samples (int) – number of different samples to record

Returns:

the size in bytes used by the profile region

Return type:

int

spinn_front_end_common.interface.profiling.profile_utils.get_profiling_data(profile_region, tag_labels, placement)[source]

Utility function to get profile data from a profile region.

Parameters:
  • profile_region (int) – DSG region to get profiling data out of SDRAM

  • tag_labels (list(str)) – labels for the profiling data

  • placement (Placement) – placement

Return type:

ProfileData

spinn_front_end_common.interface.profiling.profile_utils.reserve_profile_region(spec, region, n_samples)[source]

Reserves the profile region for recording the profile data.

Parameters:
  • spec (DataSpecificationGenerator) – the DSG specification writer

  • region (int) – region ID for the profile data

  • n_samples (int) – number of elements being sampled

spinn_front_end_common.interface.profiling.profile_utils.write_profile_region_data(spec, region, n_samples)[source]

Writes the profile region data.

Parameters:
  • spec (DataSpecificationGenerator) – the DSG specification writer

  • region (int) – region ID for the profile data

  • n_samples (int) – number of elements being sampled

Module contents
class spinn_front_end_common.interface.profiling.AbstractHasProfileData[source]

Bases: object

Indicates a MachineVertex that can record a profile.

abstract get_profile_data(placement)[source]

Get the profile data recorded during simulation.

Parameters:

placement (Placement) –

Return type:

ProfileData

class spinn_front_end_common.interface.profiling.ProfileData(tag_labels)[source]

Bases: object

A container for profile data.

Parameters:

tag_labels (list(str)) – A list of labels indexed by tag ID

DURATION = 1
START_TIME = 0
add_data(data)[source]

Add profiling data read from the profile section.

Parameters:

data (bytearray) – Data read from the profile section on the machine

get_mean_ms(tag)[source]

Get the mean time in milliseconds spent on operations with the given tag.

Parameters:

tag (str) – The tag to get the mean time for

Return type:

float

get_mean_ms_per_ts(tag)[source]

Get the mean time in milliseconds spent on operations with the given tag per timestep.

Parameters:

tag (str) – The tag to get the data for

Return type:

float

get_mean_n_calls_per_ts(tag)[source]

Get the mean number of times the given tag was recorded per timestep.

Parameters:

tag (str) – The tag to get the data for

Return type:

float

get_n_calls(tag)[source]

Get the number of times the given tag was recorded.

Parameters:

tag (str) – The tag to get the number of calls of

Return type:

int

property tags

The tags recorded as labels.

Return type:

list(str)

spinn_front_end_common.interface.provenance package
Submodules
spinn_front_end_common.interface.provenance.router_prov_mapper module
class spinn_front_end_common.interface.provenance.router_prov_mapper.Plotter(db_filename, verbose=False)[source]

Bases: object

cmap
get_per_chip_prov_details(info)[source]
get_per_chip_prov_types()[source]
get_per_core_prov_types()[source]
get_sum_chip_prov_details(info)[source]
plot_per_chip_data(key, output_filename)[source]
plot_per_core_data(key, output_filename)[source]
spinn_front_end_common.interface.provenance.router_prov_mapper.main()[source]
Module contents
class spinn_front_end_common.interface.provenance.AbstractProvidesLocalProvenanceData[source]

Bases: object

Indicates an object that provides locally obtained provenance data.

GraphProvenanceGatherer will check all Vertices and all Edges in the ApplicationGraph

abstract get_local_provenance_data()[source]

Get an iterable of provenance data items.

Return type:

iterable

class spinn_front_end_common.interface.provenance.AbstractProvidesProvenanceDataFromMachine[source]

Bases: object

Indicates that an object provides provenance data retrieved from the machine.

abstract get_provenance_data_from_machine(placement)[source]

Get an iterable of provenance data items.

Parameters:

placement (Placement) – the placement of the object

Return type:

iterable

class spinn_front_end_common.interface.provenance.FecTimer(algorithm, work)[source]

Bases: object

APPLICATION_RUNNER = 'Application runner'
classmethod end_category(category)[source]

This method should only be called via the View!

Parameters:

category (SimulatorStage) – Stage to end

error(reason)[source]
classmethod setup(simulator)[source]
skip(reason)[source]
skip_if_cfg_false(section, option)[source]
skip_if_cfgs_false(section, option1, option2)[source]
skip_if_empty(value, name)[source]
skip_if_has_not_run()[source]
skip_if_virtual_board()[source]
classmethod start_category(category, machine_on=None)[source]

This method should only be called via the View!

Parameters:
  • category (TimerCategory) – category to switch to

  • machine_on (None or bool) – What to change machine on too. Or None to leave as is

classmethod stop_category_timing()[source]
class spinn_front_end_common.interface.provenance.GlobalProvenance(database_file=None, memory=False)[source]

Bases: SQLiteDB

Specific implementation of the Database for SQLite 3.

Note

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

Note

This totally relies on the way SQLite’s type affinities function. You can’t port to a different database engine without a lot of work.

Parameters:
  • database_file (str or None) – The name of a file that contains (or will contain) an SQLite database holding the data. If omitted, either the default file path or an unshared in-memory database will be used (suitable only for testing).

  • memory (bool) – Flag to say unshared in-memory can be used. Otherwise a None file will mean the default should be used

get_category_timer_sum(category)[source]

Get the total runtime for one category of algorithms

Parameters:

category (TimerCategory) –

Returns:

total off all run times with this category

Return type:

int

get_category_timer_sums(category)[source]

Get the runtime for one category of algorithms split machine on, machine off

Parameters:

category (TimerCategory) –

Returns:

total on and off time of instances with this category

Return type:

int

classmethod get_global_provenace_path()[source]

Get the path of the current provenance database of the last run

Warning

Calling this method between start/reset and run may result in a path to a database not yet created.

Raises:

ValueError – if the system is in a state where path can’t be retrieved, for example before run is called

get_run_time_of_BufferExtractor()[source]

Gets the buffer extractor provenance item(s) from the last run

Returns:

A possibly multiline string with for each row which matches the LIKE %BufferExtractor

Return type:

str

get_run_times()[source]

Gets the algorithm running times from the last run. If an algorithm is invoked multiple times in the run, its times are summed.

Returns:

A possibly multiline string with for each row which matches the like a line description_name: time. The times are in seconds.

Return type:

str

get_timer_provenance(algorithm)[source]

Gets the timer provenance item(s) from the last run

Parameters:

algorithm (str) – The value to LIKE search for in the algorithm column. Can be the full name, or have % and _ wildcards.

Returns:

A possibly multiline string with for each row which matches the like a line algorithm: value

Return type:

str

get_timer_sum_by_algorithm(algorithm)[source]

Get the total runtime for one algorithm

Parameters:

algorithm (str) –

Returns:

total off all runtimes with this algorithm

Return type:

int

get_timer_sum_by_category(category)[source]

Get the total runtime for one category of algorithms

Parameters:

category (TimerCategory) –

Returns:

total off all run times with this category

Return type:

int

get_timer_sum_by_work(work)[source]

Get the total runtime for one work type of algorithms

Parameters:

work (TimerWork) –

Returns:

total off all runtimes with this category

Return type:

int

insert_category(category, machine_on)[source]

Inserts category into the category_timer_provenance returning id

Parameters:
  • category (TimerCategory) – Name of Category starting

  • machine_on (bool) – If the machine was done during all or some of the time

insert_category_timing(category_id, timedelta)[source]

Inserts run time into the category

Parameters:
  • category_id (int) – id of the Category finished

  • timedelta (timedelta) – Time to be recorded

insert_timing(category, algorithm, work, timedelta, skip_reason)[source]

Inserts algorithms run times into the timer_provenance table

Parameters:
  • category (int) – Category Id of the Algorithm

  • algorithm (str) – Algorithm name

  • work (TimerWork) – Type of work being done

  • timedelta (timedelta) – Time to be recorded

  • skip_reason (str or None) – The reason the algorithm was skipped or None if it was not skipped

insert_version(description, the_value)[source]

Inserts data into the version_provenance table

Parameters:
  • description (str) – The package for which the version applies

  • the_value (str) – The version to be recorded

retreive_log_messages(min_level=0)[source]

Retrieves all log messages at or above the min_level

Parameters:

min_level (int) –

Return type:

list(tuple(int, str))

run_query(query, params=())[source]

Opens a connection to the database, runs a query, extracts the results and closes the connection

The return type depends on the use_sqlite_rows parameter. By default this method returns tuples (lookup by index) but the advanced tuple type can be used instead, which supports lookup by name used in the query (use AS name in the query to set).

This method will not allow queries that change the database unless the read_only flag is set to False.

Note

This method is mainly provided as a support method for the later methods that return specific data. For new IntergationTests please add a specific method rather than call this directly.

Parameters:
  • query (str) – The SQL query to be run. May include ? wildcards

  • params (Iterable(str or int)) – The values to replace the ? wildcards with. The number and types must match what the query expects

  • read_only (bool) – see get_database_handle()

  • use_sqlite_rows (bool) – see get_database_handle()

Returns:

A list possibly empty of tuples/rows (one for each row in the database) where the number and type of the values corresponds to the where statement

Return type:

list(tuple or Row)

store_log(level, message, timestamp=None)[source]

Stores log messages into the database

Parameters:
  • level (int) –

  • message (str) –

class spinn_front_end_common.interface.provenance.LogStoreDB[source]

Bases: LogStore

get_location()[source]

Retrieves the location of the log store.

Return type:

str

retreive_log_messages(min_level=0)[source]

Retrieves all log messages at or above the min_level.

Parameters:

min_level (int) – Constraint on the minimum logging level to retrieve.

Returns:

A list of messages that satisfy the constraint.

Return type:

list(tuple(int, str))

store_log(level, message, timestamp=None)[source]

Writes the log message for later retrieval.

Parameters:
  • level (int) – The logging level.

  • message (str) – The logged message.

  • timestamp (datetime or None) – The time-stamp of the message.

class spinn_front_end_common.interface.provenance.ProvenanceReader(provenance_data_path=None)[source]

Bases: BaseDatabase

Provides a connection to a database containing provenance for the current run and some convenience methods for extracting provenance data from it.

By default this will wrap around the database used to store the provenance of the last run. The path is not updated so this reader is not effected by a reset or an end.

The assumption is that the database is in the current provenance format. This includes both that DDL statements used to create the database but also the underlying database structure (currently sqlite3)

Warning

This class is only a wrapper around the database file so if the file is deleted the class will no longer work.

Create a wrapper around the database.

The suggested way to call this is without the provenance_data_path parameter, allowing get_last_run_database_path() to find the correct path.

Parameters:

provenance_data_path (None or str) – Path to the provenance database to wrap

cores_with_late_spikes()[source]

Gets the x, y, p and count of the cores where late spikes arrived.

Cores that received spikes but where none were late are not included.

Returns:

A list hopefully empty of tuples (x, y, p, count) of cores where their where late arriving spikes.

Return type:

list(tuple(int, int, int, int))

static demo()[source]

A demonstration of how to use this class.

See also unittests/interface/provenance/test_provenance_database.py

get_cores_with_provenace()[source]

Gets the cores with provenance.

Returns:

A list tuples (x, y, p)

Return type:

list(tuple(int, int, int))

classmethod get_last_run_database_path()[source]

Get the path of the current provenance database of the last run.

Warning

Calling this method between start/reset and run may result in a path to a database not yet created.

raises ValueError:

if the system is in a state where path can’t be retrieved, for example before run is called

get_monitor_by_chip(description)[source]

Gets the monitor values for a specific item.

Parameters:

description (str) –

Returns:

list of tuples x, y, value)

Return type:

list(tuple(int, int, float))

get_provenance_for_router(x, y)[source]

Gets the provenance item(s) from the last run relating to a chip.

Parameters:
  • x (int) – The X coordinate of the chip

  • y (int) – The Y coordinate of the chip

Returns:

A possibly multi-line string with for each row which matches the like a line description_name: value

Return type:

str

get_router_by_chip(description)[source]

Gets the router values for a specific item.

Parameters:

description (str) –

Returns:

list of tuples x, y, value)

Return type:

list(tuple(int, int, float))

messages()[source]

List all the provenance messages.

Returns:

all messages logged or not; order is whatever the DB chooses

Return type:

list(str)

run_query(query, params=())[source]

Opens a connection to the database, runs a query, extracts the results and closes the connection.

The return type depends on the use_sqlite_rows parameter. By default this method returns tuples (lookup by index) but the advanced tuple type can be used instead, which supports lookup by name used in the query (use AS name in the query to set).

This method will not allow queries that change the database unless the read_only flag is set to False.

Note

This method is mainly provided as a support method for the later methods that return specific data. For new IntergationTests please add a specific method rather than call this directly.

Parameters:
  • query (str) – The SQL query to be run. May include ? wildcards

  • params (Iterable(str or int)) – The values to replace the ? wildcards with. The number and types must match what the query expects

  • read_only (bool) – see get_database_handle()

  • use_sqlite_rows (bool) – see get_database_handle()

Returns:

A list possibly empty of tuples/rows (one for each row in the database) where the number and type of the values corresponds to the where statement

Return type:

list(tuple or Row)

class spinn_front_end_common.interface.provenance.ProvenanceWriter(database_file=None)[source]

Bases: BaseDatabase

Specific implementation of the Database for SQLite 3.

Note

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

Note

This totally relies on the way SQLite’s type affinities function. You can’t port to a different database engine without a lot of work.

Parameters:
  • database_file (str or None) – The name of a file that contains (or will contain) an SQLite database holding the data. If omitted, either the default file path or an unshared in-memory database will be used (suitable only for testing).

  • memory (bool) – Flag to say unshared in-memory can be used. Otherwise a None file will mean the default should be used

insert_board_provenance(connections)[source]

Write the connection details retrieved from spalloc_client job to the boards_provenance table.

Parameters:

connections (dict((int, int): str) or None) – {(x, y): hostname, …} or None

insert_connector(pre_population, post_population, the_type, description, the_value)[source]

Inserts edge data into the connector_provenance

Parameters:
  • pre_population (str) – Name of the pre-population / vertex

  • post_population (str) – Name of the post-population / vertex

  • the_type (str) – Class of the connector

  • description (str) – type of value

  • the_value (int) – data

insert_core(x, y, p, description, the_value)[source]

Inserts data for a specific core into the core_provenance table.

Parameters:
  • x (int) – X coordinate of the chip

  • y (int) – Y coordinate of the chip

  • p (int) – ID of the core

  • description (str) – type of value

  • the_value (int) – data

insert_gatherer(x, y, address, bytes_read, run, description, the_value)[source]

Records provenance into the gatherer_provenance table.

Parameters:
  • x (int) – X coordinate of the chip

  • y (int) – Y coordinate of the chip

  • address (int) – SDRAM address read from

  • bytes_read (int) – number of bytes read

  • run (int) – run number

  • description (str) – type of value

  • the_value (float) – data

insert_monitor(x, y, description, the_value)[source]

Inserts data into the monitor_provenance table.

Parameters:
  • x (int) – X coordinate of the chip

  • y (int) – Y coordinate of the chip

  • description (str) – type of value

  • the_value (int) – data

insert_power(description, the_value)[source]

Inserts a general power value into the power_provenance table.

Parameters:
  • description (str) – Type of value

  • the_value (float) – data

insert_report(message)[source]

Save and if applicable logs a message to the reports table.

Only logs the messages up to the cut-off set by configuration provenance_report_cutoff

Parameters:

message (str) –

insert_router(x, y, description, the_value, expected=True)[source]

Inserts data into the router_provenance table.

Parameters:
  • x (int) – X coordinate of the chip

  • y (int) – Y coordinate of the chip

  • description (str) – type of value

  • the_value (float) – data

  • expected (bool) – Flag to say this data was expected

class spinn_front_end_common.interface.provenance.ProvidesProvenanceDataFromMachineImpl[source]

Bases: AbstractProvidesProvenanceDataFromMachine

An implementation that gets provenance data from a region of integers on the machine.

N_SYSTEM_PROVENANCE_WORDS = 6
class PROVENANCE_DATA_ENTRIES(value)[source]

Bases: Enum

Entries for the provenance data generated by models using provides provenance vertex.

CALLBACK_QUEUE_OVERLOADED = 1

The counter of the number of times the callback queue was overloaded

DMA_QUEUE_OVERLOADED = 2

The counter of the number of times the DMA queue was overloaded

MAX_NUMBER_OF_TIMER_TIC_OVERRUN = 5

The counter of the number of times the timer tick overran

TIMER_TIC_HAS_OVERRUN = 4

Whether the timer tick has overrun at all at any point

TRANSMISSION_EVENT_OVERFLOW = 0

The counter of transmission overflows

USER_QUEUE_OVERLOADED = 3

The counter of the number of times the user event queue overloaded

get_provenance_data_from_machine(placement)[source]

Retrieve the provenance data.

Parameters:

placement (Placement) – Which vertex are we retrieving from, and where was it

classmethod get_provenance_data_size(n_additional_data_items)[source]
Parameters:

n_additional_data_items (int) –

Return type:

int

parse_extra_provenance_items(label, x, y, p, provenance_data)[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) – The list of words of raw provenance data.

parse_system_provenance_items(label, x, y, p, provenance_data)[source]

Given some words of provenance data, convert the portion of them that describes the system provenance into proper provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) –

reserve_provenance_data_region(spec)[source]
Parameters:

spec (DataSpecificationGenerator) – The data specification being written.

class spinn_front_end_common.interface.provenance.TimerCategory(value)[source]

Bases: Enum

Different Categories a FecTimer can be in

DATA_GENERATION = <enum.auto object>
GET_MACHINE = <enum.auto object>
LOADING = <enum.auto object>
MAPPING = <enum.auto object>
RESETTING = <enum.auto object>
RUN_LOOP = <enum.auto object>
RUN_OTHER = <enum.auto object>
SETTING_UP = <enum.auto object>
SHUTTING_DOWN = <enum.auto object>
WAITING = <enum.auto object>
property category_name
class spinn_front_end_common.interface.provenance.TimerWork(value)[source]

Bases: Enum

Different Work types an Algorithm could be doing

BITFIELD = <enum.auto object>
COMPRESSING = <enum.auto object>
CONTROL = <enum.auto object>
EXTRACTING = <enum.auto object>
EXTRACT_DATA = <enum.auto object>
GET_MACHINE = <enum.auto object>
LOADING = <enum.auto object>
OTHER = <enum.auto object>
REPORT = <enum.auto object>
RUNNING = <enum.auto object>
SYNAPSE = <enum.auto object>
property work_name
spinn_front_end_common.interface.simulation package
Module contents
spinn_front_end_common.interface.simulation.get_simulation_header_array(binary_file_name)[source]

Get data to be written to the simulation header.

Parameters:

binary_file_name (str) – The name of the binary of the application

Returns:

An array of values to be written as the simulation header

Return type:

list(int)

spinn_front_end_common.interface.simulation.get_simulation_header_array_no_timestep(binary_file_name)[source]

Get data to be written to the simulation header.

Parameters:

binary_file_name (str) – The name of the binary of the application

Returns:

An array of values to be written as the simulation header

Return type:

list(int)

spinn_front_end_common.interface.splitter_selectors package
Module contents
spinn_front_end_common.interface.splitter_selectors.splitter_selector()[source]

Basic selector which puts the legacy splitter object on everything without a splitter object.

spinn_front_end_common.interface.splitter_selectors.vertex_selector(app_vertex)[source]

Main point for selecting a splitter object for a given app vertex.

Will assume the SplitterFixedLegacy if no heuristic is known for the app vertex.

Parameters:

app_vertex (ApplicationVertex) – app vertex to give a splitter object to

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(data_writer_cls=None)[source]

Bases: ConfigHandler

Main interface into the tools logic flow.

Parameters:
  • n_chips_required (int) – Overrides the number of chips to allocate from spalloc_client

  • n_boards_required (int) – Overrides the number of boards to allocate from spalloc_client

  • data_writer_cls (FecDataWriter) – The Global data writer class

continue_simulation()[source]

Continue a simulation that has been started in stepped mode.

exception_handler(exc_type, value, traceback_obj)[source]

Handler of exceptions.

Parameters:
  • exc_type (type) – the type of exception received

  • value (Exception) – the value of the exception

  • traceback_obj (traceback) – the trace back stuff

property 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

reset()[source]

Puts the simulation back at time zero.

run(run_time, sync_time=0)[source]

Run a simulation for a fixed amount of time.

Parameters:
  • run_time (int) – the run duration in milliseconds.

  • sync_time (float) – If not 0, this specifies that the simulation should pause after this duration. The continue_simulation() method must then be called for the simulation to continue.

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

stop()[source]

End running of the simulation.

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.

Raises:

SpiNNUtilsException – If the stop_run was not expected in the current state.

spinn_front_end_common.interface.config_handler module
class spinn_front_end_common.interface.config_handler.ConfigHandler(data_writer_cls=None)[source]

Bases: object

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

Parameters:

data_writer (FecDataWriter) – The Global data writer object

write_errored_file()[source]

Writes an errored file that allows file removal to only remove folders that have errors if requested to do so

write_finished_file()[source]

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

spinn_front_end_common.interface.config_setup module
spinn_front_end_common.interface.config_setup.add_spinnaker_cfg()[source]

Add the local configuration and all dependent configuration files.

spinn_front_end_common.interface.config_setup.unittest_setup()[source]

Does all the steps that may be required before a unit test.

Resets the configurations so only the local default configurations are included.

Unsets any previous simulators and temporary directories.

Note

This file should only be called from spinn_front_end_common/tests

spinn_front_end_common.interface.java_caller module
class spinn_front_end_common.interface.java_caller.JavaCaller[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/configuration parameters.

Raises:

ConfigurationException – if simple parameter checking fails.

execute_app_data_specification(use_monitors)[source]

Writes all the data specifications for application cores, uploading the result to the machine.

Note

May assume that system cores are already loaded and running if use_monitors is set to True.

Parameters:

use_monitors (bool) –

Raises:

PacmanExternalAlgorithmFailedToCompleteException – On failure of the Java code.

execute_data_specification()[source]

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

Raises:

PacmanExternalAlgorithmFailedToCompleteException – On failure of the Java code.

execute_system_data_specification()[source]

Writes all the data specifications 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()[source]

Create information describing what’s going on with the monitor cores.

set_placements(used_placements)[source]

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

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:

used_placements (Placements) – Placements that are recording. May not be all placements

Module contents
spinn_front_end_common.utilities package
Subpackages
spinn_front_end_common.utilities.connections package
Module contents
class spinn_front_end_common.utilities.connections.LiveEventConnection(live_packet_gather_label, receive_labels=None, send_labels=None, local_host=None, local_port=19999)[source]

Bases: DatabaseConnection

A connection for receiving and sending live events from and to SpiNNaker.

Note

This class is intended to be potentially usable from another process than the one that the simulator is present in.

Parameters:
  • live_packet_gather_label (str) – The label of the vertex to which received events are being sent

  • receive_labels (iterable(str)) – Labels of vertices from which live events will be received.

  • send_labels (iterable(str)) – Labels of vertices to which live events will be sent

  • 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_init_callback(label, init_callback)[source]

Add a callback to be called to initialise a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • init_callback (callable(str, int, float, float) -> None) – A function to be called to initialise the vertex. This should take as parameters the label of the vertex, the number of neurons in the population, the run time of the simulation in milliseconds, and the simulation timestep in milliseconds

add_pause_stop_callback(label, pause_stop_callback)[source]

Add a callback for the pause and stop state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • pause_stop_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the pause or stop message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

add_receive_callback(label, live_event_callback, translate_key=True)[source]

Add a callback for the reception of live events from a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • live_event_callback (callable(str, int, list(int)) -> None) – A function to be called when events are received. This should take as parameters the label of the vertex, the simulation timestep when the event occurred, and an array-like of atom IDs.

  • translate_key (bool) – True if the key is to be converted to an atom ID, False if the key should stay a key

add_receive_label(label)[source]
add_send_label(label)[source]
add_start_callback(label, start_callback)[source]

Add a callback for the start of the simulation.

Parameters:
  • start_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the start message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events

  • label (str) – the label of the function to be sent

add_start_resume_callback(label, start_resume_callback)[source]

Add a callback for the start and resume state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • start_resume_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the start or resume message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

close()[source]

Closes the connection.

send_eieio_message(message, label)[source]

Send an EIEIO message (using one-way the live input) to the vertex with the given label.

Parameters:
  • message (AbstractEIEIOMessage) – The EIEIO message to send

  • label (str) – The label of the receiver machine vertex

send_event(label, atom_id, send_full_keys=False)[source]

Send an event from a single atom.

Parameters:
  • label (str) – The label of the vertex from which the event will originate

  • atom_id (int) – The ID of the atom sending the event

  • send_full_keys (bool) – Determines whether to send full 32-bit keys, getting the key for each atom from the database, or whether to send 16-bit atom IDs directly

send_event_with_payload(label, atom_id, payload)[source]

Send an event with a payload from a single atom.

Parameters:
  • label (str) – The label of the vertex from which the event will originate

  • atom_id (int) – The ID of the atom sending the event

  • payload (int) – The payload to send

send_events(label, atom_ids, send_full_keys=False)[source]

Send a number of events.

Parameters:
  • label (str) – The label of the vertex from which the events will originate

  • atom_ids (list(int)) – array-like of atom IDs sending events

  • send_full_keys (bool) – Determines whether to send full 32-bit keys, getting the key for each atom from the database, or whether to send 16-bit atom IDs directly

send_events_with_payloads(label, atom_ids_and_payloads)[source]

Send a number of events with payloads.

Parameters:
  • label (str) – The label of the vertex from which the events will originate

  • atom_ids_and_payloads (list(tuple(int,int))) – array-like of tuples of atom IDs sending events with their payloads

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: 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.

Note

This class coordinates with the NotificationProtocol class without routing messages via SpiNNaker.

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: 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_job()[source]

Get the job described in the database. If no job exists, direct connection to boards should be used.

Returns:

Job handle, if one exists. None otherwise.

Return type:

SpallocJob

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_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, chip_x, chip_y)

Return type:

tuple(str, int, bool, str, 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[source]

Bases: SQLiteDB

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

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 (suitable only for testing).

  • read_only (bool) – Whether the database is in read-only mode. When the database is in read-only mode, it must already exist.

  • ddl_file (str or None) – The name of a file (typically containing SQL DDL commands used to create the tables) to be evaluated against the database before this object completes construction. If None, nothing will be evaluated. You probably don’t want to specify a DDL file at the same time as setting read_only=True.

  • row_factory (Callable or None) – Callable used to create the rows of result sets. Either tuple or sqlite3.Row (default); can be None to use the DB driver default.

  • text_factory (Callable or None) – Callable used to create the Python values of non-numeric columns in result sets. Usually memoryview (default) but should be str when you’re expecting string results; can be None to use the DB driver default.

  • case_insensitive_like (bool) – Whether we want the LIKE matching operator to be case-sensitive or case-insensitive (default).

add_application_vertices()[source]

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

add_lpg_mapping()[source]

Add mapping from machine vertex to LPG machine vertex.

Returns:

A list of (source vertex, partition id)

Return type:

list(MachineVertex, str)

add_machine_objects()[source]

Store the machine object into the database.

add_placements()[source]

Adds the placements objects into the database.

add_proxy_configuration()[source]

Store the proxy configuration.

add_system_params(runtime)[source]

Write system parameters into the database.

Parameters:

runtime (int) – the amount of time the application is to run for

add_tags()[source]

Adds the tags into the database.

static auto_detect_database()[source]

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

Returns:

whether the database is needed for the application

Return type:

bool

create_atom_to_event_id_mapping(machine_vertices)[source]
Parameters:

machine_vertices (list(tuple(MachineVertex,int))) –

property database_path
Return type:

str

spinn_front_end_common.utilities.notification_protocol package
Module contents
class spinn_front_end_common.utilities.notification_protocol.NotificationProtocol[source]

Bases: AbstractContextManager

The protocol which hand shakes with external devices about the database and starting execution.

The messages sent by this are received by instances of DatabaseConnection (and its subclasses). They are not routed via SpiNNaker.

close()[source]

Closes the thread pool and the connections.

send_read_notification()[source]

Sends notifications to all devices which have expressed an interest in when the database has been written

send_start_resume_notification()[source]

Either waits till all sources have confirmed read the database and are configured, and/or just sends the start notification (when the system is executing).

send_stop_pause_notification()[source]

Sends the pause / stop notifications when the script has either finished or paused.

property sent_visualisation_confirmation

Whether the external application has actually been notified yet.

Return type:

bool

wait_for_confirmation()[source]

If asked to wait for confirmation, waits for all external systems to confirm that they are configured and have read the database.

spinn_front_end_common.utilities.report_functions package
Submodules
spinn_front_end_common.utilities.report_functions.reports module
spinn_front_end_common.utilities.report_functions.reports.generate_comparison_router_report(compressed_routing_tables)[source]

Make a report on comparison of the compressed and uncompressed routing tables.

Parameters:

compressed_routing_tables (MulticastRoutingTables) – the compressed routing tables

spinn_front_end_common.utilities.report_functions.reports.generate_routing_table(routing_table, top_level_folder)[source]
Parameters:
spinn_front_end_common.utilities.report_functions.reports.partitioner_report()[source]

Generate report on the partitioning of vertices.

spinn_front_end_common.utilities.report_functions.reports.placement_report_with_application_graph_by_core()[source]

Generate report on the placement of vertices onto cores by core.

spinn_front_end_common.utilities.report_functions.reports.placement_report_with_application_graph_by_vertex()[source]

Generate report on the placement of vertices onto cores by vertex.

spinn_front_end_common.utilities.report_functions.reports.placer_reports_with_application_graph()[source]

Reports that can be produced from placement given a application graph’s existence.

spinn_front_end_common.utilities.report_functions.reports.router_compressed_summary_report(routing_tables)[source]

Generates a text file of routing summaries.

Parameters:

routing_tables (MulticastRoutingTables) – The in-operation COMPRESSED routing tables.

Return type:

RouterSummary

spinn_front_end_common.utilities.report_functions.reports.router_report_from_compressed_router_tables(routing_tables)[source]

Report the compressed routing tables.

Parameters:

routing_tables (MulticastRoutingTables) – the compressed routing tables

spinn_front_end_common.utilities.report_functions.reports.router_report_from_paths()[source]

Generates a text file of routing paths.

spinn_front_end_common.utilities.report_functions.reports.router_report_from_router_tables()[source]

Report the uncompressed routing tables.

spinn_front_end_common.utilities.report_functions.reports.router_summary_report()[source]

Generates a text file of routing summaries.

Return type:

RouterSummary

spinn_front_end_common.utilities.report_functions.reports.routing_info_report(extra_allocations)[source]

Generates a report which says which keys is being allocated to each vertex.

spinn_front_end_common.utilities.report_functions.reports.sdram_usage_report_per_chip()[source]

Reports the SDRAM used per chip.

spinn_front_end_common.utilities.report_functions.reports.tag_allocator_report()[source]

Reports the tags that are being used by the tool chain for this simulation.

spinn_front_end_common.utilities.report_functions.router_summary module
class spinn_front_end_common.utilities.report_functions.router_summary.RouterSummary(total_entries, max_per_chip, max_defaultable, max_link, unqiue_routes)[source]

Bases: object

property max_defaultable
Return type:

int

Return type:

int

property max_per_chip
Return type:

int

property total_entries
Return type:

int

property unqiue_routes
Return type:

int

spinn_front_end_common.utilities.report_functions.routing_compression_report module
spinn_front_end_common.utilities.report_functions.routing_compression_report.generate_routing_compression_checker_report(routing_tables, compressed_routing_tables)[source]

Make a full report of how the compressed covers all routes in the and uncompressed routing table.

Parameters:
Module contents
class spinn_front_end_common.utilities.report_functions.BitFieldSummary(total_merged, max_per_chip, lowest_per_chip, total_to_merge, max_to_merge_per_chip, low_to_merge_per_chip, average_per_chip_merged, average_per_chip_to_merge)[source]

Bases: object

Summary description of generated bitfields.

Parameters:
  • total_merged (int) –

  • max_per_chip (int) –

  • lowest_per_chip (int) –

  • total_to_merge (int) –

  • max_to_merge_per_chip (int) –

  • low_to_merge_per_chip (int) –

  • average_per_chip_merged (float) –

  • average_per_chip_to_merge (float) –

property average_per_chip_merged
Return type:

float

property average_per_chip_to_merge
Return type:

float

property low_to_merge_per_chip
Return type:

int

property lowest_per_chip
Return type:

int

property max_per_chip
Return type:

int

property max_to_merge_per_chip
Return type:

int

property total_merged
Return type:

int

property total_to_merge
Return type:

int

class spinn_front_end_common.utilities.report_functions.EnergyReport[source]

Bases: object

This class creates a report about the approximate total energy consumed by a SpiNNaker job execution.

JOULES_TO_KILOWATT_HOURS = 3600000

converter between joules to kilowatt hours

write_energy_report(power_used)[source]

Writes the report.

Parameters:
spinn_front_end_common.utilities.report_functions.bitfield_compressor_report()[source]

Generates a report that shows the impact of the compression of bitfields into the routing table.

Returns:

a summary, or None if the report file can’t be written

Return type:

BitFieldSummary

spinn_front_end_common.utilities.report_functions.board_chip_report()[source]

Creates a report that states where in SDRAM each region is.

spinn_front_end_common.utilities.report_functions.drift_report()[source]

A report on the clock drift as reported by each chip

spinn_front_end_common.utilities.report_functions.fixed_route_from_machine_report()[source]

Writes the fixed routes from the machine.

spinn_front_end_common.utilities.report_functions.memory_map_on_host_chip_report()[source]

Report on memory usage. Creates a report that states where in SDRAM each region is (read from machine).

spinn_front_end_common.utilities.report_functions.memory_map_on_host_report()[source]

Report on memory usage.

spinn_front_end_common.utilities.report_functions.network_specification()[source]

Generate report on the user’s network specification.

spinn_front_end_common.utilities.report_functions.routing_table_from_machine_report(routing_tables)[source]

Report the routing table that was actually on the machine.

folder_name = os.path.join(FecDataView().run_dir_path, _FOLDER_NAME) os.mkdir(folder_name)

Parameters:
spinn_front_end_common.utilities.report_functions.tags_from_machine_report()[source]

Describes what the tags actually present on the machine are.

spinn_front_end_common.utilities.report_functions.write_json_machine(json_folder=None, progress_bar=True, validate=True)[source]

Runs the code to write the machine in Java readable JSON.

Warning

The file in this folder will be overwritten!

Parameters:
  • json_folder (str) – the folder to which the JSON are being written

  • progress_bar (bool) – Flag if Progress Bar should be shown

  • validate (bool) – Flag to disable the validation.

Returns:

the name of the generated file

Return type:

str

spinn_front_end_common.utilities.report_functions.write_json_placements()[source]

Runs the code to write the placements in JSON.

spinn_front_end_common.utilities.report_functions.write_json_routing_tables(router_tables)[source]

Runs the code to write the machine in Java readable JSON.

Parameters:
  • router_tables (MulticastRoutingTables) – Routing Tables to convert. Could be uncompressed or compressed

  • json_folder (str) – the folder to which the JSON are being written

spinn_front_end_common.utilities.scp package
Module contents
class spinn_front_end_common.utilities.scp.ClearIOBUFProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

How to clear the IOBUF buffers of a set of cores.

Note

The cores must be using the simulation interface.

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

clear_iobuf(core_subsets, n_cores=None)[source]
Parameters:
  • core_subsets (CoreSubsets) –

  • n_cores (int) – Defaults to the number of cores in core_subsets.

class spinn_front_end_common.utilities.scp.UpdateRuntimeProcess(connection_selector)[source]

Bases: AbstractMultiConnectionProcess

How to update the target running time of a set of cores.

Note

The cores must be using the simulation interface.

Parameters:

connection_selector (AbstractMultiConnectionProcessConnectionSelector) –

update_runtime(current_time, run_time, infinite_run, core_subsets, n_cores, n_sync_steps)[source]
Parameters:
  • current_time (int) –

  • run_time (int) –

  • infinite_run (bool) –

  • core_subsets (CoreSubsets) –

  • n_cores (int) – Number of cores being updated

spinn_front_end_common.utilities.utility_objs package
Subpackages
spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages package
Submodules
spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.reinjector_scp_commands module
class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.reinjector_scp_commands.ReinjectorSCPCommands(value)[source]

Bases: Enum

SCP Command codes for reinjection

CLEAR = 6
EXIT = 5
GET_STATUS = 3
RESET_COUNTERS = 4
SET_PACKET_TYPES = 2
SET_ROUTER_WAIT1_TIMEOUT = 0
SET_ROUTER_WAIT2_TIMEOUT = 1
spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.speedup_in_scp_commands module
class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.speedup_in_scp_commands.SpeedupInSCPCommands(value)[source]

Bases: Enum

SCP Command codes for data speed up in.

LOAD_APPLICATION_MC_ROUTES = 7
LOAD_SYSTEM_MC_ROUTES = 8
SAVE_APPLICATION_MC_ROUTES = 6
Module contents
class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.ClearReinjectionQueueMessage(x, y, p)[source]

Bases: AbstractSCPRequest

An SCP Request to set the dropped packet reinjected packet types.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

  • p (int) – The processor running the extra monitor vertex, between 0 and 17

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.GetReinjectionStatusMessage(x, y, p)[source]

Bases: AbstractSCPRequest

An SCP Request to get the status of the dropped packet reinjection.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

  • p (int) – The processor running the extra monitor vertex, between 0 and 17

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.GetReinjectionStatusMessageResponse(command_code)[source]

Bases: AbstractSCPResponse

An SCP response to a request for the dropped packet reinjection status

read_data_bytestring(data, offset)[source]

Reads the remainder of the data following the header.

Parameters:
  • data (bytes) – The byte-string to read from

  • offset (int) – The offset into the data after the headers

property reinjection_functionality_status
class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.LoadApplicationMCRoutesMessage(x, y, p)[source]

Bases: AbstractSCPRequest

An SCP Request to write the application multicast routes into the router.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

  • p (int) – The processor running the extra monitor vertex, between 0 and 17

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.LoadSystemMCRoutesMessage(x, y, p)[source]

Bases: AbstractSCPRequest

An SCP Request to write the system multicast routes into the router.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

  • p (int) – The processor running the extra monitor vertex, between 0 and 17

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.ResetCountersMessage(x, y, p)[source]

Bases: AbstractSCPRequest

An SCP Request to reset the statistics counters of the dropped packet reinjection.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

  • p (int) – The processor running the extra monitor vertex, between 0 and 17

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.SetReinjectionPacketTypesMessage(x, y, p, multicast, point_to_point, fixed_route, nearest_neighbour)[source]

Bases: AbstractSCPRequest

An SCP Request to set the dropped packet reinjected packet types.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

  • p (int) – The processor running the extra monitor vertex, between 0 and 17

  • point_to_point (bool) – If point to point should be set

  • multicast (bool) – If multicast should be set

  • nearest_neighbour (bool) – If nearest neighbour should be set

  • fixed_route (bool) – If fixed route should be set

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_messages.SetRouterTimeoutMessage(x, y, p, timeout_mantissa, timeout_exponent, wait=1)[source]

Bases: AbstractSCPRequest

An SCP Request to the extra monitor core to set the router timeout for dropped packet reinjection.

Parameters:
  • x (int) – The x-coordinate of a chip, between 0 and 255

  • y (int) – The y-coordinate of a chip, between 0 and 255

  • p (int) – The processor running the extra monitor vertex, between 0 and 17

  • timeout_mantissa (int) – The mantissa of the timeout value, between 0 and 15

  • timeout_exponent (int) – The exponent of the timeout value, between 0 and 15

  • wait (int) – Which wait to set. Should be 1 or 2.

get_scp_response()[source]

Get an SCP response message to be used to process any response received.

Returns:

An SCP response, or None if no response is required

Return type:

AbstractSCPResponse

spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_processes package
Module contents
class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_processes.ClearQueueProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: AbstractMultiConnectionProcess

How to send messages to clear the reinjection queue.

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

reset_counters(core_subsets)[source]
Parameters:

core_subsets (CoreSubsets) –

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_processes.LoadApplicationMCRoutesProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: AbstractMultiConnectionProcess

How to send messages to load the saved application multicast routing tables.

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

load_application_mc_routes(core_subsets)[source]
Parameters:

core_subsets (CoreSubsets) – sets of cores to send command to

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_processes.LoadSystemMCRoutesProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: AbstractMultiConnectionProcess

How to send messages to load the configured system multicast routing tables (and save the application routing tables).

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

load_system_mc_routes(core_subsets)[source]
Parameters:

core_subsets (CoreSubsets) – sets of cores to send command to

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_processes.ReadStatusProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: AbstractMultiConnectionProcess

How to send messages to read the status of extra monitors.

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

get_reinjection_status(x, y, p)[source]
Parameters:
Return type:

ReInjectionStatus

get_reinjection_status_for_core_subsets(core_subsets)[source]
Parameters:

core_subsets (CoreSubsets) –

Return type:

dict(tuple(int,int), ReInjectionStatus)

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_processes.ResetCountersProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: AbstractMultiConnectionProcess

How to send messages to clear the reinjection state counters.

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

reset_counters(core_subsets)[source]
Parameters:

core_subsets (CoreSubsets) –

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_processes.SetPacketTypesProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: AbstractMultiConnectionProcess

How to send messages to control what messages are reinjected.

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

set_packet_types(core_subsets, point_to_point, multicast, nearest_neighbour, fixed_route)[source]

Set what types of packets should be reinjected.

Parameters:
  • core_subsets (CoreSubsets) – sets of cores to send command to

  • point_to_point (bool) – If point-to-point should be set

  • multicast (bool) – If multicast should be set

  • nearest_neighbour (bool) – If nearest neighbour should be set

  • fixed_route (bool) – If fixed route should be set

class spinn_front_end_common.utilities.utility_objs.extra_monitor_scp_processes.SetRouterTimeoutProcess(next_connection_selector, n_retries=10, timeout=1.0, n_channels=8, intermediate_channel_waits=7)[source]

Bases: AbstractMultiConnectionProcess

How to send messages to set router timeouts. These messages need to be sent to cores running the extra monitor binary.

Note

SCAMP sets wait2 to zero by default!

Note

Timeouts are specified in a weird floating point format. See the SpiNNaker datasheet for details.

Parameters:
  • next_connection_selector (AbstractMultiConnectionProcessConnectionSelector) – How to choose the connection.

  • n_retries (int) – The number of retries of a message to use. Passed to SCPRequestPipeLine

  • timeout (float) – The timeout, in seconds. Passed to SCPRequestPipeLine

  • n_channels (int) – The maximum number of channels to use when talking to a particular SCAMP instance. Passed to SCPRequestPipeLine

  • intermediate_channel_waits (int) – The maximum number of outstanding message/reply pairs to have on a particular connection. Passed to SCPRequestPipeLine

set_wait1_timeout(mantissa, exponent, core_subsets)[source]

The wait1 timeout is the time from when a packet is received to when emergency routing becomes enabled.

Parameters:
  • mantissa (int) – Timeout mantissa (0 to 15)

  • exponent (int) – Timeout exponent (0 to 15)

  • core_subsets (CoreSubsets) – Where the extra monitors that manage the routers are located.

set_wait2_timeout(mantissa, exponent, core_subsets)[source]

The wait2 timeout is the time from when a packet has emergency routing enabled for it to when it is dropped.

Parameters:
  • mantissa (int) – Timeout mantissa (0 to 15)

  • exponent (int) – Timeout exponent (0 to 15)

  • core_subsets (CoreSubsets) – Where the extra monitors that manage the routers are located.

Module contents
class spinn_front_end_common.utilities.utility_objs.DPRIFlags(value)[source]

Bases: Enum

SCP Dropped Packet Reinjection (DPRI) packet type flags.

FIXED_ROUTE = 8
MULTICAST = 1
NEAREST_NEIGHBOUR = 4
POINT_TO_POINT = 2
class spinn_front_end_common.utilities.utility_objs.ExecutableType[source]

Bases: object

This class is deprecated. Please use spinnman.model.enums.ExecutableType

NO_APPLICATION = 3
RUNNING = 0
SYNC = 1
SYSTEM = 4
USES_SIMULATION_INTERFACE = 2
class spinn_front_end_common.utilities.utility_objs.LivePacketGatherParameters(port=None, hostname=None, tag=None, strip_sdp=True, use_prefix=False, key_prefix=None, prefix_type=None, message_type=EIEIOType.KEY_32_BIT, right_shift=0, payload_as_time_stamps=True, use_payload_prefix=True, payload_prefix=None, payload_right_shift=0, number_of_packets_sent_per_time_step=0, label=None, received_key_mask=4294967295, translate_keys=False, translated_key_right_shift=0)[source]

Bases: object

Parameter holder for LivePacketGatherers so that they can be instantiated at a later date.

Raises:

ConfigurationException – If the parameters passed are known to be an invalid combination.

get_iptag_resource()[source]

Get a description of the IPTag that the LPG for these parameters will require.

Return type:

IPtagResource

property hostname

Where to send data from SpiNNaker: the host name of the listening UDP socket.

Return type:

bool

property key_prefix

The EIEIO key prefix to remove from messages.

Return type:

int

property label

A label.

Return type:

str

property message_type

The type of messages to send.

Return type:

EIEIOType

property number_of_packets_sent_per_time_step

The maximum number of packets to send in a timestep.

Return type:

int

property payload_as_time_stamps

Whether the payloads are timestamps.

Return type:

bool

property payload_prefix

The payload prefix to remove if applying compaction.

Return type:

int

property payload_right_shift

Shift to apply to payloads.

Return type:

int

property port

Where to send data from SpiNNaker: the port of the listening UDP socket.

Return type:

int

property prefix_type

The type of prefix.

Return type:

EIEIOPrefix

property received_key_mask

A mask to select which keys are dispatched.

Return type:

int

property right_shift

Shift to apply to keys.

Return type:

int

property strip_sdp

Whether to remove SDP headers from the messages before sending.

Return type:

bool

property tag

A fixed tag ID to assign, or None if any tag is OK

Return type:

int or None

property translate_keys

Whether to apply translation to keys.

Return type:

bool

property translated_key_right_shift

Shift to apply in key translation.

Return type:

int

property use_payload_prefix

Whether to use prefix compaction for payloads.

Return type:

bool

property use_prefix

Whether to use EIEIO prefix compaction on keys.

Return type:

bool

class spinn_front_end_common.utilities.utility_objs.PowerUsed[source]

Bases: object

Describes the power used by a simulation.

property active_cores

Enumeration of the coordinates of the cores that can report active energy usage.

Return type:

iterable(tuple(int, int, int))

property active_routers

Enumeration of the coordinates of the routers that can report active energy usage.

Return type:

iterable(tuple(int, int))

add_core_active_energy(x, y, p, joules)[source]

Adds energy for a particular core. It can be called multiple times per core.

Only intended to be used during construction of this object.

Parameters:
  • x (int) –

  • y (int) –

  • p (int) –

  • joules (float) – the energy to add for this core, in Joules.

add_router_active_energy(x, y, joules)[source]

Adds energy for a particular router. It can be called multiple times per router.

Only intended to be used during construction of this object.

Parameters:
  • x (int) –

  • y (int) –

  • joules (float) – the energy to add for this router, in Joules.

property baseline_joules

Baseline/idle energy used, in Joules. This is used by things like the frames the SpiNNaker boards are held in, the cooling system, etc.

Return type:

float

property booted_time_secs

Time taken when the machine is booted, in seconds.

Return type:

float

property chip_energy_joules

Energy used by all SpiNNaker chips during active simulation running, in Joules.

Return type:

float

property data_gen_joules

Energy used during the data generation phase, in Joules. Assumes that the SpiNNaker system has been shut down.

Return type:

float

property data_gen_time_secs

Time taken by data generation phase, in seconds.

Return type:

float

property exec_time_secs

Time taken by active simulation running, in seconds.

Return type:

float

property fpga_exec_energy_joules

Energy used by all FPGAs during active simulation running, in Joules. This is included in the total FPGA energy.

Return type:

float

property fpga_total_energy_joules

Energy used by all FPGAs in total, in Joules.

Return type:

float

get_core_active_energy_joules(x, y, p)[source]

Energy used (above idle baseline) by a particular core, in Joules.

Unused cores always report 0.0 for this.

Parameters:
Return type:

float

get_router_active_energy_joules(x, y)[source]

Energy used (above idle baseline) by a particular router, in Joules.

Unused routers always report 0.0 for this.

Parameters:
Return type:

float

property loading_joules

Energy used during data loading, in Joules.

Return type:

float

property loading_time_secs

Time taken by data loading, in seconds.

Return type:

float

property mapping_joules

Energy used during the mapping phase, in Joules. Assumes that the SpiNNaker system has been shut down.

Return type:

float

property mapping_time_secs

Time taken by the mapping phase, in seconds.

Return type:

float

property num_chips

The total number of chips used.

Return type:

int

property num_cores

The total number of cores used, including for SCAMP.

Return type:

int

property num_fpgas

The total number of FPGAs used.

Return type:

int

property num_frames

The total number of frames used.

Return type:

int

property packet_joules

Energy used by packet transmission, in Joules.

Return type:

float

property saving_joules

Energy used during data extraction, in Joules.

Return type:

float

property saving_time_secs

Time taken by data extraction, in seconds.

Return type:

float

property total_energy_joules

Total of all energy costs, in Joules.

Return type:

float

property total_time_secs

Time taken in total, in seconds.

Return type:

float

class spinn_front_end_common.utilities.utility_objs.ReInjectionStatus(data, offset)[source]

Bases: object

Represents a status information report from dropped packet reinjection.

Parameters:
  • data (bytes) – The data containing the information

  • offset (int) – The offset in the data where the information starts

property is_reinjecting_fixed_route

True if re-injection of fixed-route packets is enabled.

Return type:

bool

property is_reinjecting_multicast

True if re-injection of multicast packets is enabled.

Return type:

bool

property is_reinjecting_nearest_neighbour

True if re-injection of nearest neighbour packets is enabled.

Return type:

bool

property is_reinjecting_point_to_point

True if re-injection of point-to-point packets is enabled.

Return type:

bool

property n_dropped_packet_overflows

Of the n_dropped_packets received, how many were lost due to not having enough space in the queue of packets to reinject.

Return type:

int

property n_dropped_packets

The number of packets dropped by the router and received by the reinjection functionality (may not fit in the queue though).

Return type:

int

The number of times that when a dropped packet was caused due to a link failing to take the packet.

Return type:

int

property n_missed_dropped_packets

The number of times that when a dropped packet was read it was found that another one or more packets had also been dropped, but had been missed.

Return type:

int

property n_processor_dumps

The number of times that when a dropped packet was caused due to a processor failing to take the packet.

Return type:

int

property n_reinjected_packets

Of the n_dropped_packets received, how many packets were successfully re-injected.

Return type:

int

property processors_dropped_from
property router_wait1_timeout

The WAIT1 timeout value of the router, in cycles.

Return type:

int

property router_wait1_timeout_parameters

The WAIT1 timeout value of the router as mantissa and exponent.

Return type:

tuple(int,int)

property router_wait2_timeout

The WAIT2 timeout value of the router, in cycles.

Return type:

int

property router_wait2_timeout_parameters

The WAIT2 timeout value of the router as mantissa and exponent.

Return type:

tuple(int,int)

Submodules
spinn_front_end_common.utilities.base_database module
class spinn_front_end_common.utilities.base_database.BaseDatabase(database_file=None, *, read_only=False, row_factory=<class 'sqlite3.Row'>, text_factory=<class 'memoryview'>)[source]

Bases: SQLiteDB, AbstractContextManager

Specific implementation of the Database for SQLite 3.

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.

If 2 database objects where opened with the database_file they hold the same data. Unless someone else deletes that file.

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 the default location will be used.

classmethod default_database_file()[source]
spinn_front_end_common.utilities.constants module
spinn_front_end_common.utilities.constants.BIT_FIELD_COMMS_SDRAM_TAG = 2

SDRAM Tags used for bitfield compressor

class spinn_front_end_common.utilities.constants.BUFFERING_OPERATIONS(value)[source]

Bases: Enum

A listing of what SpiNNaker specific EIEIO commands there are.

BUFFER_READ = 0

Database handshake with external program

BUFFER_WRITE = 1

Host confirming data being read form SpiNNaker memory

spinn_front_end_common.utilities.constants.CLOCKS_PER_US = 200

The number of clock cycles per micro-second (at 200Mhz)

spinn_front_end_common.utilities.constants.COMPRESSOR_SDRAM_TAG = 1

SDRAM Tag used by the compressor to find the routing tables

spinn_front_end_common.utilities.constants.CORE_DATA_SDRAM_BASE_TAG = 200

Base SDRAM tag used by cores when loading data (tags 201-217 will be used by cores 1-17)

spinn_front_end_common.utilities.constants.DATA_SPECABLE_BASIC_SETUP_INFO_N_BYTES = 400

The number of words in the AbstractDataSpecable basic setup information. This is the amount required by the pointer table plus a SARK allocation.

spinn_front_end_common.utilities.constants.DEFAULT_BUFFER_SIZE_BEFORE_RECEIVE = 16384

The default size of a recording buffer before receive request is sent

spinn_front_end_common.utilities.constants.DSE_DATA_STRUCT_SIZE = 16

size of the on-chip DSE data structure required, in bytes

spinn_front_end_common.utilities.constants.MAX_DATABASE_PATH_LENGTH = 50000

Database file path maximum length for database notification messages. Note that this is not sent to SpiNNaker and so is not subject to the usual SDP limit.

spinn_front_end_common.utilities.constants.MAX_POSSIBLE_BINARY_SIZE = 33792

the ITCM max limit for a binary

spinn_front_end_common.utilities.constants.MAX_SAFE_BINARY_SIZE = 32768

the ITCM max safe limit for a binary

spinn_front_end_common.utilities.constants.MAX_SIZE_OF_BUFFERED_REGION_ON_CHIP = 1048576

max size expected to be used by the reverse ip_tag multicast source during buffered operations.

spinn_front_end_common.utilities.constants.NOTIFY_PORT = 19999

The default local port that the toolchain listens on for the notification protocol.

spinn_front_end_common.utilities.constants.PARTITION_ID_FOR_MULTICAST_DATA_SPEED_UP = 'DATA_SPEED_UP_ROAD'

partition IDs preallocated to functionality

spinn_front_end_common.utilities.constants.SARK_PER_MALLOC_SDRAM_USAGE = 8

The number of bytes used by SARK per memory allocation

class spinn_front_end_common.utilities.constants.SDP_PORTS(value)[source]

Bases: Enum

SDP port handling output buffering data streaming.

EXTRA_MONITOR_CORE_DATA_IN_SPEED_UP = 6

Extra monitor core inbound data transfer protocol See SpeedupInSCPCommands

EXTRA_MONITOR_CORE_DATA_SPEED_UP = 5

Extra monitor core outbound data transfer protocol

EXTRA_MONITOR_CORE_REINJECTION = 4

Extra monitor core reinjection control protocol. See ReinjectorSCPCommands

INPUT_BUFFERING_SDP_PORT = 1

Command port for the buffered in functionality.

OUTPUT_BUFFERING_SDP_PORT = 2

Command port for the buffered out functionality.

RUNNING_COMMAND_SDP_PORT = 3

Command port for resetting runtime, etc. See SDP_RUNNING_MESSAGE_CODES

class spinn_front_end_common.utilities.constants.SDP_RUNNING_MESSAGE_CODES(value)[source]

Bases: Enum

Codes for sending control messages to spin1_api.

SDP_CLEAR_IOBUF_CODE = 9
SDP_NEW_RUNTIME_ID_CODE = 7
SDP_STOP_ID_CODE = 6
SDP_UPDATE_PROVENCE_REGION_AND_EXIT = 8
spinn_front_end_common.utilities.constants.SDRAM_BASE_ADDR = 1879048192

start of where SDRAM starts (either unbuffered or buffered)

spinn_front_end_common.utilities.constants.SDRAM_EDGE_BASE_TAG = 100

Base SDRAM tag used by SDRAM edges when allocating (allows up to 100 edges per chip)

spinn_front_end_common.utilities.constants.SIMULATION_N_BYTES = 12

The number of bytes used by the simulation interface. This is one word for the machine_time_step, one for the SDP port, and one for the application hash.

spinn_front_end_common.utilities.constants.SYSTEM_BYTES_REQUIREMENT = 412

The number of bytes used by the DSG and simulation interfaces

spinn_front_end_common.utilities.emergency_recovery module
spinn_front_end_common.utilities.emergency_recovery.emergency_recover_state_from_failure(vertex, placement)[source]

Used to get at least some information out of a core when something goes badly wrong. Not a replacement for what abstract spinnaker base does.

Parameters:
spinn_front_end_common.utilities.emergency_recovery.emergency_recover_states_from_failure()[source]

Used to get at least some information out of a core when something goes badly wrong. Not a replacement for what abstract spinnaker base does.

Parameters:

executable_targets (ExecutableTargets) – The what/where mapping

spinn_front_end_common.utilities.exceptions module
exception spinn_front_end_common.utilities.exceptions.BufferableRegionTooSmall[source]

Bases: SpinnFrontEndException

Raised when the SDRAM space of the region for buffered packets is too small to contain any packet at all.

exception spinn_front_end_common.utilities.exceptions.BufferedRegionNotPresent[source]

Bases: SpinnFrontEndException

Raised when trying to issue buffered packets for a region not managed.

exception spinn_front_end_common.utilities.exceptions.CantFindSDRAMToUseException[source]

Bases: SpinnFrontEndException

Raised when malloc and SDRAM stealing cannot occur.

exception spinn_front_end_common.utilities.exceptions.ConfigurationException[source]

Bases: SpinnFrontEndException

Raised when the front end determines a input parameter is invalid.

exception spinn_front_end_common.utilities.exceptions.DsDatabaseException[source]

Bases: SpinnFrontEndException

Raise when a query in the Data Specification database failed.

exception spinn_front_end_common.utilities.exceptions.ExecutableFailedToStartException[source]

Bases: SpinnFrontEndException

Raised when an executable has not entered the expected state during start up.

exception spinn_front_end_common.utilities.exceptions.ExecutableFailedToStopException[source]

Bases: SpinnFrontEndException

Raised when an executable has not entered the expected state during execution.

exception spinn_front_end_common.utilities.exceptions.ExecutableNotFoundException[source]

Bases: SpinnFrontEndException

Raised when a specified executable could not be found.

exception spinn_front_end_common.utilities.exceptions.RallocException[source]

Bases: SpinnFrontEndException

Raised when there are not enough routing table entries.

exception spinn_front_end_common.utilities.exceptions.SpinnFrontEndException[source]

Bases: Exception

Raised when the front end detects an error.

spinn_front_end_common.utilities.helpful_functions module
spinn_front_end_common.utilities.helpful_functions.convert_string_into_chip_and_core_subset(cores)[source]

Translate a string list of cores into a core subset.

Parameters:

cores (str or None) – string representing down cores formatted as x,y,p[:x,y,p]*

Return type:

CoreSubsets

spinn_front_end_common.utilities.helpful_functions.convert_vertices_to_core_subset(vertices)[source]

Converts vertices into core subsets.

Parameters:

vertices (iterable(MachineVertex)) – the vertices to convert to core subsets

Returns:

the CoreSubSets of the vertices

Return type:

CoreSubsets

spinn_front_end_common.utilities.helpful_functions.determine_flow_states(executable_types, no_sync_changes)[source]

Get the start and end states for these executable types.

Parameters:
  • executable_types (dict(ExecutableType,any)) – the execute types to locate start and end states from

  • no_sync_changes (int) – the number of times sync signals been sent

Returns:

dict of executable type to states.

Return type:

tuple(dict(ExecutableType,CPUState), dict(ExecutableType,CPUState))

spinn_front_end_common.utilities.helpful_functions.flood_fill_binary_to_spinnaker(binary)[source]

Flood fills a binary to SpiNNaker.

Parameters:

binary (str) – The name of the file containing the APLX binary to load

Returns:

the number of cores it was loaded onto

Return type:

int

spinn_front_end_common.utilities.helpful_functions.generate_unique_folder_name(folder, filename, extension)[source]

Generate a unique file name with a given extension in a given folder.

Parameters:
  • folder (str) – where to put this unique file

  • filename (str) – the name of the first part of the file without extension

  • extension (str) – extension of the file

Returns:

file path with a unique addition

Return type:

str

spinn_front_end_common.utilities.helpful_functions.get_defaultable_source_id(entry)[source]

Hack to support the source requirement for the router compressor on chip.

Parameters:

entry (MulticastRoutingEntry) – the multicast router table entry.

Returns:

return the source value

Return type:

int

spinn_front_end_common.utilities.helpful_functions.get_ethernet_chip(machine, board_address)[source]

Locate the chip with the given board IP address.

Parameters:
  • machine (Machine) – the SpiNNaker machine

  • board_address (str) – the board address to locate the chip of.

Returns:

The chip that supports that board address

Return type:

Chip

Raises:

ConfigurationException – when that board address has no chip associated with it

spinn_front_end_common.utilities.helpful_functions.get_region_base_address_offset(app_data_base_address, region)[source]

Find the address of the of a given region for the DSG.

Parameters:
  • app_data_base_address (int) – base address for the core

  • region (int) – the region ID we’re looking for

spinn_front_end_common.utilities.helpful_functions.locate_extra_monitor_mc_receiver(placement_x, placement_y)[source]

Get the data speed up gatherer that can be used to talk to a particular chip. This will be on the same board.

Parameters:
  • placement_x (int) – The X coordinate of the reference chip

  • placement_y (int) – The Y coordinate of the reference chip

Return type:

DataSpeedUpPacketGatherMachineVertex

spinn_front_end_common.utilities.helpful_functions.locate_memory_region_for_placement(placement, region)[source]

Get the address of a region for a placement.

Parameters:
  • region (int) – the region to locate the base address of

  • placement (Placement) – the placement object to get the region address of

  • transceiver (Transceiver) – the python interface to the SpiNNaker machine

Returns:

the address

Return type:

int

spinn_front_end_common.utilities.helpful_functions.n_word_struct(n_words)[source]

Manages a precompiled cache of :py:class`~struct.Struct`s for parsing blocks of words. Thus, this:

data = n_word_struct(n_words).unpack(data_blob)

Is much like doing this:

data = struct.unpack(f"<{n_words}I", data_blob)

except quite a bit more efficient because things are shared including the cost of parsing the format.

Parameters:

n_words (int) – The number of SpiNNaker words to be handled.

Returns:

A struct for working with that many words.

Return type:

Struct

spinn_front_end_common.utilities.helpful_functions.read_data(x, y, address, length, data_format)[source]

Reads and converts a single data item from memory.

Parameters:
  • x (int) – chip x

  • y (int) – chip y

  • address (int) – base address of the SDRAM chip to read

  • length (int) – length to read

  • data_format (str) – the format to read memory (see struct.pack())

Returns:

whatever is produced by unpacking the data

Return type:

tuple

spinn_front_end_common.utilities.helpful_functions.write_address_to_user0(x, y, p, address)[source]

Writes the given address into the user_0 register of the given core.

Parameters:
  • x (int) – Chip coordinate.

  • y (int) – Chip coordinate.

  • p (int) – Core ID on chip.

  • address (int) – Value to write (32-bit integer)

spinn_front_end_common.utilities.helpful_functions.write_address_to_user1(x, y, p, address)[source]

Writes the given address into the user_1 register of the given core.

Parameters:
  • x (int) – Chip coordinate.

  • y (int) – Chip coordinate.

  • p (int) – Core ID on chip.

  • address (int) – Value to write (32-bit integer)

spinn_front_end_common.utilities.iobuf_extractor module
class spinn_front_end_common.utilities.iobuf_extractor.IOBufExtractor(executable_targets=None, recovery_mode=False, filename_template='iobuf_for_chip_{}_{}_processor_id_{}.txt', suppress_progress=False)[source]

Bases: object

Extract the logging output buffers from the machine, and separates lines based on their prefix.

Parameters:
  • recovery_mode (bool) –

  • filename_template (str) –

  • suppress_progress (bool) –

  • executable_targets (ExecutableTargets or None) – Which Binaries and core to extract from. None to extract from all.

  • from_cores (str) –

  • binary_types (str) –

extract_iobuf()[source]

Perform the extraction of IOBUF.

Returns:

error_entries, warn_entries

Return type:

tuple(list(str),list(str))

spinn_front_end_common.utilities.math_constants module

random math constants

spinn_front_end_common.utilities.sqlite_db module
class spinn_front_end_common.utilities.sqlite_db.Isolation(value)[source]

Bases: Enum

Transaction isolation levels for SQLiteDB.transaction().

DEFERRED = 'DEFERRED'

Standard transaction type; postpones holding a lock until required.

EXCLUSIVE = 'EXCLUSIVE'

Take a write lock immediately. This is the strongest lock type.

IMMEDIATE = 'IMMEDIATE'

Take the lock immediately; this may be a read-lock that gets upgraded.

class spinn_front_end_common.utilities.sqlite_db.SQLiteDB(database_file=None, *, read_only=False, ddl_file=None, row_factory=<class 'sqlite3.Row'>, text_factory=<class 'memoryview'>, case_insensitive_like=True)[source]

Bases: AbstractContextManager

General support class for SQLite databases. This handles a lot of the low-level detail of setting up a connection.

Basic usage (with the default row type):

with SQLiteDB("db_file.sqlite3") as db:
    with db.transaction() as cursor:
        for row in cursor.execute("SELECT thing FROM ..."):
            print(row["thing"])

This class is designed to be either used as above or by subclassing. See the SQLite SQL documentation for details of how to write queries, and the Python sqlite3 module for how to do parameter binding.

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 (suitable only for testing).

  • read_only (bool) – Whether the database is in read-only mode. When the database is in read-only mode, it must already exist.

  • ddl_file (str or None) – The name of a file (typically containing SQL DDL commands used to create the tables) to be evaluated against the database before this object completes construction. If None, nothing will be evaluated. You probably don’t want to specify a DDL file at the same time as setting read_only=True.

  • row_factory (Callable or None) – Callable used to create the rows of result sets. Either tuple or sqlite3.Row (default); can be None to use the DB driver default.

  • text_factory (Callable or None) – Callable used to create the Python values of non-numeric columns in result sets. Usually memoryview (default) but should be str when you’re expecting string results; can be None to use the DB driver default.

  • case_insensitive_like (bool) – Whether we want the LIKE matching operator to be case-sensitive or case-insensitive (default).

close()[source]

Finalises and closes the database.

property connection

The underlying SQLite database connection.

Warning

If you’re using this a lot, consider contacting the SpiNNaker Software Team with details of your use case so we can extend the relevant core class to support you. Normally it is better to use transaction() to obtain a cursor with appropriate transactional guards.

Return type:

Connection

Raises:

AttributeError – if the database connection has been closed

pragma(pragma_name, value)[source]

Set a database PRAGMA. See the SQLite PRAGMA documentation for details.

Parameters:
  • pragma_name (str) – The name of the pragma to set.

  • value (bool or int or str) – The value to set the pragma to.

transaction(isolation_level=None)[source]

Get a context manager that manages a transaction on the database. The value of the context manager is a Cursor. This means you can do this:

with db.transaction() as cursor:
    cursor.execute(...)
Parameters:

isolation_level (Isolation) –

The transaction isolation level.

Note

This sets it for the connection! Can usually be not specified.

Return type:

ContextManager(Cursor)

spinn_front_end_common.utilities.system_control_logic module
spinn_front_end_common.utilities.system_control_logic.run_system_application(executable_cores, app_id, read_algorithm_iobuf, check_for_success_function, cpu_end_states, needs_sync_barrier, filename_template, binaries_to_track=None, progress_bar=None, logger=None, timeout=None)[source]

Executes the given _system_ application. Used for on-chip expanders, compressors, etc.

Parameters:
  • executable_cores (ExecutableTargets) – the cores to run the executable on.

  • app_id (int) – the app-id for the executable

  • read_algorithm_iobuf (bool) – whether to report IOBUFs

  • check_for_success_function (callable) – function used to check success; expects executable_cores, transceiver as inputs

  • cpu_end_states (set(CPUState)) – the states that a successful run is expected to terminate in

  • needs_sync_barrier (bool) – whether a sync barrier is needed

  • filename_template (str) – the IOBUF filename template.

  • binaries_to_track (list(str)) – A list of binary names to check for exit state. Or None for all binaries

  • progress_bar (ProgressBar or None) – Possible progress bar to update. end() will be called after state checked

  • logger (Logger) – If provided and IOBUF is extracted, will be used to log errors and warnings

  • timeout (float or None) – Number of seconds to wait before force stopping, or None to wait forever

Raises:

SpinnmanException – If one should arise from the underlying SpiNNMan calls

spinn_front_end_common.utilities.utility_calls module

Utility calls for interpreting bits of the DSG

spinn_front_end_common.utilities.utility_calls.get_data_spec_and_file_writer_filename(processor_chip_x, processor_chip_y, processor_id, application_run_time_report_folder='TEMP')[source]

Encapsulates the creation of the DSG writer and the file paths.

Parameters:
  • processor_chip_x (int) – X coordinate of the chip

  • processor_chip_y (int) – Y coordinate of the chip

  • processor_id (int) – The processor ID

  • application_run_time_report_folder (str) – The folder to contain the resulting specification files; if TEMP then a temporary directory is used.

Returns:

the filename of the data writer and the data specification object

Return type:

tuple(str, DataSpecificationGenerator)

spinn_front_end_common.utilities.utility_calls.get_region_base_address_offset(app_data_base_address, region)[source]

Find the address of the of a given region for the DSG.

Parameters:
  • app_data_base_address (int) – base address for the core

  • region (int) – the region ID we’re looking for

spinn_front_end_common.utilities.utility_calls.get_report_writer(processor_chip_x, processor_chip_y, processor_id)[source]

Check if text reports are needed, and if so initialise the report writer to send down to DSG.

Parameters:
  • processor_chip_x (int) – X coordinate of the chip

  • processor_chip_y (int) – Y coordinate of the chip

  • processor_id (int) – The processor ID

Returns:

the report_writer_object, or None if not reporting

Return type:

FileIO or None

spinn_front_end_common.utilities.utility_calls.open_scp_connection(chip_x, chip_y, chip_ip_address)[source]

Create an SCP connection to the given Ethernet-enabled chip. SpiNNaker will not be configured to map that connection to a tag; that is the caller’s responsibility.

Parameters:
  • chip_x (int) – X coordinate of the Ethernet-enabled chip to connect to.

  • chip_y (int) – Y coordinate of the Ethernet-enabled chip to connect to.

  • chip_ip_address (str) – IP address of the Ethernet-enabled chip to connect to.

Return type:

SCAMPConnection

spinn_front_end_common.utilities.utility_calls.parse_old_spalloc(spalloc_server, spalloc_port=22244, spalloc_user='unknown user')[source]

Parse a URL to the old-style service. This may take the form:

spalloc://user@spalloc.host.example.com:22244

The leading spalloc:// is the mandatory part (as is the actual host name). If the port and user are omitted, the defaults given in the other arguments are used (or default defaults).

A bare hostname can be used instead. If that’s the case (i.e., there’s no spalloc:// prefix) then the port and user are definitely used.

Parameters:
  • spalloc_server (str) – Hostname or URL

  • spalloc_port (int) – Default port

  • spalloc_user (str) – Default user

Returns:

hostname, port, username

Return type:

tuple(str,int,str)

spinn_front_end_common.utilities.utility_calls.retarget_tag(connection, x, y, tag, ip_address=None, strip=True)[source]

Make a tag deliver to the given connection.

Parameters:
  • connection (UDPConnection) – The connection to deliver to.

  • x (int) – The X coordinate of the Ethernet-enabled chip we are sending the message to.

  • y (int) – The Y coordinate of the Ethernet-enabled chip we are sending the message to.

  • tag (int) – The ID of the tag to retarget.

  • ip_address (str) – What IP address to send the message to. If None, the connection is assumed to be connected to a specific board already.

  • strip (bool) – Whether the tag should strip the SDP header before sending to the connection.

Module contents
spinn_front_end_common.utility_models package
Submodules
spinn_front_end_common.utility_models.lpg_splitter module
class spinn_front_end_common.utility_models.lpg_splitter.LPGSplitter[source]

Bases: AbstractSplitterCommon

Splitter for the LivePacketGather vertex.

create_machine_vertices(chip_counter)[source]

Method for specific splitter objects to override.

Parameters:

chip_counter (ChipCounter) – counter of used chips

create_vertices(system_placements)[source]

Special way of making LPG machine vertices, where one is placed on each Ethernet-enabled chip.

Note

This adds to system placements.

get_in_coming_slices()[source]

The slices of the input vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_in_coming_vertices(partition_id)[source]

Get machine post-vertices for a given partition.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method returns all that could be used for any source machine vertex in the given partition.

Parameters:

partition_id (str) – The identifier of the incoming partition

Return type:

list(MachineVertex)

get_out_going_slices()[source]

The slices of the output vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_out_going_vertices(partition_id)[source]

Get machine pre-vertices.

The output vertices are the ones that will serve as source vertices for external edges.

Parameters:

partition_id (str) – The identifier of the outgoing partition

Return type:

list(MachineVertex)

get_source_specific_in_coming_vertices(source_vertex, partition_id)[source]

Get machine post-vertices for a given source.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method allows filtering of the targets for a specific source machine vertex.

This default method makes every machine vertex a target for the source. This should be overridden if there are specific machine vertices for any given source vertex.

Parameters:
  • source_vertex (ApplicationVertex) – The source to get incoming vertices for

  • partition_id (str) – The identifier of the incoming partition

Returns:

A list of tuples of (target machine vertex, list of source machine or application vertices that should hit the target)

Return type:

list(tuple(MachineVertex, list(MachineVertex or ApplicationVertex)))

machine_vertices_for_recording(variable_to_record)[source]

Gets the machine vertices which are recording this variable.

Parameters:

variable_to_record (str) – the variable to get machine vertices for.

Returns:

list of machine vertices

Return type:

iterable(MachineVertex)

reset_called()[source]

Reset the splitter to be as if it has not operated a splitting yet.

property targeted_lpgs

Which LPG machine vertex is targeted by which machine vertex and partition.

Returns:

A set of (LPG machine vertex, source machine vertex, partition_id)

Return type:

set(tuple(LivePacketGatherMachineVertex, MachineVertex, str))

Module contents
class spinn_front_end_common.utility_models.ChipPowerMonitorMachineVertex(label, sampling_frequency)[source]

Bases: MachineVertex, AbstractHasAssociatedBinary, AbstractGeneratesDataSpecification, AbstractReceiveBuffersToHost

Machine vertex for C code representing functionality to record idle times in a machine graph.

Note

This is an unusual machine vertex, in that it has no associated application vertex.

Parameters:
  • label (str) – vertex label

  • sampling_frequency (int) – how often to sample, in microseconds

static binary_file_name()[source]

Get the filename of the binary.

Return type:

str

static binary_start_type()[source]

The type of binary that implements this vertex.

Returns:

start-type

Return type:

ExecutableType

generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

get_recorded_data(placement)[source]

Get data from SDRAM given placement and buffer manager. Also arranges for provenance data to be available.

Parameters:

placement (Placement) – the location on machine to get data from

Returns:

results, an array with 1 dimension of uint32 values

Return type:

ndarray

get_recorded_region_ids()[source]

Get the recording region IDs that have been recorded using buffering.

Returns:

The region numbers that have active recording

Return type:

iterable(int)

get_recording_region_base_address(placement)[source]

Get the recording region base address.

Parameters:

placement (Placement) – the placement object of the core to find the address of

Returns:

the base address of the recording region

Return type:

int

static get_resources(sampling_frequency)[source]

Get the resources used by this vertex.

Parameters:

sampling_frequency (float) –

Return type:

VariableSDRAM

property sampling_frequency

How often to sample, in microseconds.

Return type:

int

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

class spinn_front_end_common.utility_models.CommandSender(label)[source]

Bases: AbstractOneAppOneMachineVertex

A utility for sending commands to a vertex (possibly an external device) at fixed times in the simulation or in response to simulation events (e.g., starting and stopping).

Parameters:

label (str) – The label of this vertex

add_commands(start_resume_commands, pause_stop_commands, timed_commands, vertex_to_send_to)[source]

Add commands to be sent down a given edge.

Parameters:
  • start_resume_commands (iterable(MultiCastCommand)) – The commands to send when the simulation starts or resumes from pause

  • pause_stop_commands (iterable(MultiCastCommand)) – The commands to send when the simulation stops or pauses after running

  • timed_commands (iterable(MultiCastCommand)) – The commands to send at specific times

  • vertex_to_send_to (AbstractVertex) – The vertex these commands are to be sent to

edges_and_partitions()[source]

Construct application edges from this vertex to the app vertices that this vertex knows how to target (and has keys allocated for).

Returns:

edges, partition IDs

Return type:

tuple(list(ApplicationEdge), list(str))

get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

class spinn_front_end_common.utility_models.CommandSenderMachineVertex(label, app_vertex=None)[source]

Bases: MachineVertex, ProvidesProvenanceDataFromMachineImpl, AbstractHasAssociatedBinary, AbstractGeneratesDataSpecification

Machine vertex for injecting packets at particular times or in response to particular events into a SpiNNaker application.

Parameters:
BINARY_FILE_NAME = 'command_sender_multicast_source.aplx'
class DATA_REGIONS(value)[source]

Bases: IntEnum

An enumeration.

COMMANDS_AT_START_RESUME = 2
COMMANDS_AT_STOP_PAUSE = 3
COMMANDS_WITH_ARBITRARY_TIMES = 1
PROVENANCE_REGION = 4
SYSTEM_REGION = 0
add_commands(start_resume_commands, pause_stop_commands, timed_commands, vertex_to_send_to)[source]

Add commands to be sent down a given edge.

Parameters:
  • start_resume_commands (iterable(MultiCastCommand)) – The commands to send when the simulation starts or resumes from pause

  • pause_stop_commands (iterable(MultiCastCommand)) – the commands to send when the simulation stops or pauses after running

  • timed_commands (iterable(MultiCastCommand)) – The commands to send at specific times

  • vertex_to_send_to (AbstractVertex) – The vertex these commands are to be sent to

edges_and_partitions()[source]

Construct machine edges from this vertex to the machine vertices that this vertex knows how to target (and has keys allocated for).

Returns:

edges, partition IDs

Return type:

tuple(list(MachineEdge), list(str))

generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

get_edges_and_partitions(pre_vertex, vertex_type, edge_type)[source]

Construct edges from this vertex to the vertices that this vertex knows how to target (and has keys allocated for).

Note

Do not call this directly from outside either a CommandSender or a CommandSenderMachineVertex.

Parameters:
Returns:

edges, partition IDs

Return type:

tuple(list(AbstractEdge), list(str))

get_fixed_key_and_mask(partition_id)[source]

Get the key and mask for the given partition.

Parameters:

partition_id (str) – The partition to get the key for

Return type:

BaseKeyAndMask

classmethod get_n_command_bytes(commands)[source]
Parameters:

commands (list(MultiCastCommand)) –

Return type:

int

get_timed_commands_bytes()[source]
Return type:

int

parse_extra_provenance_items(label, x, y, p, provenance_data)[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) – The list of words of raw provenance data.

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

class spinn_front_end_common.utility_models.DataSpeedUpPacketGatherMachineVertex(x, y, ip_address)[source]

Bases: MachineVertex, AbstractGeneratesDataSpecification, AbstractHasAssociatedBinary, AbstractProvidesProvenanceDataFromMachine

Machine vertex for handling fast data transfer between host and SpiNNaker. This machine vertex is only ever placed on chips with a working Ethernet connection; it collaborates with the ExtraMonitorSupportMachineVertex to write data on other chips.

Note

This is an unusual machine vertex, in that it has no associated application vertex.

Parameters:
  • x (int) – Where this gatherer is.

  • y (int) – Where this gatherer is.

  • ip_address (str) – How to talk directly to the chip where the gatherer is.

BASE_KEY = 4294967289

base key (really nasty hack to tie in fixed route keys)

BASE_MASK = 4294967291

to use with multicast stuff (reinjection acks have to be fixed route)

END_FLAG_KEY = 4294967286
END_FLAG_KEY_OFFSET = 3
FIRST_DATA_KEY = 4294967287
FIRST_DATA_KEY_OFFSET = 2
FLAG_FOR_MISSING_ALL_SEQUENCES = 4294967294
IN_REPORT_NAME = 'speeds_gained_in_speed_up_process.rpt'

report name for tracking performance gains

NEW_SEQ_KEY = 4294967288
NEW_SEQ_KEY_OFFSET = 1
OUT_REPORT_NAME = 'routers_used_in_speed_up_process.rpt'

report name for tracking used routers

TRANSACTION_ID_KEY = 4294967285
TRANSACTION_ID_KEY_OFFSET = 4
calculate_max_seq_num()[source]

Deduce the max sequence number expected to be received.

Returns:

the biggest sequence number expected

Return type:

int

clear_reinjection_queue()[source]

Clears the queues for reinjection.

Parameters:

placements (Placements) – the placements object

generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

get_data(extra_monitor, placement, memory_address, length_in_bytes)[source]

Gets data from a given core and memory address.

Parameters:
  • extra_monitor (ExtraMonitorSupportMachineVertex) – the extra monitor used for this data

  • placement (Placement) – placement object for where to get data from

  • memory_address (int) – the address in SDRAM to start reading from

  • length_in_bytes (int) – the length of data to read in bytes

Returns:

byte array of the data

Return type:

bytearray

get_provenance_data_from_machine(placement)[source]

Get an iterable of provenance data items.

Parameters:

placement (Placement) – the placement of the object

Return type:

iterable

property iptags

The IPTags used by this vertex, if any.

Return type:

iterable(IPtagResource)

static load_application_routing_tables()[source]

Set all chips to have application table loaded in the router.

static load_system_routing_tables()[source]

Set all chips to have the system table loaded in the router.

static locate_correct_write_data_function_for_chip_location(uses_advanced_monitors, x, y, transceiver, extra_monitor_cores_to_ethernet_connection_map)[source]

Supports other components figuring out which gatherer and function to call for writing data onto SpiNNaker.

Parameters:
  • uses_advanced_monitors (bool) – Whether the system is using advanced monitors

  • x (int) – the chip x coordinate to write data to

  • y (int) – the chip y coordinate to write data to

  • transceiver (Transceiver) – the SpiNNMan instance

  • extra_monitor_cores_to_ethernet_connection_map (dict(tuple(int,int), DataSpeedUpPacketGatherMachineVertex)) – mapping between cores and connections

Returns:

a write function of either a LPG or the spinnMan

Return type:

callable

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

send_data_into_spinnaker(x, y, base_address, data, n_bytes=None, offset=0, cpu=0, is_filename=False)[source]

Sends a block of data into SpiNNaker to a given chip.

Parameters:
  • x (int) – chip x for data

  • y (int) – chip y for data

  • base_address (int) – the address in SDRAM to start writing memory

  • data (bytes or bytearray or memoryview or str) – the data to write (or filename to load data from, if is_filename is True; that’s the only time this is a str)

  • n_bytes (int) – how many bytes to read, or None if not set

  • offset (int) – where in the data to start from

  • cpu (int) –

  • is_filename (bool) – whether data is actually a file.

set_cores_for_data_streaming()[source]

Helper method for setting the router timeouts to a state usable for data streaming.

set_router_wait1_timeout(timeout)[source]

Set the wait1 field for a set of routers.

Parameters:
set_router_wait2_timeout(timeout)[source]

Set the wait2 field for a set of routers.

Parameters:

timeout (tuple(int,int)) –

unset_cores_for_data_streaming()[source]

Helper method for restoring the router timeouts to normal after being in a state usable for data streaming.

update_transaction_id_from_machine()[source]

Looks up from the machine what the current transaction ID is and updates the data speed up gatherer.

class spinn_front_end_common.utility_models.ExtraMonitorSupportMachineVertex(reinject_point_to_point=False, reinject_nearest_neighbour=False, reinject_fixed_route=False)[source]

Bases: MachineVertex, AbstractHasAssociatedBinary, AbstractGeneratesDataSpecification, AbstractProvidesProvenanceDataFromMachine

Machine vertex for talking to extra monitor cores. Supports reinjection control and the faster data transfer protocols.

Usually deployed once per chip.

Note

This is an unusual machine vertex, in that it has no associated application vertex.

Parameters:
  • reinject_point_to_point (bool) – if we reinject point-to-point packets

  • reinject_nearest_neighbour (bool) – if we reinject nearest-neighbour packets

  • reinject_fixed_route (bool) – if we reinject fixed route packets

clear_reinjection_queue(extra_monitor_cores_to_set)[source]

Clears the queues for reinjection.

Parameters:

extra_monitor_cores_to_set (iterable(ExtraMonitorSupportMachineVertex)) – Which extra monitors need to clear their queues.

generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

get_provenance_data_from_machine(placement)[source]

Get an iterable of provenance data items.

Parameters:

placement (Placement) – the placement of the object

Return type:

iterable

get_reinjection_status()[source]

Get the reinjection status from this extra monitor vertex.

Returns:

the reinjection status for this vertex

Return type:

ReInjectionStatus

get_reinjection_status_for_vertices()[source]

Get the reinjection status from a set of extra monitor cores.

Return type:

dict(tuple(int,int), ReInjectionStatus)

load_application_mc_routes()[source]

Get the extra monitor cores to load up the application-based multicast routes (used by the Data In protocol).

load_system_mc_routes()[source]

Get the extra monitor cores to load up the system-based multicast routes (used by the Data In protocol).

Parameters:

transceiver (Transceiver) – the spinnMan interface

property placement
Return type:

Placement

property reinject_fixed_route
Return type:

bool

property reinject_multicast
Return type:

bool

property reinject_nearest_neighbour
Return type:

bool

property reinject_point_to_point
Return type:

bool

reset_reinjection_counters(extra_monitor_cores_to_set)[source]

Resets the counters for reinjection.

Parameters:
property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

set_reinjection_packets(point_to_point=None, multicast=None, nearest_neighbour=None, fixed_route=None)[source]
Parameters:
  • point_to_point (bool or None) – If point to point should be set, or None if left as before

  • multicast (bool or None) – If multicast should be set, or None if left as before

  • nearest_neighbour (bool or None) – If nearest neighbour should be set, or None if left as before

  • fixed_route (bool or None) – If fixed route should be set, or None if left as before.

set_router_wait1_timeout(timeout, extra_monitor_cores_to_set)[source]

Supports setting of the router time outs for a set of chips via their extra monitor cores. This sets the timeout for the time between when a packet arrives and when it starts to be emergency routed. (Actual emergency routing is disabled by default.)

Parameters:
  • timeout (tuple(int,int)) – The mantissa and exponent of the timeout value, each between 0 and 15

  • extra_monitor_cores_to_set (iterable(ExtraMonitorSupportMachineVertex)) – which monitors control the routers to set the timeout of

set_router_wait2_timeout(timeout, extra_monitor_cores_to_set)[source]

Supports setting of the router time outs for a set of chips via their extra monitor cores. This sets the timeout for the time between when a packet starts to be emergency routed and when it is dropped. (Actual emergency routing is disabled by default.)

Parameters:
  • timeout (tuple(int,int)) – The mantissa and exponent of the timeout value, each between 0 and 15

  • extra_monitor_cores_to_set (iterable(ExtraMonitorSupportMachineVertex)) – which monitors control the routers to set the timeout of

static static_get_binary_file_name()[source]

The name of the binary implementing this vertex.

Return type:

str

static static_get_binary_start_type()[source]

The type of the binary implementing this vertex.

Return type:

ExecutableType

property transaction_id
update_transaction_id()[source]
update_transaction_id_from_machine()[source]

Looks up from the machine what the current transaction id is and updates the extra monitor.

class spinn_front_end_common.utility_models.LivePacketGather(params, label=None)[source]

Bases: ApplicationVertex

A vertex that gathers and forwards multicast packets to the host.

Parameters:
property n_atoms

The number of atoms in the vertex.

Return type:

int

property params
class spinn_front_end_common.utility_models.LivePacketGatherMachineVertex(lpg_params, app_vertex=None, label=None)[source]

Bases: MachineVertex, ProvidesProvenanceDataFromMachineImpl, AbstractGeneratesDataSpecification, AbstractHasAssociatedBinary

Used to gather multicast packets coming from cores and stream them out to a receiving application on host. Only ever deployed on chips with a working Ethernet connection.

Parameters:
KEY_ENTRY_SIZE = 12
TRAFFIC_IDENTIFIER = 'LPG_EVENT_STREAM'

Used to identify tags involved with the live packet gatherer.

add_incoming_source(m_vertex, partition_id)[source]

Add a machine vertex source incoming into this gatherer.

Parameters:
  • m_vertex (MachineVertex) – The source machine vertex

  • partition_id (str) – The incoming partition id

generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

classmethod get_sdram_usage()[source]

Get the SDRAM used by this vertex.

Return type:

int

property iptags

The IPTags used by this vertex, if any.

Return type:

iterable(IPtagResource)

property params
parse_extra_provenance_items(label, x, y, p, provenance_data)[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) – The list of words of raw provenance data.

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

class spinn_front_end_common.utility_models.MultiCastCommand(key, payload=None, time=None, repeat=0, delay_between_repeats=0)[source]

Bases: object

A command to be sent to a vertex.

Parameters:
  • key (int) – The key of the command

  • payload (int or None) – The payload of the command

  • time (int or None) – The time within the simulation at which to send the command, or None if this is not a timed command

  • repeat (int) – The number of times that the command should be repeated after sending it once. This could be used to ensure that the command is sent despite lost packets. Must be between 0 and 65535

  • delay_between_repeats (int) – The amount of time in microseconds to wait between sending repeats of the same command. Must be between 0 and 65535, and must be 0 if repeat is 0

Raises:

ConfigurationException – If the repeat or delay are out of range

property delay_between_repeats
Return type:

int

property is_payload

Whether this command has a payload. By default, this returns True if the payload passed in to the constructor is not None, but this can be overridden to indicate that a payload will be generated, despite None being passed to the constructor

Return type:

bool

property is_timed

Whether this command is a timed command.

Return type:

bool

property key
Return type:

int

property payload

The payload of the command, or None if there is no payload.

Return type:

int or None

property repeat
Return type:

int

property time

The time within the simulation at which to send the command, or None if this is not a timed command.

Return type:

int or None

class spinn_front_end_common.utility_models.ReverseIPTagMulticastSourceMachineVertex(label, vertex_slice=None, app_vertex=None, n_keys=None, receive_port=None, receive_sdp_port=1, receive_tag=None, receive_rate=10, virtual_key=None, prefix=None, prefix_type=None, check_keys=False, send_buffer_times=None, send_buffer_partition_id=None, reserve_reverse_ip_tag=False, injection_partition_id=None)[source]

Bases: MachineVertex, AbstractGeneratesDataSpecification, AbstractHasAssociatedBinary, AbstractSupportsDatabaseInjection, ProvidesProvenanceDataFromMachineImpl, SendsBuffersFromHostPreBufferedImpl, AbstractReceiveBuffersToHost

A model which allows events to be injected into SpiNNaker and converted in to multicast packets.

Parameters:
  • label (str or None) – The label of this vertex

  • vertex_slice (Slice or None) – The slice served via this multicast source

  • app_vertex (ApplicationVertex or None) – The associated application vertex

  • n_keys (int) – The number of keys to be sent via this multicast source (can’t be None if vertex_slice is also None)

  • board_address (str) – The IP address of the board on which to place this vertex if receiving data, either buffered or live (by default, any board is chosen)

  • receive_port (int) – The port on the board that will listen for incoming event packets (default is to disable this feature; set a value to enable it, or set the reserve_reverse_ip_tag parameter to True if a random port is to be used)

  • receive_sdp_port (int) – The SDP port to listen on for incoming event packets (defaults to 1)

  • receive_tag (int) – The IP tag to use for receiving live events (uses any by default)

  • receive_rate (float) –

  • virtual_key (int) – The base multicast key to send received events with (assigned automatically by default)

  • prefix (int) – The prefix to “or” with generated multicast keys (default is no prefix)

  • prefix_type (EIEIOPrefix) – Whether the prefix should apply to the upper or lower half of the multicast keys (default is upper half)

  • check_keys (bool) – True if the keys of received events should be verified before sending (default False)

  • send_buffer_times (ndarray) – An array of arrays of time steps at which keys should be sent (one array for each key, default disabled)

  • send_buffer_partition_id (str) – The ID of the partition containing the edges down which the events are to be sent

  • reserve_reverse_ip_tag (bool) – True if the source should set up a tag through which it can receive packets; if port is set to None this can be used to enable the reception of packets on a randomly assigned port, which can be read from the database

  • injection_partition (str) – If not None, will enable injection and specify the partition to send injected keys with

  • label – The optional name of the vertex

  • app_vertex – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.

  • vertex_slice – The slice of the application vertex that this machine vertex implements.

Raises:
buffering_input()[source]

Return True if the input of this vertex is to be buffered.

Return type:

bool

static calculate_mask(n_neurons)[source]
Parameters:

n_neurons (int) –

Return type:

int

enable_recording(new_state=True)[source]

Enable recording of the keys sent.

Parameters:

new_state (bool) –

generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

get_recorded_region_ids()[source]

Get the recording region IDs that have been recorded using buffering.

Returns:

The region numbers that have active recording

Return type:

iterable(int)

get_recording_region_base_address(placement)[source]

Get the recording region base address.

Parameters:

placement (Placement) – the placement object of the core to find the address of

Returns:

the base address of the recording region

Return type:

int

get_region_buffer_size(region)[source]
Parameters:

region (int) – Region ID

Returns:

Size of buffer, in bytes.

Return type:

int

get_regions()[source]

Get the set of regions for which there are keys to be sent.

Returns:

Iterable of region IDs

Return type:

iterable(int)

classmethod get_sdram_usage(send_buffer_times, recording_enabled, receive_rate, n_keys)[source]
Parameters:
  • send_buffer_times (ndarray(ndarray(numpy.int32)) or list(ndarray(numpy.int32)) or None) – When events will be sent

  • recording_enabled (bool) – Whether recording is done

  • receive_rate (float) – What the expected message receive rate is

  • n_keys (int) – How many keys are being sent

Return type:

VariableSDRAM

get_virtual_key()[source]

Updates and returns the virtual key. None is give a zero value

Return type:

int or None

property injection_partition_id

The partition that packets are being injected with.

Return type:

str

property is_in_injection_mode

Whether this vertex is actually in injection mode.

Return type:

bool

property mask
Return type:

int or None

parse_extra_provenance_items(label, x, y, p, provenance_data)[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) – The list of words of raw provenance data.

property reverse_iptags

The ReverseIPTags used by this vertex, if any.

Return type:

iterable(ReverseIPtagResource)

rewind(region)[source]

Rewinds the internal buffer in preparation of re-sending the spikes.

Parameters:

region (int) – The region to rewind

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

property send_buffer_times

When events will be sent.

Return type:

ndarray(ndarray(numpy.int32)) or list(ndarray(numpy.int32)) or None

property send_buffers
Return type:

dict(int,BufferedSendingRegion)

update_virtual_key()[source]
class spinn_front_end_common.utility_models.ReverseIpTagMultiCastSource(n_keys, label=None, max_atoms_per_core=9223372036854775807, receive_port=None, receive_sdp_port=1, receive_tag=None, receive_rate=10, virtual_key=None, prefix=None, prefix_type=None, check_keys=False, send_buffer_times=None, send_buffer_partition_id=None, reserve_reverse_ip_tag=False, injection_partition_id=None, splitter=None)[source]

Bases: ApplicationVertex, LegacyPartitionerAPI

A model which will allow events to be injected into a SpiNNaker machine and converted into multicast packets.

Parameters:
  • n_keys (int) – The number of keys to be sent via this multicast source

  • label (str) – The label of this vertex

  • max_atoms_per_core (int) –

  • board_address (str or None) – The IP address of the board on which to place this vertex if receiving data, either buffered or live (by default, any board is chosen)

  • receive_port (int or None) – The port on the board that will listen for incoming event packets (default is to disable this feature; set a value to enable it)

  • receive_sdp_port (int) – The SDP port to listen on for incoming event packets (defaults to 1)

  • receive_tag (IPTag) – The IP tag to use for receiving live events (uses any by default)

  • receive_rate (float) – The estimated rate of packets that will be sent by this source

  • virtual_key (int) – The base multicast key to send received events with (assigned automatically by default)

  • prefix (int) – The prefix to “or” with generated multicast keys (default is no prefix)

  • prefix_type (EIEIOPrefix) – Whether the prefix should apply to the upper or lower half of the multicast keys (default is upper half)

  • check_keys (bool) – True if the keys of received events should be verified before sending (default False)

  • send_buffer_times (ndarray(ndarray(numpy.int32)) or list(ndarray(int32)) or None) – An array of arrays of times at which keys should be sent (one array for each key, default disabled)

  • send_buffer_partition_id (str or None) – The ID of the partition containing the edges down which the events are to be sent

  • reserve_reverse_ip_tag (bool) – Extra flag for input without a reserved port

  • injection_partition (str) – If not None, will enable injection and specify the partition to send injected keys with

  • splitter (AbstractSplitterCommon or None) – the splitter object needed for this vertex

create_machine_vertex(vertex_slice, sdram, label=None)[source]

Create a machine vertex from this application vertex.

Parameters:
  • vertex_slice (Slice) – The slice of atoms that the machine vertex will cover.

  • sdram (AbstractSDRAM) – The SDRAM used by the machine vertex.

  • label (str or None) – human readable label for the machine vertex

Returns:

The created machine vertex

Return type:

MachineVertex

enable_recording(new_state=True)[source]
get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

get_sdram_used_by_atoms(vertex_slice)[source]

Get the separate SDRAM requirements for a range of atoms.

Parameters:

vertex_slice (Slice) – the low value of atoms to calculate resources from

Return type:

AbstractSDRAM

property n_atoms

The number of atoms in the vertex.

Return type:

int

property send_buffer_times

When messages will be sent.

Return type:

ndarray(ndarray(numpy.int32)) or list(ndarray(int32)) or None

class spinn_front_end_common.utility_models.StreamingContextManager(gatherers)[source]

Bases: object

The implementation of the context manager object for streaming configuration control.

Parameters:

gatherers (iterable(DataSpeedUpPacketGatherMachineVertex)) –

Module contents

Indices and tables

SpiNNFrontEndCommon_github

SpiNNFrontEndCommon_individual_docs

sPyNNaker

This package provides a PyNN 0.9 implementation for SpiNNaker.

sPyNNaker

Contents

spynnaker
spynnaker package
Subpackages
spynnaker.pyNN package
Subpackages
spynnaker.pyNN.connections package
Module contents
class spynnaker.pyNN.connections.EthernetCommandConnection(translator, command_containers=None, local_host=None, local_port=19999)[source]

Bases: DatabaseConnection

A connection that can send commands to a device at the start and end of a simulation.

Parameters:
  • translator (AbstractEthernetTranslator) – A translator of multicast commands to device commands

  • command_containers (list(AbstractSendMeMulticastCommandsVertex)) – A list of vertices that have commands to be sent at the start and end of simulation

  • local_host (str) – The optional host to listen on for the start/resume message

  • local_port (int) – The optional port to listen on for the stop/pause message

add_command_container(command_container)[source]

Add a command container.

Parameters:

command_container (AbstractSendMeMulticastCommandsVertex) – A vertex that has commands to be sent at the start and end of simulation

class spynnaker.pyNN.connections.EthernetControlConnection(translator, label, live_packet_gather_label, local_host=None, local_port=None)[source]

Bases: LiveEventConnection

A connection that can translate Ethernet control messages received from a Population.

Parameters:
  • translator (AbstractEthernetTranslator) – The translator of multicast to control commands

  • label (str) – The label of the vertex to attach the translator to

  • live_packet_gather_label (str) – The label of the LPG vertex that this control connection will listen to.

  • local_host (str) – The optional host to listen on

  • local_port (int) – The optional port to listen on

add_translator(label, translator)[source]

Add another translator that routes via the LPG.

Parameters:
  • label (str) – The label of the vertex to attach the translator to

  • translator (AbstractEthernetTranslator) – The translator of multicast to control commands

class spynnaker.pyNN.connections.SPIFLiveSpikesConnection(receive_labels, spif_host, spif_port=3332, events_per_packet=32, time_per_packet=500, local_host=None, local_port=None)[source]

Bases: DatabaseConnection

A connection for receiving live spikes from SPIF.

Parameters:
  • receive_labels (iterable(str)) – Labels of vertices from which live events will be received.

  • spif_host (str) – The location of the SPIF board receiving packets

  • spif_port (int) – The port of the SPIF board (default 3332)

  • events_per_packet (int) – The maximum number of events in each packet. SPIF will be configured to send a packet as soon as it reaches this size if not before (default is 32)

  • time_per_packet (int) – The maximum time between sending non-empty packets. SPIF will be configured to send a packet that isn’t empty after this many microseconds (default is 500)

  • 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_init_callback(label, init_callback)[source]

Add a callback to be called to initialise a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • init_callback (callable(str, int, float, float) -> None) – A function to be called to initialise the vertex. This should take as parameters the label of the vertex, the number of neurons in the population, the run time of the simulation in milliseconds, and the simulation timestep in milliseconds

add_pause_stop_callback(label, pause_stop_callback)[source]

Add a callback for the pause and stop state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • pause_stop_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the pause or stop message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

add_receive_callback(label, live_event_callback, translate_key=True)[source]

Add a callback for the reception of live events from a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • live_event_callback (callable(str, list(int)) -> None) – A function to be called when events are received. This should take as parameters the label of the vertex, and an array-like of atom IDs.

  • translate_key (bool) – True if the key is to be converted to an atom ID, False if the key should stay a key

add_receive_label(label)[source]
Parameters:

label (str) –

add_start_resume_callback(label, start_resume_callback)[source]

Add a callback for the start and resume state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • start_resume_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the start or resume message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

class spynnaker.pyNN.connections.SpynnakerLiveSpikesConnection(receive_labels=None, send_labels=None, local_host=None, local_port=19999, live_packet_gather_label='LiveSpikeReceiver')[source]

Bases: LiveEventConnection

A connection for receiving and sending live spikes from and to SpiNNaker.

Parameters:
  • receive_labels (iterable(str)) – Labels of population from which live spikes will be received.

  • send_labels (iterable(str)) – Labels of population to which live spikes will be sent

  • 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)

send_spike(label, neuron_id, send_full_keys=False)[source]

Send a spike from a single neuron.

Parameters:
  • label (str) – The label of the population from which the spike will originate

  • neuron_id (int) – The ID of the neuron sending a spike

  • send_full_keys (bool) – Determines whether to send full 32-bit keys, getting the key for each neuron from the database, or whether to send 16-bit neuron IDs directly

send_spikes(label, neuron_ids, send_full_keys=False)[source]

Send a number of spikes.

Parameters:
  • label (str) – The label of the population from which the spikes will originate

  • neuron_ids (list(int)) – array-like of neuron IDs sending spikes

  • send_full_keys (bool) – Determines whether to send full 32-bit keys, getting the key for each neuron from the database, or whether to send 16-bit neuron IDs directly

class spynnaker.pyNN.connections.SpynnakerPoissonControlConnection(poisson_labels=None, local_host=None, local_port=19999, control_label_extension='_control')[source]

Bases: LiveEventConnection

A connection used to control a Poisson-distributed random event source’s firing rate at runtime.

Parameters:
  • poisson_labels (iterable(str)) – Labels of Poisson populations to be controlled

  • 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)

  • control_label_extension (str) – The extra name added to the label of each Poisson source

add_init_callback(label, init_callback)[source]

Add a callback to be called to initialise a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • init_callback (callable(str, int, float, float) -> None) – A function to be called to initialise the vertex. This should take as parameters the label of the vertex, the number of neurons in the population, the run time of the simulation in milliseconds, and the simulation timestep in milliseconds

add_pause_stop_callback(label, pause_stop_callback)[source]

Add a callback for the pause and stop state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • pause_stop_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the pause or stop message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

add_poisson_label(label)[source]
Parameters:

label (str) – The label of the Poisson source population.

add_receive_callback(label, live_event_callback, translate_key=False)[source]

Add a callback for the reception of live events from a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • live_event_callback (callable(str, int, list(int)) -> None) – A function to be called when events are received. This should take as parameters the label of the vertex, the simulation timestep when the event occurred, and an array-like of atom IDs.

  • translate_key (bool) – True if the key is to be converted to an atom ID, False if the key should stay a key

add_start_callback(label, start_callback)[source]

Add a callback for the start of the simulation.

Parameters:
  • start_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the start message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events

  • label (str) – the label of the function to be sent

add_start_resume_callback(label, start_resume_callback)[source]

Add a callback for the start and resume state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • start_resume_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the start or resume message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

set_rate(label, neuron_id, rate)[source]

Set the rate of a Poisson neuron within a Poisson source.

Parameters:
  • label (str) – The label of the Population to set the rates of

  • neuron_id (int) – The neuron ID to set the rate of

  • rate (float) – The rate to set in Hz

set_rates(label, neuron_id_rates)[source]

Set the rates of multiple Poisson neurons within a Poisson source.

Parameters:
  • label (str) – The label of the Population to set the rates of

  • neuron_id_rates (list(tuple(int,float))) – A list of tuples of (neuron ID, rate) to be set

spynnaker.pyNN.data package
Submodules
spynnaker.pyNN.data.spynnaker_data_writer module
class spynnaker.pyNN.data.spynnaker_data_writer.SpynnakerDataWriter(state)[source]

Bases: FecDataWriter, SpynnakerDataView

See UtilsDataWriter.

This class is designed to only be used directly by spinn_front_end_common.interface.abstract_spinnaker_base.AbstractSpinnakerBase and its subclasses and within the PyNN repositories unit tests.

Parameters:

state (DataStatus) – State writer should be in

set_up_timings_and_delay(simulation_time_step_us, time_scale_factor, min_delay)[source]
Parameters:
  • simulation_time_step_us (int or None) – An explicitly specified time step for the simulation in microseconds. If None, the value is read from the configuration

  • time_scale_factor (float or None) – An explicitly specified time scale factor for the simulation. If None, the value is read from the configuration

  • min_delay (int, float or None) – new value or None to say use simulation_time_step_ms

shut_down()[source]

Puts all data into the state expected after sim.end.

Most methods that change data, or state will raise an exception after this call.

Most data however will still be available.

Module contents
class spynnaker.pyNN.data.SpynnakerDataView[source]

Bases: FecDataView

Adds the extra Methods to the View for PyNN level.

See UtilsDataView for a more detailed description.

Use this class wherever possible as it inherits all methods from all View classes.

classmethod add_population(population)[source]

Called by each population to add itself to the list.

Usage other than from Population.__init__ is not supported and likely to raise an exception

Increments the all population ID counter by the size of the population.

Parameters:

population (Population) – Population to add

Returns:

The first and last global IDs for this Population

Return type:

tuple(int, int)

Raises:
  • SimulatorRunningException – If sim.run is currently running

  • SimulatorNotSetupException – If called before sim.setup

  • SimulatorShutdownException – If called after sim.end

classmethod add_projection(projection)[source]

Called by each projection to add itself to the list.

Usage other than from Projection.__init__ is not supported and likely to raise an exception

Parameters:

projection (Projection) – Projection to add

Raises:

SpiNNUtilsException – If projections should not be added in the current state

classmethod get_min_delay()[source]

The minimum supported delay if available, in milliseconds.

Typically simulation_time_step_per_ms but may be a positive multiple of it.

Return type:

float

Raises:

SpiNNUtilsException – If the min_delay is currently unavailable

classmethod get_n_populations()[source]

The number of populations previously added.

Return type:

int

classmethod get_n_projections()[source]

The number of projections previously added.

rtype: int

classmethod get_segment_counter()[source]

The number of the current recording segment being generated.

Returns:

the segment counter

Return type:

int

classmethod get_sim_name()[source]

Gets the name to be returned by pyNN.spiNNaker.name.

Return type:

str

classmethod has_min_delay()[source]

Report if there is a minimum supported delay available.

Return type:

bool

classmethod iterate_populations()[source]

An iteration of the populations previously added.

The iteration will be empty if no populations added.

Return type:

iterable(Population)

classmethod iterate_projections()[source]

An iteration of the projections previously added.

The iteration will be empty if no projections added.

Return type:

iterable(Projection)

classmethod set_number_of_neurons_per_dimension_per_core(neuron_type, max_permitted)[source]

Sets a ceiling on the number of neurons of a given type that can be placed on a single core for each dimension.

Parameters:
spynnaker.pyNN.external_devices package
Module contents

This contains functions and classes for handling external devices such as the PushBot (https://spinnakermanchester.github.io/docs/push_bot/).

Note

When using external devices, it is normally important to configure your SpiNNaker system to run in real-time mode, which usually reduces numerical accuracy to gain performance.

class spynnaker.pyNN.external_devices.ArbitraryFPGADevice(n_neurons, fpga_link_id, fpga_id, board_address=None, chip_coords=None, label=None)[source]

Bases: ApplicationFPGAVertex, PopulationApplicationVertex

Parameters:
  • n_neurons (int) – Number of neurons

  • fpga_link_id (int) –

  • fpga_id (int) –

  • board_address (str or None) –

  • chip_coords (tuple(int, int) or None) –

  • label (str or None) –

class spynnaker.pyNN.external_devices.EIEIOType(value)[source]

Bases: Enum

Possible types of EIEIO packets.

KEY_16_BIT = 0
KEY_32_BIT = 2
KEY_PAYLOAD_16_BIT = 1
KEY_PAYLOAD_32_BIT = 3
property key_bytes

The number of bytes used by each key element.

Return type:

int

property max_value

The maximum value of the key or payload (if there is a payload).

Return type:

int

property payload_bytes

The number of bytes used by each payload element.

Return type:

int

class spynnaker.pyNN.external_devices.ExternalCochleaDevice(n_neurons, spinnaker_link, label=None, board_address=None)[source]

Bases: ApplicationSpiNNakerLinkVertex, PopulationApplicationVertex

Parameters:
  • n_neurons (int) – Number of neurons

  • spinnaker_link (int) – The SpiNNaker link to which the cochlea is connected

  • label (str) –

  • board_address (str) –

class spynnaker.pyNN.external_devices.ExternalDeviceLifControl(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Abstract control module for the PushBot, based on the LIF neuron, but without spikes, and using the voltage as the output to the various devices.

Parameters:
create_vertex(n_neurons, label, spikes_per_second, ring_buffer_sigma, incoming_spike_buffer_size, n_steps_per_timestep, drop_late_spikes, splitter, seed, n_colour_bits)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

  • spikes_per_second (float) –

  • ring_buffer_sigma (float) –

  • incoming_spike_buffer_size (int) –

  • drop_late_spikes (bool) –

  • splitter (AbstractSplitterCommon or None) –

  • seed (float) –

  • n_colour_bits (int) –

  • n_steps_per_timestep (int) –

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

class spynnaker.pyNN.external_devices.ExternalFPGARetinaDevice(mode, retina_key, spinnaker_link_id, polarity, label=None, board_address=None)[source]

Bases: ApplicationSpiNNakerLinkVertex, PopulationApplicationVertex, AbstractSendMeMulticastCommandsVertex

Parameters:
  • mode (str) – The retina “mode”

  • retina_key (int) – The value of the top 16-bits of the key

  • spinnaker_link_id (int) – The SpiNNaker link to which the retina is connected

  • polarity (str) – The “polarity” of the retina data

  • label (str) –

  • board_address (str) –

DOWN_POLARITY = 'DOWN'
MERGED_POLARITY = 'MERGED'
MODE_128 = '128'
MODE_16 = '16'
MODE_32 = '32'
MODE_64 = '64'
UP_POLARITY = 'UP'
get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

static get_n_neurons(mode, polarity)[source]
Parameters:
  • mode (str) – 128 or 64 or 32 or 16

  • parity (str) – UP or DOWN or MERGED

Return type:

int

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices.ICUBRetinaDevice(base_key=0, width=304, height=240, sub_width=16, sub_height=16, spinnaker_link_id=0, board_address=None)[source]

Bases: Application2DSpiNNakerLinkVertex, HasShapeKeyFields

An ICUB retina device connected to SpiNNaker using a SpiNNakerLink.

Parameters:
  • base_key (int) – The key that is common over the whole vertex

  • width (int) – The width of the retina in pixels

  • height (int) – The height of the retina in pixels

  • sub_width (int) – The width of rectangles to split the retina into for efficiency of sending

  • sub_height (int) – The height of rectangles to split the retina into for efficiency of sending

  • spinnaker_link_id (int) – The ID of the SpiNNaker link that the device is connected to

  • board_address (str or None) – The board to which the device is connected, or None for the first board

get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

get_incoming_slice(index)[source]

Get the slice to be given to the connection.

Parameters:

index (int) – The index of the connection, for when n_machine_vertices > 1

Return type:

Slice

get_machine_fixed_key_and_mask(machine_vertex, partition_id)[source]

Get a fixed key and mask for the given machine vertex and partition identifier, or None if not fixed (the default).

If this doesn’t return None, get_fixed_key_and_mask() must also not return None, and the keys returned here must align with those such that for each key:mask returned here, key & app_mask == app_key. It is OK for this to return None and get_fixed_key_and_mask() to return non-None if and only if there is only one machine vertex.

Parameters:
  • machine_vertex (MachineVertex) – A source machine vertex of this application vertex

  • partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

get_shape_key_fields(vertex_slice)[source]

Get the fields to be used for each dimension in the shape of the given source vertex slice, as a list of start, size, mask, shift values in the order of the fields.

Parameters:

vertex_slice (Slice) – The slice of the source vertex

Return type:

list(tuple(int, int, int, int))

class spynnaker.pyNN.external_devices.MunichIoSpiNNakerLinkProtocol(mode, instance_key=None, uart_id=0)[source]

Bases: object

Provides Multicast commands for the Munich SpiNNaker-Link protocol.

Parameters:
  • mode (MUNICH_MODES) – The mode of operation of the protocol

  • instance_key (int or None) – The optional instance key to use

  • uart_id (int) – The ID of the UART when needed

add_payload_logic_to_current_output(payload, time=None)[source]
property add_payload_logic_to_current_output_key
bias_values(bias_id, bias_value, time=None)[source]
property bias_values_key
configure_master_key(new_key, time=None)[source]
property configure_master_key_key
disable_retina(time=None)[source]
property disable_retina_key
property enable_disable_motor_key
generic_motor0_raw_output_leak_to_0(pwm_signal, time=None)[source]
property generic_motor0_raw_output_leak_to_0_key
generic_motor0_raw_output_permanent(pwm_signal, time=None)[source]
property generic_motor0_raw_output_permanent_key
generic_motor1_raw_output_leak_to_0(pwm_signal, time=None)[source]
property generic_motor1_raw_output_leak_to_0_key
generic_motor1_raw_output_permanent(pwm_signal, time=None)[source]
property generic_motor1_raw_output_permanent_key
generic_motor_disable(time=None)[source]
generic_motor_enable(time=None)[source]
generic_motor_total_period(time_in_ms, time=None)[source]
property generic_motor_total_period_key
property instance_key

The key of this instance of the protocol.

Return type:

int

property master_slave_key
master_slave_set_master_clock_active(time=None)[source]
master_slave_set_master_clock_not_started(time=None)[source]
master_slave_set_slave(time=None)[source]
master_slave_use_internal_counter(time=None)[source]
property mode
Return type:

MUNICH_MODES

poll_individual_sensor_continuously(sensor_id, time_in_ms, time=None)[source]
property poll_individual_sensor_continuously_key
poll_sensors_once(sensor_id, time=None)[source]
property poll_sensors_once_key
protocol_instance = 0
push_bot_laser_config_active_time(active_time, time=None)[source]
property push_bot_laser_config_active_time_key
push_bot_laser_config_total_period(total_period, time=None)[source]
property push_bot_laser_config_total_period_key
push_bot_laser_set_frequency(frequency, time=None)[source]
property push_bot_laser_set_frequency_key
push_bot_led_back_active_time(active_time, time=None)[source]
property push_bot_led_back_active_time_key
push_bot_led_front_active_time(active_time, time=None)[source]
property push_bot_led_front_active_time_key
push_bot_led_set_frequency(frequency, time=None)[source]
property push_bot_led_set_frequency_key
push_bot_led_total_period(total_period, time=None)[source]
property push_bot_led_total_period_key
push_bot_motor_0_leaking_towards_zero(velocity, time=None)[source]
property push_bot_motor_0_leaking_towards_zero_key
push_bot_motor_0_permanent(velocity, time=None)[source]
property push_bot_motor_0_permanent_key
push_bot_motor_1_leaking_towards_zero(velocity, time=None)[source]
property push_bot_motor_1_leaking_towards_zero_key
push_bot_motor_1_permanent(velocity, time=None)[source]
property push_bot_motor_1_permanent_key
push_bot_speaker_config_active_time(active_time, time=None)[source]
property push_bot_speaker_config_active_time_key
push_bot_speaker_config_total_period(total_period, time=None)[source]
property push_bot_speaker_config_total_period_key
push_bot_speaker_set_melody(melody, time=None)[source]
property push_bot_speaker_set_melody_key
push_bot_speaker_set_tone(frequency, time=None)[source]
property push_bot_speaker_set_tone_key
pwm_pin_output_timer_a_channel_0_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_a_channel_0_ratio_key
pwm_pin_output_timer_a_channel_1_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_a_channel_1_ratio_key
pwm_pin_output_timer_a_duration(timer_period, time=None)[source]
property pwm_pin_output_timer_a_duration_key
pwm_pin_output_timer_b_channel_0_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_b_channel_0_ratio_key
pwm_pin_output_timer_b_channel_1_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_b_channel_1_ratio_key
pwm_pin_output_timer_b_duration(timer_period, time=None)[source]
property pwm_pin_output_timer_b_duration_key
pwm_pin_output_timer_c_channel_0_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_c_channel_0_ratio_key
pwm_pin_output_timer_c_channel_1_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_c_channel_1_ratio_key
pwm_pin_output_timer_c_duration(timer_period, time=None)[source]
property pwm_pin_output_timer_c_duration_key
query_state_of_io_lines(time=None)[source]
property query_state_of_io_lines_key
remove_payload_logic_to_current_output(payload, time=None)[source]
property remove_payload_logic_to_current_output_key
reset_retina(time=None)[source]
property reset_retina_key
sensor_transmission_key(sensor_id)[source]
static sent_mode_command()[source]

True if the mode command has ever been requested by any instance.

set_mode(time=None)[source]
property set_mode_key
set_output_pattern_for_payload(payload, time=None)[source]
property set_output_pattern_for_payload_key
set_payload_pins_to_high_impedance(payload, time=None)[source]
property set_payload_pins_to_high_impedance_key
set_retina_key(new_key, time=None)[source]
property set_retina_key_key
set_retina_transmission(retina_key=RetinaKey.NATIVE_128_X_128, retina_payload=None, time=None)[source]

Set the retina transmission key.

Parameters:
  • retina_key (RetinaKey) – the new key for the retina

  • retina_payload (RetinaPayload or None) – the new payload for the set retina key command packet

  • time (int or float or None) – when to transmit this packet

Returns:

the command to send

Return type:

MultiCastCommand

property set_retina_transmission_key
turn_off_sensor_reporting(sensor_id, time=None)[source]
property turn_off_sensor_reporting_key
property uart_id
Return type:

int

class spynnaker.pyNN.external_devices.MunichMotorDevice(spinnaker_link_id, board_address=None, speed=30, sample_time=4096, update_time=512, delay_time=5, delta_threshold=23, continue_if_not_different=True, label=None)[source]

Bases: AbstractOneAppOneMachineVertex, AbstractVertexWithEdgeToDependentVertices, PopulationApplicationVertex

An Omnibot motor control device. This has a real vertex and an external device vertex.

Parameters:
  • spinnaker_link_id (int) – The SpiNNaker link to which the motor is connected

  • board_address (str or None) –

  • speed (int) –

  • sample_time (int) –

  • update_time (int) –

  • delay_time (int) –

  • delta_threshold (int) –

  • continue_if_not_different (bool) –

  • label (str or None) –

default_initial_values = {}
default_parameters = {'board_address': None, 'continue_if_not_different': True, 'delay_time': 5, 'delta_threshold': 23, 'label': None, 'sample_time': 4096, 'speed': 30, 'update_time': 512}
dependent_vertices()[source]

Return the vertices which this vertex depends upon.

Return type:

iterable(ApplicationVertex)

edge_partition_identifiers_for_dependent_vertex(vertex)[source]

Return the dependent edge identifiers for a particular dependent vertex.

Parameters:

vertex (ApplicationVertex) –

Return type:

iterable(str)

class spynnaker.pyNN.external_devices.MunichRetinaDevice(retina_key, spinnaker_link_id, position, label='MunichRetinaDevice', polarity=None, board_address=None)[source]

Bases: ApplicationSpiNNakerLinkVertex, PopulationApplicationVertex, AbstractSendMeMulticastCommandsVertex

An Omnibot silicon retina device.

Parameters:
  • retina_key (int) –

  • spinnaker_link_id (int) – The SpiNNaker link to which the retina is connected

  • position (str) – LEFT or RIGHT

  • label (str) –

  • polarity (str) – UP, DOWN or MERGED

  • board_address (str or None) –

DOWN_POLARITY = 'DOWN'
LEFT_RETINA = 'LEFT'

Select the left retina

MERGED_POLARITY = 'MERGED'
RIGHT_RETINA = 'RIGHT'

Select the right retina

UP_POLARITY = 'UP'
default_parameters = {'board_address': None, 'label': 'MunichRetinaDevice', 'polarity': None}
get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices.PushBotEthernetLEDDevice(led, protocol, start_active_time_front=None, start_active_time_back=None, start_total_period=None, start_frequency=None, timesteps_between_send=None)[source]

Bases: PushBotEthernetDevice, AbstractSendMeMulticastCommandsVertex

The LED of a PushBot.

Parameters:
  • led (PushBotLED) – The LED to control

  • protocol (MunichIoEthernetProtocol) – The protocol instance to get commands from

  • start_active_time_front (int) – The “active time” to set for the front LED at the start

  • start_active_time_back (int) – The “active time” to set for the back LED at the start

  • start_total_period (int) – The “total period” to set at the start

  • start_frequency (int) – The “frequency” to set at the start

  • timesteps_between_send (int) – The number of timesteps between sending commands to the device, or None to use the default

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

set_command_protocol(command_protocol)[source]

Set the protocol use to send setup and shutdown commands, separately from the protocol used to control the device.

Parameters:

command_protocol (MunichIoSpiNNakerLinkProtocol) – The protocol to use for this device

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices.PushBotEthernetLaserDevice(laser, protocol, start_active_time=None, start_total_period=None, start_frequency=None, timesteps_between_send=None)[source]

Bases: PushBotEthernetDevice, AbstractSendMeMulticastCommandsVertex

The Laser of a PushBot.

Parameters:
  • laser (PushBotLaser) – The PushBotLaser value to control

  • protocol (MunichIoEthernetProtocol) – The protocol instance to get commands from

  • start_active_time (int) – The “active time” value to send at the start

  • start_total_period (int) – The “total period” value to send at the start

  • start_frequency (int) – The “frequency” to send at the start

  • timesteps_between_send (int) – The number of timesteps between sending commands to the device, or None to use the default

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

set_command_protocol(command_protocol)[source]

Set the protocol use to send setup and shutdown commands, separately from the protocol used to control the device.

Parameters:

command_protocol (MunichIoSpiNNakerLinkProtocol) – The protocol to use for this device

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices.PushBotEthernetMotorDevice(motor, protocol, timesteps_between_send=None)[source]

Bases: PushBotEthernetDevice, AbstractSendMeMulticastCommandsVertex

The motor of a PushBot.

Parameters:
  • motor (PushBotMotor) – indicates which motor to control

  • protocol (MunichIoEthernetProtocol) – The protocol used to control the device

  • timesteps_between_send (int) – The number of timesteps between sending commands to the device, or None to use the default

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

set_command_protocol(command_protocol)[source]

Set the protocol use to send setup and shutdown commands, separately from the protocol used to control the device.

Parameters:

command_protocol (MunichIoSpiNNakerLinkProtocol) – The protocol to use for this device

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices.PushBotEthernetRetinaDevice(protocol, resolution, pushbot_ip_address, pushbot_port=56000, injector_port=None, local_host=None, local_port=None, retina_injector_label='PushBotRetinaInjector')[source]

Bases: AbstractPushBotRetinaDevice, AbstractEthernetSensor

Parameters:
get_database_connection()[source]

Get a Database Connection instance that this device uses to inject packets.

Return type:

SpynnakerLiveSpikesConnection

Return type:

PushBotRetinaConnection

get_injector_label()[source]

Get the label to give to the Spike Injector.

Return type:

str

get_injector_parameters()[source]

Get the parameters of the Spike Injector to use with this device.

Return type:

dict(str,Any)

get_n_neurons()[source]

Get the number of neurons that will be sent out by the device.

Return type:

int

get_translator()[source]

Get a translator of multicast commands to Ethernet commands.

Return type:

AbstractEthernetTranslator

class spynnaker.pyNN.external_devices.PushBotEthernetSpeakerDevice(speaker, protocol, start_active_time=0, start_total_period=0, start_frequency=0, start_melody=None, timesteps_between_send=None)[source]

Bases: PushBotEthernetDevice, AbstractSendMeMulticastCommandsVertex

The Speaker of a PushBot.

Parameters:
  • speaker (PushBotSpeaker) – The speaker to control

  • protocol (MunichIoEthernetProtocol) – The protocol instance to get commands from

  • start_active_time (int) – The “active time” to set at the start

  • start_total_period (int) – The “total period” to set at the start

  • start_frequency (int) – The “frequency” to set at the start

  • start_melody (int) – The “melody” to set at the start

  • timesteps_between_send (int) – The number of timesteps between sending commands to the device, or None to use the default

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

set_command_protocol(command_protocol)[source]

Set the protocol use to send setup and shutdown commands, separately from the protocol used to control the device.

Parameters:

command_protocol (MunichIoSpiNNakerLinkProtocol) – The protocol to use for this device

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices.PushBotLED(value)[source]

Bases: AbstractPushBotOutputDevice

The properties of the LED device that may be set.

LED_BACK_ACTIVE_TIME = 2
LED_FREQUENCY = 3
LED_FRONT_ACTIVE_TIME = 1
LED_TOTAL_PERIOD = 0
class spynnaker.pyNN.external_devices.PushBotLaser(value)[source]

Bases: AbstractPushBotOutputDevice

The properties of the laser device that may be set.

LASER_ACTIVE_TIME = 1

The active period for the laser (no larger than the total period)

LASER_FREQUENCY = 2

The frequency of the laser

LASER_TOTAL_PERIOD = 0

The total period for the laser

class spynnaker.pyNN.external_devices.PushBotLifEthernet(**kwargs)[source]

Bases: ExternalDeviceLifControl

Leaky integrate and fire neuron with an exponentially decaying current input.

Parameters:
  • protocol (MunichIoEthernetProtocol) – How to talk to the bot.

  • devices (iterable(AbstractMulticastControllableDevice)) – The devices on the bot that we are interested in.

  • pushbot_ip_address (str) – Where is the pushbot?

  • pushbot_port (int) – (defaulted)

  • tau_m (float) – LIF neuron parameter (defaulted)

  • cm (float) – LIF neuron parameter (defaulted)

  • v_rest (float) – LIF neuron parameter (defaulted)

  • v_reset (float) – LIF neuron parameter (defaulted)

  • tau_syn_E (float) – LIF neuron parameter (defaulted)

  • tau_syn_I (float) – LIF neuron parameter (defaulted)

  • tau_refrac (float) – LIF neuron parameter (defaulted)

  • i_offset (float) – LIF neuron parameter (defaulted)

  • v (float) – LIF neuron parameter (defaulted)

  • isyn_exc (float) – LIF neuron parameter (defaulted)

  • isyn_inh (float) – LIF neuron parameter (defaulted)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

class spynnaker.pyNN.external_devices.PushBotLifSpinnakerLink(**kwargs)[source]

Bases: ExternalDeviceLifControl

Control module for a PushBot connected to a SpiNNaker Link.

Parameters:
  • protocol (MunichIoSpiNNakerLinkProtocol) – How to talk to the bot.

  • devices (iterable(AbstractMulticastControllableDevice)) – The devices on the bot that we are interested in.

  • tau_m (float) – LIF neuron parameter (defaulted)

  • cm (float) – LIF neuron parameter (defaulted)

  • v_rest (float) – LIF neuron parameter (defaulted)

  • v_reset (float) – LIF neuron parameter (defaulted)

  • tau_syn_E (float) – LIF neuron parameter (defaulted)

  • tau_syn_I (float) – LIF neuron parameter (defaulted)

  • tau_refrac (float) – LIF neuron parameter (defaulted)

  • i_offset (float) – LIF neuron parameter (defaulted)

  • v (float) – LIF neuron parameter (defaulted)

  • isyn_exc (float) – LIF neuron parameter (defaulted)

  • isyn_inh (float) – LIF neuron parameter (defaulted)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

class spynnaker.pyNN.external_devices.PushBotMotor(value)[source]

Bases: AbstractPushBotOutputDevice

The properties of the motor devices that may be set. The pushbot has two motors, 0 (left) and 1 (right).

MOTOR_0_LEAKY = 1

For motor 0, set a variable speed depending on time since event receive

MOTOR_0_PERMANENT = 0

For motor 0, set a particular speed

MOTOR_1_LEAKY = 3

For motor 1, set a variable speed depending on time since event receive

MOTOR_1_PERMANENT = 2

For motor 0, set a particular speed

class spynnaker.pyNN.external_devices.PushBotRetinaResolution(value)[source]

Bases: Enum

Resolutions supported by the pushbot retina device.

DOWNSAMPLE_16_X_16 = RetinaKey.DOWNSAMPLE_16_X_16

Down sampled 64 (\(8 \times 8\)) pixels to 1

DOWNSAMPLE_32_X_32 = RetinaKey.DOWNSAMPLE_32_X_32

Down sampled 16 (\(4 \times 4\)) pixels to 1

DOWNSAMPLE_64_X_64 = RetinaKey.DOWNSAMPLE_64_X_64

Down sampled 4 (\(2 \times 2\)) pixels to 1

NATIVE_128_X_128 = RetinaKey.NATIVE_128_X_128

The native resolution

class spynnaker.pyNN.external_devices.PushBotRetinaViewer(retina_resolution, label, sim)[source]

Bases: object

Viewer of retina from the PushBot.

property port

The port the connection is listening on.

Return type:

int

run(run_time)[source]

Run the viewer and simulation for a fixed time.

run_until_closed()[source]

Run the viewer and simulation until the viewer is closed.

class spynnaker.pyNN.external_devices.PushBotSpeaker(value)[source]

Bases: AbstractPushBotOutputDevice

The properties of the speaker device that may be set.

SPEAKER_ACTIVE_TIME = 1
SPEAKER_MELODY = 3
SPEAKER_TONE = 2
SPEAKER_TOTAL_PERIOD = 0
class spynnaker.pyNN.external_devices.PushBotSpiNNakerLinkLEDDevice(led, protocol, spinnaker_link_id, n_neurons=1, label=None, board_address=None, start_active_time_front=None, start_active_time_back=None, start_total_period=None, start_frequency=None)[source]

Bases: PushBotEthernetLEDDevice, ApplicationSpiNNakerLinkVertex, PopulationApplicationVertex

The LED of a PushBot

Parameters:
  • led (PushBotLED) – The LED device to control

  • protocol (MunichIoSpiNNakerLinkProtocol) – The protocol instance to get commands from

  • spinnaker_link_id (int) – The SpiNNakerLink connected to

  • n_neurons (int) – The number of neurons in the device

  • label (str) – The label of the device

  • board_address (str or None) – The IP address of the board that the device is connected to

  • start_active_time_front (int or None) – The “active time” to set for the front LED at the start

  • start_active_time_back (int or None) – The “active time” to set for the back LED at the start

  • start_total_period (int or None) – The “total period” to set at the start

  • start_frequency (int or None) – The “frequency” to set at the start

default_parameters = {'board_address': None, 'label': None, 'n_neurons': 1, 'start_active_time_back': None, 'start_active_time_front': None, 'start_frequency': None, 'start_total_period': None}
class spynnaker.pyNN.external_devices.PushBotSpiNNakerLinkLaserDevice(laser, protocol, spinnaker_link_id, n_neurons=1, label=None, board_address=None, start_active_time=0, start_total_period=0, start_frequency=0)[source]

Bases: PushBotEthernetLaserDevice, ApplicationSpiNNakerLinkVertex, PopulationApplicationVertex

The Laser of a PushBot.

Parameters:
  • laser (PushBotLaser) – Which laser device to control

  • protocol (MunichIoSpiNNakerLinkProtocol) – The protocol instance to get commands from

  • spinnaker_link_id (int) – The SpiNNakerLink that the PushBot is connected to

  • n_neurons (int) – The number of neurons in the device

  • label (str) – A label for the device

  • board_address (str or None) – The IP address of the board that the device is connected to

  • start_active_time (int) – The “active time” value to send at the start

  • start_total_period (int) – The “total period” value to send at the start

  • start_frequency (int) – The “frequency” to send at the start

default_parameters = {'board_address': None, 'label': None, 'n_neurons': 1, 'start_active_time': 0, 'start_frequency': 0, 'start_total_period': 0}
class spynnaker.pyNN.external_devices.PushBotSpiNNakerLinkMotorDevice(motor, protocol, spinnaker_link_id, n_neurons=1, label=None, board_address=None)[source]

Bases: PushBotEthernetMotorDevice, ApplicationSpiNNakerLinkVertex, PopulationApplicationVertex

The motor of a PushBot.

Parameters:
  • motor (PushBotMotor) – the motor to control

  • protocol (MunichIoSpiNNakerLinkProtocol) – The protocol used to control the device

  • spinnaker_link_id (int) – The SpiNNakerLink connected to

  • n_neurons (int) – The number of neurons in the device

  • label (str) – The label of the device

  • board_address (str or None) – The IP address of the board that the device is connected to

default_parameters = {'board_address': None, 'label': None, 'n_neurons': 1}
class spynnaker.pyNN.external_devices.PushBotSpiNNakerLinkRetinaDevice(spinnaker_link_id, protocol, resolution, board_address=None, label=None, n_machine_vertices=1)[source]

Bases: AbstractPushBotRetinaDevice, ApplicationSpiNNakerLinkVertex, PopulationApplicationVertex

Parameters:
default_parameters = {'board_address': None, 'label': None, 'n_machine_vertices': 1}
new_key_command_payload()[source]

Support method to obtain the key after the key allocator has run

Parameters:

routing_info

Returns:

the key

Return type:

int

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices.PushBotSpiNNakerLinkSpeakerDevice(speaker, protocol, spinnaker_link_id, n_neurons=1, label=None, board_address=None, start_active_time=50, start_total_period=100, start_frequency=None, start_melody=None)[source]

Bases: PushBotEthernetSpeakerDevice, ApplicationSpiNNakerLinkVertex, PopulationApplicationVertex

The speaker of a PushBot.

Parameters:
  • speaker (PushBotSpeaker) – Which speaker device to control

  • protocol (MunichIoSpiNNakerLinkProtocol) – The protocol instance to get commands from

  • spinnaker_link_id (int) – The SpiNNakerLink connected to

  • n_neurons (int) – The number of neurons in the device

  • label (str) – The label of the device

  • board_address (str or None) – The IP address of the board that the device is connected to

  • start_active_time (int) – The “active time” to set at the start

  • start_total_period (int) – The “total period” to set at the start

  • start_frequency (int) – The “frequency” to set at the start

  • start_melody (int) – The “melody” to set at the start

default_parameters = {'board_address': None, 'label': None, 'n_neurons': 1, 'start_active_time': 50, 'start_frequency': None, 'start_melody': None, 'start_total_period': 100}
class spynnaker.pyNN.external_devices.SPIFLiveSpikesConnection(receive_labels, spif_host, spif_port=3332, events_per_packet=32, time_per_packet=500, local_host=None, local_port=None)[source]

Bases: DatabaseConnection

A connection for receiving live spikes from SPIF.

Parameters:
  • receive_labels (iterable(str)) – Labels of vertices from which live events will be received.

  • spif_host (str) – The location of the SPIF board receiving packets

  • spif_port (int) – The port of the SPIF board (default 3332)

  • events_per_packet (int) – The maximum number of events in each packet. SPIF will be configured to send a packet as soon as it reaches this size if not before (default is 32)

  • time_per_packet (int) – The maximum time between sending non-empty packets. SPIF will be configured to send a packet that isn’t empty after this many microseconds (default is 500)

  • 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_init_callback(label, init_callback)[source]

Add a callback to be called to initialise a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • init_callback (callable(str, int, float, float) -> None) – A function to be called to initialise the vertex. This should take as parameters the label of the vertex, the number of neurons in the population, the run time of the simulation in milliseconds, and the simulation timestep in milliseconds

add_pause_stop_callback(label, pause_stop_callback)[source]

Add a callback for the pause and stop state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • pause_stop_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the pause or stop message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

add_receive_callback(label, live_event_callback, translate_key=True)[source]

Add a callback for the reception of live events from a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • live_event_callback (callable(str, list(int)) -> None) – A function to be called when events are received. This should take as parameters the label of the vertex, and an array-like of atom IDs.

  • translate_key (bool) – True if the key is to be converted to an atom ID, False if the key should stay a key

add_receive_label(label)[source]
Parameters:

label (str) –

add_start_resume_callback(label, start_resume_callback)[source]

Add a callback for the start and resume state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • start_resume_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the start or resume message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

class spynnaker.pyNN.external_devices.SPIFOutputDevice(board_address=None, chip_coords=None, label=None, create_database=True, database_notify_host=None, database_notify_port_num=None, database_ack_port_num=None)[source]

Bases: ApplicationFPGAVertex, PopulationApplicationVertex, AbstractSendMeMulticastCommandsVertex

Output (only) to a SPIF device.

Parameters:
  • n_atoms (int) – The number of atoms in the vertex

  • incoming_fpga_connections (list(FPGAConnection) or None) – The connections from one or more FPGAs that that packets are expected to be received from for this device, or None if no incoming traffic is expected from the device

  • outgoing_fpga_connection (FPGAConnection or None) – The connection to an FPGA that packets to be sent to this device should be sent down, or None if no outgoing traffic is expected to be sent to the device.

  • label (str) – The optional name of the vertex.

  • n_machine_vertices_per_link (int) – The optional number of machine vertices to create for each FPGA link (1 by default)

add_incoming_edge(edge, partition)[source]

Add an edge incoming to this vertex. This is ignored by default, but could be used to track incoming edges, and/or report faults.

Parameters:
property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices.SPIFRetinaDevice(pipe, width, height, sub_width, sub_height, base_key=None, input_x_shift=16, input_y_shift=0, board_address=None, chip_coords=None)[source]

Bases: Application2DFPGAVertex, PopulationApplicationVertex, AbstractSendMeMulticastCommandsVertex, HasShapeKeyFields

A retina device connected to SpiNNaker using a SPIF board.

Parameters:
  • pipe (int) – Which pipe on SPIF the retina is connected to

  • width (int) – The width of the retina in pixels

  • height (int) – The height of the retina in pixels

  • sub_width (int) – The width of rectangles to split the retina into for efficiency of sending

  • sub_height (int) – The height of rectangles to split the retina into for efficiency of sending

  • base_key (int or None) – The key that is common over the whole vertex, or None to use the pipe number as the key

  • input_x_shift (int) – The shift to get the x coordinate from the input keys sent to SPIF

  • input_y_shift (int) – The shift to get the y coordinate from the input keys sent to SPIF

  • board_address (str or None) –

    The IP address of the board to which the FPGA is connected, or None to use the default board or chip_coords.

    Note

    chip_coords will be used first if both are specified, with board_address then being used if the coordinates don’t connect to an FPGA.

  • chip_coords (tuple(int, int) or None) –

    The coordinates of the chip to which the FPGA is connected, or None to use the default board or board_address.

    Note

    chip_coords will be used first if board_address is also specified, with board_address then being used if the coordinates don’t connect to an FPGA.

X_MASK = 3

See Y_MASK for description

X_PER_ROW = 4

The number of X values per row

Y_MASK = 1

SPIF outputs to 8 FPGA output links, so we split into (2 x 4), meaning a mask of (1 x 3)

get_atom_key_map(pre_vertex, partition_id, routing_info)[source]

Get the mapping between atoms and keys for the given partition id, and for the given machine pre-vertex.

Parameters:
  • pre_vertex (MachineVertex) – The machine vertex to get the map for

  • partition_id (str) – The partition to get the map for

  • routing_info (RoutingInfo) – Routing information

Returns:

A list of (atom_id, key)

Return type:

list(tuple(int,int))

get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

get_incoming_slice_for_link(link, index)[source]

Get the slice to be given to the connection from the given link.

Parameters:
  • link (FPGAConnection) – The FPGA connection to get the slice for

  • index (int) – The index of the connection on the FGPA link, for when n_machine_vertices_per_link > 1

Return type:

Slice

get_machine_fixed_key_and_mask(machine_vertex, partition_id)[source]

Get a fixed key and mask for the given machine vertex and partition identifier, or None if not fixed (the default).

If this doesn’t return None, get_fixed_key_and_mask() must also not return None, and the keys returned here must align with those such that for each key:mask returned here, key & app_mask == app_key. It is OK for this to return None and get_fixed_key_and_mask() to return non-None if and only if there is only one machine vertex.

Parameters:
  • machine_vertex (MachineVertex) – A source machine vertex of this application vertex

  • partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

get_shape_key_fields(vertex_slice)[source]

Get the fields to be used for each dimension in the shape of the given source vertex slice, as a list of start, size, mask, shift values in the order of the fields.

Parameters:

vertex_slice (Slice) – The slice of the source vertex

Return type:

list(tuple(int, int, int, int))

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

spynnaker.pyNN.external_devices.SpikeInjector(notify=True, database_notify_host=None, database_notify_port_num=None, database_ack_port_num=None)[source]

Supports creating a spike injector that can be added to the application graph.

Parameters:
  • notify (bool) – Whether to register for notifications

  • database_notify_host (str or None) – the hostname for the device which is listening to the database notification.

  • database_ack_port_num (int or None) – the port number to which a external device will acknowledge that they have finished reading the database and are ready for it to start execution

  • database_notify_port_num (int or None) – The port number to which a external device will receive the database is ready command

Returns:

The spike injector model object that can be placed in a pyNN Population.

Return type:

AbstractPyNNModel

class spynnaker.pyNN.external_devices.SpynnakerLiveSpikesConnection(receive_labels=None, send_labels=None, local_host=None, local_port=19999, live_packet_gather_label='LiveSpikeReceiver')[source]

Bases: LiveEventConnection

A connection for receiving and sending live spikes from and to SpiNNaker.

Parameters:
  • receive_labels (iterable(str)) – Labels of population from which live spikes will be received.

  • send_labels (iterable(str)) – Labels of population to which live spikes will be sent

  • 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)

send_spike(label, neuron_id, send_full_keys=False)[source]

Send a spike from a single neuron.

Parameters:
  • label (str) – The label of the population from which the spike will originate

  • neuron_id (int) – The ID of the neuron sending a spike

  • send_full_keys (bool) – Determines whether to send full 32-bit keys, getting the key for each neuron from the database, or whether to send 16-bit neuron IDs directly

send_spikes(label, neuron_ids, send_full_keys=False)[source]

Send a number of spikes.

Parameters:
  • label (str) – The label of the population from which the spikes will originate

  • neuron_ids (list(int)) – array-like of neuron IDs sending spikes

  • send_full_keys (bool) – Determines whether to send full 32-bit keys, getting the key for each neuron from the database, or whether to send 16-bit neuron IDs directly

class spynnaker.pyNN.external_devices.SpynnakerPoissonControlConnection(poisson_labels=None, local_host=None, local_port=19999, control_label_extension='_control')[source]

Bases: LiveEventConnection

A connection used to control a Poisson-distributed random event source’s firing rate at runtime.

Parameters:
  • poisson_labels (iterable(str)) – Labels of Poisson populations to be controlled

  • 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)

  • control_label_extension (str) – The extra name added to the label of each Poisson source

add_init_callback(label, init_callback)[source]

Add a callback to be called to initialise a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • init_callback (callable(str, int, float, float) -> None) – A function to be called to initialise the vertex. This should take as parameters the label of the vertex, the number of neurons in the population, the run time of the simulation in milliseconds, and the simulation timestep in milliseconds

add_pause_stop_callback(label, pause_stop_callback)[source]

Add a callback for the pause and stop state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • pause_stop_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the pause or stop message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

add_poisson_label(label)[source]
Parameters:

label (str) – The label of the Poisson source population.

add_receive_callback(label, live_event_callback, translate_key=False)[source]

Add a callback for the reception of live events from a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • live_event_callback (callable(str, int, list(int)) -> None) – A function to be called when events are received. This should take as parameters the label of the vertex, the simulation timestep when the event occurred, and an array-like of atom IDs.

  • translate_key (bool) – True if the key is to be converted to an atom ID, False if the key should stay a key

add_start_callback(label, start_callback)[source]

Add a callback for the start of the simulation.

Parameters:
  • start_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the start message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events

  • label (str) – the label of the function to be sent

add_start_resume_callback(label, start_resume_callback)[source]

Add a callback for the start and resume state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • start_resume_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the start or resume message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

set_rate(label, neuron_id, rate)[source]

Set the rate of a Poisson neuron within a Poisson source.

Parameters:
  • label (str) – The label of the Population to set the rates of

  • neuron_id (int) – The neuron ID to set the rate of

  • rate (float) – The rate to set in Hz

set_rates(label, neuron_id_rates)[source]

Set the rates of multiple Poisson neurons within a Poisson source.

Parameters:
  • label (str) – The label of the Population to set the rates of

  • neuron_id_rates (list(tuple(int,float))) – A list of tuples of (neuron ID, rate) to be set

spynnaker.pyNN.external_devices.activate_live_output_for(population, database_notify_host=None, database_notify_port_num=None, database_ack_port_num=None, port=None, host=None, tag=None, strip_sdp=True, use_prefix=False, key_prefix=None, prefix_type=None, message_type=EIEIOType.KEY_32_BIT, right_shift=0, payload_as_time_stamps=True, notify=True, use_payload_prefix=True, payload_prefix=None, payload_right_shift=0, number_of_packets_sent_per_time_step=0, translate_keys=False)

Output the spikes from a given population from SpiNNaker as they occur in the simulation.

Parameters:
  • population (Population) – The population to activate the live output for

  • database_notify_host (str) – The hostname for the device which is listening to the database notification.

  • database_ack_port_num (int) – The port number to which a external device will acknowledge that they have finished reading the database and are ready for it to start execution

  • database_notify_port_num (int) – The port number to which a external device will receive the database is ready command

  • key_prefix (int or None) – the prefix to be applied to the key

  • prefix_type (EIEIOPrefix) – if the prefix type is 32 bit or 16 bit

  • message_type (EIEIOType) – If the message is a EIEIO command message, or an EIEIO data message with 16 bit or 32 bit keys.

  • payload_as_time_stamps (bool) –

  • right_shift (int) –

  • use_payload_prefix (bool) –

  • notify (bool) –

  • payload_prefix (int or None) –

  • payload_right_shift (int) –

  • number_of_packets_sent_per_time_step (int) –

  • port (int) – The UDP port to which the live spikes will be sent. If not specified, the port will be taken from the “live_spike_port” parameter in the “Recording” section of the sPyNNaker configuration file.

  • host (str) – The host name or IP address to which the live spikes will be sent. If not specified, the host will be taken from the “live_spike_host” parameter in the “Recording” section of the sPyNNaker configuration file.

  • tag (int) – The IP tag to be used for the spikes. If not specified, one will be automatically assigned

  • strip_sdp (bool) – Determines if the SDP headers will be stripped from the transmitted packet.

  • use_prefix (bool) – Determines if the spike packet will contain a common prefix for the spikes

  • label (str) – The label of the gatherer vertex

  • partition_ids (list(str)) – The names of the partitions to create edges for

  • translate_keys (bool) – Whether the incoming keys from the cores should be translated to global keys rather than core-based keys

spynnaker.pyNN.external_devices.activate_live_output_to(population, device, partition_id='SPIKE')

Activate the output of spikes from a population to an external device.

Note

All spikes will be sent to the device.

Parameters:
  • population (Population) – The pyNN population object from which spikes will be sent.

  • device (Population or ApplicationVertex) – The pyNN population or external device to which the spikes will be sent.

  • partition_id (str) – The partition ID to activate live output to.

spynnaker.pyNN.external_devices.add_poisson_live_rate_control(poisson_population, control_label_extension='_control', receive_port=None, database_notify_host=None, database_notify_port_num=None, database_ack_port_num=None, notify=True, reserve_reverse_ip_tag=False)

Add a live rate controller to a Poisson population.

Parameters:
  • poisson_population (Population) – The population to control

  • control_label_extension (str) – An extension to add to the label of the Poisson source. Must match up with the equivalent in the SpynnakerPoissonControlConnection

  • receive_port (int) – The port that the SpiNNaker board should listen on

  • database_notify_host (str) – the hostname for the device which is listening to the database notification.

  • database_ack_port_num (int) – the port number to which a external device will acknowledge that they have finished reading the database and are ready for it to start execution

  • database_notify_port_num (int) – The port number to which an external device will receive the database is ready command

  • notify (bool) – adds to the notification protocol if set.

  • reserve_reverse_ip_tag (bool) – True if a reverse IP tag is to be used, False if SDP is to be used (default)

spynnaker.pyNN.external_devices.register_database_notification_request(hostname, notify_port, ack_port)[source]

Adds a socket system which is registered with the notification protocol.

Parameters:
  • hostname (str) – hostname to connect to

  • notify_port (int) – UDP port number for the notify command

  • ack_port (int) – UDP port number for the acknowledge command

spynnaker.pyNN.external_devices.run_forever(sync_time=0)[source]

Supports running forever in PyNN 0.8/0.9 format.

Parameters:

sync_time – The time in milliseconds after which to pause before the host must continue the simulation.

Returns:

Only when the application has started running on the SpiNNaker platform; no value is returned.

spynnaker.pyNN.external_devices_models package
Subpackages
spynnaker.pyNN.external_devices_models.push_bot package
Subpackages
spynnaker.pyNN.external_devices_models.push_bot.control package
Module contents
class spynnaker.pyNN.external_devices_models.push_bot.control.PushBotLifEthernet(**kwargs)[source]

Bases: ExternalDeviceLifControl

Leaky integrate and fire neuron with an exponentially decaying current input.

Parameters:
  • protocol (MunichIoEthernetProtocol) – How to talk to the bot.

  • devices (iterable(AbstractMulticastControllableDevice)) – The devices on the bot that we are interested in.

  • pushbot_ip_address (str) – Where is the pushbot?

  • pushbot_port (int) – (defaulted)

  • tau_m (float) – LIF neuron parameter (defaulted)

  • cm (float) – LIF neuron parameter (defaulted)

  • v_rest (float) – LIF neuron parameter (defaulted)

  • v_reset (float) – LIF neuron parameter (defaulted)

  • tau_syn_E (float) – LIF neuron parameter (defaulted)

  • tau_syn_I (float) – LIF neuron parameter (defaulted)

  • tau_refrac (float) – LIF neuron parameter (defaulted)

  • i_offset (float) – LIF neuron parameter (defaulted)

  • v (float) – LIF neuron parameter (defaulted)

  • isyn_exc (float) – LIF neuron parameter (defaulted)

  • isyn_inh (float) – LIF neuron parameter (defaulted)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

Bases: ExternalDeviceLifControl

Control module for a PushBot connected to a SpiNNaker Link.

Parameters:
  • protocol (MunichIoSpiNNakerLinkProtocol) – How to talk to the bot.

  • devices (iterable(AbstractMulticastControllableDevice)) – The devices on the bot that we are interested in.

  • tau_m (float) – LIF neuron parameter (defaulted)

  • cm (float) – LIF neuron parameter (defaulted)

  • v_rest (float) – LIF neuron parameter (defaulted)

  • v_reset (float) – LIF neuron parameter (defaulted)

  • tau_syn_E (float) – LIF neuron parameter (defaulted)

  • tau_syn_I (float) – LIF neuron parameter (defaulted)

  • tau_refrac (float) – LIF neuron parameter (defaulted)

  • i_offset (float) – LIF neuron parameter (defaulted)

  • v (float) – LIF neuron parameter (defaulted)

  • isyn_exc (float) – LIF neuron parameter (defaulted)

  • isyn_inh (float) – LIF neuron parameter (defaulted)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

spynnaker.pyNN.external_devices_models.push_bot.ethernet package
Module contents
class spynnaker.pyNN.external_devices_models.push_bot.ethernet.PushBotEthernetDevice(protocol, device, uses_payload, time_between_send, first_send_timestep=100)[source]

Bases: AbstractMulticastControllableDevice

An arbitrary PushBot device.

Parameters:
  • protocol (MunichIoEthernetProtocol) – The protocol instance to get commands from

  • device (AbstractPushBotOutputDevice) – The Enum instance of the device to control

  • uses_payload (bool) – True if the device uses a payload for control

  • time_between_send (int) – The timesteps between sending

  • first_send_timestep (int) – The first timestep to send

property device_control_first_send_timestep

The first timestep that the device should send in (0 by default).

Return type:

int

property device_control_key

The key that must be sent to the device to control it.

Return type:

int

property device_control_max_value

The maximum value to send to the device.

Return type:

float

property device_control_min_value

The minimum value to send to the device.

Return type:

float

property device_control_partition_id

A partition ID to give to an outgoing edge partition that will control this device.

Return type:

str

property device_control_send_type

The type of data to be sent.

Return type:

SendType

property device_control_timesteps_between_sending

The number of timesteps between sending commands to the device. This defines the “sampling interval” for the device.

Return type:

int

property device_control_uses_payload

Whether the control of the device accepts an arbitrary valued payload, the value of which will change the devices behaviour.

Return type:

bool

property protocol

The protocol instance, for use in the subclass.

Return type:

MunichIoEthernetProtocol

abstract set_command_protocol(command_protocol)[source]

Set the protocol use to send setup and shutdown commands, separately from the protocol used to control the device.

Parameters:

command_protocol (MunichIoSpiNNakerLinkProtocol) – The protocol to use for this device

class spynnaker.pyNN.external_devices_models.push_bot.ethernet.PushBotEthernetLEDDevice(led, protocol, start_active_time_front=None, start_active_time_back=None, start_total_period=None, start_frequency=None, timesteps_between_send=None)[source]

Bases: PushBotEthernetDevice, AbstractSendMeMulticastCommandsVertex

The LED of a PushBot.

Parameters:
  • led (PushBotLED) – The LED to control

  • protocol (MunichIoEthernetProtocol) – The protocol instance to get commands from

  • start_active_time_front (int) – The “active time” to set for the front LED at the start

  • start_active_time_back (int) – The “active time” to set for the back LED at the start

  • start_total_period (int) – The “total period” to set at the start

  • start_frequency (int) – The “frequency” to set at the start

  • timesteps_between_send (int) – The number of timesteps between sending commands to the device, or None to use the default

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

set_command_protocol(command_protocol)[source]

Set the protocol use to send setup and shutdown commands, separately from the protocol used to control the device.

Parameters:

command_protocol (MunichIoSpiNNakerLinkProtocol) – The protocol to use for this device

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices_models.push_bot.ethernet.PushBotEthernetLaserDevice(laser, protocol, start_active_time=None, start_total_period=None, start_frequency=None, timesteps_between_send=None)[source]

Bases: PushBotEthernetDevice, AbstractSendMeMulticastCommandsVertex

The Laser of a PushBot.

Parameters:
  • laser (PushBotLaser) – The PushBotLaser value to control

  • protocol (MunichIoEthernetProtocol) – The protocol instance to get commands from

  • start_active_time (int) – The “active time” value to send at the start

  • start_total_period (int) – The “total period” value to send at the start

  • start_frequency (int) – The “frequency” to send at the start

  • timesteps_between_send (int) – The number of timesteps between sending commands to the device, or None to use the default

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

set_command_protocol(command_protocol)[source]

Set the protocol use to send setup and shutdown commands, separately from the protocol used to control the device.

Parameters:

command_protocol (MunichIoSpiNNakerLinkProtocol) – The protocol to use for this device

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices_models.push_bot.ethernet.PushBotEthernetMotorDevice(motor, protocol, timesteps_between_send=None)[source]

Bases: PushBotEthernetDevice, AbstractSendMeMulticastCommandsVertex

The motor of a PushBot.

Parameters:
  • motor (PushBotMotor) – indicates which motor to control

  • protocol (MunichIoEthernetProtocol) – The protocol used to control the device

  • timesteps_between_send (int) – The number of timesteps between sending commands to the device, or None to use the default

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

set_command_protocol(command_protocol)[source]

Set the protocol use to send setup and shutdown commands, separately from the protocol used to control the device.

Parameters:

command_protocol (MunichIoSpiNNakerLinkProtocol) – The protocol to use for this device

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices_models.push_bot.ethernet.PushBotEthernetRetinaDevice(protocol, resolution, pushbot_ip_address, pushbot_port=56000, injector_port=None, local_host=None, local_port=None, retina_injector_label='PushBotRetinaInjector')[source]

Bases: AbstractPushBotRetinaDevice, AbstractEthernetSensor

Parameters:
get_database_connection()[source]

Get a Database Connection instance that this device uses to inject packets.

Return type:

SpynnakerLiveSpikesConnection

Return type:

PushBotRetinaConnection

get_injector_label()[source]

Get the label to give to the Spike Injector.

Return type:

str

get_injector_parameters()[source]

Get the parameters of the Spike Injector to use with this device.

Return type:

dict(str,Any)

get_n_neurons()[source]

Get the number of neurons that will be sent out by the device.

Return type:

int

get_translator()[source]

Get a translator of multicast commands to Ethernet commands.

Return type:

AbstractEthernetTranslator

class spynnaker.pyNN.external_devices_models.push_bot.ethernet.PushBotEthernetSpeakerDevice(speaker, protocol, start_active_time=0, start_total_period=0, start_frequency=0, start_melody=None, timesteps_between_send=None)[source]

Bases: PushBotEthernetDevice, AbstractSendMeMulticastCommandsVertex

The Speaker of a PushBot.

Parameters:
  • speaker (PushBotSpeaker) – The speaker to control

  • protocol (MunichIoEthernetProtocol) – The protocol instance to get commands from

  • start_active_time (int) – The “active time” to set at the start

  • start_total_period (int) – The “total period” to set at the start

  • start_frequency (int) – The “frequency” to set at the start

  • start_melody (int) – The “melody” to set at the start

  • timesteps_between_send (int) – The number of timesteps between sending commands to the device, or None to use the default

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

set_command_protocol(command_protocol)[source]

Set the protocol use to send setup and shutdown commands, separately from the protocol used to control the device.

Parameters:

command_protocol (MunichIoSpiNNakerLinkProtocol) – The protocol to use for this device

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices_models.push_bot.ethernet.PushBotRetinaConnection(retina_injector_label, pushbot_wifi_connection, resolution=PushBotRetinaResolution.NATIVE_128_X_128, local_host=None, local_port=None)[source]

Bases: SpynnakerLiveSpikesConnection

A connection that sends spikes from the PushBot retina to a spike injector in SpiNNaker.

Note

This assumes a packet format of 16-bits per retina event.

Parameters:
class spynnaker.pyNN.external_devices_models.push_bot.ethernet.PushBotTranslator(protocol, pushbot_wifi_connection)[source]

Bases: AbstractEthernetTranslator

Translates packets between PushBot Multicast packets and PushBot Wi-Fi Commands.

Parameters:
translate_control_packet(multicast_packet)[source]

Translate a multicast packet received over Ethernet and send appropriate messages to the external device.

Parameters:

multicast_packet (AbstractDataElement) – A received multicast packet

class spynnaker.pyNN.external_devices_models.push_bot.ethernet.PushBotWIFIConnection(remote_host, remote_port=56000)[source]

Bases: Connection, Listenable

A connection to a PushBot via Wi-Fi.

Parameters:
  • remote_host (str) – The IP address of the PushBot

  • remote_port (int) – The port number of the PushBot (default 56000)

Raises:

SpinnmanIOException – If there is an error setting up the communication channel

RECV_SIZE = 1024
close()[source]

See spinnman.connections.Connection.close().

get_receive_method()[source]

Get the method that receives for this connection.

is_connected()[source]

See is_connected().

is_ready_to_receive(timeout=0)[source]

Determines if there is an SCP packet to be read without blocking.

Parameters:

timeout (int) – The time to wait before returning if the connection is not ready

Returns:

True if there is an SCP packet to be read

Return type:

bool

property local_ip_address

The local IP address to which the connection is bound, as a dotted string, e.g. 0.0.0.0.

Return type:

str

property local_port

The local port to which the connection is bound.

Return type:

int

receive(timeout=None)[source]

Receive data from the connection

Parameters:

timeout (float or None) – The timeout, or None to wait forever

Returns:

The data received

Return type:

bytes

Raises:
property remote_ip_address

The remote IP address to which the connection is connected, as a dotted string, or None if not connected remotely.

Return type:

str or None

property remote_port

The remote port to which the connection is connected, or None if not connected remotely.

Return type:

int or None

send(data)[source]

Send data down this connection

Parameters:

data (bytearray) – The data to be sent

Raises:

SpinnmanIOException – If there is an error sending the data

spynnaker.pyNN.external_devices_models.push_bot.ethernet.get_pushbot_wifi_connection(remote_host, remote_port=56000)[source]

Get an existing connection to a PushBot, or make a new one.

Parameters:
  • remote_host (str) – The IP address of the PushBot

  • remote_port (int) – The port number of the PushBot (default 56000)

spynnaker.pyNN.external_devices_models.push_bot.parameters package
Module contents
class spynnaker.pyNN.external_devices_models.push_bot.parameters.PushBotLED(value)[source]

Bases: AbstractPushBotOutputDevice

The properties of the LED device that may be set.

LED_BACK_ACTIVE_TIME = 2
LED_FREQUENCY = 3
LED_FRONT_ACTIVE_TIME = 1
LED_TOTAL_PERIOD = 0
class spynnaker.pyNN.external_devices_models.push_bot.parameters.PushBotLaser(value)[source]

Bases: AbstractPushBotOutputDevice

The properties of the laser device that may be set.

LASER_ACTIVE_TIME = 1

The active period for the laser (no larger than the total period)

LASER_FREQUENCY = 2

The frequency of the laser

LASER_TOTAL_PERIOD = 0

The total period for the laser

class spynnaker.pyNN.external_devices_models.push_bot.parameters.PushBotMotor(value)[source]

Bases: AbstractPushBotOutputDevice

The properties of the motor devices that may be set. The pushbot has two motors, 0 (left) and 1 (right).

MOTOR_0_LEAKY = 1

For motor 0, set a variable speed depending on time since event receive

MOTOR_0_PERMANENT = 0

For motor 0, set a particular speed

MOTOR_1_LEAKY = 3

For motor 1, set a variable speed depending on time since event receive

MOTOR_1_PERMANENT = 2

For motor 0, set a particular speed

class spynnaker.pyNN.external_devices_models.push_bot.parameters.PushBotRetinaResolution(value)[source]

Bases: Enum

Resolutions supported by the pushbot retina device.

DOWNSAMPLE_16_X_16 = RetinaKey.DOWNSAMPLE_16_X_16

Down sampled 64 (\(8 \times 8\)) pixels to 1

DOWNSAMPLE_32_X_32 = RetinaKey.DOWNSAMPLE_32_X_32

Down sampled 16 (\(4 \times 4\)) pixels to 1

DOWNSAMPLE_64_X_64 = RetinaKey.DOWNSAMPLE_64_X_64

Down sampled 4 (\(2 \times 2\)) pixels to 1

NATIVE_128_X_128 = RetinaKey.NATIVE_128_X_128

The native resolution

class spynnaker.pyNN.external_devices_models.push_bot.parameters.PushBotRetinaViewer(retina_resolution, label, sim)[source]

Bases: object

Viewer of retina from the PushBot.

property port

The port the connection is listening on.

Return type:

int

run(run_time)[source]

Run the viewer and simulation for a fixed time.

run_until_closed()[source]

Run the viewer and simulation until the viewer is closed.

class spynnaker.pyNN.external_devices_models.push_bot.parameters.PushBotSpeaker(value)[source]

Bases: AbstractPushBotOutputDevice

The properties of the speaker device that may be set.

SPEAKER_ACTIVE_TIME = 1
SPEAKER_MELODY = 3
SPEAKER_TONE = 2
SPEAKER_TOTAL_PERIOD = 0
Module contents
class spynnaker.pyNN.external_devices_models.push_bot.AbstractPushBotOutputDevice(value)[source]

Bases: Enum

Superclass of all output device descriptors.

property max_value
property min_value
property protocol_property
Return type:

property

property send_type
Return type:

SendType

property time_between_send
Return type:

int

class spynnaker.pyNN.external_devices_models.push_bot.AbstractPushBotRetinaDevice(protocol, resolution)[source]

Bases: AbstractSendMeMulticastCommandsVertex

An abstraction of a silicon retina attached to a SpiNNaker system.

Parameters:
property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

Submodules
spynnaker.pyNN.external_devices_models.external_device_lif_control_vertex module
class spynnaker.pyNN.external_devices_models.external_device_lif_control_vertex.ExternalDeviceLifControlVertex(devices, create_edges, max_atoms_per_core, neuron_impl, pynn_model, translator=None, spikes_per_second=None, label=None, ring_buffer_sigma=None, incoming_spike_buffer_size=None, drop_late_spikes=None, splitter=None, seed=None, n_colour_bits=None)[source]

Bases: AbstractPopulationVertex, AbstractEthernetController, AbstractVertexWithEdgeToDependentVertices, HasCustomAtomKeyMap

Abstract control module for the pushbot, based on the LIF neuron, but without spikes, and using the voltage as the output to the various devices.

Parameters:
  • devices (list(AbstractMulticastControllableDevice)) – The AbstractMulticastControllableDevice instances to be controlled by the population

  • create_edges (bool) – True if edges to the devices should be added by this dev (set to False if using the dev over Ethernet using a translator)

  • max_atoms_per_core (int) –

  • neuron_impl (AbstractNeuronImpl) –

  • pynn_model (AbstractPyNNNeuronModel) –

  • translator (AbstractEthernetTranslator or None) – Translator to be used when used for Ethernet communication. Must be provided if the dev is to be controlled over Ethernet.

  • spikes_per_second (float) –

  • label (str) –

  • ring_buffer_sigma (float) –

  • incoming_spike_buffer_size (int) –

  • splitter (AbstractSplitterCommon or None) – splitter from application vertices to machine vertices

  • n_colour_bits (int) – The number of colour bits to use

dependent_vertices()[source]

Return the vertices which this vertex depends upon.

Return type:

iterable(ApplicationVertex)

edge_partition_identifiers_for_dependent_vertex(vertex)[source]

Return the dependent edge identifiers for a particular dependent vertex.

Parameters:

vertex (ApplicationVertex) –

Return type:

iterable(str)

get_atom_key_map(pre_vertex, partition_id, routing_info)[source]

Get the mapping between atoms and keys for the given partition id, and for the given machine pre-vertex.

Parameters:
  • pre_vertex (MachineVertex) – The machine vertex to get the map for

  • partition_id (str) – The partition to get the map for

  • routing_info (RoutingInfo) – Routing information

Returns:

A list of (atom_id, key)

Return type:

list(tuple(int,int))

get_external_devices()[source]

Get the external devices that are to be controlled by the controller.

Return type:

iterable(AbstractMulticastControllableDevice)

get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

get_message_translator()[source]

Get the translator of messages.

Return type:

AbstractEthernetTranslator

get_outgoing_partition_ids()[source]

Get the partition IDs of messages coming out of the controller.

Return type:

list(str)

spynnaker.pyNN.external_devices_models.spif_devices module

Devices connected to the SpiNNaker peripheral interface (SPIF).

spynnaker.pyNN.external_devices_models.spif_devices.N_FIELDS = 4

The number of fields supported for each pipe

spynnaker.pyNN.external_devices_models.spif_devices.N_FILTERS = 8

The number of filters supported for each pipe

spynnaker.pyNN.external_devices_models.spif_devices.N_INPUTS = 8

The number of FPGA inputs per pipe

Note

The 16 inputs are not actually separated in the hardware, but a logical separation per pipe is useful.

spynnaker.pyNN.external_devices_models.spif_devices.N_PIPES = 2

The number of pipes

class spynnaker.pyNN.external_devices_models.spif_devices.SPIFRegister(value)[source]

Bases: IntEnum

The register offsets on a SPIF device.

CONFIG_PKT_CNT = 65

The configuration packet count register

DROPPED_PKT_CNT = 66

The dropped packet count register

FL_MASK_BASE = 176

The filter mask base register (8 filters per pipe)

FL_VALUE_BASE = 144

The filter value base register (8 filters per pipe)

IN_PERIPH_PKT_CNT = 67

The input peripheral packet count register

IR_KEY_BASE = 16

The input key register base (8 inputs per pipe)

IR_MASK_BASE = 32

The input mask register base (8 inputs per pipe)

IR_ROUTE_BASE = 48

The input route register base (8 inputs per pipe)

MP_FLD_LIMIT_BASE = 128

The output mapper field limit base register (4 fields per pipe)

MP_FLD_MASK_BASE = 96

The output mapper field mask base register (4 fields per pipe)

MP_FLD_SHIFT_BASE = 112

The output mapper field shift base register (4 fields per pipe)

MP_KEY_BASE = 80

The output mapper key base register (2 pipes)

OUT_PERIPH_PKT_CNT = 64

The output peripheral packet count register

REPLY_KEY = 2

The key to send messages back when requested

cmd(payload=None, index=0)[source]

Make a command to send to a SPIF device to set a register value.

Parameters:
  • payload (int or None) – The payload to use in the command, or None for no payload

  • index (int) – The index of the register to send to when there are multiple registers starting from a base

Return type:

MultiCastCommand

spynnaker.pyNN.external_devices_models.spif_devices.SPIF_FPGA_ID = 0

SPIF is always connected to FPGA 0

SPIF always gets input from odd links on FPGA 0 (1, 3, 5, 7, 9, 11, 13, 15)

SPIF always outputs to FPGA link 15 on FPGA 0

class spynnaker.pyNN.external_devices_models.spif_devices.SpiNNFPGARegister(value)[source]

Bases: IntEnum

The register offsets on the SpiNNaker FPGAs for devices.

LC_KEY = 12

The base key which identifies packets to write to the FPGA registers

LC_MASK = 13

The mask which identifies packets to write to the FPGA registers

P_KEY = 2

The base key which identifies packets to send out to the peripheral

P_MASK = 3

The mask which identifies packets to send out to the peripheral

RC_KEY = 14

The base key which identifies packets to write to the peripheral registers

RC_MASK = 15

The mask which identifies packets to write to the peripheral registers

START = 17

The register to write to to start the sending of data from the peripheral to SpiNNaker

STOP = 16

The register to write to to stop the sending of data from the peripheral to SpiNNaker

cmd(payload=None)[source]

Make a command to send to the FPGA to set a register value.

Parameters:

payload (int or None) – The payload to use in the command, or None for no payload

Return type:

MultiCastCommand

delayed_command(get_payload)[source]

Make a command to send to the FPGA to set a register value, where the value itself is currently unknown.

Parameters:

get_payload (callable()->int) – A function to call to get the payload later

Return type:

MultiCastCommand

spynnaker.pyNN.external_devices_models.spif_devices.set_field_limit(pipe, index, limit)[source]

Get a command to set the limit of a mapper field on SPIF. This sets a limit on the value of the field after shifting and masking.

Parameters:
  • pipe (int) – The SPIF pipe to set the limit of (0-1)

  • index (int) – The index of the field to set (0-3)

  • limit (int) – The maximum value of the field

Return type:

MultiCastCommand

spynnaker.pyNN.external_devices_models.spif_devices.set_field_mask(pipe, index, mask)[source]

Get a command to set the mask of a mapper field on SPIF. This masks off the bits of the field from the incoming UDP or USB packet values (which are 32-bits each).

Parameters:
  • pipe (int) – The SPIF pipe to set the mask of (0-1)

  • index (int) – The index of the field to set (0-3)

  • mask (int) – The mask to set

Return type:

MultiCastCommand

spynnaker.pyNN.external_devices_models.spif_devices.set_field_shift(pipe, index, shift)[source]

Get a command to set the shift of a mapper field on SPIF. This shifts the masked bits of the field from the incoming UDP or USB packet values (which are 32-bits each).

Parameters:
  • pipe (int) – The SPIF pipe to set the shift of (0-1)

  • index (int) – The index of the field to set (0-3)

  • shift (int) – The shift value to set (0-31); positive = right, negative = left

Return type:

MultiCastCommand

spynnaker.pyNN.external_devices_models.spif_devices.set_filter_mask(pipe, index, mask)[source]

Get a command to set the mask of a filter of SPIF. This will drop input events from the UDP or USB packets where filter value == filter mask & event value.

Parameters:
  • pipe (int) – The SPIF pipe to set the filter of (0-1)

  • index (int) – The index of the filter to set (0-7)

  • mask (int) – The filter mask to set

Return type:

MultiCastCommand

spynnaker.pyNN.external_devices_models.spif_devices.set_filter_value(pipe, index, value)[source]

Get a command to set the value of a filter of SPIF. This will drop input events from the UDP or USB packets where filter value == filter mask & event value.

Parameters:
  • pipe (int) – The SPIF pipe to set the filter of (0-1)

  • index (int) – The index of the filter to set (0-7)

  • value (int) – The filter value to set

Return type:

MultiCastCommand

spynnaker.pyNN.external_devices_models.spif_devices.set_input_key(pipe, index, key)[source]

Get a command to set the key of the FPGA input of SPIF. This tells SPIF how to route the incoming packets after they have been assembled by the mapper; when incoming key & input mask == input_key, the packet will be routed to input_route.

Parameters:
  • pipe (int) – The SPIF pipe to set the input of (0-1)

  • index (int) – The index of the input to set (0-7)

  • key (int) – The key to set

Return type:

MultiCastCommand

spynnaker.pyNN.external_devices_models.spif_devices.set_input_mask(pipe, index, mask)[source]

Get a command to set the mask of the FPGA input of SPIF. This tells SPIF how to route the incoming packets after they have been assembled by the mapper; when incoming key & input mask == input_key, the packet will be routed to input_route.

Parameters:
  • pipe (int) – The SPIF pipe to set the input of (0-1)

  • index (int) – The index of the input to set (0-7)

  • mask (int) – The mask to set

Return type:

MultiCastCommand

spynnaker.pyNN.external_devices_models.spif_devices.set_input_route(pipe, index, route)[source]

Get a command to set the route of the FPGA input of SPIF. This tells SPIF how to route the incoming packets after they have been assembled by the mapper; when incoming key & input mask == input_key, the packet will be routed to input_route.

Note

route 0 refers to FPGA link 15, 1 to 13 and so on in twos.

Parameters:
  • pipe (int) – The SPIF pipe to set the input of (0-1)

  • index (int) – The index of the input to set (0-7)

  • route (int) – The route to set

Return type:

MultiCastCommand

spynnaker.pyNN.external_devices_models.spif_devices.set_mapper_key(pipe, key)[source]

Get a command to set the output base key for packets from SPIF. This will be added to the keys determined by the mapper output.

Parameters:
  • pipe (int) – The SPIF pipe to set the key of (0-1)

  • key (int) – The output key to set

Return type:

MultiCastCommand

Module contents
class spynnaker.pyNN.external_devices_models.AbstractEthernetController[source]

Bases: object

A controller that can send multicast packets which can be received over Ethernet and translated to control an external device.

abstract get_external_devices()[source]

Get the external devices that are to be controlled by the controller.

Return type:

iterable(AbstractMulticastControllableDevice)

abstract get_message_translator()[source]

Get the translator of messages.

Return type:

AbstractEthernetTranslator

abstract get_outgoing_partition_ids()[source]

Get the partition IDs of messages coming out of the controller.

Return type:

list(str)

class spynnaker.pyNN.external_devices_models.AbstractEthernetSensor[source]

Bases: object

abstract get_database_connection()[source]

Get a Database Connection instance that this device uses to inject packets.

Return type:

SpynnakerLiveSpikesConnection

abstract get_injector_label()[source]

Get the label to give to the Spike Injector.

Return type:

str

abstract get_injector_parameters()[source]

Get the parameters of the Spike Injector to use with this device.

Return type:

dict(str,Any)

abstract get_n_neurons()[source]

Get the number of neurons that will be sent out by the device.

Return type:

int

abstract get_translator()[source]

Get a translator of multicast commands to Ethernet commands.

Return type:

AbstractEthernetTranslator

class spynnaker.pyNN.external_devices_models.AbstractEthernetTranslator[source]

Bases: object

A module that can translate packets received over Ethernet into control of an external device.

abstract translate_control_packet(multicast_packet)[source]

Translate a multicast packet received over Ethernet and send appropriate messages to the external device.

Parameters:

multicast_packet (AbstractDataElement) – A received multicast packet

class spynnaker.pyNN.external_devices_models.AbstractMulticastControllableDevice[source]

Bases: object

A device that can be controlled by sending multicast packets to it, either directly, or via Ethernet using an AbstractEthernetTranslator.

property device_control_first_send_timestep

The first timestep that the device should send in (0 by default).

Return type:

int

abstract property device_control_key

The key that must be sent to the device to control it.

Return type:

int

abstract property device_control_max_value

The maximum value to send to the device.

Return type:

float

abstract property device_control_min_value

The minimum value to send to the device.

Return type:

float

abstract property device_control_partition_id

A partition ID to give to an outgoing edge partition that will control this device.

Return type:

str

property device_control_scaling_factor

The scaling factor used to send the payload to this device.

Return type:

int

abstract property device_control_send_type

The type of data to be sent.

Return type:

SendType

abstract property device_control_timesteps_between_sending

The number of timesteps between sending commands to the device. This defines the “sampling interval” for the device.

Return type:

int

abstract property device_control_uses_payload

Whether the control of the device accepts an arbitrary valued payload, the value of which will change the devices behaviour.

Return type:

bool

class spynnaker.pyNN.external_devices_models.ArbitraryFPGADevice(n_neurons, fpga_link_id, fpga_id, board_address=None, chip_coords=None, label=None)[source]

Bases: ApplicationFPGAVertex, PopulationApplicationVertex

Parameters:
  • n_neurons (int) – Number of neurons

  • fpga_link_id (int) –

  • fpga_id (int) –

  • board_address (str or None) –

  • chip_coords (tuple(int, int) or None) –

  • label (str or None) –

class spynnaker.pyNN.external_devices_models.ExternalCochleaDevice(n_neurons, spinnaker_link, label=None, board_address=None)[source]

Bases: ApplicationSpiNNakerLinkVertex, PopulationApplicationVertex

Parameters:
  • n_neurons (int) – Number of neurons

  • spinnaker_link (int) – The SpiNNaker link to which the cochlea is connected

  • label (str) –

  • board_address (str) –

class spynnaker.pyNN.external_devices_models.ExternalDeviceLifControl(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Abstract control module for the PushBot, based on the LIF neuron, but without spikes, and using the voltage as the output to the various devices.

Parameters:
create_vertex(n_neurons, label, spikes_per_second, ring_buffer_sigma, incoming_spike_buffer_size, n_steps_per_timestep, drop_late_spikes, splitter, seed, n_colour_bits)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

  • spikes_per_second (float) –

  • ring_buffer_sigma (float) –

  • incoming_spike_buffer_size (int) –

  • drop_late_spikes (bool) –

  • splitter (AbstractSplitterCommon or None) –

  • seed (float) –

  • n_colour_bits (int) –

  • n_steps_per_timestep (int) –

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

class spynnaker.pyNN.external_devices_models.ExternalFPGARetinaDevice(mode, retina_key, spinnaker_link_id, polarity, label=None, board_address=None)[source]

Bases: ApplicationSpiNNakerLinkVertex, PopulationApplicationVertex, AbstractSendMeMulticastCommandsVertex

Parameters:
  • mode (str) – The retina “mode”

  • retina_key (int) – The value of the top 16-bits of the key

  • spinnaker_link_id (int) – The SpiNNaker link to which the retina is connected

  • polarity (str) – The “polarity” of the retina data

  • label (str) –

  • board_address (str) –

DOWN_POLARITY = 'DOWN'
MERGED_POLARITY = 'MERGED'
MODE_128 = '128'
MODE_16 = '16'
MODE_32 = '32'
MODE_64 = '64'
UP_POLARITY = 'UP'
get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

static get_n_neurons(mode, polarity)[source]
Parameters:
  • mode (str) – 128 or 64 or 32 or 16

  • parity (str) – UP or DOWN or MERGED

Return type:

int

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices_models.ICUBRetinaDevice(base_key=0, width=304, height=240, sub_width=16, sub_height=16, spinnaker_link_id=0, board_address=None)[source]

Bases: Application2DSpiNNakerLinkVertex, HasShapeKeyFields

An ICUB retina device connected to SpiNNaker using a SpiNNakerLink.

Parameters:
  • base_key (int) – The key that is common over the whole vertex

  • width (int) – The width of the retina in pixels

  • height (int) – The height of the retina in pixels

  • sub_width (int) – The width of rectangles to split the retina into for efficiency of sending

  • sub_height (int) – The height of rectangles to split the retina into for efficiency of sending

  • spinnaker_link_id (int) – The ID of the SpiNNaker link that the device is connected to

  • board_address (str or None) – The board to which the device is connected, or None for the first board

get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

get_incoming_slice(index)[source]

Get the slice to be given to the connection.

Parameters:

index (int) – The index of the connection, for when n_machine_vertices > 1

Return type:

Slice

get_machine_fixed_key_and_mask(machine_vertex, partition_id)[source]

Get a fixed key and mask for the given machine vertex and partition identifier, or None if not fixed (the default).

If this doesn’t return None, get_fixed_key_and_mask() must also not return None, and the keys returned here must align with those such that for each key:mask returned here, key & app_mask == app_key. It is OK for this to return None and get_fixed_key_and_mask() to return non-None if and only if there is only one machine vertex.

Parameters:
  • machine_vertex (MachineVertex) – A source machine vertex of this application vertex

  • partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

get_shape_key_fields(vertex_slice)[source]

Get the fields to be used for each dimension in the shape of the given source vertex slice, as a list of start, size, mask, shift values in the order of the fields.

Parameters:

vertex_slice (Slice) – The slice of the source vertex

Return type:

list(tuple(int, int, int, int))

class spynnaker.pyNN.external_devices_models.MachineMunichMotorDevice(speed, sample_time, update_time, delay_time, delta_threshold, continue_if_not_different, label=None, app_vertex=None)[source]

Bases: MachineVertex, AbstractGeneratesDataSpecification, AbstractHasAssociatedBinary, ProvidesProvenanceDataFromMachineImpl

An Omnibot motor control device. This has a real vertex and an external device vertex.

Parameters:
  • speed (int) –

  • sample_time (int) –

  • update_time (int) –

  • delay_time (int) –

  • delta_threshold (int) –

  • continue_if_not_different (bool) –

  • label (str) –

  • app_vertex (ApplicationVertex) –

INPUT_BUFFER_FULL_NAME = 'Times_the_input_buffer_lost_packets'

The name of the provenance item saying that packets were lost.

MOTOR_PARTITION_ID = 'MOTOR'
generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

get_n_keys_for_partition(partition_id)[source]

Get the number of keys required by the given partition of edges.

Parameters:

partition_id (str) – The identifier of the partition; the partition_id param is only used by some MachineVertex subclasses

Returns:

The number of keys required

Return type:

int

parse_extra_provenance_items(label, x, y, p, provenance_data)[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) – The list of words of raw provenance data.

reserve_memory_regions(spec)[source]

Reserve SDRAM space for memory areas:

  1. Area for information on what data to record

  2. area for start commands

  3. area for end commands

Parameters:

spec (DataSpecificationGenerator) – The data specification to write to

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

class spynnaker.pyNN.external_devices_models.MunichMotorDevice(spinnaker_link_id, board_address=None, speed=30, sample_time=4096, update_time=512, delay_time=5, delta_threshold=23, continue_if_not_different=True, label=None)[source]

Bases: AbstractOneAppOneMachineVertex, AbstractVertexWithEdgeToDependentVertices, PopulationApplicationVertex

An Omnibot motor control device. This has a real vertex and an external device vertex.

Parameters:
  • spinnaker_link_id (int) – The SpiNNaker link to which the motor is connected

  • board_address (str or None) –

  • speed (int) –

  • sample_time (int) –

  • update_time (int) –

  • delay_time (int) –

  • delta_threshold (int) –

  • continue_if_not_different (bool) –

  • label (str or None) –

default_initial_values = {}
default_parameters = {'board_address': None, 'continue_if_not_different': True, 'delay_time': 5, 'delta_threshold': 23, 'label': None, 'sample_time': 4096, 'speed': 30, 'update_time': 512}
dependent_vertices()[source]

Return the vertices which this vertex depends upon.

Return type:

iterable(ApplicationVertex)

edge_partition_identifiers_for_dependent_vertex(vertex)[source]

Return the dependent edge identifiers for a particular dependent vertex.

Parameters:

vertex (ApplicationVertex) –

Return type:

iterable(str)

class spynnaker.pyNN.external_devices_models.MunichRetinaDevice(retina_key, spinnaker_link_id, position, label='MunichRetinaDevice', polarity=None, board_address=None)[source]

Bases: ApplicationSpiNNakerLinkVertex, PopulationApplicationVertex, AbstractSendMeMulticastCommandsVertex

An Omnibot silicon retina device.

Parameters:
  • retina_key (int) –

  • spinnaker_link_id (int) – The SpiNNaker link to which the retina is connected

  • position (str) – LEFT or RIGHT

  • label (str) –

  • polarity (str) – UP, DOWN or MERGED

  • board_address (str or None) –

DOWN_POLARITY = 'DOWN'
LEFT_RETINA = 'LEFT'

Select the left retina

MERGED_POLARITY = 'MERGED'
RIGHT_RETINA = 'RIGHT'

Select the right retina

UP_POLARITY = 'UP'
default_parameters = {'board_address': None, 'label': 'MunichRetinaDevice', 'polarity': None}
get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices_models.SPIFOutputDevice(board_address=None, chip_coords=None, label=None, create_database=True, database_notify_host=None, database_notify_port_num=None, database_ack_port_num=None)[source]

Bases: ApplicationFPGAVertex, PopulationApplicationVertex, AbstractSendMeMulticastCommandsVertex

Output (only) to a SPIF device.

Parameters:
  • n_atoms (int) – The number of atoms in the vertex

  • incoming_fpga_connections (list(FPGAConnection) or None) – The connections from one or more FPGAs that that packets are expected to be received from for this device, or None if no incoming traffic is expected from the device

  • outgoing_fpga_connection (FPGAConnection or None) – The connection to an FPGA that packets to be sent to this device should be sent down, or None if no outgoing traffic is expected to be sent to the device.

  • label (str) – The optional name of the vertex.

  • n_machine_vertices_per_link (int) – The optional number of machine vertices to create for each FPGA link (1 by default)

add_incoming_edge(edge, partition)[source]

Add an edge incoming to this vertex. This is ignored by default, but could be used to track incoming edges, and/or report faults.

Parameters:
property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices_models.SPIFRetinaDevice(pipe, width, height, sub_width, sub_height, base_key=None, input_x_shift=16, input_y_shift=0, board_address=None, chip_coords=None)[source]

Bases: Application2DFPGAVertex, PopulationApplicationVertex, AbstractSendMeMulticastCommandsVertex, HasShapeKeyFields

A retina device connected to SpiNNaker using a SPIF board.

Parameters:
  • pipe (int) – Which pipe on SPIF the retina is connected to

  • width (int) – The width of the retina in pixels

  • height (int) – The height of the retina in pixels

  • sub_width (int) – The width of rectangles to split the retina into for efficiency of sending

  • sub_height (int) – The height of rectangles to split the retina into for efficiency of sending

  • base_key (int or None) – The key that is common over the whole vertex, or None to use the pipe number as the key

  • input_x_shift (int) – The shift to get the x coordinate from the input keys sent to SPIF

  • input_y_shift (int) – The shift to get the y coordinate from the input keys sent to SPIF

  • board_address (str or None) –

    The IP address of the board to which the FPGA is connected, or None to use the default board or chip_coords.

    Note

    chip_coords will be used first if both are specified, with board_address then being used if the coordinates don’t connect to an FPGA.

  • chip_coords (tuple(int, int) or None) –

    The coordinates of the chip to which the FPGA is connected, or None to use the default board or board_address.

    Note

    chip_coords will be used first if board_address is also specified, with board_address then being used if the coordinates don’t connect to an FPGA.

X_MASK = 3

See Y_MASK for description

X_PER_ROW = 4

The number of X values per row

Y_MASK = 1

SPIF outputs to 8 FPGA output links, so we split into (2 x 4), meaning a mask of (1 x 3)

get_atom_key_map(pre_vertex, partition_id, routing_info)[source]

Get the mapping between atoms and keys for the given partition id, and for the given machine pre-vertex.

Parameters:
  • pre_vertex (MachineVertex) – The machine vertex to get the map for

  • partition_id (str) – The partition to get the map for

  • routing_info (RoutingInfo) – Routing information

Returns:

A list of (atom_id, key)

Return type:

list(tuple(int,int))

get_fixed_key_and_mask(partition_id)[source]

Get a fixed key and mask for the application vertex or None if not fixed (the default). See get_machine_gixed_key_and_mask() for the conditions.

Parameters:

partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

Get the slice to be given to the connection from the given link.

Parameters:
  • link (FPGAConnection) – The FPGA connection to get the slice for

  • index (int) – The index of the connection on the FGPA link, for when n_machine_vertices_per_link > 1

Return type:

Slice

get_machine_fixed_key_and_mask(machine_vertex, partition_id)[source]

Get a fixed key and mask for the given machine vertex and partition identifier, or None if not fixed (the default).

If this doesn’t return None, get_fixed_key_and_mask() must also not return None, and the keys returned here must align with those such that for each key:mask returned here, key & app_mask == app_key. It is OK for this to return None and get_fixed_key_and_mask() to return non-None if and only if there is only one machine vertex.

Parameters:
  • machine_vertex (MachineVertex) – A source machine vertex of this application vertex

  • partition_id (str) – The identifier of the partition to get the key for

Return type:

BaseKeyAndMask or None

get_shape_key_fields(vertex_slice)[source]

Get the fields to be used for each dimension in the shape of the given source vertex slice, as a list of start, size, mask, shift values in the order of the fields.

Parameters:

vertex_slice (Slice) – The slice of the source vertex

Return type:

list(tuple(int, int, int, int))

property pause_stop_commands

The commands needed when pausing or stopping simulation.

Return type:

iterable(MultiCastCommand)

property start_resume_commands

The commands needed when starting or resuming simulation.

Return type:

iterable(MultiCastCommand)

property timed_commands

The commands to be sent at given times in the simulation.

Return type:

iterable(MultiCastCommand)

class spynnaker.pyNN.external_devices_models.SendType(value)[source]

Bases: Enum

The data type to be sent in the payload of the multicast packet.

SEND_TYPE_ACCUM = 2

Signed accum (s15.16)

SEND_TYPE_FRACT = 4

Signed fract (s0.31)

SEND_TYPE_INT = 0

Signed integer

SEND_TYPE_UACCUM = 3

Unsigned accum (u16.16)

SEND_TYPE_UFRACT = 5

Unsigned fract (u0.32)

SEND_TYPE_UINT = 1

Unsigned integer

class spynnaker.pyNN.external_devices_models.ThresholdTypeMulticastDeviceControl(devices)[source]

Bases: AbstractThresholdType

A threshold type that can send multicast keys with the value of membrane voltage as the payload.

Parameters:

device (list(AbstractMulticastControllableDevice)) –

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

spynnaker.pyNN.extra_algorithms package
Subpackages
spynnaker.pyNN.extra_algorithms.splitter_components package
Module contents
class spynnaker.pyNN.extra_algorithms.splitter_components.AbstractSpynnakerSplitterDelay[source]

Bases: object

Defines that a splitter is able to handle delays in some way.

Ideally the splitter, and therefore the vertices it creates, are able to handle some delay themselves and if more is needed have the ability to accept spikes from a DelayExtensionMachineVertex.

accepts_edges_from_delay_vertex()[source]

Confirms that the splitter’s vertices can handle spikes coming from a DelayExtensionMachineVertex.

If this method returns False and the users ask for a delay larger than that allowed by max_support_delay(), an exception will be raised saying a different splitter is required.

Return type:

bool

abstract max_support_delay()[source]

returns the max amount of delay this post vertex can support.

Returns:

max delay supported in ticks

Return type:

int

class spynnaker.pyNN.extra_algorithms.splitter_components.AbstractSupportsOneToOneSDRAMInput[source]

Bases: object

An interface for a splitter that supports one-to-one input using SDRAM. The splitter is assumed to handle the splitting on any inputs that are actually one-to-one, as it will have to create the vertices.

abstract handles_source_vertex(projection)[source]

Determine if the source vertex of the given projection is to be handled by the target splitter.

Parameters:

projection (Projection) – The projection to check the source of

Return type:

bool

class spynnaker.pyNN.extra_algorithms.splitter_components.SplitterAbstractPopulationVertexFixed[source]

Bases: AbstractSplitterCommon, AbstractSpynnakerSplitterDelay

Handles the splitting of the AbstractPopulationVertex using fixed slices.

accepts_edges_from_delay_vertex()[source]

Confirms that the splitter’s vertices can handle spikes coming from a DelayExtensionMachineVertex.

If this method returns False and the users ask for a delay larger than that allowed by max_support_delay(), an exception will be raised saying a different splitter is required.

Return type:

bool

create_machine_vertex(vertex_slice, sdram, label, structural_sz, ring_buffer_shifts, weight_scales, index, max_atoms_per_core, synaptic_matrices, neuron_data)[source]
create_machine_vertices(chip_counter)[source]

Method for specific splitter objects to override.

Parameters:

chip_counter (ChipCounter) – counter of used chips

get_in_coming_slices()[source]

The slices of the input vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_in_coming_vertices(partition_id)[source]

Get machine post-vertices for a given partition.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method returns all that could be used for any source machine vertex in the given partition.

Parameters:

partition_id (str) – The identifier of the incoming partition

Return type:

list(MachineVertex)

get_out_going_slices()[source]

The slices of the output vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_out_going_vertices(partition_id)[source]

Get machine pre-vertices.

The output vertices are the ones that will serve as source vertices for external edges.

Parameters:

partition_id (str) – The identifier of the outgoing partition

Return type:

list(MachineVertex)

get_sdram_used_by_atoms(n_atoms, all_syn_block_sz, structural_sz)[source]

Gets the resources of a slice of atoms.

Parameters:

n_atoms (int) –

Return type:

MultiRegionSDRAM

get_source_specific_in_coming_vertices(source_vertex, partition_id)[source]

Get machine post-vertices for a given source.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method allows filtering of the targets for a specific source machine vertex.

This default method makes every machine vertex a target for the source. This should be overridden if there are specific machine vertices for any given source vertex.

Parameters:
  • source_vertex (ApplicationVertex) – The source to get incoming vertices for

  • partition_id (str) – The identifier of the incoming partition

Returns:

A list of tuples of (target machine vertex, list of source machine or application vertices that should hit the target)

Return type:

list(tuple(MachineVertex, list(MachineVertex or ApplicationVertex)))

machine_vertices_for_recording(variable_to_record)[source]

Gets the machine vertices which are recording this variable.

Parameters:

variable_to_record (str) – the variable to get machine vertices for.

Returns:

list of machine vertices

Return type:

iterable(MachineVertex)

max_support_delay()[source]

returns the max amount of delay this post vertex can support.

Returns:

max delay supported in ticks

Return type:

int

reset_called()[source]

Reset the splitter to be as if it has not operated a splitting yet.

set_governed_app_vertex(app_vertex)[source]

Sets a application vertex to be governed by this splitter object. Once set it can’t be reset.

Parameters:

app_vertex (ApplicationVertex) – the app vertex to govern

Raises:

PacmanConfigurationException – if the app vertex has already been set.

class spynnaker.pyNN.extra_algorithms.splitter_components.SplitterAbstractPopulationVertexNeuronsSynapses(n_synapse_vertices=1, max_delay=None, allow_delay_extension=None)[source]

Bases: AbstractSplitterCommon, AbstractSpynnakerSplitterDelay, AbstractSupportsOneToOneSDRAMInput

Splits an AbstractPopulationVertex so that there are separate neuron cores each being fed by one or more synapse cores. Incoming one-to-one Poisson cores are also added here if they meet the criteria.

Parameters:
  • n_synapse_vertices (int) – The number of synapse cores per neuron core

  • max_delay (int or None) – The maximum delay supported by each synapse core; by default this is computed based on the number of atoms per core, the number of synapse types, and the space available for delays on the core

  • allow_delay_extension (bool or None) – Whether delay extensions are allowed in the network. If max_delay is provided, this will default to True. If max_delay is not provided, and this is given as None, it will be computed based on whether delay extensions should be needed.

accepts_edges_from_delay_vertex()[source]

Confirms that the splitter’s vertices can handle spikes coming from a DelayExtensionMachineVertex.

If this method returns False and the users ask for a delay larger than that allowed by max_support_delay(), an exception will be raised saying a different splitter is required.

Return type:

bool

create_machine_vertices(chip_counter)[source]

Method for specific splitter objects to override.

Parameters:

chip_counter (ChipCounter) – counter of used chips

get_in_coming_slices()[source]

The slices of the input vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_in_coming_vertices(partition_id)[source]

Get machine post-vertices for a given partition.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method returns all that could be used for any source machine vertex in the given partition.

Parameters:

partition_id (str) – The identifier of the incoming partition

Return type:

list(MachineVertex)

get_internal_multicast_partitions()[source]

Get edge partitions between machine vertices that are to be handled by Multicast. Returns empty by default, override if there are Multicast connections between internal vertices

Return type:

list(MulticastEdgePartition)

get_internal_sdram_partitions()[source]

Get edge partitions between machine vertices that are to be handled by SDRAM. Returns empty by default, override if there are SDRAM connections between internal vertices

Return type:

list(AbstractSDRAMPartition)

get_out_going_slices()[source]

The slices of the output vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_out_going_vertices(partition_id)[source]

Get machine pre-vertices.

The output vertices are the ones that will serve as source vertices for external edges.

Parameters:

partition_id (str) – The identifier of the outgoing partition

Return type:

list(MachineVertex)

get_same_chip_groups()[source]

Get a list of lists of vertices and SDRAM which must be allocated on the same chip. By default this returns a list of each machine vertex and its SDRAM; override if there are groups of machine vertices on the same chip.

Return type:

list(list(MachineVertex), AbstractSDRAM)

get_source_specific_in_coming_vertices(source_vertex, partition_id)[source]

Get machine post-vertices for a given source.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method allows filtering of the targets for a specific source machine vertex.

This default method makes every machine vertex a target for the source. This should be overridden if there are specific machine vertices for any given source vertex.

Parameters:
  • source_vertex (ApplicationVertex) – The source to get incoming vertices for

  • partition_id (str) – The identifier of the incoming partition

Returns:

A list of tuples of (target machine vertex, list of source machine or application vertices that should hit the target)

Return type:

list(tuple(MachineVertex, list(MachineVertex or ApplicationVertex)))

handles_source_vertex(projection)[source]

Determine if the source vertex of the given projection is to be handled by the target splitter.

Parameters:

projection (Projection) – The projection to check the source of

Return type:

bool

is_direct_poisson_source(pre_vertex, connector, dynamics)[source]

Determine if a given Poisson source can be created by this splitter.

Parameters:
Return type:

bool

machine_vertices_for_recording(variable_to_record)[source]

Gets the machine vertices which are recording this variable.

Parameters:

variable_to_record (str) – the variable to get machine vertices for.

Returns:

list of machine vertices

Return type:

iterable(MachineVertex)

max_support_delay()[source]

returns the max amount of delay this post vertex can support.

Returns:

max delay supported in ticks

Return type:

int

property n_synapse_vertices

The number of synapse vertices per neuron vertex.

Return type:

int

reset_called()[source]

Reset the splitter to be as if it has not operated a splitting yet.

set_governed_app_vertex(app_vertex)[source]

Sets a application vertex to be governed by this splitter object. Once set it can’t be reset.

Parameters:

app_vertex (ApplicationVertex) – the app vertex to govern

Raises:

PacmanConfigurationException – if the app vertex has already been set.

class spynnaker.pyNN.extra_algorithms.splitter_components.SplitterDelayVertexSlice[source]

Bases: AbstractSplitterCommon

Handles the splitting of the DelayExtensionVertex via slice logic.

DELAY_RECORDING_ERROR = 'The delay extensions does not record any variables. Therefore asking for them is deemed an error.'
NEED_EXACT_ERROR_MESSAGE = 'DelayExtensionsSplitters need exact incoming slices. Please fix and try again'
create_machine_vertex(source_app_vertex, vertex_slice)[source]

Creates a delay extension machine vertex and adds to the tracker.

Parameters:

source_vertex (MachineVertex) – The source of the delay

Returns:

machine vertex

Return type:

DelayExtensionMachineVertex

create_machine_vertices(chip_counter)[source]

Method for specific splitter objects to override.

Parameters:

chip_counter (ChipCounter) – counter of used chips

get_in_coming_slices()[source]

The slices of the input vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_in_coming_vertices(partition_id)[source]

Get machine post-vertices for a given partition.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method returns all that could be used for any source machine vertex in the given partition.

Parameters:

partition_id (str) – The identifier of the incoming partition

Return type:

list(MachineVertex)

get_machine_vertex(vertex_slice)[source]

Get a delay extension machine vertex for a given vertex slice.

Parameters:

vertex_slice (Slice) – The slice to get the data for

Return type:

DelayExtensionMachineVertex

get_out_going_slices()[source]

The slices of the output vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_out_going_vertices(partition_id)[source]

Get machine pre-vertices.

The output vertices are the ones that will serve as source vertices for external edges.

Parameters:

partition_id (str) – The identifier of the outgoing partition

Return type:

list(MachineVertex)

get_sdram_used_by_atoms()[source]

Gets the amount of SDRAM used by the delay extension.

Return type:

ConstantSDRAM

get_source_specific_in_coming_vertices(source_vertex, partition_id)[source]

Get machine post-vertices for a given source.

The input vertices are the ones that will serve as target vertices for external edges.

Note

This method allows filtering of the targets for a specific source machine vertex.

This default method makes every machine vertex a target for the source. This should be overridden if there are specific machine vertices for any given source vertex.

Parameters:
  • source_vertex (ApplicationVertex) – The source to get incoming vertices for

  • partition_id (str) – The identifier of the incoming partition

Returns:

A list of tuples of (target machine vertex, list of source machine or application vertices that should hit the target)

Return type:

list(tuple(MachineVertex, list(MachineVertex or ApplicationVertex)))

machine_vertices_for_recording(variable_to_record)[source]

Gets the machine vertices which are recording this variable.

Parameters:

variable_to_record (str) – the variable to get machine vertices for.

Returns:

list of machine vertices

Return type:

iterable(MachineVertex)

reset_called()[source]

Reset the splitter to be as if it has not operated a splitting yet.

set_governed_app_vertex(app_vertex)[source]

Sets a application vertex to be governed by this splitter object. Once set it can’t be reset.

Parameters:

app_vertex (ApplicationVertex) – the app vertex to govern

Raises:

PacmanConfigurationException – if the app vertex has already been set.

class spynnaker.pyNN.extra_algorithms.splitter_components.SplitterPoissonDelegate[source]

Bases: SplitterFixedLegacy

A splitter for Poisson sources that will ignore sources that are one-to-one connected to a single Population.

create_machine_vertices(chip_counter)[source]

Method for specific splitter objects to override.

Parameters:

chip_counter (ChipCounter) – counter of used chips

get_in_coming_slices()[source]

The slices of the input vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_out_going_slices()[source]

The slices of the output vertices.

Returns:

list of Slices

Return type:

list(Slice)

get_out_going_vertices(partition_id)[source]

Get machine pre-vertices.

The output vertices are the ones that will serve as source vertices for external edges.

Parameters:

partition_id (str) – The identifier of the outgoing partition

Return type:

list(MachineVertex)

get_same_chip_groups()[source]

Get a list of lists of vertices and SDRAM which must be allocated on the same chip. By default this returns a list of each machine vertex and its SDRAM; override if there are groups of machine vertices on the same chip.

Return type:

list(list(MachineVertex), AbstractSDRAM)

property send_over_sdram

Whether this vertex is to be sent using SDRAM.

Return type:

bool

set_governed_app_vertex(app_vertex)[source]

Sets a application vertex to be governed by this splitter object. Once set it can’t be reset.

Parameters:

app_vertex (ApplicationVertex) – the app vertex to govern

Raises:

PacmanConfigurationException – if the app vertex has already been set.

spynnaker.pyNN.extra_algorithms.splitter_components.spynnaker_splitter_partitioner()[source]

A splitter partitioner that’s bespoke for sPyNNaker vertices.

Returns:

The number of chips needed to satisfy this partitioning.

Return type:

int

spynnaker.pyNN.extra_algorithms.splitter_components.spynnaker_splitter_selector()[source]

Add a splitter to every vertex that doesn’t already have one.

The default for AbstractPopulationVertex is the SplitterAbstractPopulationVertexFixed. The default for external device splitters are SplitterExternalDevice. The default for the rest is the SplitterFixedLegacy.

Raises:

PacmanConfigurationException – If a bad configuration is set

Module contents
class spynnaker.pyNN.extra_algorithms.SpYNNakerConnectionHolderGenerator[source]

Bases: object

Sets up connection holders for reports to use.

__call__(application_graph)[source]
Parameters:

application_graph (ApplicationGraph) – application graph

Returns:

the set of connection holders for after data specification generation

Return type:

dict(tuple(ProjectionApplicationEdge, SynapseInformation), ConnectionHolder)

class spynnaker.pyNN.extra_algorithms.SpYNNakerSynapticMatrixReport[source]

Bases: object

Generate the synaptic matrices for reporting purposes.

__call__(connection_holder)[source]

Convert synaptic matrix for every application edge.

Parameters:

connection_holder (dict(tuple(ProjectionApplicationEdge, SynapseInformation), ConnectionHolder)) – where the synaptic matrices are stored (possibly after retrieval from the machine)

spynnaker.pyNN.extra_algorithms.delay_support_adder()[source]

Adds the delay extensions to the application graph, now that all the splitter objects have been set.

spynnaker.pyNN.extra_algorithms.finish_connection_holders()[source]

Finishes the connection holders after data has been generated within them, allowing any waiting callbacks to be called.

Parameters:

application_graph (ApplicationGraph) –

spynnaker.pyNN.extra_algorithms.neuron_expander()[source]

Run the neuron expander.

Note

Needs to be done after data has been loaded.

spynnaker.pyNN.extra_algorithms.redundant_packet_count_report()[source]
spynnaker.pyNN.extra_algorithms.spynnaker_machine_bitField_pair_router_compressor()[source]

Perform routing table compression using pairs with bit fields.

spynnaker.pyNN.extra_algorithms.spynnaker_machine_bitfield_ordered_covering_compressor()[source]

Perform routing table compression using ordered coverings with bit fields.

spynnaker.pyNN.extra_algorithms.spynnaker_neuron_graph_network_specification_report()[source]

Produces a report describing the graph created from the neural populations and projections.

Parameters:

report_folder (str) – the report folder to put figure into

spynnaker.pyNN.extra_algorithms.synapse_expander()[source]

Run the synapse expander.

Note

Needs to be done after data has been loaded.

spynnaker.pyNN.extra_models package
Module contents
class spynnaker.pyNN.extra_models.IFCondExpStoc(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Leaky integrate and fire neuron with a stochastic threshold.

Habenschuss S, Jonke Z, Maass W. Stochastic computations in cortical microcircuit models. PLoS Computational Biology. 2013;9(11):e1003311. doi:10.1371/journal.pcbi.1003311

Parameters:
  • tau_m (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_m\)

  • cm (float, iterable(float), RandomDistribution or (mapping) function) – \(C_m\)

  • v_rest (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{rest}\)

  • v_reset (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{reset}\)

  • v_thresh (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{thresh}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • tau_refrac (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{refrac}\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • e_rev_E (float, iterable(float), RandomDistribution or (mapping) function) – \(E^{rev}_e\)

  • e_rev_I (float, iterable(float), RandomDistribution or (mapping) function) – \(E^{rev}_i\)

  • du_th (float, iterable(float), RandomDistribution or (mapping) function) – \(du_{thresh}\)

  • tau_th (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{thresh}\)

  • v (Float, float, iterable(float), RandomDistribution or (mapping) function) – \(V_{init}\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_inh (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

spynnaker.pyNN.extra_models.IFCurDelta

alias of IFCurrDelta

class spynnaker.pyNN.extra_models.IFCurrExpCa2Adaptive(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Model from Liu, Y. H., & Wang, X. J. (2001). Spike-frequency adaptation of a generalized leaky integrate-and-fire model neuron. Journal of Computational Neuroscience, 10(1), 25-45. doi:10.1023/A:1008916026143

Parameters:
  • tau_m (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_m\)

  • cm (float, iterable(float), RandomDistribution or (mapping) function) – \(C_m\)

  • v_rest (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{rest}\)

  • v_reset (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{reset}\)

  • v_thresh (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{thresh}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • tau_refrac (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{refrac}\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • tau_ca2 (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{\mathrm{Ca}^{+2}}\)

  • i_ca2 (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{\mathrm{Ca}^{+2}}\)

  • i_alpha (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_\alpha\)

  • v (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{init}\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_inh (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

spynnaker.pyNN.extra_models.IF_curr_dual_exp

alias of IFCurrDualExpBase

spynnaker.pyNN.extra_models.IF_curr_exp_sEMD

alias of IFCurrExpSEMDBase

spynnaker.pyNN.extra_models.Izhikevich_cond

alias of IzkCondExpBase

spynnaker.pyNN.extra_models.Izhikevich_cond_dual

alias of IzkCondDualExpBase

spynnaker.pyNN.extra_models.Neuromodulation

alias of SynapseDynamicsNeuromodulation

spynnaker.pyNN.extra_models.PfisterSpikeTriplet

alias of TimingDependencePfisterSpikeTriplet

spynnaker.pyNN.extra_models.RecurrentRule

alias of TimingDependenceRecurrent

spynnaker.pyNN.extra_models.SpikeNearestPairRule

alias of TimingDependenceSpikeNearestPair

class spynnaker.pyNN.extra_models.SpikeSourcePoissonVariable(rates, starts, durations=None)[source]

Bases: AbstractPyNNModel

absolute_max_atoms_per_core = 500
create_vertex(n_neurons, label, seed, splitter)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

  • seed (float) –

  • splitter (AbstractSplitterCommon or None) –

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

default_population_parameters = {'seed': None, 'splitter': None}
spynnaker.pyNN.extra_models.Vogels2011Rule

alias of TimingDependenceVogels2011

class spynnaker.pyNN.extra_models.WeightDependenceAdditiveTriplet(w_min=0.0, w_max=1.0, A3_plus=0.01, A3_minus=0.01)[source]

Bases: AbstractHasAPlusAMinus, AbstractWeightDependence

An triplet-based additive weight dependence STDP rule.

Parameters:
  • w_min (float) – \(w^{min}\)

  • w_max (float) – \(w^{max}\)

  • A3_plus (float) – \(A_3^+\)

  • A3_minus (float) – \(A_3^-\)

property A3_minus

\(A_3^-\)

Return type:

float

property A3_plus

\(A_3^+\)

Return type:

float

default_parameters = {'A3_minus': 0.01, 'A3_plus': 0.01, 'w_max': 1.0, 'w_min': 0.0}
get_parameter_names()[source]

Returns the parameter names.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes(n_synapse_types, n_weight_terms)[source]

Get the amount of SDRAM used by the parameters of this rule.

Parameters:
  • n_synapse_types (int) –

  • n_weight_terms (int) –

Return type:

int

is_same_as(weight_dependence)[source]

Determine if this weight dependence is the same as another.

Parameters:

weight_dependence (AbstractWeightDependence) –

Return type:

bool

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

property w_max

\(w^{max}\)

Return type:

float

property w_min

\(w^{min}\)

Return type:

float

property weight_maximum

The maximum weight that will ever be set in a synapse as a result of this rule.

Return type:

float

write_parameters(spec, global_weight_scale, synapse_weight_scales, n_weight_terms)[source]

Write the parameters of the rule to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

  • n_weight_terms (int) – The number of terms used by the synapse rule

spynnaker.pyNN.model_binaries package
Module contents

Note

This module contains no Python code.

spynnaker.pyNN.models package
Subpackages
spynnaker.pyNN.models.abstract_models package
Module contents
class spynnaker.pyNN.models.abstract_models.AbstractAcceptsIncomingSynapses[source]

Bases: object

Indicates an application vertex that can be a post-vertex in a PyNN projection.

abstract clear_connection_cache()[source]

Clear the connection data stored in the vertex so far.

abstract get_connections_from_machine(app_edge, synapse_info)[source]

Get the connections from the machine post-run.

Parameters:
Return type:

ndarray

abstract get_synapse_id_by_target(target)[source]

Get the ID of a synapse given the name.

Parameters:

target (str) – The name of the synapse

Return type:

int

abstract set_synapse_dynamics(synapse_dynamics)[source]

Set the synapse dynamics of this vertex.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

verify_splitter(splitter)[source]

Check that the splitter implements the API(s) expected by the SynapticMatrices

Any Vertex that implements this API should override ApplicationVertex.splitter method to also call this function.

Parameters:

splitter (AbstractSpynnakerSplitterDelay) – the splitter

Raises:

PacmanConfigurationException – if the splitter is not an instance of AbstractSpynnakerSplitterDelay

class spynnaker.pyNN.models.abstract_models.AbstractHasDelayStages[source]

Bases: object

Indicates that this object (an application vertex) has delay stages that are used to increase the space required for bitfields in spynnaker.pyNN.utilities.bit_field_utilities.get_estimated_sdram_for_bit_field_region()

abstract property n_delay_stages

The maximum number of delay stages required by any connection out of this delay extension vertex.

Return type:

int

class spynnaker.pyNN.models.abstract_models.AbstractMaxSpikes[source]

Bases: object

Indicates a class (a MachineVertex) that can describe the maximum rate that it sends spikes.

The SynapticManager assumes that all machine vertexes share the same synapse_information will have the same rates.

abstract max_spikes_per_second()[source]

Get maximum expected number of spikes per second.

Parameters:

variable (str) – the variable to find units from

Returns:

the units as a string.

Return type:

str

abstract max_spikes_per_ts()[source]

Get maximum expected number of spikes per timestep.

Return type:

int

class spynnaker.pyNN.models.abstract_models.AbstractNeuronExpandable[source]

Bases: object

Indicates a class (a MachineVertex) that has may need to run the neuron expander APLX.

abstract gen_neurons_on_machine()[source]

True if the neurons of a the slice of this vertex should be generated on the machine.

Note

The typical implementation for this method will be to ask the neuron data

Return type:

bool

abstract property neuron_generator_region

The region containing the parameters of neuron expansion.

Return type:

int

abstract read_generated_initial_values(placement)[source]

Fill in any requested initial values.

Parameters:

placement (Placement) – Where the data is on the machine

class spynnaker.pyNN.models.abstract_models.AbstractSynapseExpandable[source]

Bases: object

Indicates a class (a MachineVertex) that has may need to run the synapse expander APLX.

Note

This is not implemented by the DelayExtensionMachineVertex, which needs a different expander APLX

abstract property bit_field_size

The amount of bit field data to be generated. This is used to calculate the timeout of the execution.

Return type:

int

abstract property connection_generator_region

The region ID containing the parameters of synaptic expansion.

Return type:

int

abstract gen_on_machine()[source]

True if the synapses of a the slice of this vertex should be generated on the machine.

Note

The typical implementation for this method will be to ask the app_vertex’s synapse_manager

Return type:

bool

abstract property max_gen_data

The maximum amount of synaptic data to be generated. This is used to calculate the timeout of the execution.

Return type:

int

abstract read_generated_connection_holders(placement)[source]

Fill in the connection holders.

Parameters:

placement (Placement) – Where the data is on the machine

class spynnaker.pyNN.models.abstract_models.HasShapeKeyFields[source]

Bases: object

Indicates a source that has keys in fields for each dimension of the source.

abstract get_shape_key_fields(vertex_slice)[source]

Get the fields to be used for each dimension in the shape of the given source vertex slice, as a list of start, size, mask, shift values in the order of the fields.

Parameters:

vertex_slice (Slice) – The slice of the source vertex

Return type:

list(tuple(int, int, int, int))

class spynnaker.pyNN.models.abstract_models.HasSynapses[source]

Bases: object

abstract get_connections_from_machine(placement, app_edge, synapse_info)[source]

Get the connections from the machine for this vertex.

Parameters:
Return type:

ndarray

class spynnaker.pyNN.models.abstract_models.ReceivesSynapticInputsOverSDRAM[source]

Bases: AbstractSupportsSDRAMEdges

An object that receives synaptic inputs over SDRAM.

The number of neurons to be sent per synapse type is rounded up to be a power of 2. A sender must send N_BYTES_PER_INPUT of data for each synapse type for each neuron, formatted as all the data for each neuron for the first synapse type, followed by all the data for each neuron for the second, and so on for each synapse type. Each input is an accumulated weight value for the timestep, scaled with the given weight scales.

N_BYTES_PER_INPUT = 2
abstract property n_bytes_for_transfer

The number of bytes to be sent over the channel. This will be calculated using the above numbers, but also rounded up to a number of words, and with the number of neurons rounded up to a power of 2.

Return type:

int

abstract property weight_scales

A list of scale factors to be applied to weights that get passed over SDRAM, one for each synapse type.

Return type:

list(int)

class spynnaker.pyNN.models.abstract_models.SendsSynapticInputsOverSDRAM[source]

Bases: AbstractSupportsSDRAMEdges

A marker interface for an object that sends synaptic inputs over SDRAM.

class spynnaker.pyNN.models.abstract_models.SupportsStructure[source]

Bases: object

Indicates an object that supports the setting of a PyNN structure.

abstract set_structure(structure)[source]

Set the structure of the object.

Parameters:

structure (BaseStructure) – The structure to set

spynnaker.pyNN.models.common package
Submodules
spynnaker.pyNN.models.common.param_generator_data module
spynnaker.pyNN.models.common.param_generator_data.MAX_PARAMS_BYTES = 16

At most, there are 4 words as param generator parameters

spynnaker.pyNN.models.common.param_generator_data.PARAM_TYPE_BY_NAME = {'exponential': 5, 'normal': 2, 'normal_clipped': 3, 'normal_clipped_to_boundary': 4, 'uniform': 1, 'uniform_int': 1}

IDs of the random parameter generators supported by the synapse expander.

spynnaker.pyNN.models.common.param_generator_data.PARAM_TYPE_CONSTANT_ID = 0

ID of the constant parameter generator.

spynnaker.pyNN.models.common.param_generator_data.PARAM_TYPE_KERNEL = 6

ID for the convolution kernel generator.

spynnaker.pyNN.models.common.param_generator_data.get_generator_type(data_type)[source]
Parameters:

data_type (DataType) –

Returns:

The generator parameter type code for the given data type.

Return type:

int

Raises:

TypeError – If an unsupported data type is given

spynnaker.pyNN.models.common.param_generator_data.is_param_generatable(value)[source]
Parameters:

value – The value to examine the type of.

Returns:

Whether the value is of a type that can be generated on chip.

Return type:

bool

spynnaker.pyNN.models.common.param_generator_data.param_generator_id(value)[source]
Parameters:

value – The value to examine the type of.

Returns:

The ID of the on-chip generator that handles the value.

Return type:

int

Raises:

TypeError – If an value of an unsupported data type is given

spynnaker.pyNN.models.common.param_generator_data.param_generator_params(values)[source]

Get the parameter generator parameters as a numpy array.

Parameters:

values (int or RandomDistribution) –

Return type:

ndarray

spynnaker.pyNN.models.common.param_generator_data.param_generator_params_size_in_bytes(values)[source]

Get the size of the parameter generator parameters in bytes.

Parameters:

values (int or RandomDistribution) –

Return type:

int

Raises:

TypeError – If values is of an unsupported data type

spynnaker.pyNN.models.common.param_generator_data.type_has_generator(data_type)[source]
Parameters:

data_type (DataType) –

Returns:

Whether there is a generator parameter type code for the given data type.

Return type:

bool

spynnaker.pyNN.models.common.recording_utils module
spynnaker.pyNN.models.common.recording_utils.make_missing_string(missing)[source]
Parameters:

missing (iterable(Placement)) –

Return type:

str

Module contents
class spynnaker.pyNN.models.common.EIEIOSpikeRecorder[source]

Bases: object

Records spikes using EIEIO format.

property record
Return type:

bool

set_recording(new_state, sampling_interval=None)[source]
Parameters:
  • new_state (bool) –

  • sampling_interval (None) – not supported functionality

class spynnaker.pyNN.models.common.MultiSpikeRecorder[source]

Bases: object

get_sdram_usage_in_bytes(n_neurons, spikes_per_timestep)[source]
Parameters:
  • n_neurons (int) –

  • spikes_per_timestep (float) –

Return type:

AbstractSDRAM

property record
Return type:

bool

class spynnaker.pyNN.models.common.NeuronRecorder(allowed_variables, data_types, bitfield_variables, n_neurons, per_timestep_variables, per_timestep_datatypes, events_per_core_variables, events_per_core_datatypes)[source]

Bases: object

Parameters:
MAX_REWIRES = 'max_rewires'

max_rewires

PACKETS = 'packets-per-timestep'

packets-per-timestep

PACKETS_TYPE = 2

packets-per-timestep data type

REWIRING = 'rewiring'

rewiring

REWIRING_TYPE = 2

rewiring data type

SPIKES = 'spikes'

flag for spikes

add_region_offset(offset)[source]

Add an offset to the regions. Used when there are multiple recorders on a single core.

Parameters:

offset (int) – The offset to add

check_indexes(indexes)[source]
Parameters:

indexes (list(int)) –

get_buffer_data_type(variable)[source]
Parameters:

variable (str) –

Return type:

BufferDataType

get_buffered_sdram(variable, vertex_slice)[source]

Returns the SDRAM used for this many time steps for a variable.

If required the total is rounded up so the space will always fit.

Parameters:
  • variable (str) – The PyNN variable name to get buffered SDRAM of

  • vertex_slice (Slice) –

Returns:

data size

Return type:

int

get_buffered_sdram_per_record(variable, vertex_slice)[source]

Return the SDRAM used per record.

Parameters:
  • variable (str) – PyNN variable name

  • vertex_slice (Slice) –

Returns:

usage

Return type:

int

get_buffered_sdram_per_timestep(variable, vertex_slice)[source]

Return the SDRAM used per timestep.

In the case where sampling is used it returns the average for recording and none recording based on the recording rate

Parameters:
  • variable (str) – PyNN variable name

  • vertex_slice (Slice) –

Returns:

usage

Return type:

int

get_data_type(variable)[source]
Parameters:

variable (str) –

Return type:

DataType

get_event_recordable_variables()[source]
Return type:

iterable(str)

get_generator_data(vertex_slice=None)[source]

Get the recorded data as a generatable data set.

Parameters:

vertex_slice (Slice or None) – The slice to generate the data for, or None to generate for all neurons (assuming all the same, otherwise error)

Return type:

numpy.ndarray

get_generator_sdram_usage_in_bytes(n_atoms)[source]

Get the SDRAM usage of the generator data for recording metadata.

Parameters:

n_atoms (int) – The number of atoms to be recorded

Return type:

int

get_max_buffered_sdram_per_record(variable, n_atoms)[source]

Return the SDRAM used per record.

Parameters:
  • variable (str) – PyNN variable name

  • vertex_slice (Slice) –

Returns:

usage

Return type:

int

get_max_variable_sdram_usage(n_atoms)[source]
Parameters:

vertex_slice (Slice) –

Return type:

VariableSDRAM

get_metadata_sdram_usage_in_bytes(n_atoms)[source]

Get the SDRAM usage of the metadata for recording.

Parameters:

n_atoms (int) – The number of atoms to record

Return type:

int

get_recordable_variables()[source]
Return type:

iterable(str)

get_recorded_indices(application_vertex, variable)[source]

Get the indices being recorded for a given variable.

Parameters:
  • application_vertex (ApplicationVertex) – The vertex being recorded

  • variable (str) – The name of the variable to get the indices of

Return type:

list(int)

get_region(variable)[source]

Get the region of a variable.

Parameters:

variable (str) – The variable to get the region of

Return type:

int

get_region_sizes(vertex_slice)[source]

Get the sizes of the regions for the variables, whether they are recorded or not, with those that are not having a size of 0.

Parameters:

vertex_slice (Slice) –

Return type:

list(int)

get_sampling_interval_ms(variable)[source]

Get the sampling interval of a variable.

Parameters:

variable (str) – The variable to get the sampling interval of

Return type:

float

get_sampling_overflow_sdram(vertex_slice)[source]

Get the extra SDRAM that should be reserved if using per_timestep.

This is the extra that must be reserved if per_timestep is an average rather than fixed for every timestep.

When sampling the average * time_steps may not be quite enough. This returns the extra space in the worst case where time_steps is a multiple of sampling rate + 1, and recording is done in the first and last time_step

Parameters:

vertex_slice (Slice) –

Returns:

Highest possible overflow needed

Return type:

int

get_variable_sdram_usage(vertex_slice)[source]
Parameters:

vertex_slice (Slice) –

Return type:

VariableSDRAM

property is_global_generatable

Whether the data for all neurons the same, i.e., all or none of the neurons are recorded for all variables.

Return type:

bool

is_recordable(variable)[source]

Identify if the given variable can be recorded.

Parameters:

variable (str) – The variable to check for

Return type:

bool

is_recording(variable)[source]
Parameters:

variable (str) –

Return type:

bool

neurons_recording(variable, vertex_slice)[source]
Parameters:
  • variable (str) –

  • vertex_slice (Slice) –

Return type:

None or iterable(int)

recorded_ids_by_slice(vertex_slice)[source]
Parameters:

vertex_slice (Slice) –

Return type:

list(int)

property recorded_region_ids
Return type:

list(int)

property recording_variables
Return type:

list(str)

set_max_rewires_per_ts(max_rewires_per_ts)[source]
Parameters:

max_rewires_per_ts (int) – the maximum rewires per timestep

set_recording(variable, new_state, sampling_interval=None, indexes=None)[source]
Parameters:
  • variable (str) – PyNN variable name

  • new_state (bool) –

  • sampling_interval (int) –

  • indexes (iterable(int)) –

write_neuron_recording_region(spec, neuron_recording_region, vertex_slice)[source]

Recording data specification.

Parameters:
  • spec (DataSpecificationGenerator) – where to write the data specification

  • neuron_recording_region (int) – the recording region

  • vertex_slice (Slice) – the vertex slice

class spynnaker.pyNN.models.common.ParameterHolder(data_items_to_return, get_call, selector=None)[source]

Bases: object

Holds a set of parameters and state variables to be returned in a PyNN-specific format.

Parameters:
  • data_items_to_return (list(str) or tuple(str)) – A list of data fields to be returned

  • get_call (callable(str, selector=None)->list) – A function to call to read a value

  • selector (None or slice or int or list(bool) or list(int)) – a description of the subrange to accept, or None for all. See: selector_to_ids()

items()[source]
keys()[source]
values()[source]
class spynnaker.pyNN.models.common.PopulationApplicationVertex(label=None, max_atoms_per_core=None, splitter=None)[source]

Bases: ApplicationVertex, HasCustomAtomKeyMap

A vertex that can be used in a Population.

Provides some default functions that can be overridden if the vertex supports these.

Parameters:
  • label (str) – The optional name of the vertex.

  • max_atoms_per_core (None or int or tuple(int,...)) – The max number of atoms that can be placed on a core for each dimension, used in partitioning. If the vertex is n-dimensional, with n > 1, the value must be a tuple with a value for each dimension. If it is single-dimensional the value can be a 1-tuple or an int.

  • splitter (None or AbstractSplitterCommon) – The splitter object needed for this vertex. Leave as None to delegate the choice of splitter to the selector.

property conductance_based

Whether the vertex models post-synaptic inputs as currents or conductance.

By default this is False; override if the model accepts conductance based input.

Return type:

bool

get_atom_key_map(pre_vertex, partition_id, routing_info)[source]

Get the mapping between atoms and keys for the given partition id, and for the given machine pre-vertex.

Parameters:
  • pre_vertex (MachineVertex) – The machine vertex to get the map for

  • partition_id (str) – The partition to get the map for

  • routing_info (RoutingInfo) – Routing information

Returns:

A list of (atom_id, key)

Return type:

list(tuple(int,int))

get_buffer_data_type(name)[source]

Get the type of data recorded by the buffer manager.

The buffer data type controls how data returned by the cores is handled in NeoBufferDatabase.

Parameters:

name (str) – The name of the variable recorded

Return type:

BufferDatabase

Raises:

KeyError – if the variable isn’t being recorded

get_current_state_values(names, selector=None)[source]

Get the current values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Return type:

ParameterHolder

Raises:

KeyError – if the variable is not something that can be read

get_data_type(name)[source]

Get the type data returned by a recording of the variable.

This is the type of data the C code is returning. For instance data such as spikes this will be None.

Parameters:

name (str) – The name of the variable to get the type of

Return type:

DataType or None

Raises:

KeyError – If the variable isn’t recordable

get_initial_state_values(names, selector=None)[source]

Get the initial values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Return type:

ParameterHolder

Raises:

KeyError – if the variable is not something that can be read

get_neurons_recording(name, vertex_slice)[source]

Gets the neurons being recorded on the core with this slice.

Typically vertex_slice.get_raster_ids(atoms_shape) but may be a sublist if doing selective recording.

Parameters:
  • name (str) – The name of the variable to get the region of

  • vertex_slice (Slice) –

Returns:

A list of the global raster IDs of the atoms in recording named variable within this slice

Return type:

list(int)

get_parameter_values(names, selector=None)[source]

Get the values of a parameter or parameters for the whole Population or a subset if the selector is used.

Parameters:
Return type:

ParameterHolder

Raises:

KeyError – if the parameter is not something that can be read

get_parameters()[source]

Get the names of all the parameters that can be obtained

Return type:

list(str)

get_recordable_variables()[source]

Get a list of the names and types of things that can be recorded.

This methods list the variable recorded via the Population.

Return type:

list(str)

get_recording_region(name)[source]

Gets the recording region for the named variable.

Parameters:

name (str) – The name of the variable to get the region of

Return type:

int

Raises:

KeyError – If the variable isn’t being recorded

get_recording_variables()[source]

Get a list of variables that are currently being recorded.

Return type:

list(str)

get_sampling_interval_ms(name)[source]

Get the sampling interval of the recording for the given variable.

The values is in ms and unless selective recording is used will be SpynnakerDataView.get_simulation_time_step_us()

Return type:

float

Raises:

KeyError – If the variable isn’t being recorded

get_state_variables()[source]

Get a list of supported state variables.

Return type:

list(str)

get_units(name)[source]

Get the units of the given parameter or state variable.

Parameters:

name (str) – the name of the parameter to get the units of

Return type:

str

Raises:

KeyError – if the name isn’t recognised or the units cannot be identified

inject(current_source, selector=None)[source]

Inject a current source into this population.

Parameters:
Raises:

ConfigurationException – if the population doesn’t support injection

property n_colour_bits

The number of colour bits sent by this vertex.

Assumed 0 unless overridden

Return type:

int

set_current_state_values(name, value, selector=None)[source]

Set the current values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Raises:

KeyError – if the variable is not something that can be changed

set_initial_state_values(name, value, selector=None)[source]

Set the initial values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Raises:

KeyError – if the variable is not something that can be changed

set_not_recording(name, indices=None)[source]

Set a variable not recording.

Parameters:
  • name (str) – The name of the variable to not record

  • indices (list(int) or None) – The list of neuron indices to not record or None for all

Raises:

KeyError – if the variable cannot be stopped from recording

set_parameter_values(name, value, selector=None)[source]

Set the values of a parameter for the whole Population or a subset if the selector is used.

Parameters:
Raises:

KeyError – if the parameter is not something that can be changed

set_recording(name, sampling_interval=None, indices=None)[source]

Set a variable recording.

Parameters:
  • name (str) – The name of the variable to set the status of

  • sampling_interval (float or None) – How often the variable should be recorded or None for every time step, in milliseconds

  • indices (list(int) or None) – The list of neuron indices to record or None for all

Raises:

KeyError – if the variable cannot be recorded

spynnaker.pyNN.models.current_sources package
Module contents
class spynnaker.pyNN.models.current_sources.ACSource(start=0.0, stop=0.0, amplitude=0.0, offset=0.0, frequency=0.0, phase=0.0)[source]

Bases: AbstractCurrentSource

AC current source (i.e. sine wave) turned on at “start” and off at “stop”, given (y-)offset, amplitude, frequency and phase.

Parameters:
property current_source_id

The ID of the current source.

Return type:

int

property get_parameter_types

The parameter types for the current source.

Return type:

dict(str, Any)

property get_parameters

The parameters of the current source.

Return type:

dict(str, Any)

get_sdram_usage_in_bytes()[source]

The SDRAM usage in bytes of the current source.

Return type:

int

set_parameters(**parameters)[source]

Set the current source parameters.

Parameters:

parameters – the parameters to set

class spynnaker.pyNN.models.current_sources.AbstractCurrentSource[source]

Bases: object

A simplified version of the PyNN class, since in most cases we work out the actual offset value on the SpiNNaker machine itself based on the parameters during the run.

property app_vertex

The application vertex associated with the current source.

Return type:

AbstractPopulationVertex

abstract property current_source_id

The ID of the current source.

Return type:

int

abstract property get_parameter_types

The parameter types for the current source.

Return type:

dict(str, Any)

abstract property get_parameters

The parameters of the current source.

Return type:

dict(str, Any)

abstract get_sdram_usage_in_bytes()[source]

The SDRAM usage in bytes of the current source.

Return type:

int

inject_into(cells)[source]

Inject this source into the specified population cells.

Parameters:

cells (PopulationBase) – The cells to inject the source into

property population

The population associated with the current source.

Return type:

Population

set_app_vertex(vertex)[source]

Set the application vertex associated with the current source.

Parameters:

vertex (AbstractPopulationVertex) – The population vertex

abstract set_parameters(**parameters)[source]

Set the current source parameters.

Parameters:

parameters – the parameters to set

set_population(population)[source]

Set the population associated with the current source.

Parameters:

population (Population) –

class spynnaker.pyNN.models.current_sources.CurrentSourceIDs(value)[source]

Bases: Enum

An enumeration.

AC_SOURCE = 2
DC_SOURCE = 1
NOISY_CURRENT_SOURCE = 4
NO_SOURCE = 0
N_SOURCES = 4
STEP_CURRENT_SOURCE = 3
class spynnaker.pyNN.models.current_sources.DCSource(amplitude=0.0, start=0.0, stop=0.0)[source]

Bases: AbstractCurrentSource

Current source with amplitude turned on at “start” and off at “stop”.

Parameters:
property current_source_id

The ID of the current source.

Return type:

int

property get_parameter_types

The parameter types for the current source.

Return type:

dict(str, Any)

property get_parameters

The parameters of the current source.

Return type:

dict(str, Any)

get_sdram_usage_in_bytes()[source]

The SDRAM usage in bytes of the current source.

Return type:

int

set_parameters(**parameters)[source]

Set the current source parameters.

Parameters:

parameters – the parameters to set

class spynnaker.pyNN.models.current_sources.NoisyCurrentSource(mean=0.0, stdev=0.0, start=0.0, stop=0.0, dt=1.0, rng=None)[source]

Bases: AbstractCurrentSource

A noisy current source beginning at “start” and ending at “stop”, with noise simulated based on the given mean and standard deviation, and updating every dt (dt should default to the machine time step).

Parameters:
property current_source_id

The ID of the current source.

Return type:

int

property get_parameter_types

The parameter types for the current source.

Return type:

dict(str, Any)

property get_parameters

The parameters of the current source.

Return type:

dict(str, Any)

get_sdram_usage_in_bytes()[source]

The SDRAM usage in bytes of the current source.

Return type:

int

set_parameters(**parameters)[source]

Set the current source parameters.

Parameters:

parameters – the parameters to set

class spynnaker.pyNN.models.current_sources.StepCurrentSource(times=None, amplitudes=None)[source]

Bases: AbstractCurrentSource

Current source where the amplitude changes based on a time array.

Parameters:
property current_source_id

The ID of the current source.

Return type:

int

property get_parameter_types

The parameter types for the current source.

Return type:

dict(str, Any)

property get_parameters

The parameters of the current source.

Return type:

dict(str, Any)

get_sdram_usage_in_bytes()[source]

The SDRAM usage in bytes of the current source.

Return type:

int

set_parameters(**parameters)[source]

Set the current source parameters.

Parameters:

parameters – the parameters to set

spynnaker.pyNN.models.neural_projections package
Subpackages
spynnaker.pyNN.models.neural_projections.connectors package
Module contents
class spynnaker.pyNN.models.neural_projections.connectors.AbstractConnector(safe=True, callback=None, verbose=False)[source]

Bases: object

Abstract class that all PyNN Connectors extend.

Parameters:
  • safe (bool) – if True, check that weights and delays have valid values. If False, this check is skipped. (NB: SpiNNaker always checks.)

  • callback (callable) – Ignored

  • verbose (bool) –

NUMPY_SYNAPSES_DTYPE = [('source', 'uint32'), ('target', 'uint16'), ('weight', 'float64'), ('delay', 'float64'), ('synapse_type', 'uint8')]
connect(projection)[source]

Apply this connector to a projection.

Warning

Do not call this! SpyNNaker does not work that way.

Parameters:

projection (Projection) –

Raises:

SpynnakerException – Always. Method not supported; profiled out.

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

abstract get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

abstract get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_delay_variance(delays, synapse_info)[source]

Get the variance of the delays.

Parameters:

delays (RandomDistribution or int or float of str) –

Return type:

float

abstract get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

abstract get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_provenance_data(synapse_info)[source]
Parameters:

synapse_info (SynapseInformation) –

abstract get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

get_weight_mean(weights, synapse_info)[source]

Get the mean of the weights.

Parameters:

weights (RandomDistribution or int or float or str) –

Return type:

float

get_weight_variance(weights, synapse_info)[source]

Get the variance of the weights.

Parameters:

weights (RandomDistribution or int or float or str) –

Return type:

float

property safe
Return type:

bool

set_projection_information(synapse_info)[source]

Sets a connectors projection info.

Parameters:

synapse_info (SynapseInformation) – the synapse info

set_space(space)[source]

Set the space object (allowed after instantiation).

Parameters:

space (Space) –

property space

The space object (may be updated after instantiation).

Return type:

Space or None

property synapse_info

The synapse_info object (may be updated after instantiation).

Return type:

synapse_info or None

use_direct_matrix(synapse_info)[source]
Parameters:

synapse_info (SynapseInformation) –

Return type:

bool

validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
property verbose
Return type:

bool

class spynnaker.pyNN.models.neural_projections.connectors.AbstractGenerateConnectorOnHost[source]

Bases: object

A connector that can be generated on host.

abstract create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

class spynnaker.pyNN.models.neural_projections.connectors.AbstractGenerateConnectorOnMachine(safe=True, callback=None, verbose=False)[source]

Bases: AbstractConnector

Indicates that the connectivity can be generated on the machine.

Parameters:
  • safe (bool) – if True, check that weights and delays have valid values. If False, this check is skipped. (NB: SpiNNaker always checks.)

  • callback (callable) – Ignored

  • verbose (bool) –

abstract property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

gen_delay_params(delays)[source]

Get the parameters of the delay generator on the machine.

Parameters:

delays (RandomDistribution or int or float) –

Return type:

ndarray(uint32)

gen_delay_params_size_in_bytes(delays)[source]

The size of the delay parameters in bytes.

Parameters:

delays (RandomDistribution or int or float) –

Return type:

int

gen_delays_id(delays)[source]

Get the id of the delay generator on the machine.

Parameters:

delays (RandomDistribution or int or float) –

Return type:

int

gen_weight_params_size_in_bytes(weights)[source]

The size of the weight parameters in bytes.

Parameters:

weights (RandomDistribution or int or float) –

Return type:

int

gen_weights_id(weights)[source]

Get the id of the weight generator on the machine.

Parameters:

weights (RandomDistribtuion or int or float) –

Return type:

int

gen_weights_params(weights)[source]

Get the parameters of the weight generator on the machine.

Parameters:

weights (RandomDistribution or int or float) –

Return type:

ndarray(uint32)

generate_on_machine(weights, delays)[source]

Determine if this instance can generate on the machine.

Default implementation returns True if the weights and delays can be generated on the machine

Parameters:
Return type:

bool

validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
class spynnaker.pyNN.models.neural_projections.connectors.AllToAllConnector(allow_self_connections=True, safe=True, verbose=None, callback=None)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

Connects all cells in the presynaptic population to all cells in the postsynaptic population.

Parameters:
  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

property allow_self_connections
Return type:

bool

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

class spynnaker.pyNN.models.neural_projections.connectors.ArrayConnector(array, safe=True, callback=None, verbose=False)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

Make connections using an array of integers based on the IDs of the neurons in the pre- and post-populations.

Parameters:
  • array (ndarray(2, uint8)) – An explicit boolean matrix that specifies the connections between the pre- and post-populations (see PyNN documentation). Must be 2D in practice.

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

class spynnaker.pyNN.models.neural_projections.connectors.CSAConnector(cset, safe=True, callback=None, verbose=False)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

Make connections using a Connection Set Algebra (Djurfeldt 2012) description between the neurons in the pre- and post-populations.

Note

If you get TypeError in Python 3 see: https://github.com/INCF/csa/issues/10

Parameters:
  • cset (csa.connset.CSet) – A description of the connection set between populations

  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

Raises:

ImportError – if the csa library isn’t present; it’s tricky to install in some environments so we don’t force it to be present unless you want to actually use this class.

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

show_connection_set(n_pre_neurons, n_post_neurons)[source]
Parameters:
  • n_pre_neurons (int) –

  • n_post_neurons (int) –

class spynnaker.pyNN.models.neural_projections.connectors.ConvolutionConnector(kernel_weights, kernel_shape=None, strides=None, padding=None, pool_shape=None, pool_stride=None, positive_receptor_type='excitatory', negative_receptor_type='inhibitory', safe=True, verbose=False, callback=None)[source]

Bases: AbstractConnector

Where the pre- and post-synaptic populations are considered as a 2D array. Connect every post(row, column) neuron to many pre(row, column, kernel) through a (kernel) set of weights and/or delays.

Parameters:
  • kernel_weights (int or list or ndarray or RandomDistribution) –

    The synaptic strengths, shared by neurons in the post population. Can be:

    • single value: kernel_shape must be provided; the same value will be used for all weights

    • simple list: kernel_shape must be provided; the list must be sized shape width * height

    • 2D list: If kernel_shape is provided, it must match

    • ndarray: As above for simple or 2D list

    • RandomDistribution: kernel_shape must be provided; weights will be drawn from the distribution

  • kernel_shape (int or tuple(int,int)) – The shape of the kernel if it cannot be determined from kernel_weights. If a single value is provided, a square kernel will be assumed. If two values are provided, it will be assumed to be (n_rows, n_columns)

  • strides (int or tuple(int, int)) – Spatial sampling frequency, jumps between the post neurons. This matches the meaning of standard ML packages. If a single value is provided, the same stride will be used for rows and columns. If two values are provided it will be assumed to be (stride_rows, stride_columns)

  • padding (bool or int or tuple(int, int) or None) – How many ‘extra pixels’ around the pre-population will be added, only zero-valued pixels are currently supported. If a single value is provided, the same padding will be used for rows and columns. If two values are provided it will be assumed to be (padding_rows, padding_columns). If True, automatic padding will be used based on the kernel shape. If False or None, no padding will be used.

  • pool_shape (int or tuple(int, int) or None) – Area of pooling, only average pooling is supported (and seems to make sense). If a single value is provided, the pooling area will be square. If two values are provided it will be assumed to be (pooling_rows, pooling_columns).

  • pool_stride (int or tuple(int, int) or None) – Jumps between pooling regions. If a single value is provided, the same stride will be used for rows and columns. If two values are provided it will be assumed to be (stride_rows, stride_columns)

  • positive_receptor_type (str) – The receptor type to add the positive weights to. By default this is “excitatory”.

  • negative_receptor_type (str) – The receptor type to add the negative weights to. By default this is “inhibitory”.

  • safe (bool) – (ignored)

  • verbose (bool) – (ignored)

  • callback (callable) – (ignored)

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_encoded_kernel_weights(app_edge, weight_scales)[source]
get_local_only_data(app_edge, vertex_slice, key, mask, n_colour_bits, delay, weight_index)[source]
get_max_n_incoming_slices(source_vertex, target_vertex)[source]
get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_post_shape(shape)[source]

Get the shape of the post image given the pre-image shape.

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

property kernel_n_bytes
property kernel_n_weights
property kernel_weights
property negative_receptor_type
property parameters_n_bytes
property positive_receptor_type
validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
class spynnaker.pyNN.models.neural_projections.connectors.DistanceDependentProbabilityConnector(d_expression, allow_self_connections=True, safe=True, verbose=False, n_connections=None, rng=None, callback=None)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

Make connections using a distribution which varies with distance.

Parameters:
  • d_expression (str) – the right-hand side of a valid python expression for probability, involving d, (e.g. "exp(-abs(d))", or "d < 3"), that can be parsed by eval(), that computes the distance dependent distribution.

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • safe (bool) – if True, check that weights and delays have valid values. If False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • n_connections (int or None) – The number of efferent synaptic connections per neuron.

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.

  • callback (callable) –

property allow_self_connections
Return type:

bool

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property d_expression

The distance expression.

Return type:

str

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

set_projection_information(synapse_info)[source]

Sets a connectors projection info.

Parameters:

synapse_info (SynapseInformation) – the synapse info

class spynnaker.pyNN.models.neural_projections.connectors.FixedNumberPostConnector(n, allow_self_connections=True, safe=True, verbose=False, with_replacement=False, rng=None, callback=None)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

Connects a fixed number of post-synaptic neurons selected at random, to all pre-synaptic neurons.

Parameters:
  • n (int) – number of random post-synaptic neurons connected to pre-neurons.

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • safe (bool) – Whether to check that weights and delays have valid values; if False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • with_replacement (bool) – this flag determines how the random selection of post-synaptic neurons is performed; if True, then every post-synaptic neuron can be chosen on each occasion, and so multiple connections between neuron pairs are possible; if False, then once a post-synaptic neuron has been connected to a pre-neuron, it can’t be connected again.

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

property allow_self_connections
create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

set_projection_information(synapse_info)[source]

Sets a connectors projection info.

Parameters:

synapse_info (SynapseInformation) – the synapse info

validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
class spynnaker.pyNN.models.neural_projections.connectors.FixedNumberPreConnector(n, allow_self_connections=True, safe=True, verbose=False, with_replacement=False, rng=None, callback=None)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

Connects a fixed number of pre-synaptic neurons selected at random, to all post-synaptic neurons.

Parameters:
  • n (int) – number of random pre-synaptic neurons connected to output

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • with_replacement (bool) – this flag determines how the random selection of pre-synaptic neurons is performed; if true, then every pre-synaptic neuron can be chosen on each occasion, and so multiple connections between neuron pairs are possible; if false, then once a pre-synaptic neuron has been connected to a post-neuron, it can’t be connected again.

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

property allow_self_connections
create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

set_projection_information(synapse_info)[source]

Sets a connectors projection info.

Parameters:

synapse_info (SynapseInformation) – the synapse info

validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
class spynnaker.pyNN.models.neural_projections.connectors.FixedProbabilityConnector(p_connect, allow_self_connections=True, safe=True, verbose=False, rng=None, callback=None)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

For each pair of pre-post cells, the connection probability is constant.

Parameters:
  • p_connect (float) – a value between zero and one. Each potential connection is created with this probability.

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

property p_connect
validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
class spynnaker.pyNN.models.neural_projections.connectors.FromFileConnector(file, distributed=False, safe=True, callback=None, verbose=False)[source]

Bases: FromListConnector

Make connections according to a list read from a file.

Parameters:
  • file (str or FileIO) –

    Either an open file object or the filename of a file containing a list of connections, in the format required by FromListConnector. Column headers, if included in the file, must be specified using a list or tuple, e.g.:

    # columns = ["i", "j", "weight", "delay", "U", "tau_rec"]
    

    Note

    The header requires # at the beginning of the line.

  • distributed (bool) –

    Basic pyNN says:

    if this is True, then each node will read connections from a file called filename.x, where x is the MPI rank. This speeds up loading connections for distributed simulations.

    Note

    Always leave this as False with sPyNNaker, which is not MPI-based.

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

get_reader(file)[source]

Get a file reader object using the PyNN methods.

Returns:

A pynn StandardTextFile or similar

Return type:

StandardTextFile

class spynnaker.pyNN.models.neural_projections.connectors.FromListConnector(conn_list, safe=True, verbose=False, column_names=None, callback=None)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

Make connections according to a list.

Parameters:
  • conn_list (ndarray or list(tuple(int,int,...))) –

    A numpy array or a list of tuples, one tuple for each connection. Each tuple should contain:

    (pre_idx, post_idx, p1, p2, ..., pn)
    

    where pre_idx is the index (i.e. order in the Population, not the ID) of the presynaptic neuron, post_idx is the index of the postsynaptic neuron, and p1, p2, etc. are the synaptic parameters (e.g., weight, delay, plasticity parameters). All tuples/rows must have the same number of items.

  • safe (bool) – if True, check that weights and delays have valid values. If False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • column_names (None or tuple(str) or list(str)) – the names of the parameters p1, p2, etc. If not provided, it is assumed the parameters are weight, delay (for backwards compatibility).

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

property column_names

The names of the columns in the array after the first two. Of particular interest is whether weight and delay columns are present.

Return type:

list(str)

property conn_list

The connection list.

Return type:

ndarray

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_delay_variance(delays, synapse_info)[source]

Get the variance of the delays.

Parameters:

delays (RandomDistribution or int or float of str) –

Return type:

float

get_extra_parameter_names()[source]

Get the names of the extra parameters.

Return type:

list(str)

get_extra_parameters()[source]

Getter for the extra parameters. Excludes weight and delay columns.

Returns:

The extra parameters

Return type:

ndarray

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

get_weight_mean(weights, synapse_info)[source]

Get the mean of the weights.

Parameters:

weights (RandomDistribution or int or float or str) –

Return type:

float

get_weight_variance(weights, synapse_info)[source]

Get the variance of the weights.

Parameters:

weights (RandomDistribution or int or float or str) –

Return type:

float

class spynnaker.pyNN.models.neural_projections.connectors.IndexBasedProbabilityConnector(index_expression, allow_self_connections=True, rng=None, safe=True, callback=None, verbose=False)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

Make connections using a probability distribution which varies dependent upon the indices of the pre- and post-populations.

Parameters:
  • index_expression (str) – the right-hand side of a valid python expression for probability, involving the indices of the pre- and post-populations, that can be parsed by eval(), that computes a probability distribution; the indices will be given as variables i and j when the expression is evaluated.

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

property allow_self_connections

When the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

Return type:

bool

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

property index_expression

The right-hand side of a valid python expression for probability, involving the indices of the pre- and post-populations, that can be parsed by eval(), that computes a probability distribution.

Return type:

str

class spynnaker.pyNN.models.neural_projections.connectors.KernelConnector(shape_pre, shape_post, shape_kernel, weight_kernel=None, delay_kernel=None, shape_common=None, pre_sample_steps_in_post=None, pre_start_coords_in_post=None, post_sample_steps_in_pre=None, post_start_coords_in_pre=None, safe=True, space=None, verbose=False, callback=None)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

Where the pre- and post-synaptic populations are considered as a 2D array. Connect every post(row, column) neuron to many pre(row, column, kernel) through a (kernel) set of weights and/or delays.

TODO

Should these include allow_self_connections and with_replacement?

Parameters:
  • shape_pre (list(int) or tuple(int,int)) – 2D shape of the pre-population (rows/height, columns/width, usually the input image shape)

  • shape_post (list(int) or tuple(int,int)) – 2D shape of the post-population (rows/height, columns/width)

  • shape_kernel (list(int) or tuple(int,int)) – 2D shape of the kernel (rows/height, columns/width)

  • weight_kernel (ndarray or RandomDistribution or int or float or list(int) or list(float) or None) – (optional) 2D matrix of size shape_kernel describing the weights

  • delay_kernel (ndarray or RandomDistribution or int or float or list(int) or list(float) or None) – (optional) 2D matrix of size shape_kernel describing the delays

  • shape_common (list(int) or tuple(int,int) or None) – (optional) 2D shape of common coordinate system (for both pre- and post-, usually the input image sizes)

  • pre_sample_steps_in_post (None or list(int) or tuple(int,int)) – (optional) Sampling steps/jumps for pre-population <=> (stepX, stepY)

  • pre_start_coords_in_post (None or list(int) or tuple(int,int)) – (optional) Starting row/column for pre-population sampling <=> (offX, offY)

  • post_sample_steps_in_pre (None or list(int) or tuple(int,int)) – (optional) Sampling steps/jumps for post-population <=> (stepX, stepY)

  • post_start_coords_in_pre (None or list(int) or tuple(int,int)) – (optional) Starting row/column for post-population sampling <=> (offX, offY)

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.

  • space (Space) – Currently ignored; for future compatibility.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • callback (callable) – (ignored)

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_delay_variance(delays, synapse_info)[source]

Get the variance of the delays.

Parameters:

delays (RandomDistribution or int or float of str) –

Return type:

float

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

get_weight_mean(weights, synapse_info)[source]

Get the mean of the weights.

Parameters:

weights (RandomDistribution or int or float or str) –

Return type:

float

get_weight_variance(weights, synapse_info)[source]

Get the variance of the weights.

Parameters:

weights (RandomDistribution or int or float or str) –

Return type:

float

class spynnaker.pyNN.models.neural_projections.connectors.MultapseConnector(n, allow_self_connections=True, with_replacement=True, safe=True, verbose=False, rng=None, callback=None)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

Create a multapse connector. The size of the source and destination populations are obtained when the projection is connected. The number of synapses is specified. when instantiated, the required number of synapses is created by selecting at random from the source and target populations with replacement. Uniform selection probability is assumed.

Parameters:
  • n (int) – This is the total number of synapses in the connection.

  • allow_self_connections (bool) – Allow a neuron to connect to itself or not.

  • with_replacement (bool) – When selecting, allow a neuron to be re-selected or not.

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_rng_next(num_synapses, prob_connect, rng)[source]

Get the required RNGs.

Parameters:
  • num_synapses (int) – The number of synapses to make random numbers for in this call

  • prob_connect (list(float)) – The probability of connection

Return type:

ndarray

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

set_projection_information(synapse_info)[source]

Sets a connectors projection info.

Parameters:

synapse_info (SynapseInformation) – the synapse info

validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
class spynnaker.pyNN.models.neural_projections.connectors.OneToOneConnector(safe=True, callback=None, verbose=False)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

Where the pre- and postsynaptic populations have the same size, connect cell i in the presynaptic population to cell i in the postsynaptic population, for all i.

Parameters:
  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

use_direct_matrix(synapse_info)[source]
Parameters:

synapse_info (SynapseInformation) –

Return type:

bool

class spynnaker.pyNN.models.neural_projections.connectors.PoolDenseConnector(weights, pool_shape=None, pool_stride=None, positive_receptor_type='excitatory', negative_receptor_type='inhibitory', safe=True, verbose=False, callback=None)[source]

Bases: AbstractConnector

Where the pre- and post-synaptic populations are considered as a 2D array. Connect every post(row, column) neuron to many pre(row, column, kernel) through a (kernel) set of weights and/or delays.

Parameters:
  • weights (int or float or list(int or float) or ndarray or RandomDistribution) –

    The synaptic strengths. Can be:

    • single value: the same value will be used for all weights

    • list: the total number of elements must be (number after pooling * number post)

    • ndarray: As above for list

    • RandomDistribution: weights will be drawn at random

  • pool_shape (int or tuple(int) or None) – Shape of average pooling. If a single value is provided, it will be used for every dimension, otherwise must be the same number of values as there are dimensions in the source.

  • pool_stride (int or tuple(int) or None) – Jumps between pooling regions. If a single value is provided, the same stride will be used for all dimensions, otherwise must be the same number of values as there are dimensions in the source. If None, and pool_shape is provided, pool_stride will be set to pool_shape.

  • positive_receptor_type (str) – The receptor type to add the positive weights to. By default this is “excitatory”.

  • negative_receptor_type (str) – The receptor type to add the negative weights to. By default this is “inhibitory”.

  • safe (bool) – (ignored)

  • verbose (bool) – (ignored)

  • callback (callable) – (ignored)

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

static get_post_pool_shape(pre_shape, pool_shape=None, pool_stride=None)[source]
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

local_only_n_bytes(incoming_slices, n_post_atoms)[source]
Parameters:
  • incoming_slices (iterable(Slice)) –

  • n_post_atoms (int) –

Return type:

int

property negative_receptor_type
Return type:

str

property positive_receptor_type
Return type:

str

validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
property weights
Return type:

ndarray

write_local_only_data(spec, app_edge, pre_vertex_slice, post_vertex_slice, key, mask, n_colour_bits, weight_scales)[source]
Parameters:
class spynnaker.pyNN.models.neural_projections.connectors.SmallWorldConnector(degree, rewiring, allow_self_connections=True, n_connections=None, rng=None, safe=True, callback=None, verbose=False)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

A connector that uses connection statistics based on the Small World network connectivity model.

Note

This is typically used from a population to itself.

Parameters:
  • degree (float) – the region length where nodes will be connected locally

  • rewiring (float) – the probability of rewiring each edge

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • n_connections (int or None) – if specified, the number of efferent synaptic connections per neuron

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.

  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

set_projection_information(synapse_info)[source]

Sets a connectors projection info.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Module contents
class spynnaker.pyNN.models.neural_projections.DelayAfferentApplicationEdge(pre_vertex, delay_vertex, label=None)[source]

Bases: ApplicationEdge

Parameters:
class spynnaker.pyNN.models.neural_projections.DelayedApplicationEdge(pre_vertex, post_vertex, synapse_information, undelayed_edge, label=None)[source]

Bases: ApplicationEdge

Parameters:
add_synapse_information(synapse_information)[source]
Parameters:

synapse_information (SynapseInformation) –

property synapse_information
Return type:

list(SynapseInformation)

property undelayed_edge

The edge for projections without extended delays.

Return type:

ProjectionApplicationEdge

class spynnaker.pyNN.models.neural_projections.ProjectionApplicationEdge(pre_vertex, post_vertex, synapse_information, label=None)[source]

Bases: ApplicationEdge, AbstractProvidesLocalProvenanceData

An edge which terminates on an AbstractPopulationVertex.

Parameters:
add_synapse_information(synapse_information)[source]
Parameters:

synapse_information (SynapseInformation) –

property delay_edge

Settable.

Return type:

DelayedApplicationEdge or None

get_local_provenance_data()[source]

Get an iterable of provenance data items.

Return type:

iterable

property is_neuromodulation

Whether this edge is providing neuromodulation.

Return type:

bool

property n_delay_stages
Return type:

int

property synapse_information
Return type:

list(SynapseInformation)

class spynnaker.pyNN.models.neural_projections.SynapseInformation(connector, pre_population, post_population, prepop_is_view, postpop_is_view, synapse_dynamics, synapse_type, receptor_type, synapse_type_from_dynamics, weights=None, delays=None)[source]

Bases: object

Contains the synapse information including the connector, synapse type and synapse dynamics.

Parameters:
  • connector (AbstractConnector) – The connector connected to the synapse

  • pre_population (Population or PopulationView) – The population sending spikes to the synapse

  • post_population (Population or PopulationView) – The population hosting the synapse

  • prepop_is_view (bool) – Whether the pre_population is a view

  • postpop_is_view (bool) – Whether the post_population is a view

  • synapse_dynamics (AbstractSynapseDynamics) – The dynamic behaviour of the synapse

  • synapse_type (int) – The type of the synapse

  • receptor_type (str) – Description of the receptor (e.g. excitatory)

  • synapse_type_from_dynamics (bool) – Whether the synapse type came from synapse dynamics

  • weights (float or list(float) or ndarray(float) or None) – The synaptic weights

  • delays (float or list(float) or ndarray(float) or None) – The total synaptic delays

add_pre_run_connection_holder(pre_run_connection_holder)[source]

Add a connection holder that will be filled in before run.

Parameters:

pre_run_connection_holder (ConnectionHolder) – The connection holder to be added

property connector

The connector connected to the synapse.

Return type:

AbstractConnector

property delays

The total synaptic delays (if any).

Return type:

float or list(float) or ndarray(float) or None

finish_connection_holders()[source]

Finish all the connection holders, and clear the list so that they are not generated again later.

may_generate_on_machine()[source]

Do we describe a collection of synapses whose synaptic matrix may be generated on SpiNNaker instead of needing to be calculated in this process and uploaded? This depends on the connector, the definitions of the weights and delays, and the dynamics of the synapses.

Returns:

True if the synaptic matrix may be generated on machine (or may have already been so done)

Return type:

bool

may_use_direct_matrix()[source]

Do the properties of the synaptic information allow it to use the direct matrix?

Return type:

bool

property n_post_neurons

The number of neurons in the post-population.

Return type:

int

property n_pre_neurons

The number of neurons in the pre-population.

Return type:

int

property post_population

The population hosting the synapse.

Return type:

Population or PopulationView

property postpop_is_view

Whether the post_population() is a view.

Return type:

bool

property pre_population

The population sending spikes to the synapse.

Return type:

Population or PopulationView

property pre_run_connection_holders

The list of connection holders to be filled in before run.

Return type:

list(ConnectionHolder)

property prepop_is_view

Whether the pre_population() is a view.

Return type:

bool

property receptor_type

A string representing the receptor type.

Return type:

str

property synapse_dynamics

The dynamic behaviour of the synapse.

Return type:

AbstractSynapseDynamics

property synapse_type

The type of the synapse.

Return type:

int

property synapse_type_from_dynamics

Whether the synapse type comes from the synapse dynamics.

Return type:

bool

property weights

The synaptic weights (if any).

Return type:

float or list(float) or ndarray(float) or None

spynnaker.pyNN.models.neural_properties package
Module contents
class spynnaker.pyNN.models.neural_properties.NeuronParameter(value, data_type)[source]

Bases: object

A settable parameter of a neuron model.

Parameters:
get_dataspec_datatype()[source]

Get the serialization type of the parameter in the neuron model.

Return type:

DataType

get_value()[source]

What the value of the parameter is; if a list or array, potentially provides a different value for each neuron.

Return type:

int or float or bool or list(int) or list(float) or list(bool) or ndarray or AbstractList

iterator_by_slice(slice_start, slice_stop, spec)[source]

Creates an iterator over the commands to use to write the parameter to the data specification being generated.

Parameters:
  • slice_start (int) – Inclusive start of the range

  • slice_stop (int) – Exclusive end of the range

  • spec (DataSpecificationGenerator) –

    The data specification to eventually write to.

    Note

    This does not actually do the write.

Returns:

Iterator that produces a command to write to the specification for each element in the slice.

Return type:

iterator(tuple(bytearray, str))

spynnaker.pyNN.models.neuron package
Subpackages
spynnaker.pyNN.models.neuron.additional_inputs package
Module contents
class spynnaker.pyNN.models.neuron.additional_inputs.AbstractAdditionalInput(structs, units)[source]

Bases: AbstractStandardNeuronComponent

Represents a possible additional independent input for a model.

Parameters:
  • structs (list(Struct)) – The structures of the component

  • units (dict) – The units to use for each parameter

class spynnaker.pyNN.models.neuron.additional_inputs.AdditionalInputCa2Adaptive(tau_ca2, i_ca2, i_alpha)[source]

Bases: AbstractAdditionalInput

Parameters:
  • tau_ca2 (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau_{\mathrm{Ca}^{+2}}\)

  • i_ca2 (float or iterable(float) or RandomDistribution or (mapping) function) – \(I_{\mathrm{Ca}^{+2}}\)

  • i_alpha (float or iterable(float) or RandomDistribution or (mapping) function) – \(I_{\alpha}\)

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

property i_alpha

Settable model parameter: \(I_{\alpha}\)

Return type:

float

property i_ca2

Settable model parameter: \(I_{\mathrm{Ca}^{+2}}\)

Return type:

float

property tau_ca2

Settable model parameter: \(\tau_{\mathrm{Ca}^{+2}}\)

Return type:

float

spynnaker.pyNN.models.neuron.builds package
Module contents
class spynnaker.pyNN.models.neuron.builds.EIFConductanceAlphaPopulation(**kwargs)[source]

Bases: object

Exponential integrate and fire neuron with spike triggered and sub-threshold adaptation currents (isfa, ista reps.)

Warning

Not currently supported by the tool chain.

default_initial_values = {'gsyn_exc': 0.0, 'gsyn_inh': 0.0, 'v': -70.6, 'w': 0.0}
default_parameters = {'a': 4.0, 'b': 0.0805, 'cm': 0.281, 'delta_T': 2.0, 'e_rev_E': 0.0, 'e_rev_I': -80.0, 'i_offset': 0.0, 'tau_m': 9.3667, 'tau_refrac': 0.1, 'tau_syn_E': 5.0, 'tau_syn_I': 0.5, 'tau_w': 144.0, 'v_reset': -70.6, 'v_rest': -70.6, 'v_spike': -40.0, 'v_thresh': -50.4}
class spynnaker.pyNN.models.neuron.builds.HHCondExp(**kwargs)[source]

Bases: object

Single-compartment Hodgkin-Huxley model with exponentially decaying current input.

Warning

Not currently supported by the tool chain.

default_initial_values = {'gsyn_exc': 0.0, 'gsyn_inh': 0.0, 'v': -65.0}
default_parameters = {'cm': 0.2, 'e_rev_E': 0.0, 'e_rev_I': -80, 'e_rev_K': -90.0, 'e_rev_Na': 50.0, 'e_rev_leak': -65.0, 'g_leak': 0.01, 'gbar_K': 6.0, 'gbar_Na': 20.0, 'i_offset': 0.0, 'tau_syn_E': 0.2, 'tau_syn_I': 2.0, 'v_offset': -63}
class spynnaker.pyNN.models.neuron.builds.IFCondAlpha(**kwargs)[source]

Bases: object

Leaky integrate and fire neuron with an alpha-shaped current input.

Warning

Not currently supported by the tool chain.

default_initial_values = {'gsyn_exc': 0.0, 'gsyn_inh': 0.0, 'v': -65.0}
default_parameters = {'cm': 1.0, 'e_rev_E': 0.0, 'e_rev_I': -70.0, 'i_offset': 0, 'tau_m': 20, 'tau_refrac': 0.1, 'tau_syn_E': 0.3, 'tau_syn_I': 0.5, 'v_reset': -65.0, 'v_rest': -65.0, 'v_thresh': -50.0}
class spynnaker.pyNN.models.neuron.builds.IFCondExpBase(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Leaky integrate and fire neuron with an exponentially decaying conductance input.

Parameters:
  • tau_m (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_m\)

  • cm (float, iterable(float), RandomDistribution or (mapping) function) – \(C_m\)

  • v_rest (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{rest}\)

  • v_reset (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{reset}\)

  • v_thresh (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{thresh}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • tau_refrac (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{refrac}\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • e_rev_E (float, iterable(float), RandomDistribution or (mapping) function) – \(E^{rev}_e\)

  • e_rev_I (float, iterable(float), RandomDistribution or (mapping) function) – \(E^{rev}_i\)

  • v (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{init}\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_inh (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

class spynnaker.pyNN.models.neuron.builds.IFCondExpStoc(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Leaky integrate and fire neuron with a stochastic threshold.

Habenschuss S, Jonke Z, Maass W. Stochastic computations in cortical microcircuit models. PLoS Computational Biology. 2013;9(11):e1003311. doi:10.1371/journal.pcbi.1003311

Parameters:
  • tau_m (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_m\)

  • cm (float, iterable(float), RandomDistribution or (mapping) function) – \(C_m\)

  • v_rest (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{rest}\)

  • v_reset (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{reset}\)

  • v_thresh (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{thresh}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • tau_refrac (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{refrac}\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • e_rev_E (float, iterable(float), RandomDistribution or (mapping) function) – \(E^{rev}_e\)

  • e_rev_I (float, iterable(float), RandomDistribution or (mapping) function) – \(E^{rev}_i\)

  • du_th (float, iterable(float), RandomDistribution or (mapping) function) – \(du_{thresh}\)

  • tau_th (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{thresh}\)

  • v (Float, float, iterable(float), RandomDistribution or (mapping) function) – \(V_{init}\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_inh (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

class spynnaker.pyNN.models.neuron.builds.IFCurrAlpha(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Leaky integrate and fire neuron with an alpha-shaped current-based input.

Parameters:
  • tau_m (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_m\)

  • cm (float, iterable(float), RandomDistribution or (mapping) function) – \(C_m\)

  • v_rest (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{rest}\)

  • v_reset (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{reset}\)

  • v_thresh (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{thresh}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • tau_refrac (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{refrac}\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • v (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{init}\)

  • exc_response (float, iterable(float), RandomDistribution or (mapping) function) – \(response^\mathrm{linear}_e\)

  • exc_exp_response (float, iterable(float), RandomDistribution or (mapping) function) – \(response^\mathrm{exponential}_e\)

  • inh_response (float, iterable(float), RandomDistribution or (mapping) function) – \(response^\mathrm{linear}_i\)

  • inh_exp_response (float, iterable(float), RandomDistribution or (mapping) function) – \(response^\mathrm{exponential}_i\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

class spynnaker.pyNN.models.neuron.builds.IFCurrDelta(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Leaky integrate and fire neuron with an instantaneous current input.

Parameters:
  • tau_m (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_m\)

  • cm (float, iterable(float), RandomDistribution or (mapping) function) – \(C_m\)

  • v_rest (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{rest}\)

  • v_reset (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{reset}\)

  • v_thresh (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{thresh}\)

  • tau_refrac (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{refrac}\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • v (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{init}\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_inh\(I^{syn}_i\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

Type:

isyn_inh: float, iterable(float), RandomDistribution or (mapping) function

class spynnaker.pyNN.models.neuron.builds.IFCurrDualExpBase(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Leaky integrate and fire neuron with two exponentially decaying excitatory current inputs, and one exponentially decaying inhibitory current input.

Parameters:
  • tau_m (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_m\)

  • cm (float, iterable(float), RandomDistribution or (mapping) function) – \(C_m\)

  • v_rest (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{rest}\)

  • v_reset (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{reset}\)

  • v_thresh (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{thresh}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_{e_1}\)

  • tau_syn_E2 (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_{e_2}\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • tau_refrac (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{refrac}\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • v (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{init}\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_{e_1}\)

  • isyn_inh (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • isyn_exc2 (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_{e_2}\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

class spynnaker.pyNN.models.neuron.builds.IFCurrExpBase(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Leaky integrate and fire neuron with an exponentially decaying current input.

Parameters:
  • tau_m (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_m\)

  • cm (float, iterable(float), RandomDistribution or (mapping) function) – \(C_m\)

  • v_rest (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{rest}\)

  • v_reset (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{reset}\)

  • v_thresh (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{thresh}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • tau_refrac (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{refrac}\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • v (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{init}\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_inh (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

class spynnaker.pyNN.models.neuron.builds.IFCurrExpCa2Adaptive(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Model from Liu, Y. H., & Wang, X. J. (2001). Spike-frequency adaptation of a generalized leaky integrate-and-fire model neuron. Journal of Computational Neuroscience, 10(1), 25-45. doi:10.1023/A:1008916026143

Parameters:
  • tau_m (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_m\)

  • cm (float, iterable(float), RandomDistribution or (mapping) function) – \(C_m\)

  • v_rest (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{rest}\)

  • v_reset (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{reset}\)

  • v_thresh (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{thresh}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • tau_refrac (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{refrac}\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • tau_ca2 (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{\mathrm{Ca}^{+2}}\)

  • i_ca2 (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{\mathrm{Ca}^{+2}}\)

  • i_alpha (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_\alpha\)

  • v (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{init}\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_inh (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

class spynnaker.pyNN.models.neuron.builds.IFCurrExpSEMDBase(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Leaky integrate and fire neuron with an exponentially decaying current input, where the excitatory input depends upon the inhibitory input (see https://www.cit-ec.de/en/nbs/spiking-insect-vision)

Parameters:
  • tau_m (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_m\)

  • cm (float, iterable(float), RandomDistribution or (mapping) function) – \(C_m\)

  • v_rest (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{rest}\)

  • v_reset (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{reset}\)

  • v_thresh (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{thresh}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_{e_1}\)

  • tau_syn_E2 (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_{e_2}\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • tau_refrac (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau_{refrac}\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • v (float, iterable(float), RandomDistribution or (mapping) function) – \(V_{init}\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_{e_1}\)

  • isyn_exc2 (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_{e_2}\)

  • isyn_inh (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • multiplicator (float, iterable(float), RandomDistribution or (mapping) function) –

  • exc2_old (float, iterable(float), RandomDistribution or (mapping) function) –

  • scaling_factor (float, iterable(float), RandomDistribution or (mapping) function) –

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

class spynnaker.pyNN.models.neuron.builds.IFFacetsConductancePopulation(**kwargs)[source]

Bases: object

Leaky integrate and fire neuron with conductance-based synapses and fixed threshold as it is resembled by the FACETS Hardware Stage 1.

Warning

Not currently supported by the tool chain.

default_initial_values = {'v': -65.0}
default_parameters = {'e_rev_I': -80, 'g_leak': 40.0, 'tau_syn_E': 30.0, 'tau_syn_I': 30.0, 'v_reset': -80.0, 'v_rest': -65.0, 'v_thresh': -55.0}
class spynnaker.pyNN.models.neuron.builds.IzkCondDualExpBase(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Izhikevich neuron model with conductance inputs and dual synapse.

Parameters:
  • a (float, iterable(float), RandomDistribution or (mapping) function) – \(a\)

  • b (float, iterable(float), RandomDistribution or (mapping) function) – \(b\)

  • c (float, iterable(float), RandomDistribution or (mapping) function) – \(c\)

  • d (float, iterable(float), RandomDistribution or (mapping) function) – \(d\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • u (float, iterable(float), RandomDistribution or (mapping) function) – \(u_{init} = \delta V_{init}\)

  • v (float, iterable(float), RandomDistribution or (mapping) function) – \(v_{init} = V_{init}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • tau_syn_E2 (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_{e_2}\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • e_rev_E (float, iterable(float), RandomDistribution or (mapping) function) – \(E^{rev}_e\)

  • e_rev_I (float, iterable(float), RandomDistribution or (mapping) function) – \(E^{rev}_i\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_exc2 (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_{e_2}\)

  • isyn_inh (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

class spynnaker.pyNN.models.neuron.builds.IzkCondExpBase(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Izhikevich neuron model with conductance inputs.

Parameters:
  • a (float, iterable(float), RandomDistribution or (mapping) function) – \(a\)

  • b (float, iterable(float), RandomDistribution or (mapping) function) – \(b\)

  • c (float, iterable(float), RandomDistribution or (mapping) function) – \(c\)

  • d (float, iterable(float), RandomDistribution or (mapping) function) – \(d\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • u (float, iterable(float), RandomDistribution or (mapping) function) – \(u_{init} = \delta V_{init}\)

  • v (float, iterable(float), RandomDistribution or (mapping) function) – \(v_{init} = V_{init}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • e_rev_E (float, iterable(float), RandomDistribution or (mapping) function) – \(E^{rev}_e\)

  • e_rev_I (float, iterable(float), RandomDistribution or (mapping) function) – \(E^{rev}_i\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_inh (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

class spynnaker.pyNN.models.neuron.builds.IzkCurrExpBase(**kwargs)[source]

Bases: AbstractPyNNNeuronModelStandard

Izhikevich neuron model with current inputs.

Parameters:
  • a (float, iterable(float), RandomDistribution or (mapping) function) – \(a\)

  • b (float, iterable(float), RandomDistribution or (mapping) function) – \(b\)

  • c (float, iterable(float), RandomDistribution or (mapping) function) – \(c\)

  • d (float, iterable(float), RandomDistribution or (mapping) function) – \(d\)

  • i_offset (float, iterable(float), RandomDistribution or (mapping) function) – \(I_{offset}\)

  • u (float, iterable(float), RandomDistribution or (mapping) function) – \(u_{init} = \delta V_{init}\)

  • v (float, iterable(float), RandomDistribution or (mapping) function) – \(v_{init} = V_{init}\)

  • tau_syn_E (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • tau_syn_I (float, iterable(float), RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • isyn_exc (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_inh (float, iterable(float), RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • model_name (str) – Name of the model.

  • binary (str) – Name of the implementation executable.

  • neuron_model (AbstractPyNNNeuronModel) – The model of the neuron soma

  • input_type (AbstractInputType) – The model of synaptic input types

  • synapse_type (AbstractSynapseType) – The model of the synapses’ dynamics

  • threshold_type (AbstractThresholdType) – The model of the firing threshold

  • additional_input_type (AbstractAdditionalInput or None) – The model (if any) of additional environmental inputs

spynnaker.pyNN.models.neuron.implementations package
Module contents
class spynnaker.pyNN.models.neuron.implementations.AbstractNeuronImpl[source]

Bases: object

An abstraction of a whole neuron model including all parts.

abstract add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

abstract add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

abstract property binary_name

The name of the binary executable of this implementation.

Return type:

str

abstract get_global_weight_scale()[source]

Get the weight scaling required by this model.

Return type:

int

abstract get_n_synapse_types()[source]

Get the number of synapse types supported by the model.

Return type:

int

abstract get_recordable_data_types()[source]

Get the data type of the variables that can be recorded.

Returns:

dictionary of name of variable to data type of variable

Return type:

dict(str,DataType)

abstract get_recordable_units(variable)[source]

Get the units of the given variable that can be recorded.

Parameters:

variable (str) – The name of the variable

abstract get_recordable_variable_index(variable)[source]

Get the index of the variable in the list of variables that can be recorded.

Parameters:

variable (str) – The name of the variable

Return type:

int

abstract get_recordable_variables()[source]

Get the names of the variables that can be recorded in this model.

Return type:

list(str)

abstract get_synapse_id_by_target(target)[source]

Get the ID of a synapse given the name.

Parameters:

target (str) – The name of the synapse

Return type:

int

abstract get_synapse_targets()[source]

Get the target names of the synapse type.

Return type:

list(str)

abstract get_units(variable)[source]

Get the units of the given variable.

Parameters:

variable (str) – The name of the variable

Return type:

str

abstract property is_conductance_based

Whether the model uses conductance.

Return type:

bool

abstract is_recordable(variable)[source]

Determine if the given variable can be recorded.

Parameters:

variable (str) – The name of the variable

Return type:

bool

abstract property model_name

The name of the model.

Return type:

str

abstract property structs

A list of structures used by the implementation.

Return type:

list(Struct)

class spynnaker.pyNN.models.neuron.implementations.AbstractStandardNeuronComponent(structs, units)[source]

Bases: object

Represents a component of a standard neural model.

Parameters:
  • structs (list(Struct)) – The structures of the component

  • units (dict) – The units to use for each parameter

abstract add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

abstract add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

get_units(variable)[source]

Get the units of the given variable.

Parameters:

variable (str) – The name of the variable

has_variable(variable)[source]

Determine if this component has a variable by the given name.

Parameters:

variable (str) – The name of the variable

Return type:

bool

property structs

The structures of the component. If there are multiple structures, the order is how they will appear in memory; where there are structures that repeat per neuron the repeats will appear adjacent e.g. for non-repeating structure g, followed by repeating structures s1 and s2 with 3 neurons the layout will be: [g, s1, s1, s1, s2, s2, s2].

Return type:

list(Struct)

class spynnaker.pyNN.models.neuron.implementations.NeuronImplStandard(model_name, binary, neuron_model, input_type, synapse_type, threshold_type, additional_input_type=None)[source]

Bases: AbstractNeuronImpl

The standard componentised neuron implementation.

Parameters:
add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

property binary_name

The name of the binary executable of this implementation.

Return type:

str

get_global_weight_scale()[source]

Get the weight scaling required by this model.

Return type:

int

get_n_synapse_types()[source]

Get the number of synapse types supported by the model.

Return type:

int

get_recordable_data_types()[source]

Get the data type of the variables that can be recorded.

Returns:

dictionary of name of variable to data type of variable

Return type:

dict(str,DataType)

get_recordable_units(variable)[source]

Get the units of the given variable that can be recorded.

Parameters:

variable (str) – The name of the variable

get_recordable_variable_index(variable)[source]

Get the index of the variable in the list of variables that can be recorded.

Parameters:

variable (str) – The name of the variable

Return type:

int

get_recordable_variables()[source]

Get the names of the variables that can be recorded in this model.

Return type:

list(str)

get_synapse_id_by_target(target)[source]

Get the ID of a synapse given the name.

Parameters:

target (str) – The name of the synapse

Return type:

int

get_synapse_targets()[source]

Get the target names of the synapse type.

Return type:

list(str)

get_units(variable)[source]

Get the units of the given variable.

Parameters:

variable (str) – The name of the variable

Return type:

str

property is_conductance_based

Whether the model uses conductance.

Return type:

bool

is_recordable(variable)[source]

Determine if the given variable can be recorded.

Parameters:

variable (str) – The name of the variable

Return type:

bool

property model_name

The name of the model.

Return type:

str

property n_steps_per_timestep
property structs

A list of structures used by the implementation.

Return type:

list(Struct)

class spynnaker.pyNN.models.neuron.implementations.RangedDictVertexSlice(ranged_dict, vertex_slice)[source]

Bases: object

A slice of a ranged dict to be used to update values.

Parameters:
spynnaker.pyNN.models.neuron.input_types package
Module contents
class spynnaker.pyNN.models.neuron.input_types.AbstractInputType(structs, units)[source]

Bases: AbstractStandardNeuronComponent

Represents a possible input type for a neuron model (e.g., current).

Parameters:
  • structs (list(Struct)) – The structures of the component

  • units (dict) – The units to use for each parameter

abstract get_global_weight_scale()[source]

Get the global weight scaling value.

Returns:

The global weight scaling value

Return type:

float

class spynnaker.pyNN.models.neuron.input_types.InputTypeConductance(e_rev_E, e_rev_I)[source]

Bases: AbstractInputType

The conductance input type.

Parameters:
  • e_rev_E (float or iterable(float) or RandomDistribution or (mapping) function) – Reversal potential for excitatory input; \(E^{rev}_e\)

  • e_rev_I (float or iterable(float) or RandomDistribution or (mapping) function) – Reversal potential for inhibitory input; \(E^{rev}_i\)

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

property e_rev_E

\(E_{{rev}_e}\)

property e_rev_I

\(E_{{rev}_i}\)

get_global_weight_scale()[source]

Get the global weight scaling value.

Returns:

The global weight scaling value

Return type:

float

class spynnaker.pyNN.models.neuron.input_types.InputTypeCurrent[source]

Bases: AbstractInputType

The current input type.

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

get_global_weight_scale()[source]

Get the global weight scaling value.

Returns:

The global weight scaling value

Return type:

float

class spynnaker.pyNN.models.neuron.input_types.InputTypeDelta[source]

Bases: AbstractInputType

The delta input type.

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

get_global_weight_scale()[source]

Get the global weight scaling value.

Returns:

The global weight scaling value

Return type:

float

spynnaker.pyNN.models.neuron.local_only package
Module contents
class spynnaker.pyNN.models.neuron.local_only.AbstractLocalOnly[source]

Bases: AbstractSynapseDynamics

Processes synapses locally without the need for SDRAM.

property absolute_max_atoms_per_core

The absolute maximum number of atoms per core supported by this synapse dynamics object.

Return type:

int

abstract get_parameters_usage_in_bytes(n_atoms, incoming_projections)[source]

Get the size of the parameters in bytes.

Parameters:
  • n_atoms (int) – The number of atoms in the vertex

  • incoming_projections (list(Projection)) – The projections to get the size of

Return type:

int

property is_combined_core_capable

Whether the synapse dynamics can run on a core combined with the neuron, or if a separate core is needed.

Return type:

bool

abstract write_parameters(spec, region, machine_vertex, weight_scales)[source]

Write the parameters to the spec.

Parameters:
class spynnaker.pyNN.models.neuron.local_only.LocalOnlyConvolution(delay=None)[source]

Bases: AbstractLocalOnly, AbstractSupportsSignedWeights

A convolution synapse dynamics that can process spikes with only DTCM.

Parameters:

delay (float) – The delay used in the connection; by default 1 time step

property changes_during_run

Whether the synapses change during a run.

Return type:

bool

property delay

The delay of connections.

Return type:

float

get_maximum_positive_weight(incoming_projection)[source]

Get the maximum likely positive weight.

Note

This must be a value >= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

get_mean_negative_weight(incoming_projection)[source]

Get the mean of the negative weights.

Note

This must be a value <= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

get_mean_positive_weight(incoming_projection)[source]

Get the mean of the positive weights.

Note

This must be a value >= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

get_minimum_negative_weight(incoming_projection)[source]

Get the minimum likely negative weight.

Note

This must be a value <= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

int

get_negative_synapse_index(incoming_projection)[source]

Get the synapse type that negative weights will arrive at.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

int

get_parameters_usage_in_bytes(n_atoms, incoming_projections)[source]

Get the size of the parameters in bytes.

Parameters:
  • n_atoms (int) – The number of atoms in the vertex

  • incoming_projections (list(Projection)) – The projections to get the size of

Return type:

int

get_positive_synapse_index(incoming_projection)[source]

Get the synapse type that positive weights will arrive at.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

int

get_variance_negative_weight(incoming_projection)[source]

Get the variance of the negative weights.

Note

This must be a value <= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

get_variance_positive_weight(incoming_projection)[source]

Get the variance of the positive weights.

Note

This must be a value >= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

get_vertex_executable_suffix()[source]

Get the executable suffix for a vertex for this dynamics.

Return type:

str

merge(synapse_dynamics)[source]

Merge with the given synapse_dynamics and return the result, or error if merge is not possible.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

AbstractSynapseDynamics

property weight

The weight of connections.

Return type:

float

write_parameters(spec, region, machine_vertex, weight_scales)[source]

Write the parameters to the spec.

Parameters:
class spynnaker.pyNN.models.neuron.local_only.LocalOnlyPoolDense(delay=None)[source]

Bases: AbstractLocalOnly, AbstractSupportsSignedWeights

A convolution synapse dynamics that can process spikes with only DTCM.

Parameters:

delay (float) – The delay used in the connection; by default 1 time step

property changes_during_run

Whether the synapses change during a run.

Return type:

bool

property delay

The delay of connections.

Return type:

float

get_maximum_positive_weight(incoming_projection)[source]

Get the maximum likely positive weight.

Note

This must be a value >= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

get_mean_negative_weight(incoming_projection)[source]

Get the mean of the negative weights.

Note

This must be a value <= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

get_mean_positive_weight(incoming_projection)[source]

Get the mean of the positive weights.

Note

This must be a value >= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

get_minimum_negative_weight(incoming_projection)[source]

Get the minimum likely negative weight.

Note

This must be a value <= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

int

get_negative_synapse_index(incoming_projection)[source]

Get the synapse type that negative weights will arrive at.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

int

get_parameters_usage_in_bytes(n_atoms, incoming_projections)[source]

Get the size of the parameters in bytes.

Parameters:
  • n_atoms (int) – The number of atoms in the vertex

  • incoming_projections (list(Projection)) – The projections to get the size of

Return type:

int

get_positive_synapse_index(incoming_projection)[source]

Get the synapse type that positive weights will arrive at.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

int

get_variance_negative_weight(incoming_projection)[source]

Get the variance of the negative weights.

Note

This must be a value <= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

get_variance_positive_weight(incoming_projection)[source]

Get the variance of the positive weights.

Note

This must be a value >= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

get_vertex_executable_suffix()[source]

Get the executable suffix for a vertex for this dynamics.

Return type:

str

merge(synapse_dynamics)[source]

Merge with the given synapse_dynamics and return the result, or error if merge is not possible.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

AbstractSynapseDynamics

property weight

The weight of connections.

Return type:

float

write_parameters(spec, region, machine_vertex, weight_scales)[source]

Write the parameters to the spec.

Parameters:
spynnaker.pyNN.models.neuron.neuron_models package
Module contents
class spynnaker.pyNN.models.neuron.neuron_models.NeuronModelIzh(a, b, c, d, v_init, u_init, i_offset)[source]

Bases: AbstractStandardNeuronComponent

Model of neuron due to Eugene M. Izhikevich et al.

Parameters:
  • a (float or iterable(float) or RandomDistribution or (mapping) function) – \(a\)

  • b (float or iterable(float) or RandomDistribution or (mapping) function) – \(b\)

  • c (float or iterable(float) or RandomDistribution or (mapping) function) – \(c\)

  • d (float or iterable(float) or RandomDistribution or (mapping) function) – \(d\)

  • v_init (float or iterable(float) or RandomDistribution or (mapping) function) – \(v_{init}\)

  • u_init (float or iterable(float) or RandomDistribution or (mapping) function) – \(u_{init}\)

  • i_offset (float or iterable(float) or RandomDistribution or (mapping) function) – \(I_{offset}\)

property a

Settable model parameter: \(a\)

Return type:

float

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

property b

Settable model parameter: \(b\)

Return type:

float

property c

Settable model parameter: \(c\)

Return type:

float

property d

Settable model parameter: \(d\)

Return type:

float

property i_offset

Settable model parameter: \(I_{offset}\)

Return type:

float

property u_init

Settable model parameter: \(u_{init}\)

Return type:

float

property v_init

Settable model parameter: \(v_{init}\)

Return type:

float

class spynnaker.pyNN.models.neuron.neuron_models.NeuronModelLeakyIntegrateAndFire(v_init, v_rest, tau_m, cm, i_offset, v_reset, tau_refrac)[source]

Bases: AbstractStandardNeuronComponent

Classic leaky integrate and fire neuron model.

Parameters:
  • v_init (float or iterable(float) or RandomDistribution or (mapping) function) – \(V_{init}\)

  • v_rest (float or iterable(float) or RandomDistribution or (mapping) function) – \(V_{rest}\)

  • tau_m (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau_{m}\)

  • cm (float or iterable(float) or RandomDistribution or (mapping) function) – \(C_m\)

  • i_offset (float or iterable(float) or RandomDistribution or (mapping) function) – \(I_{offset}\)

  • v_reset (float or iterable(float) or RandomDistribution or (mapping) function) – \(V_{reset}\)

  • tau_refrac (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau_{refrac}\)

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

property cm

Settable model parameter: \(C_m\)

Return type:

float

property i_offset

Settable model parameter: \(I_{offset}\)

Return type:

float

property tau_m

Settable model parameter: \(\tau_{m}\)

Return type:

float

property tau_refrac

Settable model parameter: \(\tau_{refrac}\)

Return type:

float

property v_init

Settable model parameter: \(V_{init}\)

Return type:

float

property v_reset

Settable model parameter: \(V_{reset}\)

Return type:

float

property v_rest

Settable model parameter: \(V_{rest}\)

Return type:

float

spynnaker.pyNN.models.neuron.plasticity package
Subpackages
spynnaker.pyNN.models.neuron.plasticity.stdp package
Subpackages
spynnaker.pyNN.models.neuron.plasticity.stdp.synapse_structure package
Module contents
class spynnaker.pyNN.models.neuron.plasticity.stdp.synapse_structure.AbstractSynapseStructure[source]

Bases: object

abstract get_n_half_words_per_connection()[source]

Get the number of bytes for each connection.

Return type:

int

abstract get_weight_half_word()[source]

The index of the half-word where the weight should be written.

Return type:

int

class spynnaker.pyNN.models.neuron.plasticity.stdp.synapse_structure.SynapseStructureWeightAccumulator[source]

Bases: AbstractSynapseStructure

get_n_half_words_per_connection()[source]

Get the number of bytes for each connection.

Return type:

int

get_weight_half_word()[source]

The index of the half-word where the weight should be written.

Return type:

int

class spynnaker.pyNN.models.neuron.plasticity.stdp.synapse_structure.SynapseStructureWeightOnly[source]

Bases: AbstractSynapseStructure

get_n_half_words_per_connection()[source]

Get the number of bytes for each connection.

Return type:

int

get_weight_half_word()[source]

The index of the half-word where the weight should be written.

Return type:

int

spynnaker.pyNN.models.neuron.plasticity.stdp.timing_dependence package
Module contents
class spynnaker.pyNN.models.neuron.plasticity.stdp.timing_dependence.AbstractTimingDependence[source]

Bases: object

abstract get_parameter_names()[source]

Return the names of the parameters supported by this timing dependency model.

Return type:

iterable(str)

abstract get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

abstract is_same_as(timing_dependence)[source]

Determine if this timing dependence is the same as another.

Parameters:

timing_dependence (AbstractTimingDependence) –

Return type:

bool

abstract property n_weight_terms

The number of weight terms expected by this timing rule.

Return type:

int

abstract property pre_trace_n_bytes

The number of bytes used by the pre-trace of the rule per neuron.

Return type:

int

abstract property synaptic_structure

The synaptic structure of the plastic part of the rows.

Return type:

AbstractSynapseStructure

abstract property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

abstract write_parameters(spec, global_weight_scale, synapse_weight_scales)[source]

Write the parameters of the rule to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

class spynnaker.pyNN.models.neuron.plasticity.stdp.timing_dependence.TimingDependencePfisterSpikeTriplet(tau_plus, tau_minus, tau_x, tau_y, A_plus, A_minus)[source]

Bases: AbstractTimingDependence

A timing dependence STDP rule based on spike triplets.

Jean-Pascal Pfister, Wulfram Gerstner. Triplets of Spikes in a Model of Spike Timing-Dependent Plasticity. Journal of Neuroscience, 20 September 2006, 26 (38) 9673-9682; DOI: 10.1523/JNEUROSCI.1425-06.2006

Parameters:
  • tau_plus (float) – \(\tau_+\)

  • tau_minus (float) – \(\tau_-\)

  • tau_x (float) – \(\tau_x\)

  • tau_y (float) – \(\tau_y\)

  • A_plus (float) – \(A^+\)

  • A_minus (float) – \(A^-\)

property A_minus

\(A^-\)

Return type:

float

property A_plus

\(A^+\)

Return type:

float

get_parameter_names()[source]

Return the names of the parameters supported by this timing dependency model.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

is_same_as(timing_dependence)[source]

Determine if this timing dependence is the same as another.

Parameters:

timing_dependence (AbstractTimingDependence) –

Return type:

bool

property n_weight_terms

The number of weight terms expected by this timing rule.

Return type:

int

property pre_trace_n_bytes

The number of bytes used by the pre-trace of the rule per neuron.

Return type:

int

property synaptic_structure

The synaptic structure of the plastic part of the rows.

Return type:

AbstractSynapseStructure

property tau_minus

\(\tau_-\)

Return type:

float

property tau_plus

\(\tau_+\)

Return type:

float

property tau_x

\(\tau_x\)

Return type:

float

property tau_y

\(\tau_y\)

Return type:

float

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec, global_weight_scale, synapse_weight_scales)[source]

Write the parameters of the rule to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

class spynnaker.pyNN.models.neuron.plasticity.stdp.timing_dependence.TimingDependenceRecurrent(accumulator_depression=-6, accumulator_potentiation=6, mean_pre_window=35.0, mean_post_window=35.0, dual_fsm=True, A_plus=0.01, A_minus=0.01)[source]

Bases: AbstractTimingDependence

A timing dependence STDP rule based on recurrences.

Parameters:
  • accumulator_depression (int) –

  • accumulator_potentiation (int) –

  • mean_pre_window (float) –

  • mean_post_window (float) –

  • dual_fsm (bool) –

  • A_plus (float) – \(A^+\)

  • A_minus (float) – \(A^-\)

property A_minus

\(A^-\)

Return type:

float

property A_plus

\(A^+\)

Return type:

float

default_parameters = {'accumulator_depression': -6, 'accumulator_potentiation': 6, 'dual_fsm': True, 'mean_post_window': 35.0, 'mean_pre_window': 35.0}
get_parameter_names()[source]

Return the names of the parameters supported by this timing dependency model.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

is_same_as(timing_dependence)[source]

Determine if this timing dependence is the same as another.

Parameters:

timing_dependence (AbstractTimingDependence) –

Return type:

bool

property n_weight_terms

The number of weight terms expected by this timing rule.

Return type:

int

property pre_trace_n_bytes

The number of bytes used by the pre-trace of the rule per neuron.

Return type:

int

property synaptic_structure

The synaptic structure of the plastic part of the rows.

Return type:

AbstractSynapseStructure

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec, global_weight_scale, synapse_weight_scales)[source]

Write the parameters of the rule to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

class spynnaker.pyNN.models.neuron.plasticity.stdp.timing_dependence.TimingDependenceSpikeNearestPair(tau_plus=20.0, tau_minus=20.0, A_plus=0.01, A_minus=0.01)[source]

Bases: AbstractTimingDependence

A timing dependence STDP rule based on nearest pairs.

Parameters:
  • tau_plus (float) – \(\tau_+\)

  • tau_minus (float) – \(\tau_-\)

  • A_plus (float) – \(A^+\)

  • A_minus (float) – \(A^-\)

property A_minus

\(A^-\)

Return type:

float

property A_plus

\(A^+\)

Return type:

float

default_parameters = {'tau_minus': 20.0, 'tau_plus': 20.0}
get_parameter_names()[source]

Return the names of the parameters supported by this timing dependency model.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

is_same_as(timing_dependence)[source]

Determine if this timing dependence is the same as another.

Parameters:

timing_dependence (AbstractTimingDependence) –

Return type:

bool

property n_weight_terms

The number of weight terms expected by this timing rule.

Return type:

int

property pre_trace_n_bytes

The number of bytes used by the pre-trace of the rule per neuron.

Return type:

int

property synaptic_structure

The synaptic structure of the plastic part of the rows.

Return type:

AbstractSynapseStructure

property tau_minus

\(\tau_-\)

Return type:

float

property tau_plus

\(\tau_+\)

Return type:

float

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec, global_weight_scale, synapse_weight_scales)[source]

Write the parameters of the rule to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

class spynnaker.pyNN.models.neuron.plasticity.stdp.timing_dependence.TimingDependenceSpikePair(tau_plus=20.0, tau_minus=20.0, A_plus=0.01, A_minus=0.01)[source]

Bases: AbstractTimingDependence

A basic timing dependence STDP rule.

Parameters:
  • tau_plus (float) – \(\tau_+\)

  • tau_minus (float) – \(\tau_-\)

  • A_plus (float) – \(A^+\)

  • A_minus (float) – \(A^-\)

property A_minus

\(A^-\)

Return type:

float

property A_plus

\(A^+\)

Return type:

float

get_parameter_names()[source]

Return the names of the parameters supported by this timing dependency model.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

is_same_as(timing_dependence)[source]

Determine if this timing dependence is the same as another.

Parameters:

timing_dependence (AbstractTimingDependence) –

Return type:

bool

property n_weight_terms

The number of weight terms expected by this timing rule.

Return type:

int

property pre_trace_n_bytes

The number of bytes used by the pre-trace of the rule per neuron.

Return type:

int

property synaptic_structure

The synaptic structure of the plastic part of the rows.

Return type:

AbstractSynapseStructure

property tau_minus

\(\tau_-\)

Return type:

float

property tau_plus

\(\tau_+\)

Return type:

float

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec, global_weight_scale, synapse_weight_scales)[source]

Write the parameters of the rule to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

class spynnaker.pyNN.models.neuron.plasticity.stdp.timing_dependence.TimingDependenceVogels2011(alpha, tau=20.0, A_plus=0.01, A_minus=0.01)[source]

Bases: AbstractTimingDependence

A timing dependence STDP rule due to Vogels (2011).

Parameters:
  • alpha (float) – \(\alpha\)

  • tau (float) – \(\tau\)

  • A_plus (float) – \(A^+\)

  • A_minus (float) – \(A^-\)

property A_minus

\(A^-\)

Return type:

float

property A_plus

\(A^+\)

Return type:

float

property alpha

\(\alpha\)

Return type:

float

default_parameters = {'tau': 20.0}
get_parameter_names()[source]

Return the names of the parameters supported by this timing dependency model.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

is_same_as(timing_dependence)[source]

Determine if this timing dependence is the same as another.

Parameters:

timing_dependence (AbstractTimingDependence) –

Return type:

bool

property n_weight_terms

The number of weight terms expected by this timing rule.

Return type:

int

property pre_trace_n_bytes

The number of bytes used by the pre-trace of the rule per neuron.

Return type:

int

property synaptic_structure

The synaptic structure of the plastic part of the rows.

Return type:

AbstractSynapseStructure

property tau

\(\tau\)

Return type:

float

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec, global_weight_scale, synapse_weight_scales)[source]

Write the parameters of the rule to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

spynnaker.pyNN.models.neuron.plasticity.stdp.weight_dependence package
Module contents
class spynnaker.pyNN.models.neuron.plasticity.stdp.weight_dependence.AbstractHasAPlusAMinus[source]

Bases: object

An object that has \(A^+\) and \(A^-\) properties.

property A_minus

Settable model parameter: \(A^-\)

Return type:

float

property A_plus

Settable model parameter: \(A^+\)

Return type:

float

set_a_plus_a_minus(a_plus, a_minus)[source]

Set the values of \(A^+\) and \(A^-\).

Parameters:
  • a_plus (float) – \(A^+\)

  • a_minus (float) – \(A^-\)

class spynnaker.pyNN.models.neuron.plasticity.stdp.weight_dependence.AbstractWeightDependence[source]

Bases: object

abstract get_parameter_names()[source]

Returns the parameter names.

Return type:

iterable(str)

abstract get_parameters_sdram_usage_in_bytes(n_synapse_types, n_weight_terms)[source]

Get the amount of SDRAM used by the parameters of this rule.

Parameters:
  • n_synapse_types (int) –

  • n_weight_terms (int) –

Return type:

int

abstract is_same_as(weight_dependence)[source]

Determine if this weight dependence is the same as another.

Parameters:

weight_dependence (AbstractWeightDependence) –

Return type:

bool

abstract property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

abstract property weight_maximum

The maximum weight that will ever be set in a synapse as a result of this rule.

Return type:

float

abstract write_parameters(spec, global_weight_scale, synapse_weight_scales, n_weight_terms)[source]

Write the parameters of the rule to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

  • n_weight_terms (int) – The number of terms used by the synapse rule

class spynnaker.pyNN.models.neuron.plasticity.stdp.weight_dependence.WeightDependenceAdditive(w_min=0.0, w_max=1.0)[source]

Bases: AbstractHasAPlusAMinus, AbstractWeightDependence

An additive weight dependence STDP rule.

Parameters:
  • w_min (float) – \(w^{min}\)

  • w_max (float) – \(w^{max}\)

get_parameter_names()[source]

Returns the parameter names.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes(n_synapse_types, n_weight_terms)[source]

Get the amount of SDRAM used by the parameters of this rule.

Parameters:
  • n_synapse_types (int) –

  • n_weight_terms (int) –

Return type:

int

is_same_as(weight_dependence)[source]

Determine if this weight dependence is the same as another.

Parameters:

weight_dependence (AbstractWeightDependence) –

Return type:

bool

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

property w_max

\(w^{max}\)

Return type:

float

property w_min

\(w^{min}\)

Return type:

float

property weight_maximum

The maximum weight that will ever be set in a synapse as a result of this rule.

Return type:

float

write_parameters(spec, global_weight_scale, synapse_weight_scales, n_weight_terms)[source]

Write the parameters of the rule to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

  • n_weight_terms (int) – The number of terms used by the synapse rule

class spynnaker.pyNN.models.neuron.plasticity.stdp.weight_dependence.WeightDependenceAdditiveTriplet(w_min=0.0, w_max=1.0, A3_plus=0.01, A3_minus=0.01)[source]

Bases: AbstractHasAPlusAMinus, AbstractWeightDependence

An triplet-based additive weight dependence STDP rule.

Parameters:
  • w_min (float) – \(w^{min}\)

  • w_max (float) – \(w^{max}\)

  • A3_plus (float) – \(A_3^+\)

  • A3_minus (float) – \(A_3^-\)

property A3_minus

\(A_3^-\)

Return type:

float

property A3_plus

\(A_3^+\)

Return type:

float

default_parameters = {'A3_minus': 0.01, 'A3_plus': 0.01, 'w_max': 1.0, 'w_min': 0.0}
get_parameter_names()[source]

Returns the parameter names.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes(n_synapse_types, n_weight_terms)[source]

Get the amount of SDRAM used by the parameters of this rule.

Parameters:
  • n_synapse_types (int) –

  • n_weight_terms (int) –

Return type:

int

is_same_as(weight_dependence)[source]

Determine if this weight dependence is the same as another.

Parameters:

weight_dependence (AbstractWeightDependence) –

Return type:

bool

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

property w_max

\(w^{max}\)

Return type:

float

property w_min

\(w^{min}\)

Return type:

float

property weight_maximum

The maximum weight that will ever be set in a synapse as a result of this rule.

Return type:

float

write_parameters(spec, global_weight_scale, synapse_weight_scales, n_weight_terms)[source]

Write the parameters of the rule to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

  • n_weight_terms (int) – The number of terms used by the synapse rule

class spynnaker.pyNN.models.neuron.plasticity.stdp.weight_dependence.WeightDependenceMultiplicative(w_min=0.0, w_max=1.0)[source]

Bases: AbstractHasAPlusAMinus, AbstractWeightDependence

A multiplicative weight dependence STDP rule.

Parameters:
  • w_min (float) – \(w^{min}\)

  • w_max (float) – \(w^{max}\)

get_parameter_names()[source]

Returns the parameter names.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes(n_synapse_types, n_weight_terms)[source]

Get the amount of SDRAM used by the parameters of this rule.

Parameters:
  • n_synapse_types (int) –

  • n_weight_terms (int) –

Return type:

int

is_same_as(weight_dependence)[source]

Determine if this weight dependence is the same as another.

Parameters:

weight_dependence (AbstractWeightDependence) –

Return type:

bool

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

property w_max

\(w^{max}\)

Return type:

float

property w_min

\(w^{min}\)

Return type:

float

property weight_maximum

The maximum weight that will ever be set in a synapse as a result of this rule.

Return type:

float

write_parameters(spec, global_weight_scale, synapse_weight_scales, n_weight_terms)[source]

Write the parameters of the rule to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

  • n_weight_terms (int) – The number of terms used by the synapse rule

Submodules
spynnaker.pyNN.models.neuron.plasticity.stdp.common module
spynnaker.pyNN.models.neuron.plasticity.stdp.common.float_to_fixed(value)[source]
Parameters:

value (float) –

Return type:

int

spynnaker.pyNN.models.neuron.plasticity.stdp.common.get_exp_lut_array(time_step, time_constant, shift=0)[source]
Parameters:
  • time_step (int) –

  • time_constant (float) –

  • shift (int) –

Return type:

ndarray

Module contents
Module contents
spynnaker.pyNN.models.neuron.structural_plasticity package
Subpackages
spynnaker.pyNN.models.neuron.structural_plasticity.synaptogenesis package
Subpackages
spynnaker.pyNN.models.neuron.structural_plasticity.synaptogenesis.elimination package
Module contents
class spynnaker.pyNN.models.neuron.structural_plasticity.synaptogenesis.elimination.AbstractElimination[source]

Bases: object

A synaptic connection elimination rule.

abstract get_parameter_names()[source]

Return the names of the parameters supported by this rule.

Return type:

iterable(str)

abstract get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

abstract property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

abstract write_parameters(spec, weight_scale)[source]

Write the parameters of the rule to the spec.

Parameters:
class spynnaker.pyNN.models.neuron.structural_plasticity.synaptogenesis.elimination.RandomByWeightElimination(threshold, prob_elim_depressed=0.0245, prob_elim_potentiated=0.00013600000000000003)[source]

Bases: AbstractElimination

Elimination Rule that depends on the weight of a synapse.

Parameters:
  • threshold (float) – Below this weight is considered depression, above or equal to this weight is considered potentiation (or the static weight of the connection on static weight connections)

  • prob_elim_depressed (float) – The probability of elimination if the weight has been depressed (ignored on static weight connections)

  • prob_elim_potentiated (float) – The probability of elimination of the weight has been potentiated or has not changed (and also used on static weight connections)

get_parameter_names()[source]

Return the names of the parameters supported by this rule.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec, weight_scale)[source]

Write the parameters of the rule to the spec.

Parameters:
spynnaker.pyNN.models.neuron.structural_plasticity.synaptogenesis.formation package
Module contents
class spynnaker.pyNN.models.neuron.structural_plasticity.synaptogenesis.formation.AbstractFormation[source]

Bases: object

A synaptic connection formation rule.

abstract get_parameter_names()[source]

Return the names of the parameters supported by this rule.

Return type:

iterable(str)

abstract get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

abstract property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

abstract write_parameters(spec)[source]

Write the parameters of the rule to the spec.

Parameters:

spec (DataSpecificationGenerator) –

class spynnaker.pyNN.models.neuron.structural_plasticity.synaptogenesis.formation.DistanceDependentFormation(grid=(16, 16), p_form_forward=0.16, sigma_form_forward=2.5, p_form_lateral=1.0, sigma_form_lateral=1.0)[source]

Bases: AbstractFormation

Formation rule that depends on the physical distance between neurons.

Parameters:
  • grid (tuple(int,int) or list(int) or ndarray(int)) – (x, y) dimensions of the grid of distance

  • p_form_forward (float) – The peak probability of formation on feed-forward connections

  • sigma_form_forward (float) – The spread of probability with distance of formation on feed-forward connections

  • p_form_lateral (float) – The peak probability of formation on lateral connections

  • sigma_form_lateral (float) – The spread of probability with distance of formation on lateral connections

distance(x0, x1, metric)[source]

Compute the distance between points x0 and x1 place on the grid using periodic boundary conditions.

Parameters:
  • x0 (ndarray(int)) – first point in space

  • x1 (ndarray(int)) – second point in space

  • grid (ndarray(int)) – shape of grid

  • metric (str) – distance metric, i.e. euclidian or manhattan or equidistant

Returns:

the distance

Return type:

float

generate_distance_probability_array(probability, sigma)[source]

Generate the exponentially decaying probability LUTs.

Parameters:
  • probability (float) – peak probability

  • sigma (float) – spread

Returns:

distance-dependent probabilities

Return type:

ndarray(float)

get_parameter_names()[source]

Return the names of the parameters supported by this rule.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec)[source]

Write the parameters of the rule to the spec.

Parameters:

spec (DataSpecificationGenerator) –

spynnaker.pyNN.models.neuron.structural_plasticity.synaptogenesis.partner_selection package
Module contents
class spynnaker.pyNN.models.neuron.structural_plasticity.synaptogenesis.partner_selection.AbstractPartnerSelection[source]

Bases: object

A partner selection rule.

abstract get_parameter_names()[source]

Return the names of the parameters supported by this rule.

Return type:

iterable(str)

abstract get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

str

abstract property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

abstract write_parameters(spec)[source]

Write the parameters of the rule to the spec.

Parameters:

spec (DataSpecificationGenerator) –

class spynnaker.pyNN.models.neuron.structural_plasticity.synaptogenesis.partner_selection.LastNeuronSelection(spike_buffer_size=64)[source]

Bases: AbstractPartnerSelection

Partner selection that picks a random source neuron from the neurons that spiked in the last timestep.

Parameters:

spike_buffer_size – The size of the buffer for holding spikes

get_parameter_names()[source]

Return the names of the parameters supported by this rule.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

str

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec)[source]

Write the parameters of the rule to the spec.

Parameters:

spec (DataSpecificationGenerator) –

class spynnaker.pyNN.models.neuron.structural_plasticity.synaptogenesis.partner_selection.RandomSelection[source]

Bases: AbstractPartnerSelection

Partner selection that picks a random source neuron from all sources.

get_parameter_names()[source]

Return the names of the parameters supported by this rule.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

str

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec)[source]

Write the parameters of the rule to the spec.

Parameters:

spec (DataSpecificationGenerator) –

Module contents
Module contents
spynnaker.pyNN.models.neuron.synapse_dynamics package
Module contents
class spynnaker.pyNN.models.neuron.synapse_dynamics.AbstractGenerateOnMachine[source]

Bases: object

A synapse dynamics that can be generated on the machine.

abstract property gen_matrix_id

The ID of the on-machine matrix generator.

Return type:

int

abstract gen_matrix_params(synaptic_matrix_offset, delayed_matrix_offset, app_edge, synapse_info, max_row_info, max_pre_atoms_per_core, max_post_atoms_per_core)[source]

Any parameters required by the matrix generator.

Return type:

ndarray(uint32)

abstract property gen_matrix_params_size_in_bytes

The size of the parameters of the matrix generator in bytes.

Return type:

int

generate_on_machine()[source]

Determines if this instance should be generated on the machine.

Default implementation returns True

Return type:

bool

class spynnaker.pyNN.models.neuron.synapse_dynamics.AbstractPlasticSynapseDynamics[source]

Bases: AbstractSDRAMSynapseDynamics

Synapses which change over time.

abstract get_n_fixed_plastic_words_per_row(fp_size)[source]

Get the number of fixed plastic words to be read from each row.

Parameters:

fp_size (ndarray) –

abstract get_n_plastic_plastic_words_per_row(pp_size)[source]

Get the number of plastic plastic words to be read from each row.

Parameters:

pp_size (ndarray) –

abstract get_n_synapses_in_rows(pp_size, fp_size)[source]

Get the number of synapses in each of the rows with plastic sizes pp_size and fp_size.

Parameters:
abstract get_n_words_for_plastic_connections(n_connections)[source]

Get the number of 32-bit words for n_connections in a single row.

Parameters:

n_connections (int) –

Return type:

int

abstract get_plastic_synaptic_data(connections, connection_row_indices, n_rows, post_vertex_slice, n_synapse_types, max_n_synapses, max_atoms_per_core)[source]

Get the fixed-plastic data, and plastic-plastic data for each row, and lengths for the fixed_plastic and plastic-plastic parts of each row.

Data is returned as an array made up of an array of 32-bit words for each row, for each of the fixed-plastic and plastic-plastic data regions. The row into which connection should go is given by connection_row_indices, and the total number of rows is given by n_rows.

Lengths are returned as an array made up of an integer for each row, for each of the fixed-plastic and plastic-plastic regions.

Parameters:
  • connections (ndarray) – The connections to get data for

  • connection_row_indices (ndarray) – The row into which each connection should go

  • n_rows (int) – The total number of rows

  • post_vertex_slice (Slice) – The slice of the post vertex to get the connections for

  • n_synapse_types (int) – The number of synapse types

  • max_n_synapses (int) – The maximum number of synapses to generate

  • max_atoms_per_core (int) – The maximum number of atoms on a core

Returns:

(fp_data, pp_data, fp_size, pp_size)

Return type:

tuple(ndarray, ndarray, ndarray, ndarray)

abstract read_plastic_synaptic_data(post_vertex_slice, n_synapse_types, pp_size, pp_data, fp_size, fp_data, max_atoms_per_core)[source]

Read the connections indicated in the connection indices from the data in pp_data and fp_data.

Parameters:
Returns:

array with columns source, target, weight, delay

Return type:

ndarray

class spynnaker.pyNN.models.neuron.synapse_dynamics.AbstractSDRAMSynapseDynamics[source]

Bases: AbstractSynapseDynamics

How do the dynamics of a synapse interact with the rest of the model.

NUMPY_CONNECTORS_DTYPE = [('source', 'uint32'), ('target', 'uint32'), ('weight', 'float64'), ('delay', 'float64')]

Type model of the basic configuration data of a connector

convert_per_connection_data_to_rows(connection_row_indices, n_rows, data, max_n_synapses)[source]

Converts per-connection data generated from connections into row-based data to be returned from get_synaptic_data.

Parameters:
  • connection_row_indices (ndarray) – The index of the row that each item should go into

  • n_rows (int) – The number of rows

  • data (ndarray) – The non-row-based data

  • max_n_synapses (int) – The maximum number of synapses to generate in each row

Return type:

list(ndarray)

abstract get_max_synapses(n_words)[source]

Get the maximum number of synapses that can be held in the given number of words.

Parameters:

n_words (int) – The number of words the synapses must fit in

Return type:

int

get_n_items(rows, item_size)[source]

Get the number of items in each row as 4-byte values, given the item size.

Parameters:
Return type:

ndarray

abstract get_parameter_names()[source]

Get the parameter names available from the synapse dynamics components.

Return type:

iterable(str)

abstract get_parameters_sdram_usage_in_bytes(n_neurons, n_synapse_types)[source]

Get the SDRAM usage of the synapse dynamics parameters in bytes.

Parameters:
  • n_neurons (int) –

  • n_synapse_types (int) –

Return type:

int

get_words(rows)[source]

Convert the row data to words.

Parameters:

rows (ndarray) –

Return type:

ndarray

abstract is_same_as(synapse_dynamics)[source]

Determines if this synapse dynamics is the same as another.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

bool

abstract property pad_to_length

The amount each row should pad to, or None if not specified.

abstract write_parameters(spec, region, global_weight_scale, synapse_weight_scales)[source]

Write the synapse parameters to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • region (int) – region ID to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

class spynnaker.pyNN.models.neuron.synapse_dynamics.AbstractStaticSynapseDynamics[source]

Bases: AbstractSDRAMSynapseDynamics

Dynamics which don’t change over time.

abstract get_n_static_words_per_row(ff_size)[source]

Get the number of bytes to be read per row for the static data given the size that was written to each row.

Parameters:

ff_size (ndarray) –

Return type:

ndarray

abstract get_n_synapses_in_rows(ff_size)[source]

Get the number of synapses in the rows with sizes ff_size.

Parameters:

ff_size (ndarray) –

Return type:

ndarray

abstract get_n_words_for_static_connections(n_connections)[source]

Get the number of 32-bit words for n_connections in a single row.

Parameters:

n_connections (int) –

Return type:

int

abstract get_static_synaptic_data(connections, connection_row_indices, n_rows, post_vertex_slice, n_synapse_types, max_n_synapses, max_atoms_per_core)[source]

Get the fixed-fixed data for each row, and lengths for the fixed-fixed parts of each row.

Data is returned as an array made up of an array of 32-bit words for each row for the fixed-fixed region. The row into which connection should go is given by connection_row_indices, and the total number of rows is given by n_rows.

Lengths are returned as an array made up of an integer for each row, for the fixed-fixed region.

Parameters:
  • connections (ndarray) – The connections to get data for

  • connection_row_indices (ndarray) – The row into which each connection should go

  • n_rows (int) – The number of rows to write

  • post_vertex_slice (Slice) – The slice of the post vertex to generate for

  • n_synapse_types (int) – The number of synapse types

  • max_n_synapses (int) – The maximum number of synapses to generate

  • max_atoms_per_core (int) – The maximum number of atoms on a core

Returns:

(ff_data, ff_size)

Return type:

tuple(list(ndarray), ndarray)

abstract read_static_synaptic_data(post_vertex_slice, n_synapse_types, ff_size, ff_data, max_atoms_per_core)[source]

Read the connections from the words of data in ff_data.

Parameters:
Return type:

ndarray

class spynnaker.pyNN.models.neuron.synapse_dynamics.AbstractSupportsSignedWeights[source]

Bases: object

A synapse dynamics object that supports signed weights.

abstract get_maximum_positive_weight(incoming_projection)[source]

Get the maximum likely positive weight.

Note

This must be a value >= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

abstract get_mean_negative_weight(incoming_projection)[source]

Get the mean of the negative weights.

Note

This must be a value <= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

abstract get_mean_positive_weight(incoming_projection)[source]

Get the mean of the positive weights.

Note

This must be a value >= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

abstract get_minimum_negative_weight(incoming_projection)[source]

Get the minimum likely negative weight.

Note

This must be a value <= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

int

abstract get_negative_synapse_index(incoming_projection)[source]

Get the synapse type that negative weights will arrive at.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

int

abstract get_positive_synapse_index(incoming_projection)[source]

Get the synapse type that positive weights will arrive at.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

int

abstract get_variance_negative_weight(incoming_projection)[source]

Get the variance of the negative weights.

Note

This must be a value <= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

abstract get_variance_positive_weight(incoming_projection)[source]

Get the variance of the positive weights.

Note

This must be a value >= 0.

Parameters:

incoming_projection (Projection) – The projection targeted

Return type:

float

class spynnaker.pyNN.models.neuron.synapse_dynamics.AbstractSynapseDynamics[source]

Bases: object

How do the dynamics of a synapse interact with the rest of the model.

property absolute_max_atoms_per_core

The absolute maximum number of atoms per core supported by this synapse dynamics object.

Return type:

int

abstract property changes_during_run

Whether the synapses change during a run.

Return type:

bool

abstract property delay

The delay of connections.

Return type:

float

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector.

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

get_delay_maximum(connector, synapse_info)[source]

Get the maximum delay for the synapses.

Parameters:
get_delay_minimum(connector, synapse_info)[source]

Get the minimum delay for the synapses. This will support the filtering of the undelayed edge from the graph, but requires fixes in the synaptic manager to happen first before this can be utilised fully.

Parameters:
get_delay_variance(connector, delays, synapse_info)[source]

Get the variance in delay for the synapses.

Parameters:
get_provenance_data(pre_population_label, post_population_label)[source]

Get the provenance data from this synapse dynamics object.

Parameters:
  • pre_population_label (str) –

  • post_population_label (str) –

Return type:

iterable(ProvenanceDataItem)

get_synapse_id_by_target(target)[source]

Get the index of the synapse type based on the name, or None if the name is not found.

Parameters:

target (str) – The name of the synapse

Return type:

int or None

get_value(key)[source]

Get a property.

Parameters:

key (str) – the name of the property

Return type:

Any or float or int or list(float) or list(int)

abstract get_vertex_executable_suffix()[source]

Get the executable suffix for a vertex for this dynamics.

Return type:

str

get_weight_maximum(connector, synapse_info)[source]

Get the maximum weight for the synapses.

Parameters:
get_weight_mean(connector, synapse_info)[source]

Get the mean weight for the synapses.

Parameters:
get_weight_variance(connector, weights, synapse_info)[source]

Get the variance in weight for the synapses.

Parameters:
abstract property is_combined_core_capable

Whether the synapse dynamics can run on a core combined with the neuron, or if a separate core is needed.

Return type:

bool

abstract merge(synapse_dynamics)[source]

Merge with the given synapse_dynamics and return the result, or error if merge is not possible.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

AbstractSynapseDynamics

set_value(key, value)[source]

Set a property.

Parameters:
  • key (str) – the name of the parameter to change

  • value (Any or float or int or list(float) or list(int)) – the new value of the parameter to assign

abstract property weight

The weight of connections.

Return type:

float

class spynnaker.pyNN.models.neuron.synapse_dynamics.AbstractSynapseDynamicsStructural[source]

Bases: object

abstract check_initial_delay(max_delay_ms)[source]

Check that delays can be done without delay extensions.

Parameters:

max_delay_ms (int) – The maximum delay supported, in milliseconds

Raises:

Exception – if the delay is out of range

abstract property elimination

The elimination rule.

Return type:

AbstractElimination

abstract property f_rew

The frequency of rewiring.

Return type:

float

abstract property formation

The formation rule.

Return type:

AbstractFormation

abstract get_max_rewires_per_ts()[source]

Get the max number of rewires per timestep.

Return type:

int

abstract get_structural_parameters_sdram_usage_in_bytes(incoming_projections, n_neurons)[source]

Get the size of the structural parameters.

Note

At the Application level this will be an estimate.

Parameters:
  • incoming_projections (list(Projection)) – The projections that target the vertex in question

  • n_neurons (int) –

Returns:

the size of the parameters, in bytes

Return type:

int

Raises:

PacmanInvalidParameterException – If the parameters make no sense.

abstract property initial_delay

The delay of a formed connection.

Return type:

float or (float, float)

abstract property initial_weight

The weight of a formed connection.

Return type:

float

abstract property partner_selection

The partner selection rule.

Return type:

AbstractPartnerSelection

abstract property s_max

The maximum number of synapses.

Return type:

int

abstract property seed

The seed to control the randomness.

abstract set_connections(connections, post_vertex_slice, app_edge, synapse_info)[source]

Set connections for structural plasticity.

Parameters:
abstract property with_replacement

Whether to allow replacement when creating synapses.

Return type:

bool

abstract write_structural_parameters(spec, region, weight_scales, app_vertex, vertex_slice, synaptic_matrices)[source]

Write structural plasticity parameters.

Parameters:
  • spec (DataSpecificationGenerator) – The data specification to write to

  • region (int) – region ID

  • weight_scales (list(float)) – Weight scaling for each synapse type

  • app_vertex (ApplicationVertex) – The target application vertex

  • vertex_slice (Slice) – The slice of the target vertex to generate for

  • synaptic_matrices (SynapticMatrices) – The synaptic matrices for this vertex

class spynnaker.pyNN.models.neuron.synapse_dynamics.PyNNSynapseDynamics(slow=None, fast=None)[source]

Bases: object

property slow
class spynnaker.pyNN.models.neuron.synapse_dynamics.SynapseDynamicsNeuromodulation(weight=pyNN.standardmodels.synapses.StaticSynapse.default_parameters.weight, tau_c=1000.0, tau_d=200.0, w_min=0.0, w_max=1.0)[source]

Bases: AbstractPlasticSynapseDynamics, AbstractGenerateOnMachine

Synapses that target a neuromodulation receptor.

property changes_during_run

Whether the synapses change during a run.

Return type:

bool

property delay

The delay of connections.

Return type:

float

property gen_matrix_id

The ID of the on-machine matrix generator.

Return type:

int

gen_matrix_params(synaptic_matrix_offset, delayed_matrix_offset, app_edge, synapse_info, max_row_info, max_pre_atoms_per_core, max_post_atoms_per_core)[source]

Any parameters required by the matrix generator.

Return type:

ndarray(uint32)

property gen_matrix_params_size_in_bytes

The size of the parameters of the matrix generator in bytes.

Return type:

int

get_max_synapses(n_words)[source]

Get the maximum number of synapses that can be held in the given number of words.

Parameters:

n_words (int) – The number of words the synapses must fit in

Return type:

int

get_n_fixed_plastic_words_per_row(fp_size)[source]

Get the number of fixed plastic words to be read from each row.

Parameters:

fp_size (ndarray) –

get_n_plastic_plastic_words_per_row(pp_size)[source]

Get the number of plastic plastic words to be read from each row.

Parameters:

pp_size (ndarray) –

get_n_synapses_in_rows(pp_size, fp_size)[source]

Get the number of synapses in each of the rows with plastic sizes pp_size and fp_size.

Parameters:
get_n_words_for_plastic_connections(n_connections)[source]

Get the number of 32-bit words for n_connections in a single row.

Parameters:

n_connections (int) –

Return type:

int

get_parameter_names()[source]

Get the parameter names available from the synapse dynamics components.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes(n_neurons, n_synapse_types)[source]

Get the SDRAM usage of the synapse dynamics parameters in bytes.

Parameters:
  • n_neurons (int) –

  • n_synapse_types (int) –

Return type:

int

get_plastic_synaptic_data(connections, connection_row_indices, n_rows, post_vertex_slice, n_synapse_types, max_n_synapses, max_atoms_per_core)[source]

Get the fixed-plastic data, and plastic-plastic data for each row, and lengths for the fixed_plastic and plastic-plastic parts of each row.

Data is returned as an array made up of an array of 32-bit words for each row, for each of the fixed-plastic and plastic-plastic data regions. The row into which connection should go is given by connection_row_indices, and the total number of rows is given by n_rows.

Lengths are returned as an array made up of an integer for each row, for each of the fixed-plastic and plastic-plastic regions.

Parameters:
  • connections (ndarray) – The connections to get data for

  • connection_row_indices (ndarray) – The row into which each connection should go

  • n_rows (int) – The total number of rows

  • post_vertex_slice (Slice) – The slice of the post vertex to get the connections for

  • n_synapse_types (int) – The number of synapse types

  • max_n_synapses (int) – The maximum number of synapses to generate

  • max_atoms_per_core (int) – The maximum number of atoms on a core

Returns:

(fp_data, pp_data, fp_size, pp_size)

Return type:

tuple(ndarray, ndarray, ndarray, ndarray)

get_synapse_id_by_target(target)[source]

Get the index of the synapse type based on the name, or None if the name is not found.

Parameters:

target (str) – The name of the synapse

Return type:

int or None

get_value(key)[source]

Get a property.

Parameters:

key (str) – the name of the property

Return type:

Any or float or int or list(float) or list(int)

get_vertex_executable_suffix()[source]

Get the executable suffix for a vertex for this dynamics.

Return type:

str

property is_combined_core_capable

Whether the synapse dynamics can run on a core combined with the neuron, or if a separate core is needed.

Return type:

bool

is_neuromodulation_same_as(other)[source]
is_same_as(synapse_dynamics)[source]

Determines if this synapse dynamics is the same as another.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

bool

merge(synapse_dynamics)[source]

Merge with the given synapse_dynamics and return the result, or error if merge is not possible.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

AbstractSynapseDynamics

property pad_to_length

The amount each row should pad to, or None if not specified.

read_plastic_synaptic_data(post_vertex_slice, n_synapse_types, pp_size, pp_data, fp_size, fp_data, max_atoms_per_core)[source]

Read the connections indicated in the connection indices from the data in pp_data and fp_data.

Parameters:
Returns:

array with columns source, target, weight, delay

Return type:

ndarray

set_value(key, value)[source]

Set a property.

Parameters:
  • key (str) – the name of the parameter to change

  • value (Any or float or int or list(float) or list(int)) – the new value of the parameter to assign

property tau_c
property tau_d
property w_max
property w_min
property weight

The weight of connections.

Return type:

float

write_parameters(spec, region, global_weight_scale, synapse_weight_scales)[source]

Write the synapse parameters to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • region (int) – region ID to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

class spynnaker.pyNN.models.neuron.synapse_dynamics.SynapseDynamicsSTDP(timing_dependence, weight_dependence, voltage_dependence=None, dendritic_delay_fraction=1.0, weight=pyNN.standardmodels.synapses.StaticSynapse.default_parameters.weight, delay=None, pad_to_length=None, backprop_delay=True)[source]

Bases: AbstractPlasticSynapseDynamics, AbstractGenerateOnMachine

The dynamics of a synapse that changes over time using a Spike Timing Dependent Plasticity (STDP) rule.

Parameters:
property backprop_delay

Settable.

Return type:

bool

property changes_during_run

Whether the synapses change during a run.

Return type:

bool

property delay

The delay of connections.

Return type:

float

property dendritic_delay_fraction

Settable.

Return type:

float

property gen_matrix_id

The ID of the on-machine matrix generator.

Return type:

int

gen_matrix_params(synaptic_matrix_offset, delayed_matrix_offset, app_edge, synapse_info, max_row_info, max_pre_atoms_per_core, max_post_atoms_per_core)[source]

Any parameters required by the matrix generator.

Return type:

ndarray(uint32)

property gen_matrix_params_size_in_bytes

The size of the parameters of the matrix generator in bytes.

Return type:

int

get_max_synapses(n_words)[source]

Get the maximum number of synapses that can be held in the given number of words.

Parameters:

n_words (int) – The number of words the synapses must fit in

Return type:

int

get_n_fixed_plastic_words_per_row(fp_size)[source]

Get the number of fixed plastic words to be read from each row.

Parameters:

fp_size (ndarray) –

get_n_plastic_plastic_words_per_row(pp_size)[source]

Get the number of plastic plastic words to be read from each row.

Parameters:

pp_size (ndarray) –

get_n_synapses_in_rows(pp_size, fp_size)[source]

Get the number of synapses in each of the rows with plastic sizes pp_size and fp_size.

Parameters:
get_n_words_for_plastic_connections(n_connections)[source]
Parameters:

n_connections (int) –

Return type:

int

get_parameter_names()[source]

Get the parameter names available from the synapse dynamics components.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes(n_neurons, n_synapse_types)[source]
Parameters:
  • n_neurons (int) –

  • n_synapse_types (int) –

Return type:

int

get_plastic_synaptic_data(connections, connection_row_indices, n_rows, post_vertex_slice, n_synapse_types, max_n_synapses, max_atoms_per_core)[source]

Get the fixed-plastic data, and plastic-plastic data for each row, and lengths for the fixed_plastic and plastic-plastic parts of each row.

Data is returned as an array made up of an array of 32-bit words for each row, for each of the fixed-plastic and plastic-plastic data regions. The row into which connection should go is given by connection_row_indices, and the total number of rows is given by n_rows.

Lengths are returned as an array made up of an integer for each row, for each of the fixed-plastic and plastic-plastic regions.

Parameters:
  • connections (ndarray) – The connections to get data for

  • connection_row_indices (ndarray) – The row into which each connection should go

  • n_rows (int) – The total number of rows

  • post_vertex_slice (Slice) – The slice of the post vertex to get the connections for

  • n_synapse_types (int) – The number of synapse types

  • max_n_synapses (int) – The maximum number of synapses to generate

  • max_atoms_per_core (int) – The maximum number of atoms on a core

Returns:

(fp_data, pp_data, fp_size, pp_size)

Return type:

tuple(ndarray, ndarray, ndarray, ndarray)

get_value(key)[source]

Get a property.

Parameters:

key (str) – the name of the property

Return type:

Any or float or int or list(float) or list(int)

get_vertex_executable_suffix()[source]
Return type:

str

get_weight_maximum(connector, synapse_info)[source]

Get the maximum weight for the synapses.

Parameters:
get_weight_mean(connector, synapse_info)[source]

Get the mean weight for the synapses.

Parameters:
get_weight_variance(connector, weights, synapse_info)[source]

Get the variance in weight for the synapses.

Parameters:
property is_combined_core_capable

Whether the synapse dynamics can run on a core combined with the neuron, or if a separate core is needed.

Return type:

bool

is_same_as(synapse_dynamics)[source]

Determines if this synapse dynamics is the same as another.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

bool

merge(synapse_dynamics)[source]

Merge with the given synapse_dynamics and return the result, or error if merge is not possible.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

AbstractSynapseDynamics

merge_neuromodulation(neuromodulation)[source]
property neuromodulation
Return type:

SynapseDynamicsNeuromodulation

property pad_to_length

The amount each row should pad to, or None if not specified.

read_plastic_synaptic_data(post_vertex_slice, n_synapse_types, pp_size, pp_data, fp_size, fp_data, max_atoms_per_core)[source]

Read the connections indicated in the connection indices from the data in pp_data and fp_data.

Parameters:
Returns:

array with columns source, target, weight, delay

Return type:

ndarray

set_value(key, value)[source]

Set a property.

Parameters:
  • key (str) – the name of the parameter to change

  • value (Any or float or int or list(float) or list(int)) – the new value of the parameter to assign

property timing_dependence
Return type:

AbstractTimingDependence

property weight

The weight of connections.

Return type:

float

property weight_dependence
Return type:

AbstractTimingDependence

write_parameters(spec, region, global_weight_scale, synapse_weight_scales)[source]

Write the synapse parameters to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • region (int) – region ID to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

class spynnaker.pyNN.models.neuron.synapse_dynamics.SynapseDynamicsStatic(weight=pyNN.standardmodels.synapses.StaticSynapse.default_parameters.weight, delay=None, pad_to_length=None)[source]

Bases: AbstractStaticSynapseDynamics, AbstractGenerateOnMachine

The dynamics of a synapse that does not change over time.

Parameters:
  • weight (float) –

  • delay (float or None) – Use None to get the simulator default minimum delay.

  • pad_to_length (int) –

property changes_during_run

Whether the synapses change during a run.

Return type:

bool

property delay

The delay of connections.

Return type:

float

property gen_matrix_id

The ID of the on-machine matrix generator.

Return type:

int

gen_matrix_params(synaptic_matrix_offset, delayed_matrix_offset, app_edge, synapse_info, max_row_info, max_pre_atoms_per_core, max_post_atoms_per_core)[source]

Any parameters required by the matrix generator.

Return type:

ndarray(uint32)

property gen_matrix_params_size_in_bytes

The size of the parameters of the matrix generator in bytes.

Return type:

int

get_max_synapses(n_words)[source]

Get the maximum number of synapses that can be held in the given number of words.

Parameters:

n_words (int) – The number of words the synapses must fit in

Return type:

int

get_n_static_words_per_row(ff_size)[source]

Get the number of bytes to be read per row for the static data given the size that was written to each row.

Parameters:

ff_size (ndarray) –

Return type:

ndarray

get_n_synapses_in_rows(ff_size)[source]

Get the number of synapses in the rows with sizes ff_size.

Parameters:

ff_size (ndarray) –

Return type:

ndarray

get_n_words_for_static_connections(n_connections)[source]

Get the number of 32-bit words for n_connections in a single row.

Parameters:

n_connections (int) –

Return type:

int

get_parameter_names()[source]

Get the parameter names available from the synapse dynamics components.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes(n_neurons, n_synapse_types)[source]

Get the SDRAM usage of the synapse dynamics parameters in bytes.

Parameters:
  • n_neurons (int) –

  • n_synapse_types (int) –

Return type:

int

get_static_synaptic_data(connections, connection_row_indices, n_rows, post_vertex_slice, n_synapse_types, max_n_synapses, max_atoms_per_core)[source]

Get the fixed-fixed data for each row, and lengths for the fixed-fixed parts of each row.

Data is returned as an array made up of an array of 32-bit words for each row for the fixed-fixed region. The row into which connection should go is given by connection_row_indices, and the total number of rows is given by n_rows.

Lengths are returned as an array made up of an integer for each row, for the fixed-fixed region.

Parameters:
  • connections (ndarray) – The connections to get data for

  • connection_row_indices (ndarray) – The row into which each connection should go

  • n_rows (int) – The number of rows to write

  • post_vertex_slice (Slice) – The slice of the post vertex to generate for

  • n_synapse_types (int) – The number of synapse types

  • max_n_synapses (int) – The maximum number of synapses to generate

  • max_atoms_per_core (int) – The maximum number of atoms on a core

Returns:

(ff_data, ff_size)

Return type:

tuple(list(ndarray), ndarray)

get_vertex_executable_suffix()[source]

Get the executable suffix for a vertex for this dynamics.

Return type:

str

property is_combined_core_capable

Whether the synapse dynamics can run on a core combined with the neuron, or if a separate core is needed.

Return type:

bool

is_same_as(synapse_dynamics)[source]

Determines if this synapse dynamics is the same as another.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

bool

merge(synapse_dynamics)[source]

Merge with the given synapse_dynamics and return the result, or error if merge is not possible.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

AbstractSynapseDynamics

property pad_to_length

The amount each row should pad to, or None if not specified.

read_static_synaptic_data(post_vertex_slice, n_synapse_types, ff_size, ff_data, max_atoms_per_core)[source]

Read the connections from the words of data in ff_data.

Parameters:
Return type:

ndarray

property weight

The weight of connections.

Return type:

float

write_parameters(spec, region, global_weight_scale, synapse_weight_scales)[source]

Write the synapse parameters to the spec.

Parameters:
  • spec (DataSpecificationGenerator) – The specification to write to

  • region (int) – region ID to write to

  • global_weight_scale (float) – The weight scale applied globally

  • synapse_weight_scales (list(float)) – The total weight scale applied to each synapse including the global weight scale

class spynnaker.pyNN.models.neuron.synapse_dynamics.SynapseDynamicsStructuralCommon[source]

Bases: AbstractSynapseDynamicsStructural

PAIR_ERROR = 'Only one Projection between each pair of Populations can use structural plasticity'
check_initial_delay(max_delay_ms)[source]

Check that delays can be done without delay extensions.

Parameters:

max_delay_ms (float) – The maximum delay supported, in milliseconds

Raises:

ValueError – if the delay is out of range

abstract property connections

Initial connectivity as defined via connector.

Return type:

dict

get_max_rewires_per_ts()[source]

Get the max number of rewires per timestep.

Return type:

int

get_parameter_names()[source]
Return type:

list(str)

abstract get_seeds(app_vertex=None)[source]

Generate a seed for the RNG on chip that is the same for all of the cores that have perform structural updates.

It should be different between application vertices but the same for the same app_vertex. It should be different every time called with None.

Parameters:

app_vertex (ApplicationVertex or None) –

Returns:

list of random seed (4 words), generated randomly

Return type:

list(int)

get_structural_parameters_sdram_usage_in_bytes(incoming_projections, n_neurons)[source]

Get the size of the structural parameters.

Note

At the Application level this will be an estimate.

Parameters:
  • incoming_projections (list(Projection)) – The projections that target the vertex in question

  • n_neurons (int) –

Returns:

the size of the parameters, in bytes

Return type:

int

Raises:

PacmanInvalidParameterException – If the parameters make no sense.

get_vertex_executable_suffix()[source]
Return type:

str

is_same_as(synapse_dynamics)[source]
Parameters:

synapse_dynamics (SynapseDynamicsStructuralCommon) –

Return type:

bool

property p_rew

The period of rewiring.

Return type:

float

write_structural_parameters(spec, region, weight_scales, app_vertex, vertex_slice, synaptic_matrices)[source]

Write structural plasticity parameters.

Parameters:
  • spec (DataSpecificationGenerator) – The data specification to write to

  • region (int) – region ID

  • weight_scales (list(float)) – Weight scaling for each synapse type

  • app_vertex (ApplicationVertex) – The target application vertex

  • vertex_slice (Slice) – The slice of the target vertex to generate for

  • synaptic_matrices (SynapticMatrices) – The synaptic matrices for this vertex

class spynnaker.pyNN.models.neuron.synapse_dynamics.SynapseDynamicsStructuralSTDP(partner_selection, formation, elimination, timing_dependence=None, weight_dependence=None, voltage_dependence=None, dendritic_delay_fraction=1.0, f_rew=10000.0, initial_weight=0.0, initial_delay=1.0, s_max=32, with_replacement=True, seed=None, weight=pyNN.standardmodels.synapses.StaticSynapse.default_parameters.weight, delay=None, backprop_delay=True)[source]

Bases: SynapseDynamicsSTDP, SynapseDynamicsStructuralCommon

Class that enables synaptic rewiring in the presence of STDP.

It acts as a wrapper around SynapseDynamicsSTDP, meaning rewiring can operate in parallel with STDP synapses.

Written by Petrut Bogdan.

Parameters:
  • partner_selection (AbstractPartnerSelection) – The partner selection rule

  • formation (AbstractFormation) – The formation rule

  • elimination (AbstractElimination) – The elimination rule

  • timing_dependence (AbstractTimingDependence) – The STDP timing dependence rule

  • weight_dependence (AbstractWeightDependence) – The STDP weight dependence rule

  • voltage_dependence (None) – The STDP voltage dependence (unsupported)

  • dendritic_delay_fraction (float) – The STDP dendritic delay fraction

  • f_rew (float) – How many rewiring attempts will be done per second.

  • initial_weight (float) – Weight assigned to a newly formed connection

  • initial_delay (float or tuple(float, float)) – Delay assigned to a newly formed connection; a single value means a fixed delay value, or a tuple of two values means the delay will be chosen at random from a uniform distribution between the given values

  • s_max (int) – Maximum fan-in per target layer neuron

  • with_replacement (bool) – If set to True (default), a new synapse can be formed in a location where a connection already exists; if False, then it must form where no connection already exists

  • seed (int or None) – seed for the random number generators

  • weight (float) – The weight of connections formed by the connector

  • delay (float or None) – The delay of connections formed by the connector Use None to get the simulator default minimum delay.

  • backprop_delay (bool) – Whether back-propagated delays are used

property connections

Initial connectivity as defined via connector.

Return type:

dict

property elimination

The elimination rule.

Return type:

AbstractElimination

property f_rew

The frequency of rewiring.

Return type:

float

property formation

The formation rule.

Return type:

AbstractFormation

generate_on_machine()[source]

Determines if this instance should be generated on the machine.

Default implementation returns True

Return type:

bool

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector.

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

get_delay_maximum(connector, synapse_info)[source]

Get the maximum delay for the synapses.

Parameters:
get_delay_minimum(connector, synapse_info)[source]

Get the minimum delay for the synapses. This will support the filtering of the undelayed edge from the graph, but requires fixes in the synaptic manager to happen first before this can be utilised fully.

Parameters:
get_delay_variance(connector, delays, synapse_info)[source]

Get the variance in delay for the synapses.

Parameters:
get_parameter_names()[source]

Get the parameter names available from the synapse dynamics components.

Return type:

iterable(str)

get_seeds(app_vertex=None)[source]

Generate a seed for the RNG on chip that is the same for all of the cores that have perform structural updates.

It should be different between application vertices but the same for the same app_vertex. It should be different every time called with None.

Parameters:

app_vertex (ApplicationVertex or None) –

Returns:

list of random seed (4 words), generated randomly

Return type:

list(int)

get_vertex_executable_suffix()[source]
Return type:

str

get_weight_maximum(connector, synapse_info)[source]

Get the maximum weight for the synapses.

Parameters:
get_weight_mean(connector, synapse_info)[source]

Get the mean weight for the synapses.

Parameters:
property initial_delay

The delay of a formed connection.

Return type:

float or (float, float)

property initial_weight

The weight of a formed connection.

Return type:

float

property is_combined_core_capable

Whether the synapse dynamics can run on a core combined with the neuron, or if a separate core is needed.

Return type:

bool

is_same_as(synapse_dynamics)[source]

Determines if this synapse dynamics is the same as another.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

bool

merge(synapse_dynamics)[source]

Merge with the given synapse_dynamics and return the result, or error if merge is not possible.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

AbstractSynapseDynamics

property partner_selection

The partner selection rule.

Return type:

AbstractPartnerSelection

property s_max

The maximum number of synapses.

Return type:

int

property seed

The seed to control the randomness.

set_connections(connections, post_vertex_slice, app_edge, synapse_info)[source]

Set connections for structural plasticity.

Parameters:
set_projection_parameter(param, value)[source]
Parameters:
  • param (str) –

  • value

property with_replacement

Whether to allow replacement when creating synapses.

Return type:

bool

class spynnaker.pyNN.models.neuron.synapse_dynamics.SynapseDynamicsStructuralStatic(partner_selection, formation, elimination, f_rew=10000.0, initial_weight=0.0, initial_delay=1.0, s_max=32, with_replacement=True, seed=None, weight=pyNN.standardmodels.synapses.StaticSynapse.default_parameters.weight, delay=None)[source]

Bases: SynapseDynamicsStatic, SynapseDynamicsStructuralCommon

Class that enables synaptic rewiring in the absence of STDP.

It acts as a wrapper around SynapseDynamicsStatic, meaning that rewiring can operate in parallel with static synapses.

Written by Petrut Bogdan.

Parameters:
  • partner_selection (AbstractPartnerSelection) – The partner selection rule

  • formation (AbstractFormation) – The formation rule

  • elimination (AbstractElimination) – The elimination rule

  • f_rew (float) – How many rewiring attempts will be done per second.

  • initial_weight (float) – Weight assigned to a newly formed connection

  • initial_delay (float or (float, float)) – Delay assigned to a newly formed connection; a single value means a fixed delay value, or a tuple of two values means the delay will be chosen at random from a uniform distribution between the given values

  • s_max (int) – Maximum fan-in per target layer neuron

  • with_replacement (bool) – If set to True (default), a new synapse can be formed in a location where a connection already exists; if False, then it must form where no connection already exists

  • seed (int) – seed the random number generators

  • weight (float) – The weight of connections formed by the connector

  • delay (float or None) – The delay of connections formed by the connector Use None to get the simulator default minimum delay.

property changes_during_run

Whether the synapses change during a run.

Return type:

bool

property connections

Initial connectivity as defined via connector.

Return type:

dict

property elimination

The elimination rule.

Return type:

AbstractElimination

property f_rew

The frequency of rewiring.

Return type:

float

property formation

The formation rule.

Return type:

AbstractFormation

generate_on_machine()[source]

Determines if this instance should be generated on the machine.

Default implementation returns True

Return type:

bool

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector.

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

get_delay_maximum(connector, synapse_info)[source]

Get the maximum delay for the synapses.

Parameters:
get_delay_minimum(connector, synapse_info)[source]

Get the minimum delay for the synapses. This will support the filtering of the undelayed edge from the graph, but requires fixes in the synaptic manager to happen first before this can be utilised fully.

Parameters:
get_delay_variance(connector, delays, synapse_info)[source]

Get the variance in delay for the synapses.

Parameters:
get_parameter_names()[source]

Get the parameter names available from the synapse dynamics components.

Return type:

iterable(str)

get_seeds(app_vertex=None)[source]

Generate a seed for the RNG on chip that is the same for all of the cores that have perform structural updates.

It should be different between application vertices but the same for the same app_vertex. It should be different every time called with None.

Parameters:

app_vertex (ApplicationVertex or None) –

Returns:

list of random seed (4 words), generated randomly

Return type:

list(int)

get_vertex_executable_suffix()[source]

Get the executable suffix for a vertex for this dynamics.

Return type:

str

get_weight_maximum(connector, synapse_info)[source]

Get the maximum weight for the synapses.

Parameters:
get_weight_mean(connector, synapse_info)[source]

Get the mean weight for the synapses.

Parameters:
get_weight_variance(connector, weights, synapse_info)[source]

Get the variance in weight for the synapses.

Parameters:
property initial_delay

The delay of a formed connection.

Return type:

float or (float, float)

property initial_weight

The weight of a formed connection.

Return type:

float

property is_combined_core_capable

Whether the synapse dynamics can run on a core combined with the neuron, or if a separate core is needed.

Return type:

bool

is_same_as(synapse_dynamics)[source]

Determines if this synapse dynamics is the same as another.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

bool

merge(synapse_dynamics)[source]

Merge with the given synapse_dynamics and return the result, or error if merge is not possible.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) –

Return type:

AbstractSynapseDynamics

property partner_selection

The partner selection rule.

Return type:

AbstractPartnerSelection

property s_max

The maximum number of synapses.

Return type:

int

property seed

The seed to control the randomness.

set_connections(connections, post_vertex_slice, app_edge, synapse_info)[source]

Set connections for structural plasticity.

Parameters:
set_projection_parameter(param, value)[source]
Parameters:
  • param (str) –

  • value

property with_replacement

Whether to allow replacement when creating synapses.

Return type:

bool

spynnaker.pyNN.models.neuron.synapse_dynamics.calculate_spike_pair_additive_stdp_weight(pre_spikes, post_spikes, initial_weight, plastic_delay, a_plus, a_minus, tau_plus, tau_minus)[source]

Calculates the expected STDP weight for SpikePair Additive STDP.

Parameters:
  • pre_spikes (iterable(int)) –

  • post_spikes (iterable(int)) –

  • initial_weight (float) –

  • plastic_delay (int) – parameter of the STDP model

  • a_plus (float) – parameter of the STDP model

  • a_minus (float) – parameter of the STDP model

  • tau_plus (float) – parameter of the STDP model

  • tau_minus (float) – parameter of the STDP model

Returns:

overall weight

Return type:

float

spynnaker.pyNN.models.neuron.synapse_dynamics.calculate_spike_pair_multiplicative_stdp_weight(pre_spikes, post_spikes, initial_weight, plastic_delay, min_weight, max_weight, a_plus, a_minus, tau_plus, tau_minus)[source]

Calculates the expected STDP weight for SpikePair Multiplicative STDP.

Parameters:
  • pre_spikes (iterable(int)) – Spikes going into the model

  • post_spikes (iterable(int)) – Spikes recorded on the model

  • initial_weight (float) – Starting weight for the model

  • plastic_delay (int) – parameter of the STDP model

  • min_weight (float) – parameter of the STDP model

  • max_weight (float) – parameter of the STDP model

  • a_plus (float) – parameter of the STDP model

  • a_minus (float) – parameter of the STDP model

  • tau_plus (float) – parameter of the STDP model

  • tau_minus (float) – parameter of the STDP model

Returns:

overall weight

Return type:

float

spynnaker.pyNN.models.neuron.synapse_types package
Module contents
class spynnaker.pyNN.models.neuron.synapse_types.AbstractSynapseType(structs, units)[source]

Bases: AbstractStandardNeuronComponent

Represents the synapse types supported.

Parameters:
  • structs (list(Struct)) – The structures of the component

  • units (dict) – The units to use for each parameter

abstract get_n_synapse_types()[source]

Get the number of synapse types supported.

Returns:

The number of synapse types supported

Return type:

int

abstract get_synapse_id_by_target(target)[source]

Get the ID of a synapse given the name.

Returns:

The ID of the synapse

Return type:

int

abstract get_synapse_targets()[source]

Get the target names of the synapse type.

Returns:

an array of strings (usually a list or tuple)

Return type:

iterable(str)

class spynnaker.pyNN.models.neuron.synapse_types.SynapseTypeAlpha(exc_response, exc_exp_response, tau_syn_E, inh_response, inh_exp_response, tau_syn_I)[source]

Bases: AbstractSynapseType

Parameters:
  • exc_response (float or iterable(float) or RandomDistribution or (mapping) function) – \(response^\mathrm{linear}_e\)

  • exc_exp_response (float or iterable(float) or RandomDistribution or (mapping) function) – \(response^\mathrm{exponential}_e\)

  • tau_syn_E (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • inh_response (float or iterable(float) or RandomDistribution or (mapping) function) – \(response^\mathrm{linear}_i\)

  • inh_exp_response (float or iterable(float) or RandomDistribution or (mapping) function) – \(response^\mathrm{exponential}_i\)

  • tau_syn_I (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

property exc_response
get_n_synapse_types()[source]

Get the number of synapse types supported.

Returns:

The number of synapse types supported

Return type:

int

get_synapse_id_by_target(target)[source]

Get the ID of a synapse given the name.

Returns:

The ID of the synapse

Return type:

int

get_synapse_targets()[source]

Get the target names of the synapse type.

Returns:

an array of strings (usually a list or tuple)

Return type:

iterable(str)

property inh_response
property tau_syn_E
property tau_syn_I
class spynnaker.pyNN.models.neuron.synapse_types.SynapseTypeDelta(isyn_exc, isyn_inh)[source]

Bases: AbstractSynapseType

This represents a synapse type with two delta synapses.

Parameters:
  • isyn_exc (float or iterable(float) or RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_inh (float or iterable(float) or RandomDistribution or (mapping) function) – \(I^{syn}_i\)

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

get_n_synapse_types()[source]

Get the number of synapse types supported.

Returns:

The number of synapse types supported

Return type:

int

get_synapse_id_by_target(target)[source]

Get the ID of a synapse given the name.

Returns:

The ID of the synapse

Return type:

int

get_synapse_targets()[source]

Get the target names of the synapse type.

Returns:

an array of strings (usually a list or tuple)

Return type:

iterable(str)

property isyn_exc
property isyn_inh
class spynnaker.pyNN.models.neuron.synapse_types.SynapseTypeDualExponential(tau_syn_E, tau_syn_E2, tau_syn_I, isyn_exc, isyn_exc2, isyn_inh)[source]

Bases: AbstractSynapseType

Parameters:
  • tau_syn_E (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau^{syn}_{e_1}\)

  • tau_syn_E2 (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau^{syn}_{e_2}\)

  • tau_syn_I (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • isyn_exc (float or iterable(float) or RandomDistribution or (mapping) function) – \(I^{syn}_{e_1}\)

  • isyn_exc2 (float or iterable(float) or RandomDistribution or (mapping) function) – \(I^{syn}_{e_2}\)

  • isyn_inh (float or iterable(float) or RandomDistribution or (mapping) function) – \(I^{syn}_i\)

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

get_n_synapse_types()[source]

Get the number of synapse types supported.

Returns:

The number of synapse types supported

Return type:

int

get_synapse_id_by_target(target)[source]

Get the ID of a synapse given the name.

Returns:

The ID of the synapse

Return type:

int

get_synapse_targets()[source]

Get the target names of the synapse type.

Returns:

an array of strings (usually a list or tuple)

Return type:

iterable(str)

property isyn_exc
property isyn_exc2
property isyn_inh
property tau_syn_E
property tau_syn_E2
property tau_syn_I
class spynnaker.pyNN.models.neuron.synapse_types.SynapseTypeExponential(tau_syn_E, tau_syn_I, isyn_exc, isyn_inh)[source]

Bases: AbstractSynapseType

Parameters:
  • tau_syn_E (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau^{syn}_e\)

  • tau_syn_I (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • isyn_exc (float or iterable(float) or RandomDistribution or (mapping) function) – \(I^{syn}_e\)

  • isyn_inh (float or iterable(float) or RandomDistribution or (mapping) function) – \(I^{syn}_i\)

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

get_n_synapse_types()[source]

Get the number of synapse types supported.

Returns:

The number of synapse types supported

Return type:

int

get_synapse_id_by_target(target)[source]

Get the ID of a synapse given the name.

Returns:

The ID of the synapse

Return type:

int

get_synapse_targets()[source]

Get the target names of the synapse type.

Returns:

an array of strings (usually a list or tuple)

Return type:

iterable(str)

property isyn_exc
property isyn_inh
property tau_syn_E
property tau_syn_I
class spynnaker.pyNN.models.neuron.synapse_types.SynapseTypeSEMD(tau_syn_E, tau_syn_E2, tau_syn_I, isyn_exc, isyn_exc2, isyn_inh, multiplicator, exc2_old, scaling_factor)[source]

Bases: AbstractSynapseType

Parameters:
  • tau_syn_E (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau^{syn}_{e_1}\)

  • tau_syn_E2 (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau^{syn}_{e_2}\)

  • tau_syn_I (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau^{syn}_i\)

  • isyn_exc (float or iterable(float) or RandomDistribution or (mapping) function) – \(I^{syn}_{e_1}\)

  • isyn_exc2 (float or iterable(float) or RandomDistribution or (mapping) function) – \(I^{syn}_{e_2}\)

  • isyn_inh (float or iterable(float) or RandomDistribution or (mapping) function) – \(I^{syn}_i\)

  • multiplicator (float or iterable(float) or RandomDistribution or (mapping) function) –

  • exc2_old (float or iterable(float) or RandomDistribution or (mapping) function) –

  • scaling_factor (float or iterable(float) or RandomDistribution or (mapping) function) –

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

property exc2_old
get_n_synapse_types()[source]

Get the number of synapse types supported.

Returns:

The number of synapse types supported

Return type:

int

get_synapse_id_by_target(target)[source]

Get the ID of a synapse given the name.

Returns:

The ID of the synapse

Return type:

int

get_synapse_targets()[source]

Get the target names of the synapse type.

Returns:

an array of strings (usually a list or tuple)

Return type:

iterable(str)

property isyn_exc
property isyn_exc2
property isyn_inh
property multiplicator
property scaling_factor
property tau_syn_E
property tau_syn_E2
property tau_syn_I
spynnaker.pyNN.models.neuron.threshold_types package
Module contents
class spynnaker.pyNN.models.neuron.threshold_types.AbstractThresholdType(structs, units)[source]

Bases: AbstractStandardNeuronComponent

Represents types of threshold for a neuron (e.g., stochastic).

Parameters:
  • structs (list(Struct)) – The structures of the component

  • units (dict) – The units to use for each parameter

class spynnaker.pyNN.models.neuron.threshold_types.ThresholdTypeMaassStochastic(du_th, tau_th, v_thresh)[source]

Bases: AbstractThresholdType

A stochastic threshold.

Habenschuss S, Jonke Z, Maass W. Stochastic computations in cortical microcircuit models. PLoS Computational Biology. 2013;9(11):e1003311. doi:10.1371/journal.pcbi.1003311

Parameters:
  • du_th (float or iterable(float) or RandomDistribution or (mapping) function) – \(du_{thresh}\)

  • tau_th (float or iterable(float) or RandomDistribution or (mapping) function) – \(\tau_{thresh}\)

  • v_thresh (float or iterable(float) or RandomDistribution or (mapping) function) – \(V_{thresh}\)

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

property du_th

\(du_{thresh}\)

property tau_th

\(\tau_{thresh}\)

property v_thresh

\(V_{thresh}\)

class spynnaker.pyNN.models.neuron.threshold_types.ThresholdTypeStatic(v_thresh)[source]

Bases: AbstractThresholdType

A threshold that is a static value.

Parameters:

v_thresh (float or iterable(float) or RandomDistribution or (mapping) function) – \(V_{thresh}\)

add_parameters(parameters)[source]

Add the initial values of the parameters to the parameter holder.

Parameters:

parameters (RangeDictionary) – A holder of the parameters

add_state_variables(state_variables)[source]

Add the initial values of the state variables to the state variables holder.

Parameters:

state_variables (RangeDictionary) – A holder of the state variables

property v_thresh

\(V_{thresh}\)

Submodules
spynnaker.pyNN.models.neuron.generator_data module
class spynnaker.pyNN.models.neuron.generator_data.GeneratorData(synaptic_matrix_offset, delayed_synaptic_matrix_offset, app_edge, synapse_information, max_row_info, max_pre_atoms_per_core, max_post_atoms_per_core)[source]

Bases: object

Data for each connection of the synapse generator.

BASE_SIZE = 44
property gen_data

The data to be written for this connection.

Return type:

list(ndarray(uint32))

property size

The size of the generated data, in bytes.

Return type:

int

spynnaker.pyNN.models.neuron.master_pop_table module
class spynnaker.pyNN.models.neuron.master_pop_table.MasterPopTableAsBinarySearch[source]

Bases: object

Master population table, implemented as binary search master.

add_application_entry(block_start_addr, row_length, key_and_mask, core_mask, core_shift, n_neurons, n_colour_bits)[source]

Add an entry for an application-edge to the population table.

Parameters:
  • block_start_addr (int) – where the synaptic matrix block starts

  • row_length (int) – how long in words each row is

  • key_and_mask (BaseKeyAndMask) – the key and mask for this master pop entry

  • core_mask (int) – Mask for the part of the key that identifies the core

  • core_shift (int) – The shift of the mask to get to the core_mask

  • n_neurons (int) – The number of neurons in each machine vertex (bar the last)

  • n_colour_bits (int) – The number of bits to use for colour

Returns:

The index of the entry, to be used to retrieve it

Return type:

int

Raises:

SynapticConfigurationException – If a bad address is used.

add_invalid_application_entry(key_and_mask, core_mask, core_shift, n_neurons, n_colour_bits)[source]

Add an entry to the table from an application vertex that doesn’t point to anywhere. Used to keep indices in synchronisation between e.g. normal and delay entries and between entries on different cores.

Parameters:
  • key_and_mask (BaseKeyAndMask) – a key_and_mask object used as part of describing an edge that will require being received to be stored in the master pop table; the whole edge will become multiple calls to this function

  • core_mask (int) – Mask for the part of the key that identifies the core

  • core_shift (int) – The shift of the mask to get to the core_mask

  • n_neurons (int) – The number of neurons in each machine vertex (bar the last)

  • n_colour_bits (int) – The number of bits to use for colour

Returns:

The index of the added entry

Return type:

int

static get_allowed_row_length(row_length)[source]

Get the next allowed row length.

Parameters:

row_length (int) – the row length being considered

Returns:

the row length available

Return type:

int

Raises:

SynapseRowTooBigException – If the row won’t fit

static get_master_population_table_size(incoming_projections)[source]

Get the size of the master population table in SDRAM.

Parameters:

incoming_projections (list(projection Projection)) – The projections arriving at the vertex that are to be handled by this table

Returns:

the size the master pop table will take in SDRAM (in bytes)

Return type:

int

static get_next_allowed_address(next_address)[source]

Get the next allowed address.

Parameters:

next_address (int) – The next address that would be used

Returns:

The next address that can be used following next_address

Return type:

int

Raises:

SynapticConfigurationException – if the address is out of range

get_pop_table_data()[source]

Get the master pop table data as a numpy array.

Return type:

ndarray

initialise_table()[source]

Initialise the master pop data structure.

property max_core_mask

The maximum core mask supported when n_neurons is > 0; this is the maximum number of cores that can be supported in a joined mask.

Return type:

int

property max_index

The maximum index of a synaptic connection.

Return type:

int

property max_n_neurons_per_core

The maximum number of neurons per core supported when a core-mask is > 0.

Return type:

int

spynnaker.pyNN.models.neuron.neuron_data module
class spynnaker.pyNN.models.neuron.neuron_data.NeuronData(app_vertex)[source]

Bases: object

Holds and creates the data for a group of neurons.

property gen_on_machine

Whether the neuron data can be generated on the machine or not.

Return type:

bool

generate_data()[source]

Do the data generation internally.

read_data(placement, neuron_regions)[source]

Read the current state of the data from the machine into the application vertex.

Parameters:
  • placement (Placement) – The placement of the vertex to read

  • neuron_regions (NeuronRegions) – The regions to read from

read_initial_data(placement, neuron_regions)[source]

Read the initial state of the data from the machine into the application vertex.

Parameters:
  • placement (Placement) – The placement of the vertex to read

  • neuron_regions (NeuronRegions) – The regions to read from

reset_generation()[source]

Reset generation so it is done again.

write_data(spec, vertex_slice, neuron_regions, gen_on_machine=True)[source]

Write the generated data.

Parameters:
  • spec (DataSpecificationGenerator) – The data specification to write to

  • vertex_slice (Slice) – The vertex slice to generate for

  • neuron_regions (NeuronRegions) – The regions to write to

  • gen_on_machine (bool) – Whether to allow generation on machine

spynnaker.pyNN.models.neuron.population_machine_common module
class spynnaker.pyNN.models.neuron.population_machine_common.CommonRegions(system: int, provenance: int, profile: int, recording: int)[source]

Bases: object

Identifiers for common regions.

profile: int

Profiling data region

provenance: int

Provenance collection region

recording: int

Recording channels region

system: int

System control region

class spynnaker.pyNN.models.neuron.population_machine_common.PopulationMachineCommon(label, app_vertex, vertex_slice, sdram, regions, n_provenance_items, profile_tags, binary_file_name)[source]

Bases: MachineVertex, ProvidesProvenanceDataFromMachineImpl, AbstractReceiveBuffersToHost, AbstractHasProfileData, AbstractHasAssociatedBinary

A common machine vertex for all population binaries.

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

  • app_vertex (AbstractPopulationVertex) – The associated application vertex

  • vertex_slice (Slice) – The slice of the population that this implements

  • sdram (AbstractSDRAM) – The SDRAM used by the vertex

  • regions (.CommonRegions) – The regions to be assigned

  • n_provenance_items (int) – The number of additional provenance items to be read

  • profile_tags (dict(int,str)) – A mapping of profile identifiers to names

  • binary_file_name (str) – The name of the binary file

get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

get_n_keys_for_partition(partition_id)[source]

Get the number of keys required by the given partition of edges.

Parameters:

partition_id (str) – The identifier of the partition; the partition_id param is only used by some MachineVertex subclasses

Returns:

The number of keys required

Return type:

int

get_profile_data(placement)[source]

Get the profile data recorded during simulation.

Parameters:

placement (Placement) –

Return type:

ProfileData

get_recording_region_base_address(placement)[source]

Get the recording region base address.

Parameters:

placement (Placement) – the placement object of the core to find the address of

Returns:

the base address of the recording region

Return type:

int

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

spynnaker.pyNN.models.neuron.population_machine_synapses module
class spynnaker.pyNN.models.neuron.population_machine_synapses.PopulationMachineSynapses[source]

Bases: PopulationMachineSynapsesProvenance, AbstractSupportsBitFieldRoutingCompression, AbstractSynapseExpandable, HasSynapses

Mix-in for machine vertices that contain synapses.

bit_field_base_address(placement)[source]

Returns the SDRAM address for the bit-field table data.

Parameters:

placement (Placement) –

Returns:

the SDRAM address for the bitfield address

Return type:

int

property bit_field_size

The amount of bit field data to be generated. This is used to calculate the timeout of the execution.

Return type:

int

property connection_generator_region

The region ID containing the parameters of synaptic expansion.

Return type:

int

gen_on_machine()[source]

True if the synapses of a the slice of this vertex should be generated on the machine.

Note

The typical implementation for this method will be to ask the app_vertex’s synapse_manager

Return type:

bool

get_connections_from_machine(placement, app_edge, synapse_info)[source]

Get the connections from the machine for this vertex.

Parameters:
Return type:

ndarray

property max_gen_data

The maximum amount of synaptic data to be generated. This is used to calculate the timeout of the execution.

Return type:

int

read_generated_connection_holders(placement)[source]

Fill in the connection holders.

Parameters:

placement (Placement) – Where the data is on the machine

regeneratable_sdram_blocks_and_sizes(placement)[source]

Returns the SDRAM addresses and sizes for the cores’ SDRAM that are available (borrowed) for generating bitfield tables.

Parameters:

placement (Placement) –

Returns:

list of tuples containing (the SDRAM address for the cores SDRAM address’s for the core’s SDRAM that can be used to generate bitfield tables loaded, and the size of memory chunks located there)

Return type:

list(tuple(int,int))

abstract set_do_synapse_regeneration()[source]

Indicates that synaptic data regeneration is required.

spynnaker.pyNN.models.neuron.synapse_io module
class spynnaker.pyNN.models.neuron.synapse_io.MaxRowInfo(undelayed_max_n_synapses, delayed_max_n_synapses, undelayed_max_bytes, delayed_max_bytes, undelayed_max_words, delayed_max_words)[source]

Bases: object

Information about the maximums for rows in a synaptic matrix.

Parameters:
  • undelayed_max_n_synapses (int) – Maximum number of synapses in a row of the undelayed matrix

  • delayed_max_n_synapses (int) – Maximum number of synapses in a row of the delayed matrix

  • undelayed_max_bytes (int) – Maximum number of bytes, including headers, in a row of the undelayed matrix, or 0 if no synapses

  • delayed_max_bytes (int) – Maximum number of bytes, including headers, in a row of the delayed matrix, or 0 if no synapses

  • undelayed_max_words (int) – Maximum number of words, excluding headers, in a row of the undelayed matrix

  • delayed_max_words (int) – Maximum number of words, excluding headers, in a row of the delayed matrix

property delayed_max_bytes

Maximum number of bytes, including headers, in a row of the delayed matrix.

Return type:

int

property delayed_max_n_synapses

Maximum number of synapses in a row of the delayed matrix.

Return type:

int

property delayed_max_words

Maximum number of words, excluding headers, in a row of the undelayed matrix.

Return type:

int

property undelayed_max_bytes

Maximum number of bytes, including headers, in a row of the undelayed matrix.

Return type:

int

property undelayed_max_n_synapses

Maximum number of synapses in a row of the undelayed matrix.

Return type:

int

property undelayed_max_words

Maximum number of words, excluding headers, in a row of the undelayed matrix.

Return type:

int

spynnaker.pyNN.models.neuron.synapse_io.convert_to_connections(synapse_info, post_vertex_slice, n_pre_atoms, max_row_length, n_synapse_types, weight_scales, data, delayed, post_vertex_max_delay_ticks, max_atoms_per_core)[source]

Read the synapses for a given projection synapse information object out of the given data and convert to connection data

Parameters:
  • synapse_info (SynapseInformation) – The synapse information of the synapses

  • n_pre_atoms (int) – The number of atoms in the pre-vertex

  • post_vertex_slice (Slice) – The slice of the target neurons of the synapses in the data

  • max_row_length (int) – The length of each row in the data

  • n_synapse_types (int) – The number of synapse types in total

  • weight_scales (list(float)) – The weight scaling of each synapse type

  • data (bytearray) – The raw data containing the synapses

  • delayed (bool) – True if the data should be considered delayed

  • post_vertex_max_delay_ticks (int) – The maximum delayed ticks supported from post vertex

  • max_atoms_per_core (int) – The maximum number of atoms on a core

Returns:

The connections read from the data; the dtype is NUMPY_CONNECTORS_DTYPE

Return type:

ndarray

spynnaker.pyNN.models.neuron.synapse_io.get_max_row_info(synapse_info, n_post_atoms, n_delay_stages, in_edge)[source]

Get the information about the maximum lengths of delayed and undelayed rows in bytes (including header), words (without header) and number of synapses.

Parameters:
  • synapse_info (SynapseInformation) – The synapse information to get the row data for

  • n_post_atoms (int) – The number of post atoms to get the maximum for

  • n_delay_stages (int) – The number of delay stages on the edge

  • in_edge (ProjectionApplicationEdge) – The incoming edge on which the synapse information is held

Return type:

MaxRowInfo

Raises:

SynapseRowTooBigException – If the synapse information can’t be represented

spynnaker.pyNN.models.neuron.synapse_io.get_maximum_delay_supported_in_ms(post_vertex_max_delay_ticks)[source]

Get the maximum delay supported by the synapse representation before extensions are required, or None if any delay is supported.

Parameters:

post_vertex_max_delay_ticks (int) – post vertex max delay

Return type:

int

spynnaker.pyNN.models.neuron.synapse_io.get_synapses(connections, synapse_info, n_delay_stages, n_synapse_types, weight_scales, app_edge, post_vertex_slice, max_row_info, gen_undelayed, gen_delayed, max_atoms_per_core)[source]

Get the synapses as an array of words for non-delayed synapses and an array of words for delayed synapses. This is used to prepare information for deployment to SpiNNaker.

Parameters:
  • connections (ndarray) – The connections to get the synapses from

  • synapse_info (SynapseInformation) – The synapse information to convert to synapses

  • n_delay_stages (int) – The number of delay stages in total to be represented

  • n_synapse_types (int) – The number of synapse types in total to be represented

  • weight_scales (list(float)) – The scaling of the weights for each synapse type

  • app_edge (ApplicationEdge) – The incoming machine edge that the synapses are on

  • post_vertex_slice (Slice) – The slice of the post-vertex to get the synapses for

  • max_row_info (MaxRowInfo) – The maximum row information for the synapses

  • gen_undelayed (bool) – Whether to generate undelayed data

  • gen_delayed (bool) – Whether to generate delayed data

  • max_atoms_per_core (int) – The maximum number of atoms on a core

Returns:

(row_data, delayed_row_data) where:

  • row_data is the undelayed connectivity data arranged into a

    row per source, each row the same length

  • delayed_row_data is the delayed connectivity data arranged

    into a row per source per delay stage, each row the same length

Return type:

tuple(ndarray, ndarray)

spynnaker.pyNN.models.neuron.synapse_io.read_all_synapses(data, delayed_data, synapse_info, n_synapse_types, weight_scales, post_vertex_slice, n_pre_atoms, post_vertex_max_delay_ticks, max_row_info, max_atoms_per_core)[source]

Read the synapses for a given projection synapse information object out of the given delayed and undelayed data.

Parameters:
  • data (bytearray) – The raw data containing the undelayed synapses

  • delayed_data (bytearray) – The raw data containing the delayed synapses

  • synapse_info (SynapseInformation) – The synapse info that generated the synapses

  • n_synapse_types (int) – The total number of synapse types available

  • weight_scales (list(float)) – A weight scale for each synapse type

  • n_pre_atoms (int) – The number of atoms in the pre-vertex

  • post_vertex_slice (Slice) – The slice of the post-vertex to read the synapses for

  • post_vertex_max_delay_ticks (int) – max delayed ticks supported from post vertex

  • max_row_info (MaxRowInfo) – The maximum information for each of the rows

  • max_atoms_per_core (int) – The maximum number of atoms on a core

Returns:

The connections read from the data; the dtype is NUMPY_CONNECTORS_DTYPE

Return type:

ndarray

spynnaker.pyNN.models.neuron.synaptic_matrices module
class spynnaker.pyNN.models.neuron.synaptic_matrices.AppKeyInfo(app_key, app_mask, core_mask, core_shift, n_neurons, n_colour_bits)[source]

Bases: object

An object which holds an application key and mask along with the other details.

Parameters:
  • app_key (int) – The application-level key

  • app_mask (int) – The application-level mask

  • core_mask (int) – The mask to get the core from the key

  • core_shift (int) – The shift to get the core from the key

  • n_neurons (int) – The neurons in each core (except possibly the last)

  • n_colour_bits (int) – The number of colour bits sent

app_key
app_mask
core_mask
core_shift
property key_and_mask

The key and mask as an object.

Return type:

BaseKeyAndMask

n_colour_bits
n_neurons
class spynnaker.pyNN.models.neuron.synaptic_matrices.SynapseRegions(synapse_params, pop_table, synaptic_matrix, synapse_dynamics, structural_dynamics, bitfield_filter, connection_builder)

Bases: tuple

Create new instance of SynapseRegions(synapse_params, pop_table, synaptic_matrix, synapse_dynamics, structural_dynamics, bitfield_filter, connection_builder)

property bitfield_filter

Alias for field number 5

property connection_builder

Alias for field number 6

property pop_table

Alias for field number 1

property structural_dynamics

Alias for field number 4

property synapse_dynamics

Alias for field number 3

property synapse_params

Alias for field number 0

property synaptic_matrix

Alias for field number 2

class spynnaker.pyNN.models.neuron.synaptic_matrices.SynapticMatrices(app_vertex, regions, max_atoms_per_core, weight_scales, all_syn_block_sz)[source]

Bases: object

Handler of synaptic matrices for a core of a population vertex.

Parameters:
property bit_field_size

The size of the bit field data.

Return type:

int

property gen_on_machine

Whether any matrices need to be generated on the machine.

Return type:

bool

generate_data()[source]
get_connections_from_machine(placement, app_edge, synapse_info)[source]

Get the synaptic connections from the machine.

Parameters:
Returns:

A list of arrays of connections, each with dtype NUMPY_CONNECTORS_DTYPE

Return type:

ndarray

get_index(app_edge, synapse_info)[source]

Get the index of an incoming projection in the population table.

Parameters:
property host_generated_block_addr

The address within the synaptic region after the last block written by the on-host synaptic generation, i.e. the start of the space that can be overwritten provided the synapse expander is run again.

Return type:

int

property max_gen_data

The maximum amount of data to be generated for the synapses.

Return type:

int

property on_chip_generated_matrix_size

The size of the space used by the generated matrix, i.e. the space that can be overwritten provided the synapse expander is run again.

Return type:

int

read_generated_connection_holders(placement)[source]

Fill in any pre-run connection holders for data which is generated on the machine, after it has been generated.

Parameters:

placement (Placement) – where the data is to be read from

write_synaptic_data(spec, post_vertex_slice, references)[source]

Write the synaptic data for all incoming projections.

Parameters:
  • spec (DataSpecificationGenerator) – The spec to write to

  • post_vertex_slice (Slice) – The slice of the post-vertex the matrix is for

  • references (SynapseRegions) – Regions which are referenced; each region which is not referenced can be None.

spynnaker.pyNN.models.neuron.synaptic_matrix_app module
class spynnaker.pyNN.models.neuron.synaptic_matrix_app.SynapticMatrixApp(synapse_info, app_edge, n_synapse_types, synaptic_matrix_region, max_atoms_per_core, all_syn_block_sz, app_key_info, delay_app_key_info, weight_scales)[source]

Bases: object

The synaptic matrix (and delay matrix if applicable) for an incoming application edge.

Parameters:
  • synapse_info (SynapseInformation) – The projection synapse information

  • app_edge (ProjectionApplicationEdge) – The projection application edge

  • n_synapse_types (int) – The number of synapse types accepted

  • synaptic_matrix_region (int) – The region where synaptic matrices are stored

  • all_syn_block_sz (int) – The space available for all synaptic matrices on the core

  • app_key_info (AppKeyInfo) – Application-level routing key information for undelayed vertices

  • delay_app_key_info (AppKeyInfo) – Application-level routing key information for delayed vertices

  • weight_scales (list(float)) – Weight scale for each synapse edge

append_matrix(post_vertex_slice, data_to_write, block_addr)[source]

Append a synaptic matrix from be written from host.

Parameters:
  • post_vertex_slice (Slice) – The slice of the post-vertex the matrix is for

  • data_to_write (list) – List to append the data to write to

  • block_addr (int) – The amount of data written so far

Returns:

The amount of data written after this data has been written

Return type:

int

property gen_size
get_connections(placement)[source]

Get the connections for this matrix from the machine.

Parameters:

placement (Placement) – Where the matrix is on the machine

Returns:

A list of arrays of connections, each with dtype NUMPY_CONNECTORS_DTYPE

Return type:

ndarray

get_generator_data()[source]

Prepare to write a matrix using an on-chip generator.

Returns:

The data to generate with

Return type:

GeneratorData

get_index()[source]

Get the index in the master population table of the matrix.

Parameters:

m_vertex (MachineVertex) – The source machine vertex

Return type:

int

read_generated_connection_holders(placement)[source]

Read any pre-run connection holders after data has been generated.

Parameters:

placement (Placement) – Where the matrix is on the machine

reserve_matrices(block_addr, pop_table)[source]

Allocate the master pop table entries for the blocks.

Parameters:
Returns:

Where the next allocation can start from

Return type:

int

Module contents
class spynnaker.pyNN.models.neuron.AbstractPopulationVertex(n_neurons, label, max_atoms_per_core, spikes_per_second, ring_buffer_sigma, incoming_spike_buffer_size, neuron_impl, pynn_model, drop_late_spikes, splitter, seed, n_colour_bits)[source]

Bases: PopulationApplicationVertex, AbstractAcceptsIncomingSynapses, AbstractCanReset, SupportsStructure

Underlying vertex model for Neural Populations. Not actually abstract.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label on the population

  • max_atoms_per_core (int) – The maximum number of atoms (neurons) per SpiNNaker core.

  • spikes_per_second (float or None) – Expected spike rate

  • ring_buffer_sigma (float or None) – How many SD above the mean to go for upper bound of ring buffer size; a good starting choice is 5.0. Given length of simulation we can set this for approximate number of saturation events.

  • incoming_spike_buffer_size (int or None) –

  • drop_late_spikes (bool) – control flag for dropping late packets.

  • neuron_impl (AbstractNeuronImpl) – The (Python side of the) implementation of the neurons themselves.

  • pynn_model (AbstractPyNNNeuronModel) – The PyNN neuron model that this vertex is working on behalf of.

  • splitter (AbstractSplitterCommon or None) – splitter object

  • seed – The Population seed, used to ensure the same random generation on each run.

  • n_colour_bits (int) – The number of colour bits to use

CORE_PARAMS_BASE_SIZE = 20
add_incoming_projection(projection)[source]

Add a projection incoming to this vertex.

Parameters:

projection (Projection) – The new projection to add

property atoms_shape

The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.

Return type:

tuple(int, …)

can_generate_on_machine()[source]

Determine if the parameters of this vertex can be generated on the machine

Return type:

bool

clear_connection_cache()[source]

Flush the cache of connection information; needed for a second run.

property combined_core_capable

Whether the vertex can manage to operate on a combined neuron-synapse core, or if a split synapse-core is more appropriate.

Note

This is currently based only on the ITCM available, not on the incoming synapses, but could be combined with n_synapse_cores_required to determine if, and how-many, synapse cores are needed.

Return type:

bool

property conductance_based

Whether the vertex models post-synaptic inputs as currents or conductance.

By default this is False; override if the model accepts conductance based input.

Return type:

bool

copy_initial_state_variables(vertex_slice)[source]

Copies the state variables into the initial state variables.

Parameters:

vertex_slice (Slice) – The slice to copy now

core_seed(vertex_slice)[source]

The seed to use for a core.

Parameters:

vertex_slice (Slice) – The machine vertex that the seed is for

Returns:

A list of 4 integers

Return type:

list(int)

property current_source_id_list

Current source ID list needed to be available to machine vertex.

Return type:

dict(AbstractCurrentSource,any)

property current_sources

Current sources needed to be available to machine vertex.

Return type:

list(AbstractCurrentSource)

describe()[source]

Get a human-readable description of the cell or synapse type.

The output may be customised by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Return type:

dict(str, any)

property drop_late_spikes

Whether spikes should be dropped if not processed in a timestep.

Return type:

bool

get_buffer_data_type(name)[source]

Get the type of data recorded by the buffer manager.

The buffer data type controls how data returned by the cores is handled in NeoBufferDatabase.

Parameters:

name (str) – The name of the variable recorded

Return type:

BufferDatabase

Raises:

KeyError – if the variable isn’t being recorded

get_common_constant_sdram(n_record, n_provenance, common_regions)[source]

Get the amount of SDRAM used by common parts.

Parameters:
  • n_record (int) – The number of recording regions

  • n_provenance (int) – The number of provenance items

  • common_regions (CommonRegions) – Region IDs

Return type:

int

get_connections_from_machine(app_edge, synapse_info)[source]

Get the connections from the machine post-run.

Parameters:
Return type:

ndarray

get_current_state_values(names, selector=None)[source]

Get the current values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Return type:

ParameterHolder

Raises:

KeyError – if the variable is not something that can be read

get_data_type(name)[source]

Get the type data returned by a recording of the variable.

This is the type of data the C code is returning. For instance data such as spikes this will be None.

Parameters:

name (str) – The name of the variable to get the type of

Return type:

DataType or None

Raises:

KeyError – If the variable isn’t recordable

get_incoming_projections_from(source_vertex)[source]

The projections that target this population vertex from the given source.

Return type:

iterable(Projection)

get_initial_state_values(names, selector=None)[source]

Get the initial values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Return type:

ParameterHolder

Raises:

KeyError – if the variable is not something that can be read

get_max_atoms_per_core()[source]

Gets the maximum number of atoms per core, which is either the number of atoms required across the whole application vertex, or a lower value set.

Return type:

int

get_max_atoms_per_dimension_per_core()[source]

Gets the maximum number of atoms per dimension per core. This will return a tuple with a number for each dimension of the vertex, which might be one if this is a single-dimension vertex.

Return type:

tuple(int,…)

get_max_delay(max_ring_buffer_bits)[source]

Get the maximum delay and whether a delay extension is needed for a given maximum number of ring buffer bits.

Parameters:

max_ring_buffer_bits (int) – The maximum number of bits that can be used for the ring buffer identifier (i.e. delay, synapse type, neuron index)

Returns:

Tuple of the maximum delay supported on the core and whether a delay extension is needed to support delays

Return type:

tuple(int, bool)

get_max_neuron_variable_sdram(n_neurons)[source]

Get the amount of SDRAM per timestep used by neuron parts.

Parameters:

vertex_slice (Slice) – The slice of neurons to get the size of

Return type:

int

get_max_row_info(synapse_info, n_post_atoms, app_edge)[source]

Get maximum row length data.

Parameters:
Return type:

MaxRowInfo

get_max_synapse_variable_sdram(n_neurons)[source]

Get the amount of SDRAM per timestep used by synapse parts.

Parameters:

vertex_slice (Slice) – The slice of neurons to get the size of

Return type:

int

get_n_atom_bits()[source]
Return type:

int

get_neuron_constant_sdram(n_atoms, neuron_regions)[source]

Get the amount of fixed SDRAM used by neuron parts.

Parameters:
  • vertex_slice (Slice) – The slice of neurons to get the size of

  • neuron_regions (NeuronRegions) – Region IDs

Return type:

int

get_neuron_variable_sdram(vertex_slice)[source]

Get the amount of SDRAM per timestep used by neuron parts.

Parameters:

vertex_slice (Slice) – The slice of neurons to get the size of

Return type:

int

get_neurons_recording(name, vertex_slice)[source]

Gets the neurons being recorded on the core with this slice.

Typically vertex_slice.get_raster_ids(atoms_shape) but may be a sublist if doing selective recording.

Parameters:
  • name (str) – The name of the variable to get the region of

  • vertex_slice (Slice) –

Returns:

A list of the global raster IDs of the atoms in recording named variable within this slice

Return type:

list(int)

get_parameter_values(names, selector=None)[source]

Get the values of a parameter or parameters for the whole Population or a subset if the selector is used.

Parameters:
Return type:

ParameterHolder

Raises:

KeyError – if the parameter is not something that can be read

get_parameters()[source]

Get the names of all the parameters that can be obtained

Return type:

list(str)

get_recordable_variables()[source]

Get a list of the names and types of things that can be recorded.

This methods list the variable recorded via the Population.

Return type:

list(str)

get_recording_region(name)[source]

Gets the recording region for the named variable.

Parameters:

name (str) – The name of the variable to get the region of

Return type:

int

Raises:

KeyError – If the variable isn’t being recorded

get_recording_variables()[source]

Get a list of variables that are currently being recorded.

Return type:

list(str)

get_ring_buffer_shifts()[source]

Get the shift of the ring buffers for transfer of values into the input buffers for this model.

Parameters:

incoming_projections (list(Projection)) – The projections to consider in the calculations

Return type:

list(int)

get_sampling_interval_ms(name)[source]

Get the sampling interval of the recording for the given variable.

The values is in ms and unless selective recording is used will be SpynnakerDataView.get_simulation_time_step_us()

Return type:

float

Raises:

KeyError – If the variable isn’t being recorded

get_sdram_usage_for_core_neuron_params(n_atoms)[source]
Parameters:

n_atoms (int) – The number of atoms per core

Returns:

The SDRAM required for the core neuron parameters

Return type:

int

get_sdram_usage_for_current_source_params(n_atoms)[source]

Calculate the SDRAM usage for the current source parameters region.

Parameters:

n_atoms (int) – The number of atoms to account for

Returns:

The SDRAM required for the current source region

Return type:

int

get_sdram_usage_for_neuron_generation(n_atoms)[source]

Calculate the SDRAM usage for the neuron generation region.

Parameters:

n_atoms (int) – The number of atoms per core

Returns:

The SDRAM required for the neuron generator region

Return type:

int

get_sdram_usage_for_neuron_params(n_atoms)[source]

Calculate the SDRAM usage for just the neuron parameters region.

Parameters:

n_atoms (int) – The number of atoms per core

Returns:

The SDRAM required for the neuron region

Return type:

int

get_state_variables()[source]

Get a list of supported state variables.

Return type:

list(str)

get_structural_dynamics_size(n_atoms)[source]

Get the size of the structural dynamics region, in bytes.

Parameters:

n_atoms (int) – The number of atoms in the slice

Return type:

int

get_synapse_dynamics_size(n_atoms)[source]

Get the size of the synapse dynamics region, in bytes.

Parameters:

vertex_slice (Slice) – The slice of the vertex to get the usage of

Return type:

int

get_synapse_expander_size()[source]

Get the size of the synapse expander region, in bytes.

Return type:

int

get_synapse_id_by_target(target)[source]

Get the id of synapse using its target name.

Parameters:

target (str) – The synapse to get the id of

Return type:

int

get_synapse_params_size()[source]

Get the size of the synapse parameters, in bytes.

Return type:

int

get_synapse_variable_sdram(vertex_slice)[source]

Get the amount of SDRAM per timestep used by synapse parts.

Parameters:

vertex_slice (Slice) – The slice of neurons to get the size of

Return type:

int

get_synapses_size(n_post_atoms)[source]

Get the maximum SDRAM usage for the synapses on a vertex slice.

Parameters:
  • n_post_atoms (int) – The number of atoms projected to

  • incoming_projections (list(Projection)) – The projections to consider in the calculations

Return type:

int

get_units(name)[source]

Get the units of the given parameter or state variable.

Parameters:

name (str) – the name of the parameter to get the units of

Return type:

str

Raises:

KeyError – if the name isn’t recognised or the units cannot be identified

get_weight_scales(ring_buffer_shifts)[source]

Get the weight scaling to apply to weights in synapses.

Parameters:

ring_buffer_shifts (list(int)) – The shifts to convert to weight scales

Return type:

list(int)

property incoming_poisson_projections

The projections that target this population vertex which originate from a Poisson source.

Return type:

iterable(Projection)

property incoming_projections

The projections that target this population vertex.

Return type:

iterable(Projection)

property incoming_spike_buffer_size

The size of the incoming spike buffer to be used on the cores.

Return type:

int

property initial_state_variables

The initial values of the state variables of the neurons.

Return type:

RangeDictionary

inject(current_source, selector=None)[source]

Inject a current source into this population.

Parameters:
Raises:

ConfigurationException – if the population doesn’t support injection

property n_atoms

The number of atoms in the vertex.

Return type:

int

property n_colour_bits

The number of colour bits sent by this vertex.

Assumed 0 unless overridden

Return type:

int

property n_profile_samples

The maximum number of profile samples to report.

Return type:

int

property n_synapse_cores_required

The estimated number of synapse cores required, when using a split synapse-neuron core model.

Note

This is currently hard-coded but could be updated to work this out based on the number of incoming synapses.

Return type:

int

property neuron_impl

The neuron implementation.

Return type:

AbstractNeuronImpl

property neuron_recordables

The names of variables that can be recorded by the neuron.

Return type:

list(str)

property neuron_recorder

The recorder for neurons.

Return type:

NeuronRecorder

property parameters

The parameters of the neurons in the population.

Return type:

RangeDictionary

property pop_seed

The seed to use for the population overall; a list of four integers.

Return type:

list(int)

property read_initial_values

Whether initial values need to be stored.

Return type:

bool

reset_to_first_timestep()[source]

Reset the object to first time step.

property ring_buffer_sigma
Return type:

float

property self_projection

Any projection from this vertex to itself.

Return type:

Projection or None

set_current_state_values(name, value, selector=None)[source]

Set the current values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Raises:

KeyError – if the variable is not something that can be changed

set_initial_state_values(name, value, selector=None)[source]

Set the initial values of a state variable for the whole Population or a subset if the selector is used.

Parameters:
Raises:

KeyError – if the variable is not something that can be changed

set_max_atoms_per_dimension_per_core(new_value)[source]

Set the maximum number of atoms per dimension per core.

Can be used to raise or lower the maximum number of atoms per core or per dimension per core.

Parameters:

new_value (None or int or tuple(int,...)) – Value to set. If the vertex is n-dimensional where n > 1, a tuple of n values must be given. If the vertex is 1 dimensional, a 1-tuple or integer can be given. If this is set to None the vertex will have atoms_shape as the maximum.

set_not_recording(name, indices=None)[source]

Set a variable not recording.

Parameters:
  • name (str) – The name of the variable to not record

  • indices (list(int) or None) – The list of neuron indices to not record or None for all

Raises:

KeyError – if the variable cannot be stopped from recording

set_parameter_values(name, value, selector=None)[source]

Set the values of a parameter for the whole Population or a subset if the selector is used.

Parameters:
Raises:

KeyError – if the parameter is not something that can be changed

set_recording(name, sampling_interval=None, indices=None)[source]

Set a variable recording.

Parameters:
  • name (str) – The name of the variable to set the status of

  • sampling_interval (float or None) – How often the variable should be recorded or None for every time step, in milliseconds

  • indices (list(int) or None) – The list of neuron indices to record or None for all

Raises:

KeyError – if the variable cannot be recorded

set_structure(structure)[source]

Set the structure of the object.

Parameters:

structure (BaseStructure) – The structure to set

set_synapse_dynamics(synapse_dynamics)[source]

Set the synapse dynamics of this population.

Parameters:

synapse_dynamics (AbstractSynapseDynamics) – The synapse dynamics to set

property size

The number of neurons in the vertex.

Return type:

int

property spikes_per_second
Return type:

float

property state_variables

The state variables of the neuron in the population.

Return type:

RangeDicationary

property synapse_dynamics

The synapse dynamics used by the synapses e.g. plastic or static. Settable.

Return type:

AbstractSynapseDynamics or None

property synapse_executable_suffix

The suffix of the executable name due to the type of synapses in use.

Return type:

str

property synapse_recordables

The names of variables that can be recorded by the synapses.

Return type:

list(str)

property synapse_recorder

The recorder for synapses.

Return type:

SynapseRecorder

property weight_scale
Return type:

float

class spynnaker.pyNN.models.neuron.AbstractPyNNNeuronModel(model)[source]

Bases: AbstractPyNNModel

Parameters:

model (AbstractNeuronImpl) – The model implementation

create_vertex(n_neurons, label, spikes_per_second, ring_buffer_sigma, incoming_spike_buffer_size, drop_late_spikes, splitter, seed, n_colour_bits)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

  • spikes_per_second (float) –

  • ring_buffer_sigma (float) –

  • incoming_spike_buffer_size (int) –

  • drop_late_spikes (bool) –

  • splitter (AbstractSplitterCommon or None) –

  • seed (float) –

  • n_colour_bits (int) –

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

default_population_parameters = {'drop_late_spikes': None, 'incoming_spike_buffer_size': None, 'n_colour_bits': None, 'ring_buffer_sigma': None, 'seed': None, 'spikes_per_second': None, 'splitter': None}
property name

The name of this model.

Return type:

str

class spynnaker.pyNN.models.neuron.AbstractPyNNNeuronModelStandard(model_name, binary, neuron_model, input_type, synapse_type, threshold_type, additional_input_type=None)[source]

Bases: AbstractPyNNNeuronModel

A neuron model that follows the sPyNNaker standard composed model pattern for point neurons.

Parameters:
create_vertex(n_neurons, label, spikes_per_second, ring_buffer_sigma, incoming_spike_buffer_size, n_steps_per_timestep, drop_late_spikes, splitter, seed, n_colour_bits)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

  • spikes_per_second (float) –

  • ring_buffer_sigma (float) –

  • incoming_spike_buffer_size (int) –

  • drop_late_spikes (bool) –

  • splitter (AbstractSplitterCommon or None) –

  • seed (float) –

  • n_colour_bits (int) –

  • n_steps_per_timestep (int) –

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

default_population_parameters = {'drop_late_spikes': None, 'incoming_spike_buffer_size': None, 'n_colour_bits': None, 'n_steps_per_timestep': 1, 'ring_buffer_sigma': None, 'seed': None, 'spikes_per_second': None, 'splitter': None}
class spynnaker.pyNN.models.neuron.ConnectionHolder(data_items_to_return, as_list, n_pre_atoms, n_post_atoms, connections=None, fixed_values=None, notify=None)[source]

Bases: object

Holds a set of connections to be returned in a PyNN-specific format.

Parameters:
  • data_items_to_return (list(int) or tuple(int) or None) – A list of data fields to be returned

  • as_list (bool) – True if the data will be returned as a list, False if it is to be returned as a matrix (or series of matrices)

  • n_pre_atoms (int) – The number of atoms in the pre-vertex

  • n_post_atoms (int) – The number of atoms in the post-vertex

  • connections (list(ndarray) or None) – Any initial connections, as a numpy structured array of source, target, weight and delay

  • fixed_values (list(tuple(str,int)) or None) –

    A list of tuples of field names and fixed values to be appended to the other fields per connection, formatted as [(field_name, value), …].

    Note

    If the field is to be returned, the name must also appear in data_items_to_return, which determines the order of items in the result.

  • notify (callable(ConnectionHolder, None) or None) – A callback to call when the connections have all been added. This should accept a single parameter, which will contain the data requested

add_connections(connections)[source]

Add connections to the holder to be returned.

Parameters:

connections (ndarray) – The connection to add, as a numpy structured array of source, target, weight and delay

property connections

The connections stored.

Return type:

list(ndarray)

finish()[source]

Finish adding connections.

class spynnaker.pyNN.models.neuron.LocalOnlyProvenance[source]

Bases: Structure

N_ITEMS = 4
max_size_input_buffer

Structure/Union member

max_spikes_per_timestep

Structure/Union member

n_spikes_dropped

Structure/Union member

n_spikes_lost_from_input

Structure/Union member

class spynnaker.pyNN.models.neuron.NeuronProvenance[source]

Bases: Structure

Provenance items from neuron processing.

N_ITEMS = 4
current_timer_tick

Structure/Union member

earliest_send

Structure/Union member

latest_send

Structure/Union member

n_tdma_misses

Structure/Union member

class spynnaker.pyNN.models.neuron.NeuronRegions(core_params: int, neuron_params: int, current_source_params: int, neuron_recording: int, neuron_builder: int, initial_values: int)[source]

Bases: object

Identifiers for neuron regions.

core_params: int
current_source_params: int
initial_values: int
neuron_builder: int
neuron_params: int
neuron_recording: int
class spynnaker.pyNN.models.neuron.PopulationMachineLocalOnlyCombinedVertex(sdram, label, app_vertex, vertex_slice, slice_index, ring_buffer_shifts, weight_scales, neuron_data, max_atoms_per_core)[source]

Bases: PopulationMachineCommon, PopulationMachineNeurons, AbstractGeneratesDataSpecification, AbstractRewritesDataSpecification

A machine vertex for PyNN Populations.

Parameters:
  • sdram (AbstractSDRAM) – The SDRAM used by the vertex

  • label (str) – The label of the vertex

  • app_vertex (AbstractPopulationVertex) – The associated application vertex

  • vertex_slice (Slice) – The slice of the population that this implements

  • slice_index (int) – The index of the slice in the ordered list of slices

  • ring_buffer_shifts (list(int)) – The shifts to apply to convert ring buffer values to S1615 values

  • weight_scales (list(int)) – The scaling to apply to weights to store them in the synapses

  • all_syn_block_sz (int) – The maximum size of the synapses in bytes

  • structural_sz (int) – The size of the structural data

  • neuron_data (NeuronData) – The handler of neuron data

  • max_atoms_per_core (int) – The maximum number of atoms per core

BACKGROUND_MAX_QUEUED_NAME = 'Max_backgrounds_queued'
BACKGROUND_OVERLOADS_NAME = 'Times_the_background_queue_overloaded'
COMMON_REGIONS = CommonRegions(system=0, provenance=1, profile=2, recording=3)
INPUT_BUFFER_FULL_NAME = 'Times_the_input_buffer_lost_packets'
LOCAL_ONLY_SIZE = 20
MAX_FILLED_SIZE_OF_INPUT_BUFFER_NAME = 'Max_filled_size_input_buffer'
MAX_SPIKES_PER_TIME_STEP_NAME = 'Max_spikes_per_time_step'
NEURON_REGIONS = NeuronRegions(core_params=4, neuron_params=5, current_source_params=6, neuron_recording=7, neuron_builder=10, initial_values=11)
N_LATE_SPIKES_NAME = 'Number_of_late_spikes'
class REGIONS(value)[source]

Bases: Enum

Regions for populations.

CORE_PARAMS = 4
CURRENT_SOURCE_PARAMS = 6
INITIAL_VALUES = 11
LOCAL_ONLY = 8
LOCAL_ONLY_PARAMS = 9
NEURON_BUILDER = 10
NEURON_PARAMS = 5
NEURON_RECORDING = 7
PROFILING = 2
PROVENANCE_DATA = 1
RECORDING = 3
SYSTEM = 0
generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_recorded_region_ids()[source]

Get the recording region IDs that have been recorded using buffering.

Returns:

The region numbers that have active recording

Return type:

iterable(int)

parse_extra_provenance_items(label, x, y, p, provenance_data)[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) – The list of words of raw provenance data.

regenerate_data_specification(spec, placement)[source]

Regenerate the data specification, only generating regions that have changed and need to be reloaded.

Parameters:
reload_required()[source]

Return true if any data region needs to be reloaded.

Return type:

bool

set_do_neuron_regeneration()[source]

Indicate that data re-generation of neuron parameters is required.

set_reload_required(new_value)[source]

Indicate that the regions have been reloaded.

Parameters:

new_value – the new value

class spynnaker.pyNN.models.neuron.PopulationMachineVertex(sdram, label, app_vertex, vertex_slice, slice_index, ring_buffer_shifts, weight_scales, structural_sz, max_atoms_per_core, synaptic_matrices, neuron_data)[source]

Bases: PopulationMachineCommon, PopulationMachineNeurons, PopulationMachineSynapses, AbstractGeneratesDataSpecification, AbstractRewritesDataSpecification

A machine vertex for PyNN Populations.

Parameters:
  • sdram (AbstractSDRAM) – The SDRAM used by the vertex

  • label (str) – The label of the vertex

  • app_vertex (AbstractPopulationVertex) – The associated application vertex

  • vertex_slice (Slice) – The slice of the population that this implements

  • slice_index (int) – The index of the slice in the ordered list of slices

  • ring_buffer_shifts (list(int)) – The shifts to apply to convert ring buffer values to S1615 values

  • weight_scales (list(int)) – The scaling to apply to weights to store them in the synapses

  • structural_sz (int) – The size of the structural data

  • n_neuron_bits (int) – The number of bits to use for neuron IDs

  • synaptic_matrices (SynapticMatrices) – The synaptic matrices

  • neuron_data (NeuronData) – The handler of neuron data

BACKGROUND_MAX_QUEUED_NAME = 'Max_backgrounds_queued'
BACKGROUND_OVERLOADS_NAME = 'Times_the_background_queue_overloaded'
COMMON_REGIONS = CommonRegions(system=0, provenance=10, profile=11, recording=15)
DMA_COMPLETE = "DMA's that were completed"
INPUT_BUFFER_FULL_NAME = 'Times_the_input_buffer_lost_packets'
MAX_FILLED_SIZE_OF_INPUT_BUFFER_NAME = 'Max_filled_size_input_buffer'
NEURON_REGIONS = NeuronRegions(core_params=1, neuron_params=2, current_source_params=3, neuron_recording=9, neuron_builder=13, initial_values=16)
N_LATE_SPIKES_NAME = 'Number_of_late_spikes'
N_REWIRES_NAME = 'Number_of_rewires'
class REGIONS(value)[source]

Bases: Enum

Regions for populations.

BIT_FIELD_FILTER = 14
CONNECTOR_BUILDER = 12
CORE_PARAMS = 1
CURRENT_SOURCE_PARAMS = 3
INITIAL_VALUES = 16
NEURON_BUILDER = 13
NEURON_PARAMS = 2
NEURON_RECORDING = 9
POPULATION_TABLE = 5
PROFILING = 11
PROVENANCE_DATA = 10
RECORDING = 15
STRUCTURAL_DYNAMICS = 8
SYNAPSE_DYNAMICS = 7
SYNAPSE_PARAMS = 4
SYNAPTIC_MATRIX = 6
SYSTEM = 0
SPIKES_PROCESSED = 'How many spikes were processed'
SYNAPSE_REGIONS = SynapseRegions(synapse_params=4, pop_table=5, synaptic_matrix=6, synapse_dynamics=7, structural_dynamics=8, bitfield_filter=14, connection_builder=12)
generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_n_keys_for_partition(partition_id)[source]

Get the number of keys required by the given partition of edges.

Parameters:

partition_id (str) – The identifier of the partition; the partition_id param is only used by some MachineVertex subclasses

Returns:

The number of keys required

Return type:

int

get_recorded_region_ids()[source]

Get the recording region IDs that have been recorded using buffering.

Returns:

The region numbers that have active recording

Return type:

iterable(int)

parse_extra_provenance_items(label, x, y, p, provenance_data)[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) – The list of words of raw provenance data.

regenerate_data_specification(spec, placement)[source]

Regenerate the data specification, only generating regions that have changed and need to be reloaded.

Parameters:
reload_required()[source]

Return true if any data region needs to be reloaded.

Return type:

bool

set_do_neuron_regeneration()[source]

Indicate that data re-generation of neuron parameters is required.

set_do_synapse_regeneration()[source]

Indicates that synaptic data regeneration is required.

set_reload_required(new_value)[source]

Indicate that the regions have been reloaded.

Parameters:

new_value – the new value

class spynnaker.pyNN.models.neuron.PopulationNeuronsMachineVertex(sdram, label, app_vertex, vertex_slice, slice_index, ring_buffer_shifts, weight_scales, neuron_data, max_atoms_per_core)[source]

Bases: PopulationMachineCommon, PopulationMachineNeurons, AbstractGeneratesDataSpecification, AbstractRewritesDataSpecification, ReceivesSynapticInputsOverSDRAM

A machine vertex for the Neurons of PyNN Populations.

Parameters:
  • sdram (AbstractSDRAM) – The SDRAM used by the vertex

  • label (str) – The label of the vertex

  • app_vertex (AbstractPopulationVertex) – The associated application vertex

  • vertex_slice (Slice) – The slice of the population that this implements

  • slice_index (int) – The index of the slice in the ordered list of slices

  • ring_buffer_shifts (list(int)) – The shifts to apply to convert ring buffer values to S1615 values

  • weight_scales (list(int)) – The scaling to apply to weights to store them in the synapses

  • neuron_data (NeuronData) – The handler of neuron data

  • max_atoms_per_core (int) – The maximum number of atoms per core

COMMON_REGIONS = CommonRegions(system=0, provenance=2, profile=3, recording=4)
NEURON_REGIONS = NeuronRegions(core_params=1, neuron_params=5, current_source_params=6, neuron_recording=7, neuron_builder=9, initial_values=10)
class REGIONS(value)[source]

Bases: Enum

Regions for populations.

CORE_PARAMS = 1
CURRENT_SOURCE_PARAMS = 6
INITIAL_VALUES = 10
NEURON_BUILDER = 9
NEURON_PARAMS = 5
NEURON_RECORDING = 7
PROFILING = 3
PROVENANCE_DATA = 2
RECORDING = 4
SDRAM_EDGE_PARAMS = 8
SYSTEM = 0
generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
static get_n_bytes_for_transfer(n_neurons, n_synapse_types)[source]
get_n_keys_for_partition(partition_id)[source]

Get the number of keys required by the given partition of edges.

Parameters:

partition_id (str) – The identifier of the partition; the partition_id param is only used by some MachineVertex subclasses

Returns:

The number of keys required

Return type:

int

get_recorded_region_ids()[source]

Get the recording region IDs that have been recorded using buffering.

Returns:

The region numbers that have active recording

Return type:

iterable(int)

property n_bytes_for_transfer

The number of bytes to be sent over the channel. This will be calculated using the above numbers, but also rounded up to a number of words, and with the number of neurons rounded up to a power of 2.

Return type:

int

parse_extra_provenance_items(label, x, y, p, provenance_data)[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) – The list of words of raw provenance data.

regenerate_data_specification(spec, placement)[source]

Regenerate the data specification, only generating regions that have changed and need to be reloaded.

Parameters:
reload_required()[source]

Return true if any data region needs to be reloaded.

Return type:

bool

sdram_requirement(sdram_machine_edge)[source]

Asks a machine vertex for the SDRAM requirement it needs.

Parameters:

sdram_machine_edge (SDRAMMachineEdge) – The SDRAM edge in question

Returns:

The size in bytes this vertex needs for the SDRAM edge.

Return type:

int (most likely a multiple of 4)

set_do_neuron_regeneration()[source]

Indicate that data re-generation of neuron parameters is required.

set_reload_required(new_value)[source]

Indicate that the regions have been reloaded.

Parameters:

new_value – the new value

set_sdram_partition(sdram_partition)[source]

Set the SDRAM partition. Must only be called once per instance.

Parameters:

sdram_partition (SourceSegmentedSDRAMMachinePartition) – The SDRAM partition to receive synapses from

property weight_scales

A list of scale factors to be applied to weights that get passed over SDRAM, one for each synapse type.

Return type:

list(int)

class spynnaker.pyNN.models.neuron.PopulationSynapsesMachineVertexCommon(sdram, label, app_vertex, vertex_slice)[source]

Bases: PopulationMachineCommon, SendsSynapticInputsOverSDRAM

Common parts of a machine vertex for the synapses of a Population.

Parameters:
  • sdram (AbstractSDRAM) – The SDRAM used by the vertex

  • label (str) – The label of the vertex

  • app_vertex (AbstractPopulationVertex) – The associated application vertex

  • vertex_slice (Slice) – The slice of the population that this implements

COMMON_REGIONS = CommonRegions(system=0, provenance=1, profile=2, recording=3)
DMA_COMPLETE = "DMA's that were completed"
EARLIEST_RECEIVE = 'Earliest_receive_time'
INPUT_BUFFER_FULL_NAME = 'Times_the_input_buffer_lost_packets'
LATEST_RECEIVE = 'Latest_receive_time'
MAX_FILLED_SIZE_OF_INPUT_BUFFER_NAME = 'Max_filled_size_input_buffer'
MAX_SPIKES_PROCESSED = 'Max_spikes_processed_in_time_step'
MAX_SPIKES_RECEIVED = 'Max_spikes_received_in_time_step'
MAX_SPIKE_OVERFLOW = 'Max_spike_overflow_in_time_step'
MAX_TRANSFER_TIMER_OVERRUNS = 'Max_transfer_overrun'
N_LATE_SPIKES_NAME = 'Number_of_late_spikes'
N_REWIRES_NAME = 'Number_of_rewires'
N_SKIPPED_TIME_STEPS = 'Times_a_time_step_was_skipped'
N_TRANSFER_TIMER_OVERRUNS = 'Times_the_transfer_did_not_complete_in_time'
class REGIONS(value)[source]

Bases: Enum

Regions for populations.

BIT_FIELD_FILTER = 9
CONNECTOR_BUILDER = 12
KEY_REGION = 11
POPULATION_TABLE = 6
PROFILING = 2
PROVENANCE_DATA = 1
RECORDING = 3
SDRAM_EDGE_PARAMS = 10
STRUCTURAL_DYNAMICS = 8
SYNAPSE_DYNAMICS = 7
SYNAPSE_PARAMS = 4
SYNAPTIC_MATRIX = 5
SYSTEM = 0
SPIKES_PROCESSED = 'How many spikes were processed'
SYNAPSE_REGIONS = SynapseRegions(synapse_params=4, pop_table=6, synaptic_matrix=5, synapse_dynamics=7, structural_dynamics=8, bitfield_filter=9, connection_builder=12)
get_recorded_region_ids()[source]

Get the recording region IDs that have been recorded using buffering.

Returns:

The region numbers that have active recording

Return type:

iterable(int)

parse_extra_provenance_items(label, x, y, p, provenance_data)[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) – The list of words of raw provenance data.

sdram_requirement(sdram_machine_edge)[source]

Asks a machine vertex for the SDRAM requirement it needs.

Parameters:

sdram_machine_edge (SDRAMMachineEdge) – The SDRAM edge in question

Returns:

The size in bytes this vertex needs for the SDRAM edge.

Return type:

int (most likely a multiple of 4)

set_neuron_vertex_and_partition_id(neuron_vertex, partition_id)[source]

Set the neuron vertex and partition ID for the case with a self-connection.

Parameters:

neuron_to_synapse_edge (MachineEdge) – The edge that we will receive spikes from

set_sdram_partition(sdram_partition)[source]

Set the SDRAM partition. Must only be called once per instance.

Parameters:

sdram_partition (SourceSegmentedSDRAMMachinePartition) – The SDRAM partition to receive synapses from

class spynnaker.pyNN.models.neuron.PopulationSynapsesMachineVertexLead(sdram, label, app_vertex, vertex_slice, ring_buffer_shifts, weight_scales, structural_sz, synapse_references, max_atoms_per_core, synaptic_matrices)[source]

Bases: PopulationSynapsesMachineVertexCommon, PopulationMachineSynapses, AbstractGeneratesDataSpecification, AbstractRewritesDataSpecification

A synaptic machine vertex that leads other synaptic machine vertices, writing shared areas.

Parameters:
  • sdram (AbstractSDRAM) – The SDRAM used by the vertex

  • label (str) – The label of the vertex

  • app_vertex (AbstractPopulationVertex) – The associated application vertex

  • vertex_slice (Slice) – The slice of the population that this implements

generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_recorded_region_ids()[source]

Get the recording region IDs that have been recorded using buffering.

Returns:

The region numbers that have active recording

Return type:

iterable(int)

regenerate_data_specification(spec, placement)[source]

Regenerate the data specification, only generating regions that have changed and need to be reloaded.

Parameters:
reload_required()[source]

Return true if any data region needs to be reloaded.

Return type:

bool

set_do_synapse_regeneration()[source]

Indicates that synaptic data regeneration is required.

set_reload_required(new_value)[source]

Indicate that the regions have been reloaded.

Parameters:

new_value – the new value

class spynnaker.pyNN.models.neuron.PopulationSynapsesMachineVertexShared(sdram, label, app_vertex, vertex_slice, synapse_references)[source]

Bases: PopulationSynapsesMachineVertexCommon, PopulationMachineSynapsesProvenance, AbstractGeneratesDataSpecification

A machine vertex for PyNN Populations.

Parameters:
  • sdram (AbstractSDRAM) – The SDRAM used by the vertex

  • label (str) – The label of the vertex

  • app_vertex (AbstractPopulationVertex) – The associated application vertex

  • vertex_slice (Slice) – The slice of the population that this implements

generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
class spynnaker.pyNN.models.neuron.SpikeProcessingFastProvenance[source]

Bases: Structure

N_ITEMS = 14
earliest_receive

Structure/Union member

latest_receive

Structure/Union member

max_size_input_buffer

Structure/Union member

max_spikes_overflow

Structure/Union member

max_spikes_processed

Structure/Union member

max_spikes_received

Structure/Union member

max_transfer_timer_overrun

Structure/Union member

n_buffer_overflows

Structure/Union member

n_dmas_complete

Structure/Union member

n_late_packets

Structure/Union member

n_rewires

Structure/Union member

n_skipped_time_steps

Structure/Union member

n_spikes_processed

Structure/Union member

n_transfer_timer_overruns

Structure/Union member

class spynnaker.pyNN.models.neuron.SpikeProcessingProvenance[source]

Bases: Structure

N_ITEMS = 6
max_size_input_buffer

Structure/Union member

n_buffer_overflows

Structure/Union member

n_dmas_complete

Structure/Union member

n_late_packets

Structure/Union member

n_rewires

Structure/Union member

n_spikes_processed

Structure/Union member

class spynnaker.pyNN.models.neuron.SynapseProvenance[source]

Bases: Structure

Provenance items from synapse processing.

N_ITEMS = 10
max_late_spike

Structure/Union member

n_failed_bitfield_reads

Structure/Union member

n_filtered_by_bitfield

Structure/Union member

n_ghost_searches

Structure/Union member

n_invalid_pop_table_hits

Structure/Union member

n_late_spikes

Structure/Union member

n_plastic_saturations

Structure/Union member

n_pre_synaptic_events

Structure/Union member

n_saturations

Structure/Union member

n_skipped_synapses

Structure/Union member

spynnaker.pyNN.models.populations package
Module contents

A population is a group of neurons with the same neuron model and synaptic model, but possibly (usually!) varying connectivity and configuration parameters.

A population view is a subset of a population, created by slicing the population:

view = population[n:m]

An assembly is an agglomeration of populations and population views, created by adding them together:

assembly = population_1 + population_2

Note

sPyNNaker only has incomplete support for assemblies; do not use.

class spynnaker.pyNN.models.populations.Assembly(*args: Any, **kwargs: Any)[source]

Bases: Assembly

A group of neurons, may be heterogeneous, in contrast to a Population where all the neurons are of the same type.

Parameters:
  • populations (Population or PopulationView) – the populations or views to form the assembly out of

  • kwargs – may contain label (a string describing the assembly)

class spynnaker.pyNN.models.populations.IDMixin(parent, selector, label=None)[source]

Bases: PopulationView

Parameters:
  • parent (Population or PopulationView) – the population or view to make the view from

  • vertex (PopulationApplicationVertex) – The actual underlying vertex

  • recorder (Recorder) – The recorder of the Population

  • selector (None or slice or int or list(bool) or list(int) or ndarray(bool) or ndarray(int)) –

    a slice or numpy mask array. The mask array should either be a boolean array (ideally) of the same size as the parent, or an integer array containing cell indices, i.e. if p.size == 5 then:

    PopulationView(p, array([False, False, True, False, True]))
    PopulationView(p, array([2, 4]))
    PopulationView(p, slice(2, 5, 2))
    

    will all create the same view.

  • label (str) – A label for the view

as_view()[source]

Return a PopulationView containing just this cell.

Return type:

PopulationView

get_initial_value(variable)[source]

Get the initial value of a state variable of the cell.

Parameters:

variable (str) – The name of the variable

Return type:

float

get_parameters()[source]

Return a dict of all cell parameters.

Return type:

dict(str, …)

property id
Return type:

int

property initial_values

A dict containing the initial values of the state variables.

Return type:

InitialValuesHolder

property local

Whether this cell is local to the current MPI node.

Return type:

bool

set_initial_value(variable, value)[source]

Set the initial value of a state variable of the cell.

Parameters:
  • variable (str) – The name of the variable

  • value (float) – The value of the variable

set_parameters(**parameters)[source]

Set cell parameters, given as a sequence of parameter=value arguments.

class spynnaker.pyNN.models.populations.Population(size, cellclass, cellparams=None, structure=None, initial_values=None, label=None, additional_parameters=None, **additional_kwargs)[source]

Bases: PopulationBase

PyNN 0.9 population object.

Parameters:
  • size (int) – The number of neurons in the population

  • cellclass (type or AbstractPyNNModel) – The implementation of the individual neurons.

  • cellparams (dict(str,object) or None) – Parameters to pass to cellclass if it is a class to instantiate. Must be None if cellclass is an instantiated object.

  • structure (BaseStructure) –

  • initial_values (dict(str,float)) – Initial values of state variables

  • label (str) – A label for the population

  • additional_parameters (dict(str, ...)) – Additional parameters to pass to the vertex creation function.

  • additional_kwargs (dict(str, ...)) – A nicer way of allowing additional things

add_placement_constraint(x, y, p=None)[source]

Add a placement constraint.

Parameters:
  • x (int) – The x-coordinate of the placement constraint

  • y (int) – The y-coordinate of the placement constraint

  • p (int) – The processor ID of the placement constraint (optional)

Raises:
all()[source]

Iterator over cell IDs on all MPI nodes.

Return type:

iterable(IDMixin)

property all_cells
Return type:

list(IDMixin)

property annotations

The annotations given by the end user.

Return type:

dict(str, …)

can_record(variable)[source]

Determine whether variable can be recorded from this population.

Parameters:

variable (str) – The variable to answer the question about

Return type:

bool

property celltype

Implements the PyNN expected celltype property.

Returns:

The cell type this property has been set to

Return type:

AbstractPyNNModel

property conductance_based

Whether the population uses conductance inputs

Return type:

bool

static create(cellclass, cellparams=None, n=1)[source]

Pass through method to the constructor defined by PyNN. Create n cells all of the same type.

Parameters:
Returns:

A New Population

Return type:

Population

property current_values

Get the current values of the state variables.

Return type:

ParameterHolder

describe(template='population_default.txt', engine='default')[source]

Returns a human-readable description of the population.

The output may be customized by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Parameters:
  • template (str) – Template filename

  • engine (str or TemplateEngine or None) – Template substitution engine

Return type:

str or dict

find_units(variable)[source]

Get the units of a variable.

Parameters:

variable (str) – The name of the variable

Returns:

The units of the variable

Return type:

str

property first_id

The ID of the first member of the population.

Return type:

int

get(parameter_names, gather=True, simplify=True)[source]

Get the values of a parameter for every local cell in the population.

Parameters:
  • parameter_names (str or iterable(str)) – Name of parameter. This is either a single string or a list of strings

  • gather (bool) – pointless on sPyNNaker

  • simplify (bool) – ignored

Returns:

A single list of values (or possibly a single value) if paramter_names is a string, or a dict of these if parameter names is a list.

Return type:

ParameterHolder

get_data(variables='all', gather=True, clear=False, annotations=None)[source]

Return a Neo Block containing the data (spikes, state variables) recorded from the Assembly.

Parameters:
  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    Whether to collect data from all MPI nodes or just the current node.

    Note

    This is irrelevant on sPyNNaker, which always behaves as if this parameter is True.

  • clear (bool) – Whether recorded data will be deleted from the Assembly.

  • annotations (dict(str, ...)) – annotations to put on the neo block

Return type:

Block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

get_spike_counts(gather=True)[source]

Return the number of spikes for each neuron.

Return type:

ndarray

id_to_index(id)[source]

Given the ID(s) of cell(s) in the Population, return its (their) index (order in the Population).

Defined by https://neuralensemble.org/docs/PyNN/reference/populations.html

Parameters:

id (int or iterable(int)) –

Return type:

int or iterable(int)

id_to_local_index(cell_id)[source]

Given the ID(s) of cell(s) in the Population, return its (their) index (order in the Population), counting only cells on the local MPI node.

Defined by https://neuralensemble.org/docs/PyNN/reference/populations.html

Parameters:

cell_id (int or iterable(int)) –

Return type:

int or iterable(int)

index_to_id(index)[source]

Given the index (order in the Population) of cell(s) in the Population, return their ID(s)

Parameters:

index (int or iterable(int)) –

Return type:

int or iterable(int)

property initial_values

The initial values of the state variables.

Note

These values will be the same as the values set with the last call to initialize rather than the actual initial values if this call has been made.

Return type:

ParameterHolder

initialize(**kwargs)[source]

Set initial values of state variables, e.g. the membrane potential. Values passed to initialize() may be:

  • single numeric values (all neurons set to the same value), or

  • RandomDistribution objects, or

  • lists / arrays of numbers of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single number.

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Examples:

p.initialize(v=-70.0)
p.initialize(v=rand_distr, gsyn_exc=0.0)
p.initialize(v=lambda i: -65 + i / 10.0)
inject(current_source)[source]

Connect a current source to all cells in the Population.

Defined by https://neuralensemble.org/docs/PyNN/reference/populations.html

property label

The label of the population.

Return type:

str

property last_id

The ID of the last member of the population.

Return type:

int

property local_size

The number of local cells.

Defined by https://neuralensemble.org/docs/PyNN/reference/populations.html

property position_generator
Return type:

callable((int), ndarray)

property positions

The position array for structured populations.

Returns:

a 3xN array

Return type:

ndarray

record(variables, to_file=None, sampling_interval=None)[source]

Record the specified variable or variables for all cells in the Population or view.

Parameters:
  • variables (str or list(str)) – either a single variable name or a list of variable names. For a given celltype class, celltype.recordable contains a list of variables that can be recorded for that celltype.

  • to_file (io or rawio or str) – a file to automatically record to (optional). write_data() will be automatically called when sim.end() is called.

  • sampling_interval (int) – a value in milliseconds, and an integer multiple of the simulation timestep.

sample(n, rng=None)[source]

Randomly sample n cells from the Population, and return a PopulationView object.

Parameters:
  • n (int) – The number of cells to put in the view.

  • rng (NumpyRNG) – The random number generator to use

Return type:

PopulationView

set(**parameters)[source]

Set one or more parameters for every cell in the population.

parameter can be a dict, in which case value should not be supplied, or a string giving the parameter name, in which case value is the parameter value. value can be a numeric value, or list of such (e.g. for setting spike times):

p._set("tau_m", 20.0).
p._set({'tau_m':20, 'v_rest':-65})
Parameters:
Raises:
set_max_atoms_per_core(max_atoms_per_core)[source]

Supports the setting of this population’s max atoms per dimension per core.

Parameters:

max_atoms_per_core (int) – the new value for the max atoms per dimension per core.

Raises:
set_state(**kwargs)[source]

Set current values of state variables, e.g. the membrane potential. Values passed to set_state() may be:

  • single numeric values (all neurons set to the same value), or

  • RandomDistribution objects, or

  • lists / arrays of numbers of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single number.

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Examples:

p.set_state(v=-70.0)
p.set_state(v=rand_distr, gsyn_exc=0.0)
p.set_state(v=lambda i: -65 + i / 10.0)
property size

The number of neurons in the population.

Return type:

int

spinnaker_get_data(variable, as_matrix=False, view_indexes=None)[source]

Public accessor for getting data as a numpy array, instead of the Neo-based object

Parameters:
  • variable (str or list(str)) – a single variable name.

  • as_matrix (bool) – If set True the data is returned as a 2d matrix

  • view_indexes – The indexes for which data should be returned. If None, all data (view_index = data_indexes)

Returns:

array of the data

Return type:

ndarray

property structure

The structure for the population.

Return type:

BaseStructure or None

write_data(io, variables='all', gather=True, clear=False, annotations=None)[source]

Write recorded data to file, using one of the file formats supported by Neo.

Parameters:
  • io (neo.io.baseio.BaseIO or str) – a Neo IO instance, or a string for where to put a neo instance

  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    Whether to bring all relevant data together.

    Note

    SpiNNaker always gathers.

  • clear (bool) – clears the storage data if set to true after reading it back

  • annotations (dict(str, ...)) – annotations to put on the neo block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

class spynnaker.pyNN.models.populations.PopulationBase[source]

Bases: object

Shared methods between Populations and PopulationViews.

Mainly pass through and not implemented.

abstract property all_cells

An array containing the cell IDs of all neurons in the Population (all MPI nodes).

Return type:

list(int)

getSpikes(*args, **kwargs)[source]

Deprecated since version 5.0: Use get_data('spikes') instead.

abstract get_data(variables='all', gather=True, clear=False, annotations=None)[source]

Return a Neo Block containing the data(spikes, state variables) recorded from the Population.

Parameters:
  • variables (str or list(str)) – Either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    For parallel simulators, if this is True, all data will be gathered to all nodes and the Neo Block will contain data from all nodes. Otherwise, the Neo Block will contain only data from the cells simulated on the local node.

    Note

    SpiNNaker always gathers.

  • clear (bool) – If this is True, recorded data will be deleted from the Population.

  • annotations (None or dict(str, ...)) – annotations to put on the neo block

Return type:

Block

get_gsyn(*args, **kwargs)[source]

Deprecated since version 5.0: Use get_data(['gsyn_exc', 'gsyn_inh']) instead.

abstract get_spike_counts(gather=True)[source]

Returns a dict containing the number of spikes for each neuron.

The dict keys are neuron IDs, not indices.

Parameters:

gather (bool) –

For parallel simulators, if this is True, all data will be gathered to all nodes and the Neo Block will contain data from all nodes. Otherwise, the Neo Block will contain only data from the cells simulated on the local node.

Note

SpiNNaker always gathers.

Return type:

dict(int, int)

get_v(*args, **kwargs)[source]

Deprecated since version 5.0: Use get_data('v') instead.

abstract inject(current_source)[source]

Connect a current source to all cells in the Population.

Parameters:

current_source (NeuronCurrentSource) –

is_local(id)[source]

Indicates whether the cell with the given ID exists on the local MPI node.

Return type:

bool

property local_cells

An array containing the cell IDs of those neurons in the Population that exist on the local MPI node.

Return type:

list(int)

property local_size

The number of cells in the population on the local MPI node.

Return type:

int

meanSpikeCount(*args, **kwargs)[source]

Deprecated since version 5.0: Use mean_spike_count() instead.

mean_spike_count(gather=True)[source]

Returns the mean number of spikes per neuron.

Parameters:

gather (bool) –

For parallel simulators, if this is True, all data will be gathered to all nodes and the Neo Block will contain data from all nodes. Otherwise, the Neo Block will contain only data from the cells simulated on the local node.

Note

SpiNNaker always gathers.

Return type:

float

nearest(position)[source]

Return the neuron closest to the specified position.

Warning

Currently unimplemented.

property position_generator

Note

NO PyNN description of this method.

Warning

Currently unimplemented.

property positions

Note

NO PyNN description of this method.

Warning

Currently unimplemented.

Return type:

ndarray(tuple(float, float, float))

printSpikes(filename, gather=True)[source]

Deprecated since version 5.0: Use write_data(file, 'spikes') instead.

Note

Method signature is the PyNN0.7 one

print_gsyn(filename, gather=True)[source]

Deprecated since version 5.0: Use write_data(file, ['gsyn_exc', 'gsyn_inh']) instead.

Note

Method signature is the PyNN0.7 one

print_v(filename, gather=True)[source]

Deprecated since version 5.0: Use write_data(file, 'v') instead.

Note

Method signature is the PyNN0.7 one

receptor_types()[source]

Note

NO PyNN description of this method.

Warning

Currently unimplemented.

abstract record(variables, to_file=None, sampling_interval=None)[source]

Record the specified variable or variables for all cells in the Population or view.

Parameters:
  • variables (str or list(str)) – either a single variable name or a list of variable names. For a given celltype class, celltype.recordable contains a list of variables that can be recorded for that celltype.

  • to_file (io or rawio or str) – a file to automatically record to (optional). write_data() will be automatically called when end() is called.

  • sampling_interval (int) – a value in milliseconds, and an integer multiple of the simulation timestep.

record_gsyn(sampling_interval=1, to_file=None)[source]

Deprecated since version 5.0: Use record(['gsyn_exc', 'gsyn_inh']) instead.

Note

Method signature is the PyNN 0.7 one with the extra non-PyNN sampling_interval and indexes

record_v(sampling_interval=1, to_file=None)[source]

Deprecated since version 5.0: Use record('v') instead.

Note

Method signature is the PyNN 0.7 one with the extra non-PyNN sampling_interval and indexes

rset(*args, **kwargs)[source]

Deprecated since version 5.0: Use set(parametername=rand_distr) instead.

save_positions(file)[source]

Save positions to file. The output format is index x y z

Warning

Currently unimplemented.

property structure

The spatial structure of the parent Population.

Warning

Currently unimplemented.

Return type:

BaseStructure

tset(**kwargs)[source]

Deprecated since version 5.0: Use set(parametername=value_array) instead.

abstract write_data(io, variables='all', gather=True, clear=False, annotations=None)[source]

Write recorded data to file, using one of the file formats supported by Neo.

Parameters:
  • io (io or rawio or str) – a Neo IO instance, or a string for where to put a Neo instance

  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    For parallel simulators, if this is True, all data will be gathered to all nodes and the Neo Block will contain data from all nodes. Otherwise, the Neo Block will contain only data from the cells simulated on the local node. This is pointless on sPyNNaker.

    Note

    SpiNNaker always gathers.

  • clear (bool) – clears the storage data if set to true after reading it back

  • annotations (None or dict(str, ...)) – annotations to put on the Neo block

class spynnaker.pyNN.models.populations.PopulationView(parent, selector, label=None)[source]

Bases: PopulationBase

A view of a subset of neurons within a Population.

In most ways, Populations and PopulationViews have the same behaviour, i.e., they can be recorded, connected with Projections, etc. It should be noted that any changes to neurons in a PopulationView will be reflected in the parent Population and vice versa.

It is possible to have views of views.

Note

Selector to Id is actually handled by AbstractSized.

Parameters:
  • parent (Population or PopulationView) – the population or view to make the view from

  • vertex (PopulationApplicationVertex) – The actual underlying vertex

  • recorder (Recorder) – The recorder of the Population

  • selector (None or slice or int or list(bool) or list(int) or ndarray(bool) or ndarray(int)) –

    a slice or numpy mask array. The mask array should either be a boolean array (ideally) of the same size as the parent, or an integer array containing cell indices, i.e. if p.size == 5 then:

    PopulationView(p, array([False, False, True, False, True]))
    PopulationView(p, array([2, 4]))
    PopulationView(p, slice(2, 5, 2))
    

    will all create the same view.

  • label (str) – A label for the view

all()[source]

Iterator over cell IDs (on all MPI nodes).

Return type:

iterable(IDMixin)

property all_cells

An array containing the cell IDs of all neurons in the Population (all MPI nodes).

Return type:

list(IDMixin)

can_record(variable)[source]

Determine whether variable can be recorded from this population.

Return type:

bool

property celltype

The type of neurons making up the underlying Population.

Return type:

AbstractPyNNModel

property conductance_based

Whether the post-synaptic response is modelled as a change in conductance or a change in current.

Return type:

bool

property current_values

A dict containing the current values of the state variables.

Return type:

InitialValuesHolder

describe(template='populationview_default.txt', engine='default')[source]

Returns a human-readable description of the population view.

The output may be customized by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Parameters:
  • template (str) – Template filename

  • engine (str or TemplateEngine or None) – Template substitution engine

Return type:

str or dict

find_units(variable)[source]

Get the units of a variable

Warning

No PyNN description of this method.

Parameters:

variable (str) – The name of the variable

Returns:

The units of the variable

Return type:

str

get(parameter_names, gather=False, simplify=True)[source]

Get the values of the given parameters for every local cell in the population, or, if gather=True, for all cells in the population.

Values will be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Note

SpiNNaker always gathers.

Parameters:
Return type:

ParameterHolder

get_data(variables='all', gather=True, clear=False, annotations=None)[source]

Return a Neo Block containing the data(spikes, state variables) recorded from the Population.

Parameters:
  • variables (str or list(str)) – Either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    For parallel simulators, if gather is True, all data will be gathered to all nodes and the Neo Block will contain data from all nodes. Otherwise, the Neo Block will contain only data from the cells simulated on the local node.

    Note

    SpiNNaker always gathers.

  • clear (bool) – If True, recorded data will be deleted from the Population.

  • annotations (dict(str, ...)) – annotations to put on the neo block

Return type:

Block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

get_spike_counts(gather=True)[source]

Returns a dict containing the number of spikes for each neuron.

The dict keys are neuron IDs, not indices.

Note

Implementation of this method is different to Population as the Populations uses PyNN 7 version of the get_spikes method which does not support indexes.

Parameters:

gather (bool) –

Note

SpiNNaker always gathers.

Return type:

dict(int,int)

property grandparent

The parent Population at the root of the tree (since the immediate parent may itself be a PopulationView).

The name “grandparent” is of course a little misleading, as it could be just the parent, or the great, great, great, …, grandparent.

Return type:

Population

id_to_index(id)[source]

Given the ID(s) of cell(s) in the PopulationView, return its / their index / indices(order in the PopulationView).

assert pv.id_to_index(pv[3]) == 3

Parameters:

id (int or list(int)) –

Return type:

int or list(int)

index_in_grandparent(indices)[source]

Given an array of indices, return the indices in the parent population at the root of the tree.

Parameters:

indices (list(int)) –

Return type:

list(int)

property initial_values

A dict containing the initial values of the state variables.

Return type:

InitialValuesHolder

initialize(**initial_values)[source]

Set initial values of state variables, e.g. the membrane potential. Values passed to initialize() may be:

  • single numeric values (all neurons set to the same value), or

  • RandomDistribution objects, or

  • lists / arrays of numbers of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single number.

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, events per second).

Examples:

p.initialize(v=-70.0)
p.initialize(v=rand_distr, gsyn_exc=0.0)
p.initialize(v=lambda i: -65 + i / 10.0)
inject(current_source)[source]

Injects the specified current_source into this PopulationView.

Parameters:

current_source (AbstractCurrentSource) – the current source to be injected

property label

A label for the Population View.

Return type:

str

property mask

The selector mask that was used to create this view.

Return type:

None or slice or int or list(bool) or list(int) or ndarray(bool) or ndarray(int)

property parent

A reference to the parent Population (that this is a view of).

Return type:

Population

record(variables, to_file=None, sampling_interval=None)[source]

Record the specified variable or variables for all cells in the Population or view.

Parameters:
  • variables (str or list(str)) – either a single variable name, or a list of variable names, or all to record everything. For a given celltype class, celltype.recordable contains a list of variables that can be recorded for that celltype.

  • to_file (io or rawio or str) – If specified, should be a Neo IO instance and write_data() will be automatically called when sim.end() is called.

  • sampling_interval (int) – should be a value in milliseconds, and an integer multiple of the simulation timestep.

sample(n, rng=None)[source]

Randomly sample n cells from the Population view, and return a new PopulationView object.

Parameters:
  • n (int) – The number of cells to select

  • rng (NumpyRNG) – Random number generator

Return type:

PopulationView

set(**parameters)[source]

Set one or more parameters for every cell in the population. Values passed to set() may be:

  • single values,

  • RandomDistribution objects, or

  • lists / arrays of values of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single value.

Here, a “single value” may be either a single number or a list / array of numbers (e.g. for spike times).

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Examples:

p.set(tau_m=20.0, v_rest=-65).
p.set(spike_times=[0.3, 0.7, 0.9, 1.4])
p.set(cm=rand_distr, tau_m=lambda i: 10 + i / 10.0)
set_state(**initial_values)[source]

Set current values of state variables, e.g. the membrane potential. Values passed to initialize() may be:

  • single numeric values (all neurons set to the same value), or

  • RandomDistribution objects, or

  • lists / arrays of numbers of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single number.

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, events per second).

Examples:

p.set_state(v=-70.0)
p.set_state(v=rand_distr, gsyn_exc=0.0)
p.set_state(v=lambda i: -65 + i / 10.0)
property size

The total number of neurons in the Population View.

Return type:

int

spinnaker_get_data(variable, as_matrix=False)[source]

Public accessor for getting data as a numpy array, instead of the Neo-based object

Parameters:
  • variable (str) – a single variable name

  • as_matrix (bool) – If set True the data is returned as a 2d matrix

Returns:

array of the data

Return type:

ndarray

spinnaker_get_spikes()[source]

Public accessor for getting spikes as a numpy array, instead of the Neo-based object

write_data(io, variables='all', gather=True, clear=False, annotations=None)[source]

Write recorded data to file, using one of the file formats supported by Neo.

Parameters:
  • io (neo.io.BaseIO or str) – a Neo IO instance or the name of a file to write

  • variables (str or list(str)) – either a single variable name or a list of variable names. These must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    For parallel simulators, if this is True, all data will be gathered to the master node and a single output file created there. Otherwise, a file will be written on each node, containing only data from the cells simulated on that node.

    Note

    SpiNNaker always gathers.

  • clear (bool) – If this is True, recorded data will be deleted from the Population.

  • annotations (dict(str, ...)) – should be a dict containing simple data types such as numbers and strings. The contents will be written into the output data file as metadata.

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

spynnaker.pyNN.models.spike_source package
Submodules
spynnaker.pyNN.models.spike_source.spike_source_array_machine_vertex module
class spynnaker.pyNN.models.spike_source.spike_source_array_machine_vertex.SpikeSourceArrayMachineVertex(label, vertex_slice=None, app_vertex=None, n_keys=None, receive_port=None, receive_sdp_port=1, receive_tag=None, receive_rate=10, virtual_key=None, prefix=None, prefix_type=None, check_keys=False, send_buffer_times=None, send_buffer_partition_id=None, reserve_reverse_ip_tag=False, injection_partition_id=None)[source]

Bases: ReverseIPTagMulticastSourceMachineVertex

Extended to add colour.

Parameters:
  • label (str or None) – The optional name of the vertex

  • app_vertex (ApplicationVertex or None) – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.

  • vertex_slice (Slice or None) – The slice of the application vertex that this machine vertex implements.

Raises:
get_n_keys_for_partition(partition_id)[source]

Get the number of keys required by the given partition of edges.

Parameters:

partition_id (str) – The identifier of the partition; the partition_id param is only used by some MachineVertex subclasses

Returns:

The number of keys required

Return type:

int

Module contents
class spynnaker.pyNN.models.spike_source.SpikeSourceArray(spike_times=None)[source]

Bases: AbstractPyNNModel

create_vertex(n_neurons, label, splitter, n_colour_bits)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

  • splitter (AbstractSplitterCommon or None) –

  • n_colour_bits (int) –

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

default_population_parameters = {'n_colour_bits': None, 'splitter': None}
class spynnaker.pyNN.models.spike_source.SpikeSourceArrayVertex(n_neurons, spike_times, label, max_atoms_per_core, model, splitter, n_colour_bits)[source]

Bases: ReverseIpTagMultiCastSource, PopulationApplicationVertex, SupportsStructure

Model for play back of spikes.

Parameters:
  • n_keys (int) – The number of keys to be sent via this multicast source

  • label (str) – The label of this vertex

  • max_atoms_per_core (int) –

  • board_address (str or None) – The IP address of the board on which to place this vertex if receiving data, either buffered or live (by default, any board is chosen)

  • receive_port (int or None) – The port on the board that will listen for incoming event packets (default is to disable this feature; set a value to enable it)

  • receive_sdp_port (int) – The SDP port to listen on for incoming event packets (defaults to 1)

  • receive_tag (IPTag) – The IP tag to use for receiving live events (uses any by default)

  • receive_rate (float) – The estimated rate of packets that will be sent by this source

  • virtual_key (int) – The base multicast key to send received events with (assigned automatically by default)

  • prefix (int) – The prefix to “or” with generated multicast keys (default is no prefix)

  • prefix_type (EIEIOPrefix) – Whether the prefix should apply to the upper or lower half of the multicast keys (default is upper half)

  • check_keys (bool) – True if the keys of received events should be verified before sending (default False)

  • send_buffer_times (ndarray(ndarray(numpy.int32)) or list(ndarray(int32)) or None) – An array of arrays of times at which keys should be sent (one array for each key, default disabled)

  • send_buffer_partition_id (str or None) – The ID of the partition containing the edges down which the events are to be sent

  • reserve_reverse_ip_tag (bool) – Extra flag for input without a reserved port

  • injection_partition (str) – If not None, will enable injection and specify the partition to send injected keys with

  • splitter (AbstractSplitterCommon or None) – the splitter object needed for this vertex

SPIKE_RECORDING_REGION_ID = 0
property atoms_shape

The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.

Return type:

tuple(int, …)

create_machine_vertex(vertex_slice, sdram, label=None)[source]

Create a machine vertex from this application vertex.

Parameters:
  • vertex_slice (Slice) – The slice of atoms that the machine vertex will cover.

  • sdram (AbstractSDRAM) – The SDRAM used by the machine vertex.

  • label (str or None) – human readable label for the machine vertex

Returns:

The created machine vertex

Return type:

MachineVertex

describe()[source]

Returns a human-readable description of the cell or synapse type.

The output may be customised by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

get_buffer_data_type(name)[source]

Get the type of data recorded by the buffer manager.

The buffer data type controls how data returned by the cores is handled in NeoBufferDatabase.

Parameters:

name (str) – The name of the variable recorded

Return type:

BufferDatabase

Raises:

KeyError – if the variable isn’t being recorded

get_data_type(name)[source]

Get the type data returned by a recording of the variable.

This is the type of data the C code is returning. For instance data such as spikes this will be None.

Parameters:

name (str) – The name of the variable to get the type of

Return type:

DataType or None

Raises:

KeyError – If the variable isn’t recordable

get_neurons_recording(name, vertex_slice)[source]

Gets the neurons being recorded on the core with this slice.

Typically vertex_slice.get_raster_ids(atoms_shape) but may be a sublist if doing selective recording.

Parameters:
  • name (str) – The name of the variable to get the region of

  • vertex_slice (Slice) –

Returns:

A list of the global raster IDs of the atoms in recording named variable within this slice

Return type:

list(int)

get_parameter_values(names, selector=None)[source]

Get the values of a parameter or parameters for the whole Population or a subset if the selector is used.

Parameters:
Return type:

ParameterHolder

Raises:

KeyError – if the parameter is not something that can be read

get_parameters()[source]

Get the names of all the parameters that can be obtained

Return type:

list(str)

get_recordable_variables()[source]

Get a list of the names and types of things that can be recorded.

This methods list the variable recorded via the Population.

Return type:

list(str)

get_recording_region(name)[source]

Gets the recording region for the named variable.

Parameters:

name (str) – The name of the variable to get the region of

Return type:

int

Raises:

KeyError – If the variable isn’t being recorded

get_recording_variables()[source]

Get a list of variables that are currently being recorded.

Return type:

list(str)

get_sampling_interval_ms(name)[source]

Get the sampling interval of the recording for the given variable.

The values is in ms and unless selective recording is used will be SpynnakerDataView.get_simulation_time_step_us()

Return type:

float

Raises:

KeyError – If the variable isn’t being recorded

get_units(name)[source]

Get the units of the given parameter or state variable.

Parameters:

name (str) – the name of the parameter to get the units of

Return type:

str

Raises:

KeyError – if the name isn’t recognised or the units cannot be identified

property n_colour_bits

The number of colour bits sent by this vertex.

Assumed 0 unless overridden

Return type:

int

set_not_recording(name, indices=None)[source]

Set a variable not recording.

Parameters:
  • name (str) – The name of the variable to not record

  • indices (list(int) or None) – The list of neuron indices to not record or None for all

Raises:

KeyError – if the variable cannot be stopped from recording

set_parameter_values(name, value, selector=None)[source]

Set the values of a parameter for the whole Population or a subset if the selector is used.

Parameters:
Raises:

KeyError – if the parameter is not something that can be changed

set_recording(name, sampling_interval=None, indices=None)[source]

Set a variable recording.

Parameters:
  • name (str) – The name of the variable to set the status of

  • sampling_interval (float or None) – How often the variable should be recorded or None for every time step, in milliseconds

  • indices (list(int) or None) – The list of neuron indices to record or None for all

Raises:

KeyError – if the variable cannot be recorded

set_structure(structure)[source]

Set the structure of the object.

Parameters:

structure (BaseStructure) – The structure to set

class spynnaker.pyNN.models.spike_source.SpikeSourceFromFile(spike_time_file, min_atom=None, max_atom=None, min_time=None, max_time=None, split_value='\t')[source]

Bases: SpikeSourceArray

A spike source that works from a file (typically a tab-separated table in a text file).

property spike_times
class spynnaker.pyNN.models.spike_source.SpikeSourcePoisson(rate=1.0, start=0, duration=None)[source]

Bases: AbstractPyNNModel

absolute_max_atoms_per_core = 500
create_vertex(n_neurons, label, seed, max_rate, splitter, n_colour_bits)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

  • seed (float) –

  • max_rate (float) –

  • splitter (AbstractSplitterCommon or None) –

  • n_colour_bits (int) –

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

default_population_parameters = {'max_rate': None, 'n_colour_bits': None, 'seed': None, 'splitter': None}
class spynnaker.pyNN.models.spike_source.SpikeSourcePoissonMachineVertex(sdram, is_recording, label=None, app_vertex=None, vertex_slice=None)[source]

Bases: MachineVertex, AbstractReceiveBuffersToHost, ProvidesProvenanceDataFromMachineImpl, AbstractHasProfileData, AbstractHasAssociatedBinary, AbstractRewritesDataSpecification, AbstractGeneratesDataSpecification, SendsSynapticInputsOverSDRAM

Parameters:
  • label (str or None) – The optional name of the vertex

  • app_vertex (ApplicationVertex or None) – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.

  • vertex_slice (Slice or None) – The slice of the application vertex that this machine vertex implements.

Raises:
class EXTRA_PROVENANCE_DATA_ENTRIES(value)[source]

Bases: IntEnum

Entries for the provenance data generated by standard neuron models.

TDMA_MISSED_SLOTS = 0

The number of pre-synaptic events

FAST_RATE_PER_TICK_CUTOFF = 10
class POISSON_SPIKE_SOURCE_REGIONS(value)[source]

Bases: IntEnum

Memory region IDs for the the Poisson source code.

EXPANDER_REGION = 7

Data for the on-chip connection generator binaries.

POISSON_PARAMS_REGION = 1

The parameters for the Poisson generator.

PROFILER_REGION = 5

Profiler data.

PROVENANCE_REGION = 4

Provenance data.

RATES_REGION = 2

Spike rates (and the times at which they apply).

SDRAM_EDGE_PARAMS = 6

Parameters for an SDRAM edge.

SPIKE_HISTORY_REGION = 3

Record of when spikes were actually sent.

SYSTEM_REGION = 0

System control information (simulation timestep, etc.)

PROFILE_TAG_LABELS = {0: 'TIMER', 1: 'PROB_FUNC'}
SEED_OFFSET_BYTES = 44
SEED_SIZE_BYTES = 16
SLOW_RATE_PER_TICK_CUTOFF = 0.01
generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

get_n_keys_for_partition(partition_id)[source]

Get the number of keys required by the given partition of edges.

Parameters:

partition_id (str) – The identifier of the partition; the partition_id param is only used by some MachineVertex subclasses

Returns:

The number of keys required

Return type:

int

get_profile_data(placement)[source]

Get the profile data recorded during simulation.

Parameters:

placement (Placement) –

Return type:

ProfileData

get_recorded_region_ids()[source]

Get the recording region IDs that have been recorded using buffering.

Returns:

The region numbers that have active recording

Return type:

iterable(int)

get_recording_region_base_address(placement)[source]

Get the recording region base address.

Parameters:

placement (Placement) – the placement object of the core to find the address of

Returns:

the base address of the recording region

Return type:

int

max_spikes_per_second()[source]

Get maximum expected number of spikes per second.

Parameters:

variable (str) – the variable to find units from

Returns:

the units as a string.

Return type:

str

max_spikes_per_ts()[source]

Get maximum expected number of spikes per timestep.

Return type:

int

parse_extra_provenance_items(label, x, y, p, provenance_data)[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) – The list of words of raw provenance data.

read_parameters_from_machine(placement)[source]
regenerate_data_specification(spec, placement)[source]

Regenerate the data specification, only generating regions that have changed and need to be reloaded.

Parameters:
reload_required()[source]

Return true if any data region needs to be reloaded.

Return type:

bool

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

sdram_requirement(sdram_machine_edge)[source]

Asks a machine vertex for the SDRAM requirement it needs.

Parameters:

sdram_machine_edge (SDRAMMachineEdge) – The SDRAM edge in question

Returns:

The size in bytes this vertex needs for the SDRAM edge.

Return type:

int (most likely a multiple of 4)

set_rate_changed()[source]
set_reload_required(new_value)[source]

Indicate that the regions have been reloaded.

Parameters:

new_value – the new value

set_sdram_partition(sdram_partition)[source]
class spynnaker.pyNN.models.spike_source.SpikeSourcePoissonVariable(rates, starts, durations=None)[source]

Bases: AbstractPyNNModel

absolute_max_atoms_per_core = 500
create_vertex(n_neurons, label, seed, splitter)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

  • seed (float) –

  • splitter (AbstractSplitterCommon or None) –

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

default_population_parameters = {'seed': None, 'splitter': None}
class spynnaker.pyNN.models.spike_source.SpikeSourcePoissonVertex(n_neurons, label, seed, max_atoms_per_core, model, rate=None, start=None, duration=None, rates=None, starts=None, durations=None, max_rate=None, splitter=None, n_colour_bits=None)[source]

Bases: PopulationApplicationVertex, LegacyPartitionerAPI, SupportsStructure

A Poisson Spike source object.

Parameters:
SPIKE_RECORDING_REGION_ID = 0
add_outgoing_projection(projection)[source]

Add an outgoing projection from this vertex.

Parameters:

projection (Projection) – The projection to add

property atoms_shape

The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.

Return type:

tuple(int, …)

clear_spike_recording()[source]
create_machine_vertex(vertex_slice, sdram, label=None)[source]

Create a machine vertex from this application vertex.

Parameters:
  • vertex_slice (Slice) – The slice of atoms that the machine vertex will cover.

  • sdram (AbstractSDRAM) – The SDRAM used by the machine vertex.

  • label (str or None) – human readable label for the machine vertex

Returns:

The created machine vertex

Return type:

MachineVertex

property data
describe()[source]

Return a human-readable description of the cell or synapse type.

The output may be customised by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Return type:

dict(str, …)

get_buffer_data_type(name)[source]

Get the type of data recorded by the buffer manager.

The buffer data type controls how data returned by the cores is handled in NeoBufferDatabase.

Parameters:

name (str) – The name of the variable recorded

Return type:

BufferDatabase

Raises:

KeyError – if the variable isn’t being recorded

get_data_type(name)[source]

Get the type data returned by a recording of the variable.

This is the type of data the C code is returning. For instance data such as spikes this will be None.

Parameters:

name (str) – The name of the variable to get the type of

Return type:

DataType or None

Raises:

KeyError – If the variable isn’t recordable

get_neurons_recording(name, vertex_slice)[source]

Gets the neurons being recorded on the core with this slice.

Typically vertex_slice.get_raster_ids(atoms_shape) but may be a sublist if doing selective recording.

Parameters:
  • name (str) – The name of the variable to get the region of

  • vertex_slice (Slice) –

Returns:

A list of the global raster IDs of the atoms in recording named variable within this slice

Return type:

list(int)

get_parameter_values(names, selector=None)[source]

Get the values of a parameter or parameters for the whole Population or a subset if the selector is used.

Parameters:
Return type:

ParameterHolder

Raises:

KeyError – if the parameter is not something that can be read

get_parameters()[source]

Get the names of all the parameters that can be obtained

Return type:

list(str)

get_recordable_variables()[source]

Get a list of the names and types of things that can be recorded.

This methods list the variable recorded via the Population.

Return type:

list(str)

get_recording_region(name)[source]

Gets the recording region for the named variable.

Parameters:

name (str) – The name of the variable to get the region of

Return type:

int

Raises:

KeyError – If the variable isn’t being recorded

get_recording_sdram_usage(vertex_slice)[source]
Parameters:

vertex_slice (Slice) –

get_recording_variables()[source]

Get a list of variables that are currently being recorded.

Return type:

list(str)

get_sampling_interval_ms(name)[source]

Get the sampling interval of the recording for the given variable.

The values is in ms and unless selective recording is used will be SpynnakerDataView.get_simulation_time_step_us()

Return type:

float

Raises:

KeyError – If the variable isn’t being recorded

get_sdram_used_by_atoms(vertex_slice)[source]

Get the separate SDRAM requirements for a range of atoms.

Parameters:
  • vertex_slice (Slice) – the low value of atoms to calculate resources from

  • vertex_slice

Return type:

AbstractSDRAM

get_units(name)[source]

Get the units of the given parameter or state variable.

Parameters:

name (str) – the name of the parameter to get the units of

Return type:

str

Raises:

KeyError – if the name isn’t recognised or the units cannot be identified

property incoming_control_edge
kiss_seed(vertex_slice)[source]
property max_n_rates
property max_rate
max_spikes_per_ts()[source]
property n_atoms

The number of atoms in the vertex.

Return type:

int

property n_colour_bits

The number of colour bits sent by this vertex.

Assumed 0 unless overridden

Return type:

int

property n_profile_samples
property outgoing_projections

The projections outgoing from this vertex.

Return type:

list(Projection)

property rates

Get the rates.

Return type:

spinn_utilities.ranged.RangedList

property seed
set_live_poisson_control_edge(edge)[source]
set_not_recording(name, indices=None)[source]

Set a variable not recording.

Parameters:
  • name (str) – The name of the variable to not record

  • indices (list(int) or None) – The list of neuron indices to not record or None for all

Raises:

KeyError – if the variable cannot be stopped from recording

set_parameter_values(name, value, selector=None)[source]

Set the values of a parameter for the whole Population or a subset if the selector is used.

Parameters:
Raises:

KeyError – if the parameter is not something that can be changed

set_recording(name, sampling_interval=None, indices=None)[source]

Set a variable recording.

Parameters:
  • name (str) – The name of the variable to set the status of

  • sampling_interval (float or None) – How often the variable should be recorded or None for every time step, in milliseconds

  • indices (list(int) or None) – The list of neuron indices to record or None for all

Raises:

KeyError – if the variable cannot be recorded

set_structure(structure)[source]

Set the structure of the object.

Parameters:

structure (BaseStructure) – The structure to set

property time_to_spike
update_kiss_seed(vertex_slice, seed)[source]

Updates a KISS seed from the machine.

Parameters:
  • vertex_slice (Slice) – the vertex slice to update seed of

  • seed (list(int)) – the seed

spynnaker.pyNN.models.utility_models package
Subpackages
spynnaker.pyNN.models.utility_models.delays package
Module contents
class spynnaker.pyNN.models.utility_models.delays.DelayExtensionMachineVertex(sdram, label, vertex_slice, app_vertex=None)[source]

Bases: MachineVertex, ProvidesProvenanceDataFromMachineImpl, AbstractHasAssociatedBinary, AbstractGeneratesDataSpecification

Parameters:
  • sdram (AbstractSDRAM) – The SDRAM required by the vertex

  • label (str) – The name of the vertex

  • vertex_slice (Slice) – The slice of the vertex

  • app_vertex (ApplicationVertex) – The application vertex that caused this machine vertex to be created. If None, there is no such application vertex.

BACKGROUND_MAX_QUEUED_NAME = 'Max_backgrounds_queued'
BACKGROUND_OVERLOADS_NAME = 'Times_the_background_queue_overloaded'
COUNT_SATURATION_NAME = 'saturation_count'
DELAYED_FOR_TRAFFIC_NAME = 'Number_of_times_delayed_to_spread_traffic'
class EXTRA_PROVENANCE_DATA_ENTRIES(value)[source]

Bases: Enum

Indices into raw provenance data about delay extension vertices.

MAX_BACKGROUND_QUEUED = 10

The maximum number of packets queued for background processing

N_BACKGROUND_OVERLOADS = 11

The number of times the background queue overflowed

N_BUFFER_OVERFLOWS = 4

The number of times a buffer overflowed

N_DELAYS = 5

The number of delays

N_LATE_SPIKES = 9

The number of packets that arrived too late

N_PACKETS_ADDED = 2

The number of packets added to a send queue

N_PACKETS_DROPPED_DUE_TO_INVALID_KEY = 8

The number of packets lost due to an invalid key

N_PACKETS_LOST_DUE_TO_COUNT_SATURATION = 6

The number of packets lost due to saturation

N_PACKETS_PROCESSED = 1

The number of packets processed

N_PACKETS_RECEIVED = 0

The number of packets received

N_PACKETS_SENT = 3

The number of packets sent

N_PACKETS_WITH_INVALID_NEURON_IDS = 7

The number of packets with bad neuron IDs

INPUT_BUFFER_LOST_NAME = 'Times_the_input_buffer_lost_packets'
INVALID_KEY_COUNT_NAME = 'invalid_key_count'
INVALID_NEURON_ID_COUNT_NAME = 'invalid_neuron_count'
MISMATCH_ADDED_FROM_PROCESSED_NAME = 'Number_of_packets_added_to_delay_slot'
N_EXTRA_PROVENANCE_DATA_ENTRIES = 12
N_LATE_SPIKES_NAME = 'Number_of_late_spikes'
N_PACKETS_PROCESSED_NAME = 'Number_of_packets_processed'
N_PACKETS_RECEIVED_NAME = 'Number_of_packets_received'
N_PACKETS_SENT_NAME = 'Number_of_packets_sent'
generate_data_specification(spec, placement)[source]

Generate a data specification.

Parameters:
get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

get_n_keys_for_partition(partition_id)[source]

Get the number of keys required by the given partition of edges.

Parameters:

partition_id (str) – The identifier of the partition; the partition_id param is only used by some MachineVertex subclasses

Returns:

The number of keys required

Return type:

int

parse_extra_provenance_items(label, x, y, p, provenance_data)[source]

Convert the remaining provenance words (those not in the standard set) into provenance items.

Called by get_provenance_data_from_machine()

Parameters:
  • label (str) – A descriptive label for the vertex (derived from label and placed position) to be used for provenance error reporting to the user.

  • x (int) – x coordinate of the chip where this core

  • y (int) – y coordinate of the core where this core

  • p (int) – virtual id of the core

  • provenance_data (list(int)) – The list of words of raw provenance data.

property sdram_required

The SDRAM space required by the vertex.

Return type:

AbstractSDRAM

write_delay_parameters(spec, vertex_slice, key, incoming_key, incoming_mask)[source]

Generate Delay Parameter data.

Parameters:
class spynnaker.pyNN.models.utility_models.delays.DelayExtensionVertex(partition, delay_per_stage, n_delay_stages, n_colour_bits, label='DelayExtension')[source]

Bases: ApplicationVertex, AbstractHasDelayStages

Provide delays to incoming spikes in multiples of the maximum delays of a neuron (typically 16 or 32).

Parameters:
  • partition (ApplicationEdgePartition) – The partition that this delay is supporting

  • delay_per_stage (int) – the delay per stage

  • n_delay_stages (int) – the (initial) number of delay stages needed

  • n_colour_bits (int) – the number of bits for event colouring

  • label (str) – the vertex label

MAX_DTCM_AVAILABLE = 54756
MAX_SLOTS = 8
SAFETY_FACTOR = 5000
add_outgoing_edge(edge)[source]

Add an outgoing edge to the delay extension.

Parameters:

edge (DelayedApplicationEdge) – The edge to add

delay_params_size()[source]

The size of the delay parameters.

Return type:

int

property delay_per_stage

The delay per stage, in timesteps.

Return type:

int

property drop_late_spikes

Whether to drop late spikes.

Return type:

bool

static get_max_delay_ticks_supported(delay_ticks_at_post_vertex)[source]
property n_atoms

The number of atoms in this vertex.

Return type:

int

property n_colour_bits

The number of bits for event colouring.

property n_delay_stages

The maximum number of delay stages required by any connection out of this delay extension vertex.

Return type:

int

property outgoing_edges

The outgoing edges from this vertex.

Return type:

list(DelayedApplicationEdge)

property partition

The partition that this delay is supporting.

set_new_n_delay_stages_and_delay_per_stage(n_delay_stages, delay_per_stage)[source]
property source_vertex
Return type:

ApplicationVertex

spynnaker.pyNN.models.utility_models.spike_injector package
Submodules
spynnaker.pyNN.models.utility_models.spike_injector.spike_injector_vertex module
class spynnaker.pyNN.models.utility_models.spike_injector.spike_injector_vertex.SpikeInjectorVertex(n_neurons, label, port, virtual_key, reserve_reverse_ip_tag, splitter)[source]

Bases: ReverseIpTagMultiCastSource, PopulationApplicationVertex, SupportsStructure

An Injector of Spikes for PyNN populations. This only allows the user to specify the virtual_key of the population to identify the population.

Parameters:
  • n_keys (int) – The number of keys to be sent via this multicast source

  • label (str) – The label of this vertex

  • max_atoms_per_core (int) –

  • board_address (str or None) – The IP address of the board on which to place this vertex if receiving data, either buffered or live (by default, any board is chosen)

  • receive_port (int or None) – The port on the board that will listen for incoming event packets (default is to disable this feature; set a value to enable it)

  • receive_sdp_port (int) – The SDP port to listen on for incoming event packets (defaults to 1)

  • receive_tag (IPTag) – The IP tag to use for receiving live events (uses any by default)

  • receive_rate (float) – The estimated rate of packets that will be sent by this source

  • virtual_key (int) – The base multicast key to send received events with (assigned automatically by default)

  • prefix (int) – The prefix to “or” with generated multicast keys (default is no prefix)

  • prefix_type (EIEIOPrefix) – Whether the prefix should apply to the upper or lower half of the multicast keys (default is upper half)

  • check_keys (bool) – True if the keys of received events should be verified before sending (default False)

  • send_buffer_times (ndarray(ndarray(numpy.int32)) or list(ndarray(int32)) or None) – An array of arrays of times at which keys should be sent (one array for each key, default disabled)

  • send_buffer_partition_id (str or None) – The ID of the partition containing the edges down which the events are to be sent

  • reserve_reverse_ip_tag (bool) – Extra flag for input without a reserved port

  • injection_partition (str) – If not None, will enable injection and specify the partition to send injected keys with

  • splitter (AbstractSplitterCommon or None) – the splitter object needed for this vertex

SPIKE_RECORDING_REGION_ID = 0
property atoms_shape

The “shape” of the atoms in the vertex i.e. how the atoms are split between the dimensions of the vertex. By default everything is 1-dimensional, so the value will be a 1-tuple but can be overridden by a vertex that supports multiple dimensions.

Return type:

tuple(int, …)

default_parameters = {'label': 'spikeInjector', 'port': None, 'virtual_key': None}
describe()[source]

Returns a human-readable description of the cell or synapse type.

The output may be customised by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

get_buffer_data_type(name)[source]

Get the type of data recorded by the buffer manager.

The buffer data type controls how data returned by the cores is handled in NeoBufferDatabase.

Parameters:

name (str) – The name of the variable recorded

Return type:

BufferDatabase

Raises:

KeyError – if the variable isn’t being recorded

get_data_type(name)[source]

Get the type data returned by a recording of the variable.

This is the type of data the C code is returning. For instance data such as spikes this will be None.

Parameters:

name (str) – The name of the variable to get the type of

Return type:

DataType or None

Raises:

KeyError – If the variable isn’t recordable

get_neurons_recording(name, vertex_slice)[source]

Gets the neurons being recorded on the core with this slice.

Typically vertex_slice.get_raster_ids(atoms_shape) but may be a sublist if doing selective recording.

Parameters:
  • name (str) – The name of the variable to get the region of

  • vertex_slice (Slice) –

Returns:

A list of the global raster IDs of the atoms in recording named variable within this slice

Return type:

list(int)

get_recordable_variables()[source]

Get a list of the names and types of things that can be recorded.

This methods list the variable recorded via the Population.

Return type:

list(str)

get_recording_region(name)[source]

Gets the recording region for the named variable.

Parameters:

name (str) – The name of the variable to get the region of

Return type:

int

Raises:

KeyError – If the variable isn’t being recorded

get_recording_variables()[source]

Get a list of variables that are currently being recorded.

Return type:

list(str)

get_sampling_interval_ms(name)[source]

Get the sampling interval of the recording for the given variable.

The values is in ms and unless selective recording is used will be SpynnakerDataView.get_simulation_time_step_us()

Return type:

float

Raises:

KeyError – If the variable isn’t being recorded

get_units(name)[source]

Get the units of the given parameter or state variable.

Parameters:

name (str) – the name of the parameter to get the units of

Return type:

str

Raises:

KeyError – if the name isn’t recognised or the units cannot be identified

set_not_recording(name, indices=None)[source]

Set a variable not recording.

Parameters:
  • name (str) – The name of the variable to not record

  • indices (list(int) or None) – The list of neuron indices to not record or None for all

Raises:

KeyError – if the variable cannot be stopped from recording

set_recording(name, sampling_interval=None, indices=None)[source]

Set a variable recording.

Parameters:
  • name (str) – The name of the variable to set the status of

  • sampling_interval (float or None) – How often the variable should be recorded or None for every time step, in milliseconds

  • indices (list(int) or None) – The list of neuron indices to record or None for all

Raises:

KeyError – if the variable cannot be recorded

set_structure(structure)[source]

Set the structure of the object.

Parameters:

structure (BaseStructure) – The structure to set

Module contents
class spynnaker.pyNN.models.utility_models.spike_injector.SpikeInjector[source]

Bases: AbstractPyNNModel

create_vertex(n_neurons, label, port, virtual_key, reserve_reverse_ip_tag, splitter)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

  • port (int) –

  • virtual_key (int) –

  • reserve_reverse_ip_tag (bool) –

  • splitter (AbstractSplitterCommon or None) –

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

default_population_parameters = {'port': None, 'reserve_reverse_ip_tag': False, 'splitter': None, 'virtual_key': None}
Module contents
Submodules
spynnaker.pyNN.models.abstract_pynn_model module
class spynnaker.pyNN.models.abstract_pynn_model.AbstractPyNNModel[source]

Bases: object

A Model that can be passed in to a Population object in PyNN.

absolute_max_atoms_per_core = 9223372036854775807
abstract create_vertex(n_neurons, label)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

default_initial_values = {}
default_parameters = {}
abstract property default_population_parameters

The default values for the parameters at the population level. These are parameters that can be passed in to the Population constructor in addition to the standard PyNN options.

Return type:

dict(str, Any)

describe(template='modeltype_default.txt', engine='default')[source]

Returns a human-readable description of the population.

The output may be customized by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Parameters:
  • template (str) – Template filename

  • engine (str or TemplateEngine or None) – Template substitution engine

Return type:

str or dict

classmethod get_model_max_atoms_per_dimension_per_core()[source]

Get the maximum number of atoms per dimension per core for this model.

Return type:

int or tuple or None

classmethod get_parameter_names()[source]

Get the names of the parameters of the model.

Return type:

list(str)

classmethod has_parameter(name)[source]

Determine if the model has a parameter with the given name.

Parameters:

name (str) – The name of the parameter to check for

Return type:

bool

property name

The name of this model.

Return type:

str

classmethod set_model_max_atoms_per_dimension_per_core(n_atoms=None)[source]

Set the default maximum number of atoms per dimension per core for this model. This can be overridden by the individual Population. The new value can be None, meaning that the maximum is the same as the number of atoms, an int, meaning all Populations of this model must have one dimension, or a tuple of n integers, meaning all Populations of this model must have n dimensions. If not all Populations of this model have the same number of dimensions, it is recommended to set this to None here and then set the maximum on each Population.

Parameters:

n_atoms (int or tuple or None) – The new maximum, or None for the largest possible

spynnaker.pyNN.models.defaults module
spynnaker.pyNN.models.defaults.default_initial_values(state_variables)[source]

Specifies arguments which are state variables. Only works on the __init__ method of a class that is additionally decorated with defaults()

Parameters:

state_variables (iterable(str)) – The names of the arguments that are state variables

spynnaker.pyNN.models.defaults.default_parameters(parameters)[source]

Specifies arguments which are parameters. Only works on the __init__ method of a class that is additionally decorated with defaults()

Parameters:

parameters (iterable(str)) – The names of the arguments that are parameters

spynnaker.pyNN.models.defaults.defaults(cls)[source]

Get the default parameters and state variables from the arguments to the __init__ method. This uses the decorators default_parameters() and default_initial_values() to determine the parameters and state variables respectively. If only one is specified, the other is assumed to be the remaining arguments. If neither are specified, it is assumed that all default arguments are parameters.

spynnaker.pyNN.models.defaults.get_dict_from_init(init_method, skip=None, include=None)[source]

Get an argument initialisation dictionary by examining an __init__ method or function.

Parameters:
  • init_method (callable) – The method.

  • skip (frozenset(str)) – The arguments to be skipped, if any

  • include (frozenset(str)) – The arguments that must be present, if any

Returns:

an initialisation dictionary

Return type:

dict(str, Any)

spynnaker.pyNN.models.projection module
class spynnaker.pyNN.models.projection.Projection(pre_synaptic_population, post_synaptic_population, connector, synapse_type=None, source=None, receptor_type=None, space=None, label=None)[source]

Bases: object

A container for all the connections of a given type (same synapse type and plasticity mechanisms) between two populations, together with methods to set parameters of those connections, including of plasticity mechanisms.

Parameters:
get(attribute_names, format, gather=True, with_address=True, multiple_synapses='last')[source]

Get a parameter/attribute of the projection.

Note

SpiNNaker always gathers.

Parameters:
  • attribute_names (str or iterable(str)) – list of attributes to gather

  • format (str) – "list" or "array"

  • gather (bool) – gather over all nodes

  • with_address (bool) – True if the source and target are to be included

  • multiple_synapses (str) – What to do with the data if format=”array” and if the multiple source-target pairs with the same values exist. Currently only “last” is supported

Returns:

values selected

getDelays(format='list', gather=True)[source]

Deprecated since version 5.0: Use get('delay') instead.

getSynapseDynamics(parameter_name, format='list', gather=True)[source]

Deprecated since version 5.0: Use get(parameter_name) instead.

getWeights(format='list', gather=True)[source]

Deprecated since version 5.0: Use get('weight') instead.

property label
Return type:

str

property post

The post-population or population view.

Return type:

PopulationBase

property pre

The pre-population or population view.

Return type:

PopulationBase

printDelays(file, format='list', gather=True)[source]

Deprecated since version 5.0: Use save('delay') instead.

Print synaptic weights to file. In the array format, zeros are printed for non-existent connections.

printWeights(file, format='list', gather=True)[source]

Deprecated since version 5.0: Use save('weight') instead.

save(attribute_names, file, format='list', gather=True, with_address=True)[source]

Print synaptic attributes (weights, delays, etc.) to file. In the array format, zeros are printed for non-existent connections. Values will be expressed in the standard PyNN units (i.e., millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Note

SpiNNaker always gathers.

Parameters:
  • attribute_names (str or list(str)) –

  • file (str or pyNN.recording.files.BaseFile) – filename or open handle (which will be closed)

  • format (str) –

  • gather (bool) – Ignored

  • with_address (bool) –

saveConnections(file, gather=True, compatible_output=True)[source]

Deprecated since version 5.0: Use save('all') instead.

set(**attributes)[source]

Warning

Not implemented.

size(gather=True)[source]

Return the total number of connections.

Note

SpiNNaker always gathers.

Warning

Not implemented.

Parameters:

gather (bool) – If False, only get the number of connections locally.

weightHistogram(min=None, max=None, nbins=10)[source]

Deprecated since version 5.0: Use numpy.histogram on the weights instead.

Return a histogram of synaptic weights. If min and max are not given, the minimum and maximum weights are calculated automatically.

spynnaker.pyNN.models.recorder module
class spynnaker.pyNN.models.recorder.Recorder(population, vertex)[source]

Bases: object

Object to hold recording behaviour, used by populations.

Parameters:
  • population (Population) – the population to record for

  • vertex (ApplicationVertex) – the SpiNNaker graph vertex used by the population

cache_data()[source]

Store data for later extraction.

csv_neo_block(csv_file, variables, view_indexes=None, annotations=None)[source]

Extracts block from the vertices and puts them into a Neo block.

Parameters:
  • variables (list(str)) – the variables to extract

  • variables – the variables to extract

  • view_indexes (slice) – the indexes to be included in the view

  • annotations (dict(str,object)) – annotations to put on the Neo block

Returns:

The Neo block

Return type:

Block

Raises:

ConfigurationException – If the recording not setup correctly

extract_neo_block(variables, view_indexes, clear, annotations)[source]

Extracts block from the vertices and puts them into a Neo block.

Parameters:
  • variables (list(str)) – the variables to extract

  • view_indexes (slice) – the indexes to be included in the view

  • clear (bool) – if the variables should be cleared after reading

  • annotations (dict(str,object)) – annotations to put on the Neo block

Returns:

The Neo block

Return type:

Block

Raises:

ConfigurationException – If the recording not setup correctly

record(variables, to_file, sampling_interval, indexes)[source]

Turns on (or off) recording.

Parameters:
  • variables (str or list(str) or None) – either a single variable name or a list of variable names. For a given celltype class, celltype.recordable contains a list of variables that can be recorded for that celltype. Can also be None to reset the list of variables.

  • to_file (io or rawio or str) – a file to automatically record to (optional). write_data() will be automatically called when sim.end() is called.

  • sampling_interval (int) – a value in milliseconds, and an integer multiple of the simulation timestep.

  • indexes (None or list(int)) – The indexes of neurons to record from. This is non-standard PyNN and equivalent to creating a view with these indexes and asking the View to record.

property recording_label
turn_off_all_recording(indexes=None)[source]

Turns off recording, is used by a pop saying .record().

Parameters:

indexes (list or None) –

turn_on_record(variable, sampling_interval=None, to_file=None, indexes=None)[source]

Tell the vertex to record data.

Parameters:
  • variable (str) – The variable to record, supported variables to record are: gsyn_exc, gsyn_inh, v, spikes.

  • sampling_interval (int) – the interval to record them

  • to_file (neo.io.baseio.BaseIO or str or None) – If set, a file to write to (by handle or name)

  • indexes (list(int) or None) – List of indexes to record or None for all

Raises:
property write_to_files_indicators

What variables should be written to files, and where should they be written.

Return type:

dict(str, neo.io.baseio.BaseIO or str or None)

Module contents
spynnaker.pyNN.protocols package
Module contents
class spynnaker.pyNN.protocols.MUNICH_MODES(value)[source]

Bases: Enum

Types of modes supported by this protocol.

BALL_BALANCER = 3
FREE = 5
MY_ORO_BOTICS = 4
PUSH_BOT = 1
RESET_TO_DEFAULT = 0
SPOMNIBOT = 2
class spynnaker.pyNN.protocols.MunichIoEthernetProtocol[source]

Bases: object

Implementation of the Munich robot IO protocol, communicating over Ethernet.

static disable_motor()[source]
static disable_retina()[source]
static enable_motor()[source]
static enable_retina()[source]
static laser_active_time(active_time)[source]
static laser_frequency(frequency)[source]
static laser_total_period(total_period)[source]
static led_back_active_time(active_time)[source]
static led_frequency(frequency)[source]
static led_front_active_time(active_time)[source]
static led_total_period(total_period)[source]
static motor_0_leaky_velocity(velocity)[source]
static motor_0_permanent_velocity(velocity)[source]
static motor_1_leaky_velocity(velocity)[source]
static motor_1_permanent_velocity(velocity)[source]
static set_retina_transmission(event_format)[source]
static speaker_active_time(active_time)[source]
static speaker_frequency(frequency)[source]
static speaker_total_period(total_period)[source]
class spynnaker.pyNN.protocols.MunichIoSpiNNakerLinkProtocol(mode, instance_key=None, uart_id=0)[source]

Bases: object

Provides Multicast commands for the Munich SpiNNaker-Link protocol.

Parameters:
  • mode (MUNICH_MODES) – The mode of operation of the protocol

  • instance_key (int or None) – The optional instance key to use

  • uart_id (int) – The ID of the UART when needed

add_payload_logic_to_current_output(payload, time=None)[source]
property add_payload_logic_to_current_output_key
bias_values(bias_id, bias_value, time=None)[source]
property bias_values_key
configure_master_key(new_key, time=None)[source]
property configure_master_key_key
disable_retina(time=None)[source]
property disable_retina_key
property enable_disable_motor_key
generic_motor0_raw_output_leak_to_0(pwm_signal, time=None)[source]
property generic_motor0_raw_output_leak_to_0_key
generic_motor0_raw_output_permanent(pwm_signal, time=None)[source]
property generic_motor0_raw_output_permanent_key
generic_motor1_raw_output_leak_to_0(pwm_signal, time=None)[source]
property generic_motor1_raw_output_leak_to_0_key
generic_motor1_raw_output_permanent(pwm_signal, time=None)[source]
property generic_motor1_raw_output_permanent_key
generic_motor_disable(time=None)[source]
generic_motor_enable(time=None)[source]
generic_motor_total_period(time_in_ms, time=None)[source]
property generic_motor_total_period_key
property instance_key

The key of this instance of the protocol.

Return type:

int

property master_slave_key
master_slave_set_master_clock_active(time=None)[source]
master_slave_set_master_clock_not_started(time=None)[source]
master_slave_set_slave(time=None)[source]
master_slave_use_internal_counter(time=None)[source]
property mode
Return type:

MUNICH_MODES

poll_individual_sensor_continuously(sensor_id, time_in_ms, time=None)[source]
property poll_individual_sensor_continuously_key
poll_sensors_once(sensor_id, time=None)[source]
property poll_sensors_once_key
protocol_instance = 0
push_bot_laser_config_active_time(active_time, time=None)[source]
property push_bot_laser_config_active_time_key
push_bot_laser_config_total_period(total_period, time=None)[source]
property push_bot_laser_config_total_period_key
push_bot_laser_set_frequency(frequency, time=None)[source]
property push_bot_laser_set_frequency_key
push_bot_led_back_active_time(active_time, time=None)[source]
property push_bot_led_back_active_time_key
push_bot_led_front_active_time(active_time, time=None)[source]
property push_bot_led_front_active_time_key
push_bot_led_set_frequency(frequency, time=None)[source]
property push_bot_led_set_frequency_key
push_bot_led_total_period(total_period, time=None)[source]
property push_bot_led_total_period_key
push_bot_motor_0_leaking_towards_zero(velocity, time=None)[source]
property push_bot_motor_0_leaking_towards_zero_key
push_bot_motor_0_permanent(velocity, time=None)[source]
property push_bot_motor_0_permanent_key
push_bot_motor_1_leaking_towards_zero(velocity, time=None)[source]
property push_bot_motor_1_leaking_towards_zero_key
push_bot_motor_1_permanent(velocity, time=None)[source]
property push_bot_motor_1_permanent_key
push_bot_speaker_config_active_time(active_time, time=None)[source]
property push_bot_speaker_config_active_time_key
push_bot_speaker_config_total_period(total_period, time=None)[source]
property push_bot_speaker_config_total_period_key
push_bot_speaker_set_melody(melody, time=None)[source]
property push_bot_speaker_set_melody_key
push_bot_speaker_set_tone(frequency, time=None)[source]
property push_bot_speaker_set_tone_key
pwm_pin_output_timer_a_channel_0_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_a_channel_0_ratio_key
pwm_pin_output_timer_a_channel_1_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_a_channel_1_ratio_key
pwm_pin_output_timer_a_duration(timer_period, time=None)[source]
property pwm_pin_output_timer_a_duration_key
pwm_pin_output_timer_b_channel_0_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_b_channel_0_ratio_key
pwm_pin_output_timer_b_channel_1_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_b_channel_1_ratio_key
pwm_pin_output_timer_b_duration(timer_period, time=None)[source]
property pwm_pin_output_timer_b_duration_key
pwm_pin_output_timer_c_channel_0_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_c_channel_0_ratio_key
pwm_pin_output_timer_c_channel_1_ratio(timer_period, time=None)[source]
property pwm_pin_output_timer_c_channel_1_ratio_key
pwm_pin_output_timer_c_duration(timer_period, time=None)[source]
property pwm_pin_output_timer_c_duration_key
query_state_of_io_lines(time=None)[source]
property query_state_of_io_lines_key
remove_payload_logic_to_current_output(payload, time=None)[source]
property remove_payload_logic_to_current_output_key
reset_retina(time=None)[source]
property reset_retina_key
sensor_transmission_key(sensor_id)[source]
static sent_mode_command()[source]

True if the mode command has ever been requested by any instance.

set_mode(time=None)[source]
property set_mode_key
set_output_pattern_for_payload(payload, time=None)[source]
property set_output_pattern_for_payload_key
set_payload_pins_to_high_impedance(payload, time=None)[source]
property set_payload_pins_to_high_impedance_key
set_retina_key(new_key, time=None)[source]
property set_retina_key_key
set_retina_transmission(retina_key=RetinaKey.NATIVE_128_X_128, retina_payload=None, time=None)[source]

Set the retina transmission key.

Parameters:
  • retina_key (RetinaKey) – the new key for the retina

  • retina_payload (RetinaPayload or None) – the new payload for the set retina key command packet

  • time (int or float or None) – when to transmit this packet

Returns:

the command to send

Return type:

MultiCastCommand

property set_retina_transmission_key
turn_off_sensor_reporting(sensor_id, time=None)[source]
property turn_off_sensor_reporting_key
property uart_id
Return type:

int

class spynnaker.pyNN.protocols.RetinaKey(value)[source]

Bases: Enum

An enumeration.

DOWNSAMPLE_16_X_16 = 268435456
DOWNSAMPLE_32_X_32 = 201326592
DOWNSAMPLE_64_X_64 = 134217728
FIXED_KEY = 0
NATIVE_128_X_128 = 67108864
property bits_per_coordinate
property n_neurons
property pixels
class spynnaker.pyNN.protocols.RetinaPayload(value)[source]

Bases: Enum

An enumeration.

ABSOLUTE_2_BYTE_TIMESTAMPS = 1073741824
ABSOLUTE_3_BYTE_TIMESTAMPS = 1610612736
ABSOLUTE_4_BYTE_TIMESTAMPS = 2147483648
DELTA_TIMESTAMPS = 536870912
EVENTS_IN_PAYLOAD = 0
NO_PAYLOAD = 0
property n_payload_bytes
spynnaker.pyNN.utilities package
Subpackages
spynnaker.pyNN.utilities.random_stats package
Module contents
class spynnaker.pyNN.utilities.random_stats.AbstractRandomStats[source]

Bases: object

Statistics about PyNN ~spynnaker.pyNN.RandomDistribution objects.

abstract cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

abstract high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

abstract low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

abstract mean(dist)[source]

Return the mean of the distribution.

abstract ppf(dist, p)[source]

Return the percent point function value for the probability p.

abstract std(dist)[source]

Return the standard deviation of the distribution.

abstract var(dist)[source]

Return the variance of the distribution.

class spynnaker.pyNN.utilities.random_stats.RandomStatsBinomialImpl[source]

Bases: AbstractRandomStats

An implementation of AbstractRandomStats for binomial distributions.

cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

mean(dist)[source]

Return the mean of the distribution.

ppf(dist, p)[source]

Return the percent point function value for the probability p.

std(dist)[source]

Return the standard deviation of the distribution.

var(dist)[source]

Return the variance of the distribution.

class spynnaker.pyNN.utilities.random_stats.RandomStatsExponentialImpl[source]

Bases: AbstractRandomStats

An implementation of AbstractRandomStats for exponential distributions.

cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

mean(dist)[source]

Return the mean of the distribution.

ppf(dist, p)[source]

Return the percent point function value for the probability p.

std(dist)[source]

Return the standard deviation of the distribution.

var(dist)[source]

Return the variance of the distribution.

class spynnaker.pyNN.utilities.random_stats.RandomStatsGammaImpl[source]

Bases: AbstractRandomStats

An implementation of AbstractRandomStats for gamma distributions.

cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

mean(dist)[source]

Return the mean of the distribution.

ppf(dist, p)[source]

Return the percent point function value for the probability p.

std(dist)[source]

Return the standard deviation of the distribution.

var(dist)[source]

Return the variance of the distribution.

class spynnaker.pyNN.utilities.random_stats.RandomStatsLogNormalImpl[source]

Bases: AbstractRandomStats

An implementation of AbstractRandomStats for log normal distributions.

cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

mean(dist)[source]

Return the mean of the distribution.

ppf(dist, p)[source]

Return the percent point function value for the probability p.

std(dist)[source]

Return the standard deviation of the distribution.

var(dist)[source]

Return the variance of the distribution.

class spynnaker.pyNN.utilities.random_stats.RandomStatsNormalClippedImpl[source]

Bases: AbstractRandomStats

An implementation of AbstractRandomStats for normal distributions that are clipped to a boundary (redrawn).

cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

mean(dist)[source]

Return the mean of the distribution.

ppf(dist, p)[source]

Return the percent point function value for the probability p.

std(dist)[source]

Return the standard deviation of the distribution.

var(dist)[source]

Return the variance of the distribution.

class spynnaker.pyNN.utilities.random_stats.RandomStatsNormalImpl[source]

Bases: AbstractRandomStats

An implementation of AbstractRandomStats for normal distributions.

cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

mean(dist)[source]

Return the mean of the distribution.

ppf(dist, p)[source]

Return the percent point function value for the probability p.

std(dist)[source]

Return the standard deviation of the distribution.

var(dist)[source]

Return the variance of the distribution.

class spynnaker.pyNN.utilities.random_stats.RandomStatsPoissonImpl[source]

Bases: AbstractRandomStats

An implementation of AbstractRandomStats for Poisson distributions.

cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

mean(dist)[source]

Return the mean of the distribution.

ppf(dist, p)[source]

Return the percent point function value for the probability p.

std(dist)[source]

Return the standard deviation of the distribution.

var(dist)[source]

Return the variance of the distribution.

class spynnaker.pyNN.utilities.random_stats.RandomStatsRandIntImpl[source]

Bases: AbstractRandomStats

An implementation of AbstractRandomStats for uniform distributions.

cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

mean(dist)[source]

Return the mean of the distribution.

ppf(dist, p)[source]

Return the percent point function value for the probability p.

std(dist)[source]

Return the standard deviation of the distribution.

var(dist)[source]

Return the variance of the distribution.

class spynnaker.pyNN.utilities.random_stats.RandomStatsScipyImpl(distribution_type)[source]

Bases: AbstractRandomStats

A Random Statistics object that uses scipy directly.

cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

mean(dist)[source]

Return the mean of the distribution.

ppf(dist, p)[source]

Return the percent point function value for the probability p.

std(dist)[source]

Return the standard deviation of the distribution.

var(dist)[source]

Return the variance of the distribution.

class spynnaker.pyNN.utilities.random_stats.RandomStatsUniformImpl[source]

Bases: AbstractRandomStats

An implementation of AbstractRandomStats for uniform distributions.

cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

mean(dist)[source]

Return the mean of the distribution.

ppf(dist, p)[source]

Return the percent point function value for the probability p.

std(dist)[source]

Return the standard deviation of the distribution.

var(dist)[source]

Return the variance of the distribution.

class spynnaker.pyNN.utilities.random_stats.RandomStatsVonmisesImpl[source]

Bases: AbstractRandomStats

An implementation of AbstractRandomStats for von Mises distributions.

cdf(dist, v)[source]

Return the cumulative distribution function value for the value v.

high(distribution)[source]

Return the high cut-off value of the distribution, or None if the distribution is unbounded.

low(distribution)[source]

Return the low cut-off value of the distribution, or None if the distribution is unbounded.

mean(dist)[source]

Return the mean of the distribution.

ppf(dist, p)[source]

Return the percent point function value for the probability p.

std(dist)[source]

Return the standard deviation of the distribution.

var(dist)[source]

Return the variance of the distribution.

spynnaker.pyNN.utilities.ranged package
Module contents
class spynnaker.pyNN.utilities.ranged.SpynnakerRangedList(size=None, value=None, key=None, use_list_as_value=False)[source]

Bases: RangedList

Adds support for RandomDistribution to RangedList.

Parameters:
  • size (int or None) – Fixed length of the list; if None, the value must be a sized object.

  • value (object or Sized) – value to given to all elements in the list

  • key – The dict key this list covers. This is used only for better Exception messages

  • use_list_as_value (bool) – True if the value is a list

static as_list(value, size, ids=None)[source]

Converts (if required) the value into a list of a given size. An exception is raised if value cannot be given size elements.

Note

This method can be extended to add other conversions to list in which case is_list() must also be extended.

Parameters:

value

Returns:

value as a list

Raises:

Exception – if the number of values and the size do not match

static is_list(value, size)[source]

Determines if the value should be treated as a list.

Note

This method can be extended to add other checks for list in which case as_list() must also be extended.

Parameters:

value – The value to examine.

Submodules
spynnaker.pyNN.utilities.bit_field_utilities module
spynnaker.pyNN.utilities.bit_field_utilities.FILTER_HEADER_WORDS = 2

n_filters, pointer for array

spynnaker.pyNN.utilities.bit_field_utilities.get_bitfield_key_map_data(incoming_projections)[source]

Get data for the key map region.

Parameters:

incoming_projections (iterable(Projection)) – The projections to generate bitfields for

Return type:

ndarray

spynnaker.pyNN.utilities.bit_field_utilities.get_sdram_for_bit_field_region(incoming_projections)[source]

The SDRAM for the bit field filter region.

Parameters:

incoming_projections (iterable(Projection)) – The projections that target the vertex in question

Returns:

the estimated number of bytes used by the bit field region

Return type:

int

spynnaker.pyNN.utilities.bit_field_utilities.get_sdram_for_keys(incoming_projections)[source]

Gets the space needed for keys.

Parameters:

incoming_projections (iterable(Projection)) – The projections that target the vertex in question

Returns:

SDRAM needed

Return type:

int

spynnaker.pyNN.utilities.bit_field_utilities.write_bitfield_init_data(spec, bit_field_region, n_bit_field_bytes, bit_field_region_ref=None)[source]

Writes the initialisation data needed for the bitfield generator.

Parameters:
  • spec (DataSpecificationGenerator) – data specification writer

  • bit_field_region (int) – the region ID for the bit-field filters

  • n_bit_field_bytes (int) – the size of the region

  • bit_field_region_ref (int) – The reference to the region

spynnaker.pyNN.utilities.buffer_data_type module
class spynnaker.pyNN.utilities.buffer_data_type.BufferDataType(value)[source]

Bases: Enum

Different functions to retrieve the data.

This class is designed to used internally by NeoBufferDatabase

EIEIO_SPIKES = 2
MATRIX = 4
MULTI_SPIKES = 3
NEURON_SPIKES = 1
NOT_NEO = 6
REWIRES = 5
spynnaker.pyNN.utilities.constants module
spynnaker.pyNN.utilities.constants.LIVE_POISSON_CONTROL_PARTITION_ID = 'CONTROL'

The partition ID used for Poisson live control data

spynnaker.pyNN.utilities.constants.MIN_SUPPORTED_DELAY = 1

the minimum supported delay slot between two neurons

spynnaker.pyNN.utilities.constants.OUT_SPIKE_BYTES = 32

The number of bytes for each spike line

spynnaker.pyNN.utilities.constants.OUT_SPIKE_SIZE = 8

The size of each output spike line

spynnaker.pyNN.utilities.constants.POP_TABLE_MAX_ROW_LENGTH = 256

The maximum row length of the master population table

spynnaker.pyNN.utilities.constants.SPIKE_PARTITION_ID = 'SPIKE'

The partition ID used for spike data

spynnaker.pyNN.utilities.constants.SYNAPSE_SDRAM_PARTITION_ID = 'SDRAM Synaptic Inputs'

The name of the partition for Synaptic SDRAM

spynnaker.pyNN.utilities.constants.SYNAPTIC_ROW_HEADER_WORDS = 3

Words: 2 for row length and number of rows and 1 for plastic region size (which might be 0)

spynnaker.pyNN.utilities.constants.WRITE_BANDWIDTH_BYTES_PER_SECOND = 262144000

The conservative amount of write bandwidth available on a chip

spynnaker.pyNN.utilities.data_population module
class spynnaker.pyNN.utilities.data_population.DataPopulation(database_file, label, indexes=None)[source]

Bases: object

describe(template=None, engine=None)[source]

Returns a human-readable description of the population.

The output may be customized by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Parameters:
  • template (str) – Template filename

  • engine (str or TemplateEngine or None) – Template substitution engine

Return type:

str or dict

find_units(variable)[source]

Get the units of a variable.

Parameters:

variable (str) – The name of the variable

Returns:

The units of the variable

Return type:

str

get_data(variables='all', gather=True, clear=False, annotations=None)[source]

Return a Neo Block containing the data (spikes, state variables) recorded from the Assembly.

Parameters:
  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    Whether to collect data from all MPI nodes or just the current node.

    Note

    This is irrelevant on sPyNNaker, which always behaves as if this parameter is True.

  • clear (bool) – Whether recorded data will be deleted from the Assembly.

  • annotations (dict(str, ...)) – annotations to put on the neo block

Return type:

Block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

get_spike_counts(gather=True)[source]

Return the number of spikes for each neuron.

Return type:

ndarray

id_to_index(id)[source]

Given the ID(s) of cell(s) in the Population, return its (their) index (order in the Population).

Defined by https://neuralensemble.org/docs/PyNN/reference/populations.html

Parameters:

id (int or iterable(int)) –

Return type:

int or iterable(int)

index_to_id(index)[source]

Given the index (order in the Population) of cell(s) in the Population, return their ID(s)

Parameters:

index (int or iterable(int)) –

Return type:

int or iterable(int)

property label
property local_size
mean_spike_count(gather=True)[source]

Returns the mean number of spikes per neuron.

Parameters:

gather (bool) –

For parallel simulators, if this is True, all data will be gathered to all nodes and the Neo Block will contain data from all nodes. Otherwise, the Neo Block will contain only data from the cells simulated on the local node.

Note

SpiNNaker always gathers.

Return type:

float

property size
spinnaker_get_data(variable, as_matrix=False, view_indexes=None)[source]

Public accessor for getting data as a numpy array, instead of the Neo-based object

Parameters:
  • variable (str or list(str)) – a single variable name.

  • as_matrix (bool) – If set True the data is returned as a 2d matrix

  • view_indexes – The indexes for which data should be returned. If None, all data (view_index = data_indexes)

Returns:

array of the data

Return type:

ndarray

write_data(io, variables='all', gather=True, clear=False, annotations=None)[source]

Write recorded data to file, using one of the file formats supported by Neo.

Parameters:
  • io (neo.io.baseio.BaseIO or str) – a Neo IO instance, or a string for where to put a neo instance

  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    Whether to bring all relevant data together.

    Note

    SpiNNaker always gathers.

  • clear (bool) – clears the storage data if set to true after reading it back

  • annotations (dict(str, ...)) – annotations to put on the neo block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

spynnaker.pyNN.utilities.extracted_data module
class spynnaker.pyNN.utilities.extracted_data.ExtractedData[source]

Bases: object

Data holder for all synaptic data being extracted in parallel.

get(projection, attribute)[source]

Allow getting data from a given projection and attribute.

Parameters:
  • projection (Projection) – the projection data was extracted from

  • attribute (list(int) or tuple(int) or None) – the attribute to retrieve

Returns:

the attribute data in a connection holder

Return type:

ConnectionHolder

set(projection, attribute, data)[source]

Allow the addition of data from a projection and attribute.

Parameters:
  • projection (Projection) – the projection data was extracted from

  • attribute (list(int) or tuple(int) or None) – the attribute to store

  • data (ConnectionHolder) – attribute data in a connection holder

spynnaker.pyNN.utilities.fake_HBP_Portal_machine_provider module
class spynnaker.pyNN.utilities.fake_HBP_Portal_machine_provider.FakeHBPPortalMachineProvider(n_boards, config)[source]

Bases: object

create()[source]
destroy()[source]
get_machine_info()[source]
wait_till_not_ready()[source]
wait_until_ready()[source]
spynnaker.pyNN.utilities.neo_buffer_database module
class spynnaker.pyNN.utilities.neo_buffer_database.NeoBufferDatabase(database_file=None, read_only=None)[source]

Bases: BufferDatabase, NeoCsv

Extra support for Neo on top of the Database for SQLite 3.

This is the same database as used by BufferManager but with extra tables and access methods added.

Parameters:
  • database_file (None or str) – The name of a file that contains (or will contain) an SQLite database holding the data. If omitted the default location will be used.

  • read_only (bool) – By default the database is read-only if given a database file. This allows to override that (mainly for clear)

add_segment(block, pop_label, variables, view_indexes=None)[source]

Adds a segment to the block.

Parameters:
  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

  • variables (str, list(str) or None) – One or more variable names or None for all available

  • view_indexes (None or list(int)) – List of neurons IDs to include or None for all

Raises:

ConfigurationException – If the recording metadata not setup correctly

static array_to_string(indexes)[source]

Converts a list of integers into a compact string. Works best if the list is sorted.

IDs are comma separated, except when a series of IDs is sequential then the start:end is used.

Parameters:

indexes (list(int)) –

Return type:

str

clear_data(pop_label, variables)[source]

Clears the data for one population and given variables.

Parameters:
  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typical the Population label, corrected for None or duplicate values

  • variables (list(str)) – names of variable to get data for

csv_block_metadata(csv_file, pop_label, annotations=None)[source]

Writes the data including metadata to a CSV file. Overwrites any previous data in the file.

Parameters:
  • csvfile (str) – Path to file to write block metadata to

  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

  • annotations (None or dict(str, ...)) – annotations to put on the neo block

Raises:

ConfigurationException – If the recording metadata not setup correctly

csv_segment(csv_file, pop_label, variables, view_indexes=None)[source]

Writes the data including metadata to a CSV file.

Parameters:
  • csvfile (str) – Path to file to write block metadata to

  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typical the Population label, corrected for None or duplicate values

  • variables (str, list(str) or None) – One or more variable names or None for all available

  • view_indexes (None or list(int)) – List of neurons IDs to include or None for all

Raises:

ConfigurationException – If the recording metadata not setup correctly

get_empty_block(pop_label, annotations=None)[source]

Creates a block with just metadata but not data segments.

Parameters:
  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

  • variables (str, list(str) or None) – One or more variable names or None for all available

  • view_indexes (None or list(int)) – List of neurons IDs to include or None for all

  • annotations (None or dict(str, ...)) – annotations to put on the neo block

Returns:

The Neo block

Return type:

Block

Raises:

ConfigurationException – If the recording metadata not setup correctly

get_full_block(pop_label, variables, view_indexes, annotations)[source]

Creates a block with metadata and data for this segment. Any previous segments will be empty.

Parameters:
  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

  • variables (str, list(str) or None) – One or more variable names or None for all available

  • view_indexes (None or list(int)) – List of neurons IDs to include or None for all

  • annotations (None or dict(str, ...)) – annotations to put on the neo block

Returns:

The Neo block

Return type:

Block

get_population(pop_label)[source]

Gets an Object with the same data retrieval API as a Population.

Retrieval is limited to recorded data and a little metadata needed to create a single Neo Segment wrapped in a Neo Block.

Note

As each database only includes data for one run (with resets creating another database) the structure is relatively simple.

Parameters:

pop_label (str) –

The label for the population of interest

Note

This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

Returns:

An Object which acts like a Population for getting neo data

Return type:

DataPopulation

get_population_metdadata(pop_label)[source]

Gets the metadata for the population with this label

Parameters:

pop_label (str) –

The label for the population of interest

Note

This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

Returns:

population size, first id and description

Return type:

(int, int, str)

Raises:

ConfigurationException – If the recording metadata not setup correctly

get_recording_metadeta(pop_label, variable)[source]

Gets the metadata ID for this population and recording label combination.

Parameters:
  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

  • variable (str) –

Returns:

data_type, t_start, sampling_interval_ms, first_id, pop_size, units

Return type:

(DataType, float, float, int, int, str)

Raises:

ConfigurationException – If the recording metadata not setup correctly

get_recording_populations()[source]

Gets a list of the labels of Populations recording. Or to be exact the ones with metadata saved so likely to be recording.

Note

These are actually the labels of the Application Vertices. Typically the Population label, corrected for None or duplicate values

Returns:

List of population labels

Return type:

list(str)

get_recording_variables(pop_label)[source]

List of the names of variables recording. Or, to be exact, list of the names of variables with metadata so likely to be recording.

Parameters:

pop_label (str) –

The label for the population of interest

Note

This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

Returns:

List of variable names

get_spike_counts(pop_label, view_indexes=None)[source]
spinnaker_get_data(pop_label, variable, as_matrix=False, view_indexes=None)[source]
static string_to_array(string)[source]

Converts a string into a list of integers. Assumes the string was created by array_to_string()

Parameters:

string (str) –

Return type:

list(int)

write_metadata()[source]

Write the current metadata to the database.

Note

The database must be writable for this to work!

write_segment_metadata()[source]

Writes the global information from the Views.

This writes information held in SpynnakerDataView so that the database is usable stand-alone.

Note

The database must be writable for this to work!

write_t_stop()[source]

Records the current run time as t_Stop.

This writes information held in SpynnakerDataView so that the database is usable stand-alone.

Note

The database must be writable for this to work!

spynnaker.pyNN.utilities.neo_compare module
spynnaker.pyNN.utilities.neo_compare.compare_analogsignal(as1, as2, same_length=True)[source]

Compares two analog signal objects to see if they are the same.

Parameters:
  • as1 (AnalogSignal) – first analog signal holding list of individual analog signal objects

  • as2 (AnalogSignal) – second analog signal holding list of individual analog signal objects

  • same_length (bool) – Flag to indicate if the same length of data is held, i.e., all spikes up to the same time. If False allows one trains to have additional data after the first ends. This is used to compare data extracted part way with data extracted at the end.

Raises:

AssertionError – If the analog signals are not equal

spynnaker.pyNN.utilities.neo_compare.compare_blocks(neo1, neo2, same_runs=True, same_data=True, same_length=True)[source]

Compares two neo Blocks to see if they hold the same data.

Parameters:
  • neo1 (Block) – First block to check

  • neo2 (Block) – Second block to check

  • same_runs (bool) – Flag to signal if blocks are the same length. If False extra segments in the larger block are ignored

  • same_data (bool) – Flag to indicate if the same type of data is held, i.e., same spikes, v, gsyn_exc and gsyn_inh. If False only data in both blocks is compared

  • same_length (bool) – Flag to indicate if the same length of data is held, i.e., all spikes up to the same time. If False allows one trains to have additional data after the first ends. This is used to compare data extracted part way with data extracted at the end.

Raises:

AssertionError – If the blocks are not equal

spynnaker.pyNN.utilities.neo_compare.compare_segments(seg1, seg2, same_data=True, same_length=True)[source]
Parameters:
  • seg1 (Segment) – First Segment to check

  • seg2 (Segment) – Second Segment to check

  • same_data (bool) – Flag to indicate if the same type of data is held, i.e., same spikes, v, gsyn_exc and gsyn_inh. If False only data in both blocks is compared

  • same_length (bool) – Flag to indicate if the same length of data is held, i.e., all spikes up to the same time. If False allows one trains to have additional data after the first ends. This is used to compare data extracted part way with data extracted at the end.

Raises:

AssertionError – If the segments are not equal

spynnaker.pyNN.utilities.neo_compare.compare_spiketrain(spiketrain1, spiketrain2, same_length=True)[source]

Checks two spike trains have the exact same data.

Parameters:
  • spiketrain1 (SpikeTrain) – first spike train

  • spiketrain2 (SpikeTrain) – second spike train

  • same_length (bool) – Flag to indicate if the same length of data is held, i.e., all spikes up to the same time. If False allows one trains to have additional spikes after the first ends. This is used to compare data extracted part way with data extracted at the end.

Raises:

AssertionError – If the spike trains are not equal

spynnaker.pyNN.utilities.neo_compare.compare_spiketrains(spiketrains1, spiketrains2, same_data=True, same_length=True)[source]

Check two Lists of spike trains have the exact same data.

Parameters:
  • spiketrains1 (list(SpikeTrain)) – First list of spike trains to compare

  • spiketrains2 (list(SpikeTrain)) – Second list of spike trains to compare

  • same_data (bool) – Flag to indicate if the same type of data is held, i.e., same spikes, v, gsyn_exc and gsyn_inh. If False allows one or both lists to be Empty. Even if False none empty lists must be the same length

  • same_length (bool) – Flag to indicate if the same length of data is held, i.e., all spikes up to the same time. If False allows one trains to have additional spikes after the first ends. This is used to compare data extracted part way with data extracted at the end.

Raises:

AssertionError – If the spike trains are not equal

spynnaker.pyNN.utilities.neo_convertor module
spynnaker.pyNN.utilities.neo_convertor.convert_analog_signal(signal_array, time_unit=quantities.ms)[source]

Converts part of a NEO object into told spynnaker7 format.

Parameters:
  • signal_array (AnalogSignal) – Extended Quantities object

  • time_unit (quantities.unitquantity.UnitTime) – Data time unit for time index

Return type:

ndarray

spynnaker.pyNN.utilities.neo_convertor.convert_data(data, name, run=0)[source]

Converts the data into a numpy array in the format ID, time, value.

Parameters:
  • data (Block) – Data as returned by a getData() call

  • name (str) – Name of the data to be extracted. Same values as used in getData()

  • run (int) – Zero based index of the run to extract data for

Return type:

ndarray

spynnaker.pyNN.utilities.neo_convertor.convert_data_list(data, name, runs=None)[source]

Converts the data into a list of numpy arrays in the format ID, time, value.

Parameters:
  • data (Block) – Data as returned by a getData() call

  • name (str) – Name of the data to be extracted. Same values as used in getData()

  • runs (list(int) or None) – List of Zero based index of the run to extract data for. Or None to extract all runs

Return type:

list(ndarray)

spynnaker.pyNN.utilities.neo_convertor.convert_gsyn(gsyn_exc, gsyn_inh)[source]

Converts two neo objects into the spynnaker7 format.

Note

It is acceptable for both neo parameters to be the same object

Parameters:
  • gsyn_exc (Block) – neo with gsyn_exc data

  • gsyn_inh (Block) – neo with gsyn_exc data

Return type:

ndarray

spynnaker.pyNN.utilities.neo_convertor.convert_gsyn_exc_list(data, runs=None)[source]

Converts the gsyn_exc into a list numpy array one per segment (all runs) in the format ID, time, value.

Parameters:
  • data (Block) – The data to convert; it must have Gsyn_exc data in it

  • runs (list(int) or None) – List of Zero based index of the run to extract data for. Or None to extract all runs

Return type:

list(ndarray)

spynnaker.pyNN.utilities.neo_convertor.convert_gsyn_inh_list(data, runs=None)[source]

Converts the gsyn_inh into a list numpy array one per segment (all runs) in the format ID, time, value.

Parameters:
  • data (Block) – The data to convert; it must have Gsyn_inh data in it

  • runs (list(int) or None) – List of Zero based index of the run to extract data for. Or None to extract all runs

Return type:

list(ndarray)

spynnaker.pyNN.utilities.neo_convertor.convert_spikes(neo, run=0)[source]

Extracts the spikes for run one from a Neo Object.

Parameters:
  • neo (Block) – neo Object including Spike Data

  • run (int) – Zero based index of the run to extract data for

Return type:

ndarray

spynnaker.pyNN.utilities.neo_convertor.convert_spiketrains(spiketrains)[source]

Converts a list of spiketrains into spynnaker7 format.

Parameters:

spiketrains (list(SpikeTrain)) – List of SpikeTrains

Return type:

ndarray

spynnaker.pyNN.utilities.neo_convertor.convert_v_list(data, runs=None)[source]

Converts the voltage into a list numpy array one per segment (all runs) in the format ID, time, value.

Parameters:
  • data (Block) – The data to convert; it must have V data in it

  • runs (list(int) or None) – List of Zero based index of the run to extract data for. Or None to extract all runs

Return type:

list(ndarray)

spynnaker.pyNN.utilities.neo_convertor.count_spikes(neo)[source]

Help function to count the number of spikes in a list of spiketrains.

Only counts run 0

Parameters:

neo (Block) – Neo Object which has spikes in it

Returns:

The number of spikes in the first segment

spynnaker.pyNN.utilities.neo_convertor.count_spiketrains(spiketrains)[source]

Help function to count the number of spikes in a list of spiketrains.

Parameters:

spiketrains (list(SpikeTrain)) – List of SpikeTrains

Returns:

Total number of spikes in all the spiketrains

Return type:

int

spynnaker.pyNN.utilities.neo_csv module
class spynnaker.pyNN.utilities.neo_csv.NeoCsv[source]

Bases: object

read_csv(csv_file)[source]

Reads a whole CSV file and creates a block with data.

Parameters:

csv_file (str) – Path of file to read

Returns:

a block with all the data in the CSV file.

Return type:

Block

spynnaker.pyNN.utilities.running_stats module
class spynnaker.pyNN.utilities.running_stats.RunningStats[source]

Bases: object

Keeps running statistics. From: https://www.johndcook.com/blog/skewness_kurtosis/

add_item(x)[source]

Adds an item to the running statistics.

Parameters:

x (int or float) – The item to add

add_items(mean, variance, n_items)[source]

Add a bunch of items (via their statistics).

Parameters:
  • mean (float) – The mean of the items to add.

  • variance (float) – The variance of the items to add.

  • n_items (int) – The number of items represented.

property mean

The mean of the items seen.

Return type:

float

property n_items

The number of items seen.

Return type:

int

property standard_deviation

The population standard deviation of the items seen.

Return type:

float

property variance

The variance of the items seen.

Return type:

float

spynnaker.pyNN.utilities.struct module
class spynnaker.pyNN.utilities.struct.Struct(fields, repeat_type=StructRepeat.PER_NEURON, default_values=None)[source]

Bases: object

Represents a C code structure.

Parameters:
  • fields (list(DataType, str)) – The types and names of the fields, ordered as they appear in the structure.

  • repeat_type (StructRepeat) – How the structure repeats

  • default_values (dict(str, int or float) or None) – Dict of field name -> value to use when values doesn’t contain the field

property fields

The types and names of the fields, ordered as they appear in the structure.

Return type:

list(DataType, str)

get_data(values, vertex_slice=None)[source]

Get a numpy array of uint32 of data for the given values.

Parameters:
  • values (dict(str, int or float or AbstractList)) – The values to fill in the data with

  • vertex_slice (Slice or None) – The vertex slice to get the data for, or None if the structure is global.

Return type:

ndarray(dtype=”uint32”)

get_generator_data(values, vertex_slice=None)[source]

Get a numpy array of uint32 of data to generate the given values.

Parameters:
  • values (~dict-like) – The values to fill in the data with

  • vertex_slice (Slice or None) – The vertex slice or None for a structure with repeat_type global, or where a single value repeats for every neuron. If this is not the case and vertex_slice is None, an error will be raised!

Return type:

ndarray(dtype=”uint32”)

get_size_in_whole_words(array_size=1)[source]

Get the size of the structure in whole words in an array of given size (default 1 item).

Parameters:

array_size (int) – The number of elements in an array of structures

Return type:

int

property is_generatable

Whether the data inside could be generated on machine.

Return type:

bool

property numpy_dtype

The numpy data type of the structure.

Return type:

dtype

read_data(data, values, data_offset=0, vertex_slice=None)[source]

Read a byte string of data and write to values.

Parameters:
  • data (bytes or bytearray) – The data to be read

  • values (RangeDictionary) – The values to update with the read data

  • data_offset (int) – Index of the byte at the start of the valid data.

  • offset (int) – The first index into values to write to.

  • array_size (int or None) – The number of structure copies to read, or None if this is a non-repeating structure.

property repeat_type

How the structure repeats.

Return type:

StructRepeat

class spynnaker.pyNN.utilities.struct.StructRepeat(value)[source]

Bases: Enum

How a structure repeats, or not, in memory.

GLOBAL = 0

Indicates a single global struct

PER_NEURON = 1

Indicates a struct that repeats per neuron

spynnaker.pyNN.utilities.utility_calls module

Utility package containing simple helper functions.

spynnaker.pyNN.utilities.utility_calls.check_directory_exists_and_create_if_not(filename)[source]

Create a parent directory for a file if it doesn’t exist.

Parameters:

filename (str) – The file whose parent directory is to be created

spynnaker.pyNN.utilities.utility_calls.check_rng(rng, where)[source]

Check for non-None rng parameter since this is no longer compatible with sPyNNaker. If not None, warn or error depending on a config value.

Parameters:

rng – The rng parameter value.

spynnaker.pyNN.utilities.utility_calls.convert_param_to_numpy(param, no_atoms)[source]

Convert parameters into numpy arrays.

Parameters:
Returns:

the converted param as an array of floats

Return type:

ndarray(float)

spynnaker.pyNN.utilities.utility_calls.convert_to(value, data_type)[source]

Convert a value to a given data type.

Parameters:
  • value – The value to convert

  • data_type (DataType) – The data type to convert to

Returns:

The converted data as a numpy data type

Return type:

ndarray(int32)

spynnaker.pyNN.utilities.utility_calls.create_mars_kiss_seeds(rng)[source]

Generates and checks that the seed values generated by the given random number generator or seed to a random number generator are suitable for use as a mars 64 kiss seed.

Parameters:
  • rng (RandomState) – the random number generator.

  • seed (int or None) – the seed to create a random number generator if not handed.

Returns:

a list of 4 integers which are used by the mars64 kiss random number generator for seeds.

Return type:

list(int)

spynnaker.pyNN.utilities.utility_calls.get_maximum_probable_value(distribution, n_items, chance=0.01)[source]

Get the likely maximum value of a RandomDistribution given a number of draws.

Parameters:
  • distribution (RandomDistribution) –

  • n_items (int) –

  • chance (float) –

spynnaker.pyNN.utilities.utility_calls.get_mean(distribution)[source]

Get the mean of a RandomDistribution.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.get_minimum_probable_value(distribution, n_items, chance=0.01)[source]

Get the likely minimum value of a RandomDistribution given a number of draws.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.get_n_bits(n_values)[source]

Determine how many bits are required for the given number of values.

Parameters:

n_values (int) – the number of values (starting at 0)

Returns:

the number of bits required to express that many values

Return type:

int

spynnaker.pyNN.utilities.utility_calls.get_neo_io(file_or_folder)[source]

Hack for https://github.com/NeuralEnsemble/python-neo/issues/1287

In Neo 0.12 neo.get_io only works with existing files

Parameters:

file_or_folder (str) –

spynnaker.pyNN.utilities.utility_calls.get_probability_within_range(distribution, lower, upper)[source]

Get the probability that a value will fall within the given range for a given RandomDistribution.

Parameters:
  • distribution (RandomDistribution) –

  • lower (float) –

  • upper (float) –

spynnaker.pyNN.utilities.utility_calls.get_probable_maximum_selected(n_total_trials, n_trials, selection_prob, chance=0.01)[source]

Get the likely maximum number of items that will be selected from a set of n_trials from a total set of n_total_trials with a probability of selection of selection_prob.

spynnaker.pyNN.utilities.utility_calls.get_probable_minimum_selected(n_total_trials, n_trials, selection_prob, chance=0.01)[source]

Get the likely minimum number of items that will be selected from a set of n_trials from a total set of n_total_trials with a probability of selection of selection_prob.

spynnaker.pyNN.utilities.utility_calls.get_standard_deviation(distribution)[source]

Get the standard deviation of a RandomDistribution.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.get_time_to_write_us(n_bytes, n_cores)[source]

Determine how long a write of a given number of bytes will take in us.

Parameters:
  • n_bytes (int) – The number of bytes to transfer

  • n_cores (int) – How many cores will be writing at the same time

spynnaker.pyNN.utilities.utility_calls.get_variance(distribution)[source]

Get the variance of a RandomDistribution.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.high(distribution)[source]

Gets the high or maximum boundary value for this distribution.

Could return None.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.low(distribution)[source]

Gets the high or minimum boundary value for this distribution.

Could return None.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.moved_in_v6(old_location, _)[source]

Tells the users that old code is no longer implemented.

Parameters:

old_location (str) – old import

Raise:

NotImplementedError

spynnaker.pyNN.utilities.utility_calls.moved_in_v7(old_location, new_location)[source]

Warns the users that they are using an old import.

In version 8 this will be upgraded to a exception and then later removed

Parameters:
  • old_location (str) – old import

  • new_location (str) – new import

Raises:

NotImplementedError – if in CONTINUOUS_INTEGRATION

spynnaker.pyNN.utilities.utility_calls.moved_in_v7_warning(message)[source]

Warns the user that they are using old code.

In version 8 this will be upgraded to a exception and then later removed

Parameters:

message (str) –

Raises:

NotImplementedError – if in CONTINUOUS_INTEGRATION

spynnaker.pyNN.utilities.utility_calls.read_in_data_from_file(file_path, min_atom, max_atom, min_time, max_time, extra=False)[source]

Read in a file of data values where the values are in a format of:

<time>  <atom ID>       <data value>
Parameters:
  • file_path (str) – absolute path to a file containing the data

  • min_atom (int) – min neuron ID to which neurons to read in

  • max_atom (int) – max neuron ID to which neurons to read in

  • extra

  • min_time (float or int) – min time slot to read neurons values of.

  • max_time (float or int) – max time slot to read neurons values of.

Returns:

a numpy array of (time stamp, atom ID, data value)

Return type:

ndarray(tuple(float, int, float))

spynnaker.pyNN.utilities.utility_calls.read_spikes_from_file(file_path, min_atom=0, max_atom=inf, min_time=0, max_time=inf, split_value='\t')[source]

Read spikes from a file formatted as:

<time>  <neuron ID>
Parameters:
  • file_path (str) – absolute path to a file containing spike values

  • min_atom (int or float) – min neuron ID to which neurons to read in

  • max_atom (int or float) – max neuron ID to which neurons to read in

  • min_time (float or int) – min time slot to read neurons values of.

  • max_time (float or int) – max time slot to read neurons values of.

  • split_value (str) – the pattern to split by

Returns:

a numpy array with max_atom elements each of which is a list of spike times.

Return type:

numpy.ndarray(int, int)

spynnaker.pyNN.utilities.utility_calls.report_non_spynnaker_pyNN(msg)[source]

Report a case of non-spynnaker-compatible PyNN being used. This will warn or error depending on the configuration setting.

Parameters:

msg (str) – The message to report

Module contents
Submodules
spynnaker.pyNN.abstract_spinnaker_common module

The code that used to be here has been merged into SpiNNaker.

This is now just a depreciation redirect hook

class spynnaker.pyNN.abstract_spinnaker_common.AbstractSpiNNakerCommon(*args: Any, **kwargs: Any)[source]

Bases: SpiNNaker

Parameters:
  • time_scale_factor (int or None) – multiplicative factor to the machine time step (does not affect the neuron models accuracy)

  • min_delay

  • n_chips_required (int or None) – Deprecated! Use n_boards_required instead. Must be None if n_boards_required specified.

  • n_boards_required (int or None) – if you need to be allocated a machine (for spalloc) before building your graph, then fill this in with a general idea of the number of boards you need so that the spalloc system can allocate you a machine big enough for your needs.

  • timestep (float or None) – the time step of the simulations in microseconds; if None the cfg value is used

static register_binary_search_path(search_path)[source]

Register an additional binary search path for executables.

Parameters:

search_path (str) – absolute search path for binaries

spynnaker.pyNN.config_setup module
spynnaker.pyNN.config_setup.add_spynnaker_cfg()[source]
spynnaker.pyNN.config_setup.setup_configs()[source]

Sets up the configurations including the users configuration file.

Clears out any previous read configurations but does not load the new configurations so a warning is generated if a configuration is used before setup is called.

spynnaker.pyNN.config_setup.unittest_setup()[source]

Does all the steps that may be required before a unit-test.

Resets the configurations so only the local default configurations are included. The user configuration is not included!

Unsets any previous simulators and temporary directories

Note

This file should only be called from sPyNNaker tests that do not call sim.setup

spynnaker.pyNN.exceptions module
exception spynnaker.pyNN.exceptions.DelayExtensionException[source]

Bases: ConfigurationException

Raised when a delay extension vertex fails.

exception spynnaker.pyNN.exceptions.FilterableException[source]

Bases: SpynnakerException

Raised when it is not possible to determine if an edge should be filtered.

exception spynnaker.pyNN.exceptions.InvalidParameterType[source]

Bases: SpynnakerException

Raised when a parameter is not recognised.

exception spynnaker.pyNN.exceptions.MemReadException[source]

Bases: SpynnakerException

Raised when the PyNN front end fails to read a certain memory region.

exception spynnaker.pyNN.exceptions.SpynnakerException[source]

Bases: Exception

Superclass of all exceptions from the PyNN module.

exception spynnaker.pyNN.exceptions.SpynnakerSplitterConfigurationException[source]

Bases: ConfigurationException

Raised when a splitter configuration fails.

exception spynnaker.pyNN.exceptions.SynapseRowTooBigException(max_size, message)[source]

Bases: SpynnakerException

Raised when a synapse row is bigger than is allowed.

Parameters:
  • max_size – the maximum permitted size of row

  • message – the exception message

property max_size

The maximum size allowed.

exception spynnaker.pyNN.exceptions.SynapticBlockGenerationException[source]

Bases: ConfigurationException

Raised when the synaptic manager fails to generate a synaptic block.

exception spynnaker.pyNN.exceptions.SynapticBlockReadException[source]

Bases: ConfigurationException

Raised when the synaptic manager fails to read a synaptic block or convert it into readable values.

exception spynnaker.pyNN.exceptions.SynapticConfigurationException[source]

Bases: ConfigurationException

Raised when the synaptic manager fails for some reason.

exception spynnaker.pyNN.exceptions.SynapticMaxIncomingAtomsSupportException[source]

Bases: ConfigurationException

Raised when a synaptic sublist exceeds the max atoms possible to be supported.

spynnaker.pyNN.random_distribution module
class spynnaker.pyNN.random_distribution.RandomDistribution(*args: Any, **kwargs: Any)[source]

Bases: RandomDistribution

Class which defines a next(n) method which returns an array of n random numbers from a given distribution.

Examples:

>>> rd = RandomDistribution('uniform', (-70, -50))
>>> rd = RandomDistribution('normal', mu=0.5, sigma=0.1)
>>> rng = NumpyRNG(seed=8658764)
>>> rd = RandomDistribution('gamma', k=2.0, theta=5.0, rng=rng)
Available distributions

Name

Parameters

Comments

binomial

n, p

gamma

k, theta

exponential

beta

lognormal

mu, sigma

normal

mu, sigma

normal_clipped

mu, sigma, low, high

Values outside (low, high) are redrawn

normal_clipped_to_boundary

mu, sigma, low, high

Values below/above low/high are set to low/high

poisson

lambda_

Trailing underscore since lambda is a Python keyword

uniform

low, high

uniform_int

low, high

Only generates integer values

vonmises

mu, kappa

Parameters:
  • distribution (str) – the name of a random number distribution.

  • parameters_pos (tuple or None) – parameters of the distribution, provided as a tuple. For the correct ordering, see random.available_distributions.

  • rng (NumpyRNG or GSLRNG or NativeRNG or None) – the random number generator to use, if a specific one is desired (e.g., to provide a seed).

  • parameters_named – parameters of the distribution, provided as keyword arguments.

Parameters may be provided either through parameters_pos or through parameters_named, but not both. All parameters must be provided, there are no default values. Parameter names are, in general, as used in Wikipedia.

spynnaker.pyNN.setup_pynn module

This script installs sPyNNaker so that it usable as the pyNN.spiNNaker module.

Note

This modifies your pyNN installation!

spynnaker.pyNN.setup_pynn.install_sPyNNaker_into(module)[source]

Do the actual installation by creating a package within the given module’s implementation. This is very nasty!

Parameters:

module (ModuleType) –

spynnaker.pyNN.setup_pynn.setup_pynn()[source]
spynnaker.pyNN.setup_pynn.version_satisfies(module, requirement)[source]

Perform a version check. This code could be smarter…

Parameters:
Returns:

Whether the module’s version satisfies the given requirement

Return type:

bool

spynnaker.pyNN.spinnaker module
class spynnaker.pyNN.spinnaker.SpiNNaker(*args: Any, **kwargs: Any)[source]

Bases: AbstractSpinnakerBase, BaseState

Main interface for the sPyNNaker implementation of PyNN 0.8/0.9.

Parameters:
  • time_scale_factor (int or None) – multiplicative factor to the machine time step (does not affect the neuron models accuracy)

  • min_delay

  • n_chips_required (int or None) – Deprecated! Use n_boards_required instead. Must be None if n_boards_required specified.

  • n_boards_required (int or None) – if you need to be allocated a machine (for spalloc) before building your graph, then fill this in with a general idea of the number of boards you need so that the spalloc system can allocate you a machine big enough for your needs.

  • timestep (float or None) – the time step of the simulations in microseconds; if None the cfg value is used

clear()[source]

Clear the current recordings and reset the simulation.

property dt

The simulation time step in milliseconds.

Returns:

the machine time step

Return type:

float

property mpi_rank

The MPI rank of the simulator.

Note

Meaningless on SpiNNaker, so we pretend we’re the head node.

Returns:

Constant: 0

Return type:

int

property name

The name of the simulator. Used to ensure PyNN recording neo blocks are correctly labelled.

Returns:

the name of the simulator.

Return type:

str

property num_processes

The number of MPI worker processes.

Note

Meaningless on SpiNNaker, so we pretend there’s one MPI process

Returns:

Constant: 1

Return type:

int

property recorders

The recorders, used by the PyNN state object.

Returns:

the internal recorders object

Return type:

list(Recorder)

static register_binary_search_path(search_path)[source]

Register an additional binary search path for executables.

Parameters:

search_path (str) – absolute search path for binaries

reset()[source]

Reset the state of the current network to time t = 0.

run(run_time, sync_time=0.0)[source]

Run the simulation for a span of simulation time.

Parameters:

run_time – the time to run for, in milliseconds

run_until(tstop)[source]

Run the simulation until the given simulation time.

Parameters:

tstop – when to run until in milliseconds

property segment_counter

The number of the current recording segment being generated.

Returns:

the segment counter

Return type:

int

property state

Used to bypass the dual level object.

Returns:

the SpiNNaker object

Return type:

SpiNNaker

stop()[source]

End running of the simulation.

property t

The current simulation time in milliseconds.

Returns:

the current runtime already executed

Return type:

float

spynnaker.pyNN.spynnaker_external_device_plugin_manager module
class spynnaker.pyNN.spynnaker_external_device_plugin_manager.SpynnakerExternalDevicePluginManager[source]

Bases: object

User-level interface for the external device plug-in manager.

static activate_live_output_for(population, database_notify_host=None, database_notify_port_num=None, database_ack_port_num=None, port=None, host=None, tag=None, strip_sdp=True, use_prefix=False, key_prefix=None, prefix_type=None, message_type=EIEIOType.KEY_32_BIT, right_shift=0, payload_as_time_stamps=True, notify=True, use_payload_prefix=True, payload_prefix=None, payload_right_shift=0, number_of_packets_sent_per_time_step=0, translate_keys=False)[source]

Output the spikes from a given population from SpiNNaker as they occur in the simulation.

Parameters:
  • population (Population) – The population to activate the live output for

  • database_notify_host (str) – The hostname for the device which is listening to the database notification.

  • database_ack_port_num (int) – The port number to which a external device will acknowledge that they have finished reading the database and are ready for it to start execution

  • database_notify_port_num (int) – The port number to which a external device will receive the database is ready command

  • key_prefix (int or None) – the prefix to be applied to the key

  • prefix_type (EIEIOPrefix) – if the prefix type is 32 bit or 16 bit

  • message_type (EIEIOType) – If the message is a EIEIO command message, or an EIEIO data message with 16 bit or 32 bit keys.

  • payload_as_time_stamps (bool) –

  • right_shift (int) –

  • use_payload_prefix (bool) –

  • notify (bool) –

  • payload_prefix (int or None) –

  • payload_right_shift (int) –

  • number_of_packets_sent_per_time_step (int) –

  • port (int) – The UDP port to which the live spikes will be sent. If not specified, the port will be taken from the “live_spike_port” parameter in the “Recording” section of the sPyNNaker configuration file.

  • host (str) – The host name or IP address to which the live spikes will be sent. If not specified, the host will be taken from the “live_spike_host” parameter in the “Recording” section of the sPyNNaker configuration file.

  • tag (int) – The IP tag to be used for the spikes. If not specified, one will be automatically assigned

  • strip_sdp (bool) – Determines if the SDP headers will be stripped from the transmitted packet.

  • use_prefix (bool) – Determines if the spike packet will contain a common prefix for the spikes

  • label (str) – The label of the gatherer vertex

  • partition_ids (list(str)) – The names of the partitions to create edges for

  • translate_keys (bool) – Whether the incoming keys from the cores should be translated to global keys rather than core-based keys

static activate_live_output_to(population, device, partition_id='SPIKE')[source]

Activate the output of spikes from a population to an external device.

Note

All spikes will be sent to the device.

Parameters:
  • population (Population) – The pyNN population object from which spikes will be sent.

  • device (Population or ApplicationVertex) – The pyNN population or external device to which the spikes will be sent.

  • partition_id (str) – The partition ID to activate live output to.

static add_application_vertex(vertex)[source]
static add_database_socket_address(database_notify_host, database_notify_port_num, database_ack_port_num)[source]
Parameters:
  • database_notify_host (str or None) – Host to talk to tell that the database (and application) is ready.

  • database_notify_port_num (int or None) – Port to talk to tell that the database (and application) is ready.

  • database_ack_port_num (int or None) – Port on which to listen for an acknowledgement that the simulation should start.

static add_edge(vertex, device_vertex, partition_id)[source]

Add an edge between two vertices (often a vertex and a external device) on a given partition.

Parameters:
  • vertex (ApplicationVertex) – the pre-population vertex to connect the edge from

  • device_vertex (ApplicationVertex) – the post-population vertex to connect the edge to

  • partition_id (str) – the partition identifier for making nets

static add_poisson_live_rate_control(poisson_population, control_label_extension='_control', receive_port=None, database_notify_host=None, database_notify_port_num=None, database_ack_port_num=None, notify=True, reserve_reverse_ip_tag=False)[source]

Add a live rate controller to a Poisson population.

Parameters:
  • poisson_population (Population) – The population to control

  • control_label_extension (str) – An extension to add to the label of the Poisson source. Must match up with the equivalent in the SpynnakerPoissonControlConnection

  • receive_port (int) – The port that the SpiNNaker board should listen on

  • database_notify_host (str) – the hostname for the device which is listening to the database notification.

  • database_ack_port_num (int) – the port number to which a external device will acknowledge that they have finished reading the database and are ready for it to start execution

  • database_notify_port_num (int) – The port number to which an external device will receive the database is ready command

  • notify (bool) – adds to the notification protocol if set.

  • reserve_reverse_ip_tag (bool) – True if a reverse IP tag is to be used, False if SDP is to be used (default)

static update_live_packet_gather_tracker(vertex_to_record_from, params, partition_ids)[source]

Add an edge from a vertex to the live packet gatherer, builds as needed and has all the parameters for the creation of the live packet gatherer if needed.

Parameters:
Module contents

The spynnaker.pyNN package contains the front end specifications and implementation for the PyNN High-level API (https://neuralensemble.org/trac/PyNN).

This package contains the profile of that code for PyNN 0.9.

class spynnaker.pyNN.ACSource(start=0.0, stop=0.0, amplitude=0.0, offset=0.0, frequency=0.0, phase=0.0)[source]

Bases: AbstractCurrentSource

AC current source (i.e. sine wave) turned on at “start” and off at “stop”, given (y-)offset, amplitude, frequency and phase.

Parameters:
property current_source_id

The ID of the current source.

Return type:

int

property get_parameter_types

The parameter types for the current source.

Return type:

dict(str, Any)

property get_parameters

The parameters of the current source.

Return type:

dict(str, Any)

get_sdram_usage_in_bytes()[source]

The SDRAM usage in bytes of the current source.

Return type:

int

set_parameters(**parameters)[source]

Set the current source parameters.

Parameters:

parameters – the parameters to set

spynnaker.pyNN.AdditiveWeightDependence

alias of WeightDependenceAdditive

class spynnaker.pyNN.AllToAllConnector(allow_self_connections=True, safe=True, verbose=None, callback=None)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

Connects all cells in the presynaptic population to all cells in the postsynaptic population.

Parameters:
  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

property allow_self_connections
Return type:

bool

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

class spynnaker.pyNN.ArrayConnector(array, safe=True, callback=None, verbose=False)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

Make connections using an array of integers based on the IDs of the neurons in the pre- and post-populations.

Parameters:
  • array (ndarray(2, uint8)) – An explicit boolean matrix that specifies the connections between the pre- and post-populations (see PyNN documentation). Must be 2D in practice.

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

class spynnaker.pyNN.Assembly(*args: Any, **kwargs: Any)[source]

Bases: Assembly

A group of neurons, may be heterogeneous, in contrast to a Population where all the neurons are of the same type.

Parameters:
  • populations (Population or PopulationView) – the populations or views to form the assembly out of

  • kwargs – may contain label (a string describing the assembly)

class spynnaker.pyNN.CSAConnector(cset, safe=True, callback=None, verbose=False)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

Make connections using a Connection Set Algebra (Djurfeldt 2012) description between the neurons in the pre- and post-populations.

Note

If you get TypeError in Python 3 see: https://github.com/INCF/csa/issues/10

Parameters:
  • cset (csa.connset.CSet) – A description of the connection set between populations

  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

Raises:

ImportError – if the csa library isn’t present; it’s tricky to install in some environments so we don’t force it to be present unless you want to actually use this class.

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

show_connection_set(n_pre_neurons, n_post_neurons)[source]
Parameters:
  • n_pre_neurons (int) –

  • n_post_neurons (int) –

spynnaker.pyNN.Convolution

alias of LocalOnlyConvolution

class spynnaker.pyNN.ConvolutionConnector(kernel_weights, kernel_shape=None, strides=None, padding=None, pool_shape=None, pool_stride=None, positive_receptor_type='excitatory', negative_receptor_type='inhibitory', safe=True, verbose=False, callback=None)[source]

Bases: AbstractConnector

Where the pre- and post-synaptic populations are considered as a 2D array. Connect every post(row, column) neuron to many pre(row, column, kernel) through a (kernel) set of weights and/or delays.

Parameters:
  • kernel_weights (int or list or ndarray or RandomDistribution) –

    The synaptic strengths, shared by neurons in the post population. Can be:

    • single value: kernel_shape must be provided; the same value will be used for all weights

    • simple list: kernel_shape must be provided; the list must be sized shape width * height

    • 2D list: If kernel_shape is provided, it must match

    • ndarray: As above for simple or 2D list

    • RandomDistribution: kernel_shape must be provided; weights will be drawn from the distribution

  • kernel_shape (int or tuple(int,int)) – The shape of the kernel if it cannot be determined from kernel_weights. If a single value is provided, a square kernel will be assumed. If two values are provided, it will be assumed to be (n_rows, n_columns)

  • strides (int or tuple(int, int)) – Spatial sampling frequency, jumps between the post neurons. This matches the meaning of standard ML packages. If a single value is provided, the same stride will be used for rows and columns. If two values are provided it will be assumed to be (stride_rows, stride_columns)

  • padding (bool or int or tuple(int, int) or None) – How many ‘extra pixels’ around the pre-population will be added, only zero-valued pixels are currently supported. If a single value is provided, the same padding will be used for rows and columns. If two values are provided it will be assumed to be (padding_rows, padding_columns). If True, automatic padding will be used based on the kernel shape. If False or None, no padding will be used.

  • pool_shape (int or tuple(int, int) or None) – Area of pooling, only average pooling is supported (and seems to make sense). If a single value is provided, the pooling area will be square. If two values are provided it will be assumed to be (pooling_rows, pooling_columns).

  • pool_stride (int or tuple(int, int) or None) – Jumps between pooling regions. If a single value is provided, the same stride will be used for rows and columns. If two values are provided it will be assumed to be (stride_rows, stride_columns)

  • positive_receptor_type (str) – The receptor type to add the positive weights to. By default this is “excitatory”.

  • negative_receptor_type (str) – The receptor type to add the negative weights to. By default this is “inhibitory”.

  • safe (bool) – (ignored)

  • verbose (bool) – (ignored)

  • callback (callable) – (ignored)

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_encoded_kernel_weights(app_edge, weight_scales)[source]
get_local_only_data(app_edge, vertex_slice, key, mask, n_colour_bits, delay, weight_index)[source]
get_max_n_incoming_slices(source_vertex, target_vertex)[source]
get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_post_shape(shape)[source]

Get the shape of the post image given the pre-image shape.

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

property kernel_n_bytes
property kernel_n_weights
property kernel_weights
property negative_receptor_type
property parameters_n_bytes
property positive_receptor_type
validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
class spynnaker.pyNN.DCSource(amplitude=0.0, start=0.0, stop=0.0)[source]

Bases: AbstractCurrentSource

Current source with amplitude turned on at “start” and off at “stop”.

Parameters:
property current_source_id

The ID of the current source.

Return type:

int

property get_parameter_types

The parameter types for the current source.

Return type:

dict(str, Any)

property get_parameters

The parameters of the current source.

Return type:

dict(str, Any)

get_sdram_usage_in_bytes()[source]

The SDRAM usage in bytes of the current source.

Return type:

int

set_parameters(**parameters)[source]

Set the current source parameters.

Parameters:

parameters – the parameters to set

class spynnaker.pyNN.DistanceDependentFormation(grid=(16, 16), p_form_forward=0.16, sigma_form_forward=2.5, p_form_lateral=1.0, sigma_form_lateral=1.0)[source]

Bases: AbstractFormation

Formation rule that depends on the physical distance between neurons.

Parameters:
  • grid (tuple(int,int) or list(int) or ndarray(int)) – (x, y) dimensions of the grid of distance

  • p_form_forward (float) – The peak probability of formation on feed-forward connections

  • sigma_form_forward (float) – The spread of probability with distance of formation on feed-forward connections

  • p_form_lateral (float) – The peak probability of formation on lateral connections

  • sigma_form_lateral (float) – The spread of probability with distance of formation on lateral connections

distance(x0, x1, metric)[source]

Compute the distance between points x0 and x1 place on the grid using periodic boundary conditions.

Parameters:
  • x0 (ndarray(int)) – first point in space

  • x1 (ndarray(int)) – second point in space

  • grid (ndarray(int)) – shape of grid

  • metric (str) – distance metric, i.e. euclidian or manhattan or equidistant

Returns:

the distance

Return type:

float

generate_distance_probability_array(probability, sigma)[source]

Generate the exponentially decaying probability LUTs.

Parameters:
  • probability (float) – peak probability

  • sigma (float) – spread

Returns:

distance-dependent probabilities

Return type:

ndarray(float)

get_parameter_names()[source]

Return the names of the parameters supported by this rule.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec)[source]

Write the parameters of the rule to the spec.

Parameters:

spec (DataSpecificationGenerator) –

class spynnaker.pyNN.DistanceDependentProbabilityConnector(d_expression, allow_self_connections=True, safe=True, verbose=False, n_connections=None, rng=None, callback=None)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

Make connections using a distribution which varies with distance.

Parameters:
  • d_expression (str) – the right-hand side of a valid python expression for probability, involving d, (e.g. "exp(-abs(d))", or "d < 3"), that can be parsed by eval(), that computes the distance dependent distribution.

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • safe (bool) – if True, check that weights and delays have valid values. If False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • n_connections (int or None) – The number of efferent synaptic connections per neuron.

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.

  • callback (callable) –

property allow_self_connections
Return type:

bool

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property d_expression

The distance expression.

Return type:

str

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

set_projection_information(synapse_info)[source]

Sets a connectors projection info.

Parameters:

synapse_info (SynapseInformation) – the synapse info

class spynnaker.pyNN.FixedNumberPostConnector(n, allow_self_connections=True, safe=True, verbose=False, with_replacement=False, rng=None, callback=None)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

Connects a fixed number of post-synaptic neurons selected at random, to all pre-synaptic neurons.

Parameters:
  • n (int) – number of random post-synaptic neurons connected to pre-neurons.

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • safe (bool) – Whether to check that weights and delays have valid values; if False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • with_replacement (bool) – this flag determines how the random selection of post-synaptic neurons is performed; if True, then every post-synaptic neuron can be chosen on each occasion, and so multiple connections between neuron pairs are possible; if False, then once a post-synaptic neuron has been connected to a pre-neuron, it can’t be connected again.

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

property allow_self_connections
create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

set_projection_information(synapse_info)[source]

Sets a connectors projection info.

Parameters:

synapse_info (SynapseInformation) – the synapse info

validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
class spynnaker.pyNN.FixedNumberPreConnector(n, allow_self_connections=True, safe=True, verbose=False, with_replacement=False, rng=None, callback=None)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

Connects a fixed number of pre-synaptic neurons selected at random, to all post-synaptic neurons.

Parameters:
  • n (int) – number of random pre-synaptic neurons connected to output

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • with_replacement (bool) – this flag determines how the random selection of pre-synaptic neurons is performed; if true, then every pre-synaptic neuron can be chosen on each occasion, and so multiple connections between neuron pairs are possible; if false, then once a pre-synaptic neuron has been connected to a post-neuron, it can’t be connected again.

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

property allow_self_connections
create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

set_projection_information(synapse_info)[source]

Sets a connectors projection info.

Parameters:

synapse_info (SynapseInformation) – the synapse info

validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
class spynnaker.pyNN.FixedProbabilityConnector(p_connect, allow_self_connections=True, safe=True, verbose=False, rng=None, callback=None)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

For each pair of pre-post cells, the connection probability is constant.

Parameters:
  • p_connect (float) – a value between zero and one. Each potential connection is created with this probability.

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

property p_connect
validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
spynnaker.pyNN.FixedTotalNumberConnector

alias of MultapseConnector

class spynnaker.pyNN.FromFileConnector(file, distributed=False, safe=True, callback=None, verbose=False)[source]

Bases: FromListConnector

Make connections according to a list read from a file.

Parameters:
  • file (str or FileIO) –

    Either an open file object or the filename of a file containing a list of connections, in the format required by FromListConnector. Column headers, if included in the file, must be specified using a list or tuple, e.g.:

    # columns = ["i", "j", "weight", "delay", "U", "tau_rec"]
    

    Note

    The header requires # at the beginning of the line.

  • distributed (bool) –

    Basic pyNN says:

    if this is True, then each node will read connections from a file called filename.x, where x is the MPI rank. This speeds up loading connections for distributed simulations.

    Note

    Always leave this as False with sPyNNaker, which is not MPI-based.

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

get_reader(file)[source]

Get a file reader object using the PyNN methods.

Returns:

A pynn StandardTextFile or similar

Return type:

StandardTextFile

class spynnaker.pyNN.FromListConnector(conn_list, safe=True, verbose=False, column_names=None, callback=None)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

Make connections according to a list.

Parameters:
  • conn_list (ndarray or list(tuple(int,int,...))) –

    A numpy array or a list of tuples, one tuple for each connection. Each tuple should contain:

    (pre_idx, post_idx, p1, p2, ..., pn)
    

    where pre_idx is the index (i.e. order in the Population, not the ID) of the presynaptic neuron, post_idx is the index of the postsynaptic neuron, and p1, p2, etc. are the synaptic parameters (e.g., weight, delay, plasticity parameters). All tuples/rows must have the same number of items.

  • safe (bool) – if True, check that weights and delays have valid values. If False, this check is skipped.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • column_names (None or tuple(str) or list(str)) – the names of the parameters p1, p2, etc. If not provided, it is assumed the parameters are weight, delay (for backwards compatibility).

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

property column_names

The names of the columns in the array after the first two. Of particular interest is whether weight and delay columns are present.

Return type:

list(str)

property conn_list

The connection list.

Return type:

ndarray

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_delay_variance(delays, synapse_info)[source]

Get the variance of the delays.

Parameters:

delays (RandomDistribution or int or float of str) –

Return type:

float

get_extra_parameter_names()[source]

Get the names of the extra parameters.

Return type:

list(str)

get_extra_parameters()[source]

Getter for the extra parameters. Excludes weight and delay columns.

Returns:

The extra parameters

Return type:

ndarray

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

get_weight_mean(weights, synapse_info)[source]

Get the mean of the weights.

Parameters:

weights (RandomDistribution or int or float or str) –

Return type:

float

get_weight_variance(weights, synapse_info)[source]

Get the variance of the weights.

Parameters:

weights (RandomDistribution or int or float or str) –

Return type:

float

spynnaker.pyNN.IF_cond_exp

alias of IFCondExpBase

spynnaker.pyNN.IF_curr_alpha

alias of IFCurrAlpha

spynnaker.pyNN.IF_curr_delta

alias of IFCurrDelta

spynnaker.pyNN.IF_curr_exp

alias of IFCurrExpBase

class spynnaker.pyNN.IndexBasedProbabilityConnector(index_expression, allow_self_connections=True, rng=None, safe=True, callback=None, verbose=False)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

Make connections using a probability distribution which varies dependent upon the indices of the pre- and post-populations.

Parameters:
  • index_expression (str) – the right-hand side of a valid python expression for probability, involving the indices of the pre- and post-populations, that can be parsed by eval(), that computes a probability distribution; the indices will be given as variables i and j when the expression is evaluated.

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

property allow_self_connections

When the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

Return type:

bool

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

property index_expression

The right-hand side of a valid python expression for probability, involving the indices of the pre- and post-populations, that can be parsed by eval(), that computes a probability distribution.

Return type:

str

spynnaker.pyNN.Izhikevich

alias of IzkCurrExpBase

class spynnaker.pyNN.KernelConnector(shape_pre, shape_post, shape_kernel, weight_kernel=None, delay_kernel=None, shape_common=None, pre_sample_steps_in_post=None, pre_start_coords_in_post=None, post_sample_steps_in_pre=None, post_start_coords_in_pre=None, safe=True, space=None, verbose=False, callback=None)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

Where the pre- and post-synaptic populations are considered as a 2D array. Connect every post(row, column) neuron to many pre(row, column, kernel) through a (kernel) set of weights and/or delays.

TODO

Should these include allow_self_connections and with_replacement?

Parameters:
  • shape_pre (list(int) or tuple(int,int)) – 2D shape of the pre-population (rows/height, columns/width, usually the input image shape)

  • shape_post (list(int) or tuple(int,int)) – 2D shape of the post-population (rows/height, columns/width)

  • shape_kernel (list(int) or tuple(int,int)) – 2D shape of the kernel (rows/height, columns/width)

  • weight_kernel (ndarray or RandomDistribution or int or float or list(int) or list(float) or None) – (optional) 2D matrix of size shape_kernel describing the weights

  • delay_kernel (ndarray or RandomDistribution or int or float or list(int) or list(float) or None) – (optional) 2D matrix of size shape_kernel describing the delays

  • shape_common (list(int) or tuple(int,int) or None) – (optional) 2D shape of common coordinate system (for both pre- and post-, usually the input image sizes)

  • pre_sample_steps_in_post (None or list(int) or tuple(int,int)) – (optional) Sampling steps/jumps for pre-population <=> (stepX, stepY)

  • pre_start_coords_in_post (None or list(int) or tuple(int,int)) – (optional) Starting row/column for pre-population sampling <=> (offX, offY)

  • post_sample_steps_in_pre (None or list(int) or tuple(int,int)) – (optional) Sampling steps/jumps for post-population <=> (stepX, stepY)

  • post_start_coords_in_pre (None or list(int) or tuple(int,int)) – (optional) Starting row/column for post-population sampling <=> (offX, offY)

  • safe (bool) – Whether to check that weights and delays have valid values. If False, this check is skipped.

  • space (Space) – Currently ignored; for future compatibility.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

  • callback (callable) – (ignored)

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_delay_variance(delays, synapse_info)[source]

Get the variance of the delays.

Parameters:

delays (RandomDistribution or int or float of str) –

Return type:

float

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

get_weight_mean(weights, synapse_info)[source]

Get the mean of the weights.

Parameters:

weights (RandomDistribution or int or float or str) –

Return type:

float

get_weight_variance(weights, synapse_info)[source]

Get the variance of the weights.

Parameters:

weights (RandomDistribution or int or float or str) –

Return type:

float

class spynnaker.pyNN.LastNeuronSelection(spike_buffer_size=64)[source]

Bases: AbstractPartnerSelection

Partner selection that picks a random source neuron from the neurons that spiked in the last timestep.

Parameters:

spike_buffer_size – The size of the buffer for holding spikes

get_parameter_names()[source]

Return the names of the parameters supported by this rule.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

str

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec)[source]

Write the parameters of the rule to the spec.

Parameters:

spec (DataSpecificationGenerator) –

spynnaker.pyNN.MultiplicativeWeightDependence

alias of WeightDependenceMultiplicative

class spynnaker.pyNN.NoisyCurrentSource(mean=0.0, stdev=0.0, start=0.0, stop=0.0, dt=1.0, rng=None)[source]

Bases: AbstractCurrentSource

A noisy current source beginning at “start” and ending at “stop”, with noise simulated based on the given mean and standard deviation, and updating every dt (dt should default to the machine time step).

Parameters:
property current_source_id

The ID of the current source.

Return type:

int

property get_parameter_types

The parameter types for the current source.

Return type:

dict(str, Any)

property get_parameters

The parameters of the current source.

Return type:

dict(str, Any)

get_sdram_usage_in_bytes()[source]

The SDRAM usage in bytes of the current source.

Return type:

int

set_parameters(**parameters)[source]

Set the current source parameters.

Parameters:

parameters – the parameters to set

class spynnaker.pyNN.OneToOneConnector(safe=True, callback=None, verbose=False)[source]

Bases: AbstractGenerateConnectorOnMachine, AbstractGenerateConnectorOnHost

Where the pre- and postsynaptic populations have the same size, connect cell i in the presynaptic population to cell i in the postsynaptic population, for all i.

Parameters:
  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

property gen_connector_id

The ID of the connection generator on the machine.

Return type:

int

gen_connector_params()[source]

Get the parameters of the on machine generation.

Return type:

ndarray(uint32)

property gen_connector_params_size_in_bytes

The size of the connector parameters, in bytes.

Return type:

int

get_connected_vertices(s_info, source_vertex, target_vertex)[source]

Get the machine vertices that are connected to each other with this connector

Parameters:
Returns:

A list of tuples of (target machine vertex, list of sources)

Return type:

list(tuple(MachineVertex, list(AbstractVertex)))

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

use_direct_matrix(synapse_info)[source]
Parameters:

synapse_info (SynapseInformation) –

Return type:

bool

spynnaker.pyNN.PoolDense

alias of LocalOnlyPoolDense

class spynnaker.pyNN.PoolDenseConnector(weights, pool_shape=None, pool_stride=None, positive_receptor_type='excitatory', negative_receptor_type='inhibitory', safe=True, verbose=False, callback=None)[source]

Bases: AbstractConnector

Where the pre- and post-synaptic populations are considered as a 2D array. Connect every post(row, column) neuron to many pre(row, column, kernel) through a (kernel) set of weights and/or delays.

Parameters:
  • weights (int or float or list(int or float) or ndarray or RandomDistribution) –

    The synaptic strengths. Can be:

    • single value: the same value will be used for all weights

    • list: the total number of elements must be (number after pooling * number post)

    • ndarray: As above for list

    • RandomDistribution: weights will be drawn at random

  • pool_shape (int or tuple(int) or None) – Shape of average pooling. If a single value is provided, it will be used for every dimension, otherwise must be the same number of values as there are dimensions in the source.

  • pool_stride (int or tuple(int) or None) – Jumps between pooling regions. If a single value is provided, the same stride will be used for all dimensions, otherwise must be the same number of values as there are dimensions in the source. If None, and pool_shape is provided, pool_stride will be set to pool_shape.

  • positive_receptor_type (str) – The receptor type to add the positive weights to. By default this is “excitatory”.

  • negative_receptor_type (str) – The receptor type to add the negative weights to. By default this is “inhibitory”.

  • safe (bool) – (ignored)

  • verbose (bool) – (ignored)

  • callback (callable) – (ignored)

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

static get_post_pool_shape(pre_shape, pool_shape=None, pool_stride=None)[source]
get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

local_only_n_bytes(incoming_slices, n_post_atoms)[source]
Parameters:
  • incoming_slices (iterable(Slice)) –

  • n_post_atoms (int) –

Return type:

int

property negative_receptor_type
Return type:

str

property positive_receptor_type
Return type:

str

validate_connection(application_edge, synapse_info)[source]

Checks that the edge supports the connector. By default this does nothing i.e. assumes the edge is OK, but can be overridden if the connector has rules that need to be checked. Returns nothing; it is assumed that an Exception will be raised if anything is wrong.

Parameters:
property weights
Return type:

ndarray

write_local_only_data(spec, app_edge, pre_vertex_slice, post_vertex_slice, key, mask, n_colour_bits, weight_scales)[source]
Parameters:
class spynnaker.pyNN.Population(size, cellclass, cellparams=None, structure=None, initial_values=None, label=None, additional_parameters=None, **additional_kwargs)[source]

Bases: PopulationBase

PyNN 0.9 population object.

Parameters:
  • size (int) – The number of neurons in the population

  • cellclass (type or AbstractPyNNModel) – The implementation of the individual neurons.

  • cellparams (dict(str,object) or None) – Parameters to pass to cellclass if it is a class to instantiate. Must be None if cellclass is an instantiated object.

  • structure (BaseStructure) –

  • initial_values (dict(str,float)) – Initial values of state variables

  • label (str) – A label for the population

  • additional_parameters (dict(str, ...)) – Additional parameters to pass to the vertex creation function.

  • additional_kwargs (dict(str, ...)) – A nicer way of allowing additional things

add_placement_constraint(x, y, p=None)[source]

Add a placement constraint.

Parameters:
  • x (int) – The x-coordinate of the placement constraint

  • y (int) – The y-coordinate of the placement constraint

  • p (int) – The processor ID of the placement constraint (optional)

Raises:
all()[source]

Iterator over cell IDs on all MPI nodes.

Return type:

iterable(IDMixin)

property all_cells
Return type:

list(IDMixin)

property annotations

The annotations given by the end user.

Return type:

dict(str, …)

can_record(variable)[source]

Determine whether variable can be recorded from this population.

Parameters:

variable (str) – The variable to answer the question about

Return type:

bool

property celltype

Implements the PyNN expected celltype property.

Returns:

The cell type this property has been set to

Return type:

AbstractPyNNModel

property conductance_based

Whether the population uses conductance inputs

Return type:

bool

static create(cellclass, cellparams=None, n=1)[source]

Pass through method to the constructor defined by PyNN. Create n cells all of the same type.

Parameters:
Returns:

A New Population

Return type:

Population

property current_values

Get the current values of the state variables.

Return type:

ParameterHolder

describe(template='population_default.txt', engine='default')[source]

Returns a human-readable description of the population.

The output may be customized by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Parameters:
  • template (str) – Template filename

  • engine (str or TemplateEngine or None) – Template substitution engine

Return type:

str or dict

find_units(variable)[source]

Get the units of a variable.

Parameters:

variable (str) – The name of the variable

Returns:

The units of the variable

Return type:

str

property first_id

The ID of the first member of the population.

Return type:

int

get(parameter_names, gather=True, simplify=True)[source]

Get the values of a parameter for every local cell in the population.

Parameters:
  • parameter_names (str or iterable(str)) – Name of parameter. This is either a single string or a list of strings

  • gather (bool) – pointless on sPyNNaker

  • simplify (bool) – ignored

Returns:

A single list of values (or possibly a single value) if paramter_names is a string, or a dict of these if parameter names is a list.

Return type:

ParameterHolder

get_data(variables='all', gather=True, clear=False, annotations=None)[source]

Return a Neo Block containing the data (spikes, state variables) recorded from the Assembly.

Parameters:
  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    Whether to collect data from all MPI nodes or just the current node.

    Note

    This is irrelevant on sPyNNaker, which always behaves as if this parameter is True.

  • clear (bool) – Whether recorded data will be deleted from the Assembly.

  • annotations (dict(str, ...)) – annotations to put on the neo block

Return type:

Block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

get_spike_counts(gather=True)[source]

Return the number of spikes for each neuron.

Return type:

ndarray

id_to_index(id)[source]

Given the ID(s) of cell(s) in the Population, return its (their) index (order in the Population).

Defined by https://neuralensemble.org/docs/PyNN/reference/populations.html

Parameters:

id (int or iterable(int)) –

Return type:

int or iterable(int)

id_to_local_index(cell_id)[source]

Given the ID(s) of cell(s) in the Population, return its (their) index (order in the Population), counting only cells on the local MPI node.

Defined by https://neuralensemble.org/docs/PyNN/reference/populations.html

Parameters:

cell_id (int or iterable(int)) –

Return type:

int or iterable(int)

index_to_id(index)[source]

Given the index (order in the Population) of cell(s) in the Population, return their ID(s)

Parameters:

index (int or iterable(int)) –

Return type:

int or iterable(int)

property initial_values

The initial values of the state variables.

Note

These values will be the same as the values set with the last call to initialize rather than the actual initial values if this call has been made.

Return type:

ParameterHolder

initialize(**kwargs)[source]

Set initial values of state variables, e.g. the membrane potential. Values passed to initialize() may be:

  • single numeric values (all neurons set to the same value), or

  • RandomDistribution objects, or

  • lists / arrays of numbers of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single number.

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Examples:

p.initialize(v=-70.0)
p.initialize(v=rand_distr, gsyn_exc=0.0)
p.initialize(v=lambda i: -65 + i / 10.0)
inject(current_source)[source]

Connect a current source to all cells in the Population.

Defined by https://neuralensemble.org/docs/PyNN/reference/populations.html

property label

The label of the population.

Return type:

str

property last_id

The ID of the last member of the population.

Return type:

int

property local_size

The number of local cells.

Defined by https://neuralensemble.org/docs/PyNN/reference/populations.html

property position_generator
Return type:

callable((int), ndarray)

property positions

The position array for structured populations.

Returns:

a 3xN array

Return type:

ndarray

record(variables, to_file=None, sampling_interval=None)[source]

Record the specified variable or variables for all cells in the Population or view.

Parameters:
  • variables (str or list(str)) – either a single variable name or a list of variable names. For a given celltype class, celltype.recordable contains a list of variables that can be recorded for that celltype.

  • to_file (io or rawio or str) – a file to automatically record to (optional). write_data() will be automatically called when sim.end() is called.

  • sampling_interval (int) – a value in milliseconds, and an integer multiple of the simulation timestep.

sample(n, rng=None)[source]

Randomly sample n cells from the Population, and return a PopulationView object.

Parameters:
  • n (int) – The number of cells to put in the view.

  • rng (NumpyRNG) – The random number generator to use

Return type:

PopulationView

set(**parameters)[source]

Set one or more parameters for every cell in the population.

parameter can be a dict, in which case value should not be supplied, or a string giving the parameter name, in which case value is the parameter value. value can be a numeric value, or list of such (e.g. for setting spike times):

p._set("tau_m", 20.0).
p._set({'tau_m':20, 'v_rest':-65})
Parameters:
Raises:
set_max_atoms_per_core(max_atoms_per_core)[source]

Supports the setting of this population’s max atoms per dimension per core.

Parameters:

max_atoms_per_core (int) – the new value for the max atoms per dimension per core.

Raises:
set_state(**kwargs)[source]

Set current values of state variables, e.g. the membrane potential. Values passed to set_state() may be:

  • single numeric values (all neurons set to the same value), or

  • RandomDistribution objects, or

  • lists / arrays of numbers of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single number.

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Examples:

p.set_state(v=-70.0)
p.set_state(v=rand_distr, gsyn_exc=0.0)
p.set_state(v=lambda i: -65 + i / 10.0)
property size

The number of neurons in the population.

Return type:

int

spinnaker_get_data(variable, as_matrix=False, view_indexes=None)[source]

Public accessor for getting data as a numpy array, instead of the Neo-based object

Parameters:
  • variable (str or list(str)) – a single variable name.

  • as_matrix (bool) – If set True the data is returned as a 2d matrix

  • view_indexes – The indexes for which data should be returned. If None, all data (view_index = data_indexes)

Returns:

array of the data

Return type:

ndarray

property structure

The structure for the population.

Return type:

BaseStructure or None

write_data(io, variables='all', gather=True, clear=False, annotations=None)[source]

Write recorded data to file, using one of the file formats supported by Neo.

Parameters:
  • io (neo.io.baseio.BaseIO or str) – a Neo IO instance, or a string for where to put a neo instance

  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    Whether to bring all relevant data together.

    Note

    SpiNNaker always gathers.

  • clear (bool) – clears the storage data if set to true after reading it back

  • annotations (dict(str, ...)) – annotations to put on the neo block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

class spynnaker.pyNN.PopulationView(parent, selector, label=None)[source]

Bases: PopulationBase

A view of a subset of neurons within a Population.

In most ways, Populations and PopulationViews have the same behaviour, i.e., they can be recorded, connected with Projections, etc. It should be noted that any changes to neurons in a PopulationView will be reflected in the parent Population and vice versa.

It is possible to have views of views.

Note

Selector to Id is actually handled by AbstractSized.

Parameters:
  • parent (Population or PopulationView) – the population or view to make the view from

  • vertex (PopulationApplicationVertex) – The actual underlying vertex

  • recorder (Recorder) – The recorder of the Population

  • selector (None or slice or int or list(bool) or list(int) or ndarray(bool) or ndarray(int)) –

    a slice or numpy mask array. The mask array should either be a boolean array (ideally) of the same size as the parent, or an integer array containing cell indices, i.e. if p.size == 5 then:

    PopulationView(p, array([False, False, True, False, True]))
    PopulationView(p, array([2, 4]))
    PopulationView(p, slice(2, 5, 2))
    

    will all create the same view.

  • label (str) – A label for the view

all()[source]

Iterator over cell IDs (on all MPI nodes).

Return type:

iterable(IDMixin)

property all_cells

An array containing the cell IDs of all neurons in the Population (all MPI nodes).

Return type:

list(IDMixin)

can_record(variable)[source]

Determine whether variable can be recorded from this population.

Return type:

bool

property celltype

The type of neurons making up the underlying Population.

Return type:

AbstractPyNNModel

property conductance_based

Whether the post-synaptic response is modelled as a change in conductance or a change in current.

Return type:

bool

property current_values

A dict containing the current values of the state variables.

Return type:

InitialValuesHolder

describe(template='populationview_default.txt', engine='default')[source]

Returns a human-readable description of the population view.

The output may be customized by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Parameters:
  • template (str) – Template filename

  • engine (str or TemplateEngine or None) – Template substitution engine

Return type:

str or dict

find_units(variable)[source]

Get the units of a variable

Warning

No PyNN description of this method.

Parameters:

variable (str) – The name of the variable

Returns:

The units of the variable

Return type:

str

get(parameter_names, gather=False, simplify=True)[source]

Get the values of the given parameters for every local cell in the population, or, if gather=True, for all cells in the population.

Values will be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Note

SpiNNaker always gathers.

Parameters:
Return type:

ParameterHolder

get_data(variables='all', gather=True, clear=False, annotations=None)[source]

Return a Neo Block containing the data(spikes, state variables) recorded from the Population.

Parameters:
  • variables (str or list(str)) – Either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    For parallel simulators, if gather is True, all data will be gathered to all nodes and the Neo Block will contain data from all nodes. Otherwise, the Neo Block will contain only data from the cells simulated on the local node.

    Note

    SpiNNaker always gathers.

  • clear (bool) – If True, recorded data will be deleted from the Population.

  • annotations (dict(str, ...)) – annotations to put on the neo block

Return type:

Block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

get_spike_counts(gather=True)[source]

Returns a dict containing the number of spikes for each neuron.

The dict keys are neuron IDs, not indices.

Note

Implementation of this method is different to Population as the Populations uses PyNN 7 version of the get_spikes method which does not support indexes.

Parameters:

gather (bool) –

Note

SpiNNaker always gathers.

Return type:

dict(int,int)

property grandparent

The parent Population at the root of the tree (since the immediate parent may itself be a PopulationView).

The name “grandparent” is of course a little misleading, as it could be just the parent, or the great, great, great, …, grandparent.

Return type:

Population

id_to_index(id)[source]

Given the ID(s) of cell(s) in the PopulationView, return its / their index / indices(order in the PopulationView).

assert pv.id_to_index(pv[3]) == 3

Parameters:

id (int or list(int)) –

Return type:

int or list(int)

index_in_grandparent(indices)[source]

Given an array of indices, return the indices in the parent population at the root of the tree.

Parameters:

indices (list(int)) –

Return type:

list(int)

property initial_values

A dict containing the initial values of the state variables.

Return type:

InitialValuesHolder

initialize(**initial_values)[source]

Set initial values of state variables, e.g. the membrane potential. Values passed to initialize() may be:

  • single numeric values (all neurons set to the same value), or

  • RandomDistribution objects, or

  • lists / arrays of numbers of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single number.

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, events per second).

Examples:

p.initialize(v=-70.0)
p.initialize(v=rand_distr, gsyn_exc=0.0)
p.initialize(v=lambda i: -65 + i / 10.0)
inject(current_source)[source]

Injects the specified current_source into this PopulationView.

Parameters:

current_source (AbstractCurrentSource) – the current source to be injected

property label

A label for the Population View.

Return type:

str

property mask

The selector mask that was used to create this view.

Return type:

None or slice or int or list(bool) or list(int) or ndarray(bool) or ndarray(int)

property parent

A reference to the parent Population (that this is a view of).

Return type:

Population

record(variables, to_file=None, sampling_interval=None)[source]

Record the specified variable or variables for all cells in the Population or view.

Parameters:
  • variables (str or list(str)) – either a single variable name, or a list of variable names, or all to record everything. For a given celltype class, celltype.recordable contains a list of variables that can be recorded for that celltype.

  • to_file (io or rawio or str) – If specified, should be a Neo IO instance and write_data() will be automatically called when sim.end() is called.

  • sampling_interval (int) – should be a value in milliseconds, and an integer multiple of the simulation timestep.

sample(n, rng=None)[source]

Randomly sample n cells from the Population view, and return a new PopulationView object.

Parameters:
  • n (int) – The number of cells to select

  • rng (NumpyRNG) – Random number generator

Return type:

PopulationView

set(**parameters)[source]

Set one or more parameters for every cell in the population. Values passed to set() may be:

  • single values,

  • RandomDistribution objects, or

  • lists / arrays of values of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single value.

Here, a “single value” may be either a single number or a list / array of numbers (e.g. for spike times).

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Examples:

p.set(tau_m=20.0, v_rest=-65).
p.set(spike_times=[0.3, 0.7, 0.9, 1.4])
p.set(cm=rand_distr, tau_m=lambda i: 10 + i / 10.0)
set_state(**initial_values)[source]

Set current values of state variables, e.g. the membrane potential. Values passed to initialize() may be:

  • single numeric values (all neurons set to the same value), or

  • RandomDistribution objects, or

  • lists / arrays of numbers of the same size as the population mapping functions, where a mapping function accepts a single argument (the cell index) and returns a single number.

Values should be expressed in the standard PyNN units (i.e. millivolts, nanoamps, milliseconds, microsiemens, nanofarads, events per second).

Examples:

p.set_state(v=-70.0)
p.set_state(v=rand_distr, gsyn_exc=0.0)
p.set_state(v=lambda i: -65 + i / 10.0)
property size

The total number of neurons in the Population View.

Return type:

int

spinnaker_get_data(variable, as_matrix=False)[source]

Public accessor for getting data as a numpy array, instead of the Neo-based object

Parameters:
  • variable (str) – a single variable name

  • as_matrix (bool) – If set True the data is returned as a 2d matrix

Returns:

array of the data

Return type:

ndarray

spinnaker_get_spikes()[source]

Public accessor for getting spikes as a numpy array, instead of the Neo-based object

write_data(io, variables='all', gather=True, clear=False, annotations=None)[source]

Write recorded data to file, using one of the file formats supported by Neo.

Parameters:
  • io (neo.io.BaseIO or str) – a Neo IO instance or the name of a file to write

  • variables (str or list(str)) – either a single variable name or a list of variable names. These must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    For parallel simulators, if this is True, all data will be gathered to the master node and a single output file created there. Otherwise, a file will be written on each node, containing only data from the cells simulated on that node.

    Note

    SpiNNaker always gathers.

  • clear (bool) – If this is True, recorded data will be deleted from the Population.

  • annotations (dict(str, ...)) – should be a dict containing simple data types such as numbers and strings. The contents will be written into the output data file as metadata.

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

spynnaker.pyNN.Projection(presynaptic_population, postsynaptic_population, connector, synapse_type=None, source=None, receptor_type='excitatory', space=None, label=None)[source]

Used to support PEP 8 spelling correctly.

Parameters:
  • presynaptic_population (Population) – the source pop

  • postsynaptic_population (Population) – the destination population

  • connector (AbstractConnector) – the connector type

  • synapse_type (AbstractStaticSynapseDynamics) – the synapse type

  • source (None) – Unsupported; must be None

  • receptor_type (str) – the receptor type

  • space (Space or None) – the space object

  • label (str or None) – the label

Returns:

a projection object for SpiNNaker

Return type:

Projection

class spynnaker.pyNN.RandomByWeightElimination(threshold, prob_elim_depressed=0.0245, prob_elim_potentiated=0.00013600000000000003)[source]

Bases: AbstractElimination

Elimination Rule that depends on the weight of a synapse.

Parameters:
  • threshold (float) – Below this weight is considered depression, above or equal to this weight is considered potentiation (or the static weight of the connection on static weight connections)

  • prob_elim_depressed (float) – The probability of elimination if the weight has been depressed (ignored on static weight connections)

  • prob_elim_potentiated (float) – The probability of elimination of the weight has been potentiated or has not changed (and also used on static weight connections)

get_parameter_names()[source]

Return the names of the parameters supported by this rule.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

int

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec, weight_scale)[source]

Write the parameters of the rule to the spec.

Parameters:
class spynnaker.pyNN.RandomDistribution(*args: Any, **kwargs: Any)[source]

Bases: RandomDistribution

Class which defines a next(n) method which returns an array of n random numbers from a given distribution.

Examples:

>>> rd = RandomDistribution('uniform', (-70, -50))
>>> rd = RandomDistribution('normal', mu=0.5, sigma=0.1)
>>> rng = NumpyRNG(seed=8658764)
>>> rd = RandomDistribution('gamma', k=2.0, theta=5.0, rng=rng)
Available distributions

Name

Parameters

Comments

binomial

n, p

gamma

k, theta

exponential

beta

lognormal

mu, sigma

normal

mu, sigma

normal_clipped

mu, sigma, low, high

Values outside (low, high) are redrawn

normal_clipped_to_boundary

mu, sigma, low, high

Values below/above low/high are set to low/high

poisson

lambda_

Trailing underscore since lambda is a Python keyword

uniform

low, high

uniform_int

low, high

Only generates integer values

vonmises

mu, kappa

Parameters:
  • distribution (str) – the name of a random number distribution.

  • parameters_pos (tuple or None) – parameters of the distribution, provided as a tuple. For the correct ordering, see random.available_distributions.

  • rng (NumpyRNG or GSLRNG or NativeRNG or None) – the random number generator to use, if a specific one is desired (e.g., to provide a seed).

  • parameters_named – parameters of the distribution, provided as keyword arguments.

Parameters may be provided either through parameters_pos or through parameters_named, but not both. All parameters must be provided, there are no default values. Parameter names are, in general, as used in Wikipedia.

class spynnaker.pyNN.RandomSelection[source]

Bases: AbstractPartnerSelection

Partner selection that picks a random source neuron from all sources.

get_parameter_names()[source]

Return the names of the parameters supported by this rule.

Return type:

iterable(str)

get_parameters_sdram_usage_in_bytes()[source]

Get the amount of SDRAM used by the parameters of this rule.

Return type:

str

property vertex_executable_suffix

The suffix to be appended to the vertex executable for this rule.

Return type:

str

write_parameters(spec)[source]

Write the parameters of the rule to the spec.

Parameters:

spec (DataSpecificationGenerator) –

spynnaker.pyNN.STDPMechanism

alias of SynapseDynamicsSTDP

class spynnaker.pyNN.SmallWorldConnector(degree, rewiring, allow_self_connections=True, n_connections=None, rng=None, safe=True, callback=None, verbose=False)[source]

Bases: AbstractConnector, AbstractGenerateConnectorOnHost

A connector that uses connection statistics based on the Small World network connectivity model.

Note

This is typically used from a population to itself.

Parameters:
  • degree (float) – the region length where nodes will be connected locally

  • rewiring (float) – the probability of rewiring each edge

  • allow_self_connections (bool) – if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population.

  • n_connections (int or None) – if specified, the number of efferent synaptic connections per neuron

  • rng (NumpyRNG or None) – Seeded random number generator, or None to make one when needed.

  • safe (bool) – If True, check that weights and delays have valid values. If False, this check is skipped.

  • callback (callable) –

    if given, a callable that display a progress bar on the terminal.

    Note

    Not supported by sPyNNaker.

  • verbose (bool) – Whether to output extra information about the connectivity to a CSV file

create_synaptic_block(post_slices, post_vertex_slice, synapse_type, synapse_info)[source]

Create a synaptic block from the data.

Parameters:
Returns:

The synaptic matrix data to go to the machine, as a Numpy array

Return type:

ndarray

get_delay_maximum(synapse_info)[source]

Get the maximum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) – the synapse info

Return type:

int or None

get_delay_minimum(synapse_info)[source]

Get the minimum delay specified by the user in ms, or None if unbounded.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int or None

get_n_connections_from_pre_vertex_maximum(n_post_atoms, synapse_info, min_delay=None, max_delay=None)[source]

Get the maximum number of connections from any neuron in the pre vertex to the neurons in the post_vertex_slice, for connections with a delay between min_delay and max_delay (inclusive) if both specified (otherwise all connections).

Parameters:
Return type:

int

get_n_connections_to_post_vertex_maximum(synapse_info)[source]

Get the maximum number of connections to any neuron in the post vertex from neurons in the pre vertex.

Parameters:

synapse_info (SynapseInformation) –

Return type:

int

get_weight_maximum(synapse_info)[source]

Get the maximum of the weights for this connection.

Parameters:

synapse_info (SynapseInformation) –

Return type:

float

set_projection_information(synapse_info)[source]

Sets a connectors projection info.

Parameters:

synapse_info (SynapseInformation) – the synapse info

spynnaker.pyNN.SpiNNakerProjection

alias of Projection

spynnaker.pyNN.SpikePairRule

alias of TimingDependenceSpikePair

class spynnaker.pyNN.SpikeSourceArray(spike_times=None)[source]

Bases: AbstractPyNNModel

create_vertex(n_neurons, label, splitter, n_colour_bits)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

  • splitter (AbstractSplitterCommon or None) –

  • n_colour_bits (int) –

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

default_population_parameters = {'n_colour_bits': None, 'splitter': None}
class spynnaker.pyNN.SpikeSourcePoisson(rate=1.0, start=0, duration=None)[source]

Bases: AbstractPyNNModel

absolute_max_atoms_per_core = 500
create_vertex(n_neurons, label, seed, max_rate, splitter, n_colour_bits)[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons (int) – The number of neurons in the population

  • label (str) – The label to give to the vertex

  • seed (float) –

  • max_rate (float) –

  • splitter (AbstractSplitterCommon or None) –

  • n_colour_bits (int) –

Returns:

An application vertex for the population

Return type:

PopulationApplicationVertex

default_population_parameters = {'max_rate': None, 'n_colour_bits': None, 'seed': None, 'splitter': None}
spynnaker.pyNN.StaticSynapse

alias of SynapseDynamicsStatic

class spynnaker.pyNN.StepCurrentSource(times=None, amplitudes=None)[source]

Bases: AbstractCurrentSource

Current source where the amplitude changes based on a time array.

Parameters:
property current_source_id

The ID of the current source.

Return type:

int

property get_parameter_types

The parameter types for the current source.

Return type:

dict(str, Any)

property get_parameters

The parameters of the current source.

Return type:

dict(str, Any)

get_sdram_usage_in_bytes()[source]

The SDRAM usage in bytes of the current source.

Return type:

int

set_parameters(**parameters)[source]

Set the current source parameters.

Parameters:

parameters – the parameters to set

spynnaker.pyNN.StructuralMechanismSTDP

alias of SynapseDynamicsStructuralSTDP

spynnaker.pyNN.StructuralMechanismStatic

alias of SynapseDynamicsStructuralStatic

spynnaker.pyNN.connect(pre, post, weight=0.0, delay=None, receptor_type=None, p=1, rng=None)[source]

Builds a projection.

Parameters:
  • pre (Population) – source pop

  • post (Population) – destination pop

  • weight (float) – weight of the connections

  • delay (float) – the delay of the connections

  • receptor_type (str) – excitatory / inhibitory

  • p (float) – probability

  • rng (NumpyRNG) – random number generator

spynnaker.pyNN.create(cellclass, cellparams=None, n=1)[source]

Builds a population with certain parameters.

Parameters:
  • cellclass (type or AbstractPyNNModel) – population class

  • cellparams – population parameters.

  • n (int) – number of neurons

Return type:

Population

spynnaker.pyNN.distance(src_cell, tgt_cell, mask=None, scale_factor=1.0, offset=0.0, periodic_boundaries=None)[source]

Return the Euclidean distance between two cells.

Parameters:
  • src_cell – Measure from this cell

  • tgt_cell – To this cell

  • mask (ndarray) –

    allows only certain dimensions to be considered, e.g.:

    • to ignore the z-dimension, use mask=array([0,1])

    • to ignore y, mask=array([0,2])

    • to just consider z-distance, mask=array([2])

  • scale_factor (float) – allows for different units in the pre- and post-position (the post-synaptic position is multiplied by this quantity).

  • offset (float) –

  • periodic_boundaries

spynnaker.pyNN.end(_=True)[source]

Cleans up the SpiNNaker machine and software

Parameters:

_ – was named compatible_output, which we don’t care about, so is a non-existent parameter

spynnaker.pyNN.get_current_time()[source]

Gets the time within the simulation.

Returns:

returns the current time

spynnaker.pyNN.get_machine()[source]

Get the SpiNNaker machine in use.

Returns:

the machine object

Return type:

Machine

spynnaker.pyNN.get_max_delay()[source]

Part of the PyNN API but does not make sense for sPyNNaker as different Projection, Vertex splitter combination could have different delays they can support.

Most likely value is timestep * 144

Raises:

NotImplementedError – As there is no system wide max_delay

spynnaker.pyNN.get_min_delay()[source]

The minimum allowed synaptic delay; delays will be clamped to be at least this.

Returns:

returns the min delay of the simulation

Return type:

int

spynnaker.pyNN.get_time_step()[source]

The integration time step.

Returns:

get the time step of the simulation (in ms)

Return type:

float

spynnaker.pyNN.initialize(cells, **initial_values)[source]

Sets cells to be initialised to the given values.

Parameters:
  • cells (Population or PopulationView) – the cells to change parameters on

  • initial_values – the parameters and their values to change

spynnaker.pyNN.list_standard_models()[source]

Return a list of all the StandardCellType classes available for this simulator.

Return type:

list(str)

spynnaker.pyNN.name()[source]

Returns the name of the simulator.

Return type:

str

spynnaker.pyNN.num_processes()[source]

The number of MPI processes.

Note

Always 1 on SpiNNaker, which doesn’t use MPI.

Returns:

the number of MPI processes

Return type:

int

spynnaker.pyNN.rank()[source]

The MPI rank of the current node.

Note

Always 0 on SpiNNaker, which doesn’t use MPI.

Returns:

MPI rank

Return type:

int

spynnaker.pyNN.record(variables, source, filename, sampling_interval=None, annotations=None)[source]

Sets variables to be recorded.

Parameters:
  • variables (str or list(str)) – may be either a single variable name or a list of variable names. For a given celltype class, celltype.recordable contains a list of variables that can be recorded for that celltype.

  • source (Population or PopulationView) – where to record from

  • filename (str) – file name to write data to

  • sampling_interval – how often to sample the recording, not ignored so far

  • annotations (dict(str, ...)) – the annotations to data writers

Returns:

neo object

Return type:

Block

spynnaker.pyNN.record_gsyn(source, filename)[source]

Deprecated method for getting both types of gsyn. This is not documented in the public facing API

Deprecated since version 5.0.

Parameters:
spynnaker.pyNN.record_v(source, filename)[source]

Deprecated method for getting voltage. This is not documented in the public facing API.

Deprecated since version 5.0.

Parameters:
spynnaker.pyNN.reset(annotations=None)[source]

Resets the simulation to t = 0.

Parameters:

annotations (dict(str, ...)) – the annotations to the data objects

spynnaker.pyNN.run(simtime, callbacks=None)[source]

The run() function advances the simulation for a given number of milliseconds.

Parameters:
  • simtime (float) – time to run for (in milliseconds)

  • callbacks – callbacks to run

Returns:

the actual simulation time that the simulation stopped at

Return type:

float

spynnaker.pyNN.run_for(simtime, callbacks=None)

The run() function advances the simulation for a given number of milliseconds.

Parameters:
  • simtime (float) – time to run for (in milliseconds)

  • callbacks – callbacks to run

Returns:

the actual simulation time that the simulation stopped at

Return type:

float

spynnaker.pyNN.run_until(tstop)[source]

Run until a (simulation) time period has completed.

Parameters:

tstop (float) – the time to stop at (in milliseconds)

Returns:

the actual simulation time that the simulation stopped at

Return type:

float

spynnaker.pyNN.set_number_of_neurons_per_core(neuron_type, max_permitted)[source]

Sets a ceiling on the number of neurons of a given model that can be placed on a single core. This can be overridden by the individual Population.

The new value can be None, meaning that the maximum is the same as the number of atoms, an int, meaning all Populations of this model must have one dimension, or a tuple of n integers, meaning all Populations of this model must have n dimensions. If not all Populations of this model have the same number of dimensions, it is recommended to set this to None here and then set the maximum on each Population.

Parameters:
spynnaker.pyNN.setup(timestep=pyNN.common.control.DEFAULT_TIMESTEP, min_delay=pyNN.common.control.DEFAULT_MIN_DELAY, max_delay=None, database_socket_addresses=None, time_scale_factor=None, n_chips_required=None, n_boards_required=None, **extra_params)[source]

The main method needed to be called to make the PyNN 0.8 setup. Needs to be called before any other function

Parameters:
  • timestep (float or None) – the time step of the simulations in microseconds; if None, the configuration value is used

  • min_delay (float or str) – the minimum delay of the simulation

  • max_delay (float or str or None) – Ignored and logs a warning if provided

  • database_socket_addresses (iterable(SocketAddress)) – the sockets used by external devices for the database notification protocol

  • time_scale_factor (int or None) – multiplicative factor to the machine time step (does not affect the neuron models accuracy)

  • n_chips_required (int or None) – Deprecated! Use n_boards_required instead. Must be None if n_boards_required specified.

  • n_boards_required (int or None) – if you need to be allocated a machine (for spalloc) before building your graph, then fill this in with a general idea of the number of boards you need so that the spalloc system can allocate you a machine big enough for your needs.

  • extra_params – other keyword arguments used to configure PyNN

Returns:

MPI rank (always 0 on SpiNNaker)

Return type:

int

Raises:

ConfigurationException – if both n_chips_required and n_boards_required are used.

Submodules
spynnaker.gsyn_tools module
spynnaker.gsyn_tools.check_gsyn(gsyn1, gsyn2)[source]

Compare two arrays of conductances. For testing.

Parameters:
  • gsyn1 – An array of conductances.

  • gsyn2 – An array of conductances.

Raises:

ValueError – If the arrays differ.

spynnaker.gsyn_tools.check_path_gysn(path, n_neurons, runtime, gsyn)[source]

Compare an arrays of conductances with baseline data from a file. For testing.

Parameters:
  • path – A file path.

  • n_neurons – The number of neurons that produced the data.

  • runtime – The length of time that the generated data represents.

  • gsyn – An array of conductances.

Raises:

ValueError – If the arrays differ.

spynnaker.gsyn_tools.check_sister_gysn(sister, n_neurons, runtime, gsyn)[source]

Compare an arrays of conductances with baseline data from a file next to a specified module. For testing.

Parameters:
  • sister – A module. The file read from will be gsyn.data adjacent to this module.

  • n_neurons – The number of neurons that produced the data.

  • runtime – The length of time that the generated data represents.

  • gsyn – An array of conductances.

Raises:

ValueError – If the arrays differ.

spynnaker.plot_utils module
spynnaker.plot_utils.heat_plot(data_sets, ylabel=None, title=None)[source]

Build a heatmap plot or plots.

Parameters:
  • data_sets (ndarray or list(ndarray)) – Numpy array of data, or list of numpy arrays of data

  • ylabel (str or None) – The label for the Y axis

  • title (str or None) – The title for the plot

spynnaker.plot_utils.line_plot(data_sets, title=None)[source]

Build a line plot or plots.

Parameters:
  • data_sets (ndarray or list(ndarray)) – Numpy array of data, or list of numpy arrays of data

  • title (str or None) – The title for the plot

spynnaker.plot_utils.plot_spikes(spikes, title='spikes')[source]

Build a spike plot or plots.

Parameters:
  • spikes (ndarray or list(ndarray)) – Numpy array of spikes, or list of numpy arrays of spikes

  • title (str) – The title for the plot

spynnaker.spike_checker module
spynnaker.spike_checker.synfire_multiple_lines_spike_checker(spikes, nNeurons, lines, wrap_around=True)[source]

Checks that there are the expected number of spike lines

Parameters:
  • spikes (ndarray or list(ndarray)) – The spikes

  • nNeurons (int) – The number of neurons.

  • lines (int) – Expected number of lines

  • wrap_around (bool) – If True the lines will wrap around when reaching the last neuron.

Raises:

Exception – If there is a problem with the data

spynnaker.spike_checker.synfire_spike_checker(spikes, nNeurons)[source]
Parameters:
  • spikes (ndarray or list(ndarray)) – The spike data to check.

  • nNeurons (int) – The number of neurons.

Raises:

Exception – If there is a problem with the data

spynnaker.spynnaker_plotting module

Plotting tools to be used together with https://github.com/NeuralEnsemble/PyNN/blob/master/pyNN/utility/plotting.py

class spynnaker.spynnaker_plotting.SpynnakerPanel(*data, **options)[source]

Bases: object

Represents a single panel in a multi-panel figure.

Compatible with pyNN.utility.plotting.Frame and can be mixed with pyNN.utility.plotting.Panel

Unlike pyNN.utility.plotting.Panel, Spikes are plotted faster, other data is plotted as a heatmap.

A panel is a Matplotlib Axes or Subplot instance. A data item may be an AnalogSignal, or a list of SpikeTrains. The Panel will automatically choose an appropriate representation. Multiple data items may be plotted in the same panel.

Valid options are any valid Matplotlib formatting options that should be applied to the Axes/Subplot, plus in addition:

data_labels:

a list of strings of the same length as the number of data items.

line_properties:

a list of dictionaries containing Matplotlib formatting options, of the same length as the number of data items.

Whole Neo Objects can be passed in as long as they contain a single Segment/run and only contain one type of data. Whole Segments can be passed in only if they only contain one type of data.

Parameters:
plot(axes)[source]

Plot the Panel’s data in the provided Axes/Subplot instance.

Parameters:

axes (Axes) – An Axes in a matplotlib figure

spynnaker.spynnaker_plotting.heat_plot_neo(axes, signal_array, label='', **options)[source]

Plots neurons, times and values into a heatmap.

Parameters:
  • axes (Axes) – An Axes in a matplotlib figure

  • signal_array (AnalogSignal) – Neo Signal array object

  • label (str) – Label for the graph

  • options – plotting options

spynnaker.spynnaker_plotting.heat_plot_numpy(axes, data, label='', **options)[source]

Plots neurons, times and values into a heatmap.

Parameters:
  • axes (Axes) – An Axes in a matplotlib figure

  • data (ndarray) – numpy array of values in spynnaker7 format

  • label (str) – Label for the graph

  • options – plotting options

spynnaker.spynnaker_plotting.plot_segment(axes, segment, label='', **options)[source]

Plots a segment into a plot of spikes or a heatmap.

If there is more than ode type of Data in the segment options must include the name of the data to plot

Note

Method signature defined by PyNN plotting. This allows mixing of this plotting tool and PyNN’s

Parameters:
  • axes (Axes) – An Axes in a matplotlib figure

  • segment (Segment) – Data for one run to plot

  • label (str) – Label for the graph

  • options – plotting options

spynnaker.spynnaker_plotting.plot_spikes_numpy(axes, spikes, label='', **options)[source]

Plot all spikes.

Parameters:
  • axes (Axes) – An Axes in a matplotlib figure

  • spikes (ndarray) – sPyNNaker7 format numpy array of spikes

  • label (str) – Label for the graph

  • options – plotting options

spynnaker.spynnaker_plotting.plot_spiketrains(axes, spiketrains, label='', **options)[source]

Plot all spike trains in a Segment in a raster plot.

Parameters:
  • axes (Axes) – An Axes in a matplotlib figure

  • spiketrains (list(SpikeTrain)) – List of spike times

  • label (str) – Label for the graph

  • options – plotting options

Module contents

Indices and tables

sPyNNaker_github

sPyNNaker_individual_docs

SpiNNakerGraphFrontEnd

This package provides a Graph Front End implementation for SpiNNaker.

SpiNNakerGraphFrontEnd

The API for running SpiNNaker simulations based on a basic (non-neural) graph.

The general usage pattern for this API something like is:

import spinnaker_graph_front_end as gfe

# Uses information from your configuration file
# You might need to specify how many SpiNNaker boards to allocate
gfe.setup()

# Make the bits that do the computation
for each vertex to add:
    gfe.add_vertex_instance(vertex)

# Connect them together so computations are coordinated
for each edge to add:
    gfe.add_edge_instance(edge)

# Actually plan and run the simulation
gfe.run(number_of_steps)

# Get the results back; what this means can be complex
for each vertex:
    results += vertex.retrieve_relevant_results()

# Shut everything down
# Only your retrieved results really exist after this
gfe.stop()

# Analyse/render the results; totally application-specific!

It is possible to use GFE-style vertices in a neural graph (e.g., to simulate the external world). Talk to the SpiNNaker team for more details.

class spinnaker_graph_front_end.ReverseIpTagMultiCastSource(n_keys, label=None, max_atoms_per_core=9223372036854775807, receive_port=None, receive_sdp_port=1, receive_tag=None, receive_rate=10, virtual_key=None, prefix=None, prefix_type=None, check_keys=False, send_buffer_times=None, send_buffer_partition_id=None, reserve_reverse_ip_tag=False, injection_partition_id=None, splitter=None)[source]

For full documentation see ReverseIpTagMultiCastSource.

Parameters:
  • n_keys (int) – The number of keys to be sent via this multicast source

  • label (str) – The label of this vertex

  • max_atoms_per_core (int) –

  • board_address (str or None) – The IP address of the board on which to place this vertex if receiving data, either buffered or live (by default, any board is chosen)

  • receive_port (int or None) – The port on the board that will listen for incoming event packets (default is to disable this feature; set a value to enable it)

  • receive_sdp_port (int) – The SDP port to listen on for incoming event packets (defaults to 1)

  • receive_tag (IPTag) – The IP tag to use for receiving live events (uses any by default)

  • receive_rate (float) – The estimated rate of packets that will be sent by this source

  • virtual_key (int) – The base multicast key to send received events with (assigned automatically by default)

  • prefix (int) – The prefix to “or” with generated multicast keys (default is no prefix)

  • prefix_type (EIEIOPrefix) – Whether the prefix should apply to the upper or lower half of the multicast keys (default is upper half)

  • check_keys (bool) – True if the keys of received events should be verified before sending (default False)

  • send_buffer_times (ndarray(ndarray(numpy.int32)) or list(ndarray(int32)) or None) – An array of arrays of times at which keys should be sent (one array for each key, default disabled)

  • send_buffer_partition_id (str or None) – The ID of the partition containing the edges down which the events are to be sent

  • reserve_reverse_ip_tag (bool) – Extra flag for input without a reserved port

  • injection_partition (str) – If not None, will enable injection and specify the partition to send injected keys with

  • splitter (AbstractSplitterCommon or None) – the splitter object needed for this vertex

spinnaker_graph_front_end.add_edge_instance(edge, partition_id)[source]

Add an edge to the unpartitioned graph.

Parameters:
  • edge (ApplicationEdge) – The edge to add.

  • partition_id (str) – The ID of the partition that the edge belongs to.

spinnaker_graph_front_end.add_socket_address(database_ack_port_num, database_notify_host, database_notify_port_num)[source]

Add a socket address for the notification protocol.

Parameters:
  • database_ack_port_num (int) – port number to send acknowledgement to

  • database_notify_host (str) – host IP to send notification to

  • database_notify_port_num (int) – port that the external device will be notified on.

spinnaker_graph_front_end.add_vertex_instance(vertex_to_add)[source]

Add an existing application vertex to the unpartitioned graph.

Parameters:

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

spinnaker_graph_front_end.buffer_manager()[source]

Get the buffer manager being used for loading/extracting buffers.

Return type:

BufferManager

spinnaker_graph_front_end.get_number_of_available_cores_on_machine()[source]

Get the number of cores on this machine that are available to the simulation.

Return type:

int

spinnaker_graph_front_end.has_ran()[source]

Get whether the simulation has already run.

Return type:

bool

spinnaker_graph_front_end.is_allocated_machine()[source]

Get whether a machine is allocated.

Return type:

bool

spinnaker_graph_front_end.machine()[source]

Get the model of the attached/allocated machine.

Return type:

Machine

spinnaker_graph_front_end.placements()[source]

Get the placements.

Deprecated since version 7.0: No Longer supported! Use View iterate_placements instead

Instead of:

front_end.placements().placements

Use:

FecDataView.iterate_placemements()

FecDataView can be imported from spinn_front_end_common.data

spinnaker_graph_front_end.routing_infos()[source]

Get information about how messages are routed on the machine.

Return type:

RoutingInfo

spinnaker_graph_front_end.run(duration=None)[source]

Run a simulation for a number of microseconds.

Parameters:

duration (int) – the number of microseconds the application code should run for

spinnaker_graph_front_end.setup(model_binary_module=None, model_binary_folder=None, database_socket_addresses=(), n_chips_required=None, n_boards_required=None, time_scale_factor=None, machine_time_step=None)[source]

Set up a graph, ready to have vertices and edges added to it, and the simulator engine that will execute the graph.

Note

This must be called before the other functions in this API.

Parameters:
  • model_binary_module (ModuleType) – the Python module where the binary files (.aplx) can be found for the compiled C code that is being used in this application; mutually exclusive with the model_binary_folder.

  • model_binary_folder (str) – the folder where the binary files can be found for the c code that is being used in this application; mutually exclusive with the model_binary_module.

  • database_socket_addresses (Iterable(SocketAddress)) – set of SocketAddresses to be added for the database notification system. These are over and above the ones used by the LiveEventConnection

  • n_chips_required (int or None) – Deprecated! Use n_boards_required instead. Must be None if n_boards_required specified.

  • n_boards_required (int or None) – if you need to be allocated a machine (for spalloc) before building your graph, then fill this in with a general idea of the number of boards you need so that the spalloc system can allocate you a machine big enough for your needs.

Raises:

ConfigurationException – if mutually exclusive options are given.

spinnaker_graph_front_end.stop()[source]

Do any necessary cleaning up before exiting. Unregisters the controller.

Contents

spinnaker_graph_front_end
spinnaker_graph_front_end package
Subpackages
spinnaker_graph_front_end.utilities package
Submodules
spinnaker_graph_front_end.utilities.data_utils module
spinnaker_graph_front_end.utilities.data_utils.generate_steps_system_data_region(spec, region_id, machine_vertex)[source]

Generate a system data region for step-based simulations.

Parameters:
spinnaker_graph_front_end.utilities.data_utils.generate_system_data_region(spec, region_id, machine_vertex)[source]

Generate a system data region for time-based simulations.

Parameters:
Module contents
class spinnaker_graph_front_end.utilities.SimulatorVertex(label, binary_name)[source]

Bases: MachineVertex, AbstractHasAssociatedBinary

A machine vertex that is implemented by a binary APLX that supports the spin1_api simulation control protocol.

Parameters:
  • label (str) – The label for the vertex.

  • binary_name (str) – The name of the APLX implementing the vertex.

property front_end

The main front end that is handling this simulator vertex.

Return type:

ModuleType

generate_recording_region(spec, region_id, channel_sizes)[source]

Generate the recording region for the data specification.

Parameters:
  • spec (DataSpecificationGenerator) – The data specification being built

  • region_id (int) – Which region is the recording region.

  • sizes (list(int)) – The sizes of each of the recording channels. The length of the list is the number of recording channels.

generate_system_region(spec, region_id=0)[source]

Generate the system region for the data specification. Assumes that the vertex uses the system timestep and time scale factor.

Note

Do not use this with untimed vertices.

Parameters:
  • spec (DataSpecificationGenerator) – The data specification being built

  • region_id (int) – Which region is the system region. Defaults to 0 because it is almost always the first one.

get_binary_file_name()[source]

Get the binary name to be run for this vertex.

Return type:

str

get_binary_start_type()[source]

Get the start type of the binary to be run.

Return type:

ExecutableType

get_recording_channel_data(recording_id)[source]

Get the data from a recording channel. The simulation must have spinnaker_graph_front_end.run() before this will work, and the vertex must set up the recording region beforehand.

Parameters:

recording_id (int) – Which recording channel to fetch

Returns:

the data, and whether any data was lost

Return type:

tuple(bytes, bool)

property placement

Get the placement of this vertex.

Note

Only valid after the simulation has run!

Return type:

Placement

Submodules
spinnaker_graph_front_end.config_setup module

Utilities for setting up the global configuration.

spinnaker_graph_front_end.config_setup.CONFIG_FILE_NAME = 'spiNNakerGraphFrontEnd.cfg'

The name of the configuration file

spinnaker_graph_front_end.config_setup.setup_configs()[source]

Sets up the configurations including the user’s configuration file.

Clears out any previous read configurations but does not load the new configurations so a warning is generated if a configuration is used before setup() is called.

spinnaker_graph_front_end.config_setup.unittest_setup()[source]

Does all the steps that may be required before a unit test.

Resets the configurations so only the local default configurations are included. The user configuration is not included!

Unsets any previous simulators and temporary directories.

Note

This file should only be called from spinnaker_graph_front_end tests that do not call setup().

spinnaker_graph_front_end.spinnaker module
class spinnaker_graph_front_end.spinnaker.SpiNNaker(n_chips_required=None, n_boards_required=None, time_scale_factor=None, machine_time_step=None)[source]

Bases: AbstractSpinnakerBase

The implementation of the SpiNNaker simulation interface.

Note

You should not normally instantiate this directly from user code. Call setup() instead.

Parameters:
  • n_chips_required (int) – How many chips are required. Prefer n_boards_required if possible.

  • n_boards_required (int) – How many boards are required. Unnecessary with a local board.

  • time_scale_factor (int) – The time slow-down factor

  • machine_time_step (int) – The size of the machine time step, in microseconds

Module contents

The API for running SpiNNaker simulations based on a basic (non-neural) graph.

The general usage pattern for this API something like is:

import spinnaker_graph_front_end as gfe

# Uses information from your configuration file
# You might need to specify how many SpiNNaker boards to allocate
gfe.setup()

# Make the bits that do the computation
for each vertex to add:
    gfe.add_vertex_instance(vertex)

# Connect them together so computations are coordinated
for each edge to add:
    gfe.add_edge_instance(edge)

# Actually plan and run the simulation
gfe.run(number_of_steps)

# Get the results back; what this means can be complex
for each vertex:
    results += vertex.retrieve_relevant_results()

# Shut everything down
# Only your retrieved results really exist after this
gfe.stop()

# Analyse/render the results; totally application-specific!

It is possible to use GFE-style vertices in a neural graph (e.g., to simulate the external world). Talk to the SpiNNaker team for more details.

class spinnaker_graph_front_end.ReverseIpTagMultiCastSource(n_keys, label=None, max_atoms_per_core=9223372036854775807, receive_port=None, receive_sdp_port=1, receive_tag=None, receive_rate=10, virtual_key=None, prefix=None, prefix_type=None, check_keys=False, send_buffer_times=None, send_buffer_partition_id=None, reserve_reverse_ip_tag=False, injection_partition_id=None, splitter=None)[source]

Bases: ReverseIpTagMultiCastSource

For full documentation see ReverseIpTagMultiCastSource.

Parameters:
  • n_keys (int) – The number of keys to be sent via this multicast source

  • label (str) – The label of this vertex

  • max_atoms_per_core (int) –

  • board_address (str or None) – The IP address of the board on which to place this vertex if receiving data, either buffered or live (by default, any board is chosen)

  • receive_port (int or None) – The port on the board that will listen for incoming event packets (default is to disable this feature; set a value to enable it)

  • receive_sdp_port (int) – The SDP port to listen on for incoming event packets (defaults to 1)

  • receive_tag (IPTag) – The IP tag to use for receiving live events (uses any by default)

  • receive_rate (float) – The estimated rate of packets that will be sent by this source

  • virtual_key (int) – The base multicast key to send received events with (assigned automatically by default)

  • prefix (int) – The prefix to “or” with generated multicast keys (default is no prefix)

  • prefix_type (EIEIOPrefix) – Whether the prefix should apply to the upper or lower half of the multicast keys (default is upper half)

  • check_keys (bool) – True if the keys of received events should be verified before sending (default False)

  • send_buffer_times (ndarray(ndarray(numpy.int32)) or list(ndarray(int32)) or None) – An array of arrays of times at which keys should be sent (one array for each key, default disabled)

  • send_buffer_partition_id (str or None) – The ID of the partition containing the edges down which the events are to be sent

  • reserve_reverse_ip_tag (bool) – Extra flag for input without a reserved port

  • injection_partition (str) – If not None, will enable injection and specify the partition to send injected keys with

  • splitter (AbstractSplitterCommon or None) – the splitter object needed for this vertex

spinnaker_graph_front_end.add_edge_instance(edge, partition_id)[source]

Add an edge to the unpartitioned graph.

Parameters:
  • edge (ApplicationEdge) – The edge to add.

  • partition_id (str) – The ID of the partition that the edge belongs to.

spinnaker_graph_front_end.add_socket_address(database_ack_port_num, database_notify_host, database_notify_port_num)[source]

Add a socket address for the notification protocol.

Parameters:
  • database_ack_port_num (int) – port number to send acknowledgement to

  • database_notify_host (str) – host IP to send notification to

  • database_notify_port_num (int) – port that the external device will be notified on.

spinnaker_graph_front_end.add_vertex_instance(vertex_to_add)[source]

Add an existing application vertex to the unpartitioned graph.

Parameters:

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

spinnaker_graph_front_end.buffer_manager()[source]

Get the buffer manager being used for loading/extracting buffers.

Return type:

BufferManager

spinnaker_graph_front_end.get_number_of_available_cores_on_machine()[source]

Get the number of cores on this machine that are available to the simulation.

Return type:

int

spinnaker_graph_front_end.has_ran()[source]

Get whether the simulation has already run.

Return type:

bool

spinnaker_graph_front_end.is_allocated_machine()[source]

Get whether a machine is allocated.

Return type:

bool

spinnaker_graph_front_end.machine()[source]

Get the model of the attached/allocated machine.

Return type:

Machine

spinnaker_graph_front_end.placements()[source]

Get the placements.

Deprecated since version 7.0: No Longer supported! Use View iterate_placements instead

Instead of:

front_end.placements().placements

Use:

FecDataView.iterate_placemements()

FecDataView can be imported from spinn_front_end_common.data

spinnaker_graph_front_end.routing_infos()[source]

Get information about how messages are routed on the machine.

Return type:

RoutingInfo

spinnaker_graph_front_end.run(duration=None)[source]

Run a simulation for a number of microseconds.

Parameters:

duration (int) – the number of microseconds the application code should run for

spinnaker_graph_front_end.setup(model_binary_module=None, model_binary_folder=None, database_socket_addresses=(), n_chips_required=None, n_boards_required=None, time_scale_factor=None, machine_time_step=None)[source]

Set up a graph, ready to have vertices and edges added to it, and the simulator engine that will execute the graph.

Note

This must be called before the other functions in this API.

Parameters:
  • model_binary_module (ModuleType) – the Python module where the binary files (.aplx) can be found for the compiled C code that is being used in this application; mutually exclusive with the model_binary_folder.

  • model_binary_folder (str) – the folder where the binary files can be found for the c code that is being used in this application; mutually exclusive with the model_binary_module.

  • database_socket_addresses (Iterable(SocketAddress)) – set of SocketAddresses to be added for the database notification system. These are over and above the ones used by the LiveEventConnection

  • n_chips_required (int or None) – Deprecated! Use n_boards_required instead. Must be None if n_boards_required specified.

  • n_boards_required (int or None) – if you need to be allocated a machine (for spalloc) before building your graph, then fill this in with a general idea of the number of boards you need so that the spalloc system can allocate you a machine big enough for your needs.

Raises:

ConfigurationException – if mutually exclusive options are given.

spinnaker_graph_front_end.stop()[source]

Do any necessary cleaning up before exiting. Unregisters the controller.

Indices and tables

SpiNNakerGraphFrontEnd_github

SpiNNakerGraphFrontEnd_individual_docs

spalloc

Spalloc is a Python client library and set of command-line programs for requesting SpiNNaker machines from a spalloc server.

The spalloc module uses a different documentation style so is not included here.

Their documentation can be found at: spalloc_readthedocs

spalloc_github

spalloc_server

A SpiNNaker machine management application which manages the partitioning and allocation of large SpiNNaker machines into smaller fragments for many simultaneous users.

The spalloc_server module uses a different documentation style so is not included here.

Their documentation can be found at: spalloc_server_readthedocs

spalloc_server_github

Indices and tables