sPyNNaker neural_modelling 7.3.1
|
This file contains the main functions for a Poisson spike generator. More...
#include <common/maths-util.h>
#include <common/send_mc.h>
#include <data_specification.h>
#include <recording.h>
#include <debug.h>
#include <normal.h>
#include <simulation.h>
#include <spin1_api.h>
#include <bit_field.h>
#include <stdfix-full-iso.h>
#include <limits.h>
#include <circular_buffer.h>
#include "profile_tags.h"
#include <profiler.h>
#include <wfi.h>
Go to the source code of this file.
Data Structures | |
struct | spike_source_t |
data structure for Poisson sources More... | |
struct | timed_out_spikes |
data structure for recording spikes More... | |
struct | rng_seed_t |
An RNG seed of 4 words. More... | |
struct | global_parameters |
Parameters of the SpikeSourcePoisson. More... | |
struct | poisson_extension_provenance |
Structure of the provenance data. More... | |
struct | source_info |
Collection of rates to apply over time to a particular spike source. More... | |
struct | source_expand_details |
struct | source_expand_region |
struct | sdram_config |
A region of SDRAM used to transfer synapses. More... | |
Macros | |
#define | END_OF_TIME 0xFFFFFFFF |
#define | NUMBER_OF_REGIONS_TO_RECORD 1 |
The number of recording regions. | |
#define | BYTE_TO_WORD_CONVERTER 4 |
Bytes per word. | |
#define | ISI_SCALE_FACTOR 1000 |
A scale factor to allow the use of integers for "inter-spike intervals". | |
Enumerations | |
enum | region { SYSTEM , POISSON_PARAMS , RATES , SPIKE_HISTORY_REGION , PROVENANCE_REGION , PROFILER_REGION , SDRAM_PARAMS_REGION , EXPANDER_REGION } |
spike source array region IDs in human readable form More... | |
enum | callback_priorities { MULTICAST = -1 , SDP = 0 , DMA = 1 , TIMER = 2 } |
Priorities for interrupt handlers. More... | |
Functions | |
static uint32_t | rng (void) |
Random number generation for the Poisson sources. This is a local version for speed of operation. | |
static uint32_t | n_spikes_poisson_fast (UFRACT exp_minus_lambda) |
How many spikes to generate for a fast Poisson source. | |
static REAL | n_steps_until_next (void) |
How many time steps until the next spike for a slow Poisson source. | |
static uint32_t | slow_spike_source_get_time_to_spike (uint32_t mean_inter_spike_interval_in_ticks) |
Determine the time in timer ticks multiplied by ISI_SCALE_FACTOR until the next spike is to occur given the mean inter-spike interval. | |
static uint32_t | fast_spike_source_get_num_spikes (UFRACT exp_minus_lambda) |
Determine how many spikes to transmit this timer tick, for a fast source. | |
static uint32_t | faster_spike_source_get_num_spikes (REAL sqrt_lambda) |
Determine how many spikes to transmit this timer tick, for a faster source (where λ is large enough that a Gaussian can be used instead of a Poisson) | |
void | set_spike_source_rate (uint32_t sub_id, UREAL rate) |
Set the spike source rate as required. | |
static void | store_provenance_data (address_t provenance_region) |
Writes the provenance data. | |
static uint32_t | ms_to_ticks (unsigned long accum ms) |
static void | set_spike_source_details (uint32_t id, bool rate_changed) |
static bit_field_t | out_spikes_bitfield (uint32_t n) |
Set specific spikes for recording. | |
static void | reset_spikes (void) |
Reset the spike buffer by clearing the bit field. | |
static void | print_spike_source (index_t s) |
Print a spike source. | |
static void | print_spike_sources (void) |
Print all spike sources. | |
static bool | read_global_parameters (global_parameters *sdram_globals) |
Read the global parameters stored in Poisson parameter region. | |
static void | read_next_rates (uint32_t id) |
Get the next chunk of rates read. | |
static bool | read_rates (source_info *sdram_sources, bool rate_changed, uint32_t next_time) |
Read the rates of the Poisson. | |
static bool | expand_rates (source_expand_region *items, source_info *sdram_sources) |
static bool | initialise_recording (data_specification_metadata_t *ds_regions) |
Initialise the recording parts of the model. | |
static void | expand_spike_recording_buffer (uint32_t n_spikes) |
Expand the space for recording spikes. | |
static bool | initialize (void) |
Initialise the model by reading in the regions and checking recording data. | |
static void | resume_callback (void) |
Run any functions needed at resume time. | |
static void | mark_spike (uint32_t neuron_id, uint32_t n_spikes) |
records spikes as needed | |
static void | record_spikes (uint32_t time) |
writing spikes to SDRAM | |
static void | add_sdram_spikes (uint32_t s_id, uint32_t num_spikes) |
static void | process_fast_source (index_t s_id, spike_source_t *source) |
Handle a fast spike source. | |
static void | process_slow_source (index_t s_id, spike_source_t *source) |
Handle a slow spike source. | |
static void | timer_callback (uint timer_count, uint unused) |
Timer interrupt callback. | |
static void | multicast_packet_callback (uint key, uint payload) |
Multicast callback used to set rate when injected in a live example. | |
void | c_main (void) |
The entry point for this model. | |
Variables | |
source_details | |
static uint32_t * | keys |
The keys to send spikes with. | |
static global_parameters | ssp_params |
The global_parameters for the sub-population. | |
static source_info ** | source_data |
Array of pointers to sequences of rate data. | |
static spike_source_t * | source |
The currently applied rate descriptors. | |
static uint32_t | recording_flags = 0 |
keeps track of which types of recording should be done to this model. | |
static uint32_t | time |
static uint32_t | simulation_ticks = 0 |
the number of timer ticks that this model should run for before exiting. | |
static uint32_t | infinite_run |
the int that represents the bool for if the run is infinite or not. | |
static timed_out_spikes * | spikes = NULL |
The recorded spikes. | |
static uint32_t | n_spike_buffers_allocated |
The number of recording spike buffers that have been allocated. | |
static uint32_t | n_spike_buffer_words |
The number of words needed for 1 bit per source. | |
static uint32_t | spike_buffer_size |
The size of each spike buffer in bytes. | |
static uint32_t | timer_period |
The timer period. | |
static struct sdram_config * | sdram_inputs |
Where synaptic input is to be written. | |
static uint16_t * | input_this_timestep |
The inputs to be sent at the end of this timestep. | |
static UREAL | ts_per_second |
The timesteps per second. | |
static circular_buffer | rate_change_buffer |
Buffer for rate change packets. | |
static uint32_t | colour |
The colour of the current time step. | |
static uint32_t | colour_mask |
The mask to apply to the time to get the colour. | |
static uint32_t | n_saturations = 0 |
This file contains the main functions for a Poisson spike generator.
Definition in file spike_source_poisson.c.
struct spike_source_t |
data structure for Poisson sources
Definition at line 50 of file spike_source_poisson.c.
Data Fields | ||
---|---|---|
uint32_t | start_ticks | When the current control regime starts, in timer ticks. |
uint32_t | end_ticks | When the current control regime ends, in timer ticks. |
uint32_t | next_ticks | When we should load the next control regime, in timer ticks. |
uint32_t | is_fast_source | Flag for whether we're in fast or slow mode. |
UFRACT | exp_minus_lambda | exp(-λ) |
UREAL | sqrt_lambda | sqrt(λ) |
uint32_t | mean_isi_ticks | Mean interspike interval, in ticks. |
uint32_t | time_to_spike_ticks | Planned time to spike, in ticks. |
struct timed_out_spikes |
data structure for recording spikes
Definition at line 71 of file spike_source_poisson.c.
Data Fields | ||
---|---|---|
uint32_t | time | Time of recording. |
uint32_t | n_buffers | Number of spike-recording buffers. |
uint32_t | out_spikes[] | Spike recording buffers; sort of a bit_field_t[]. |
struct rng_seed_t |
An RNG seed of 4 words.
Definition at line 112 of file spike_source_poisson.c.
Data Fields | ||
---|---|---|
uint32_t | x | |
uint32_t | y | |
uint32_t | z | |
uint32_t | c |
struct global_parameters |
Parameters of the SpikeSourcePoisson.
Definition at line 120 of file spike_source_poisson.c.
Data Fields | ||
---|---|---|
uint32_t | has_key | True if there is a key to transmit, False otherwise. |
uint32_t | set_rate_neuron_id_mask | The mask to work out the neuron ID when setting the rate. |
UFRACT | seconds_per_tick | The time between ticks in seconds for setting the rate. |
UREAL | ticks_per_ms | The number of ticks per millisecond for setting the start and duration. |
UREAL | slow_rate_per_tick_cutoff | The border rate between slow and fast sources. |
UREAL | fast_rate_per_tick_cutoff | The border rate between fast and faster sources. |
uint32_t | first_source_id | The ID of the first source relative to the population as a whole. |
uint32_t | n_spike_sources | The number of sources in this sub-population. |
uint32_t | max_spikes_per_tick | Maximum expected spikes per tick (for recording) |
uint32_t | n_colour_bits | Number of bits to use for colour. |
rng_seed_t | spike_source_seed | The seed for the Poisson generation process. |
struct poisson_extension_provenance |
Structure of the provenance data.
Definition at line 146 of file spike_source_poisson.c.
Data Fields | ||
---|---|---|
uint32_t | n_saturations | number of saturations |
struct source_info |
Collection of rates to apply over time to a particular spike source.
Definition at line 56 of file local_only_conv_impl.c.
Data Fields | ||
---|---|---|
key_info | key_info | Information about the key. |
uint32_t | source_height_per_core: 16 | The source population height per core. |
uint32_t | source_width_per_core: 16 | The source population width per core. |
uint32_t | source_height_last_core: 16 | The source population height on the last core in a column. |
uint32_t | source_width_last_core: 16 | The source population width on the last core on a row. |
uint32_t | cores_per_source_height: 16 | The number cores in a height of the source. |
uint32_t | cores_per_source_width: 16 | Number of cores in a width of the source. |
div_const | source_width_div | Used to calculate division by the source width per core efficiently. |
div_const | source_width_last_div | Division by last core width. |
div_const | cores_per_width_div | Division by cores per source width. |
uint32_t | n_dims | |
source_dim | source_dim[] | |
uint32_t | n_rates | The number of rates. |
uint32_t | index | Where in the array of rate descriptors we are. |
source_details | details[] | Array of rates. |
struct source_expand_details |
Definition at line 172 of file spike_source_poisson.c.
Data Fields | ||
---|---|---|
uint32_t | count | The number of items to expand. |
source_info | info | The details for the given number of items. |
struct source_expand_region |
Definition at line 179 of file spike_source_poisson.c.
Data Fields | ||
---|---|---|
uint32_t | rate_changed | Determine if any rates have been changed. |
uint32_t | n_items | |
source_expand_details | items[] |
struct sdram_config |
A region of SDRAM used to transfer synapses.
Definition at line 87 of file c_main_neurons.c.
#define END_OF_TIME 0xFFFFFFFF |
Definition at line 47 of file spike_source_poisson.c.
#define NUMBER_OF_REGIONS_TO_RECORD 1 |
The number of recording regions.
Definition at line 93 of file spike_source_poisson.c.
#define BYTE_TO_WORD_CONVERTER 4 |
Bytes per word.
Definition at line 95 of file spike_source_poisson.c.
#define ISI_SCALE_FACTOR 1000 |
A scale factor to allow the use of integers for "inter-spike intervals".
Definition at line 97 of file spike_source_poisson.c.
enum region |
spike source array region IDs in human readable form
Enumerator | |
---|---|
SYSTEM | simulation interface master control |
POISSON_PARAMS | application configuration; global_parameters |
RATES | rates to apply; source_info |
SPIKE_HISTORY_REGION | spike history recording region |
PROVENANCE_REGION | provenance region |
PROFILER_REGION | profiling region |
SDRAM_PARAMS_REGION | SDRAM transfer parameters region. |
EXPANDER_REGION | Expanding of parameters. |
Definition at line 81 of file spike_source_poisson.c.
enum callback_priorities |
Priorities for interrupt handlers.
Definition at line 100 of file spike_source_poisson.c.
|
inlinestatic |
Random number generation for the Poisson sources. This is a local version for speed of operation.
Definition at line 265 of file spike_source_poisson.c.
|
inlinestatic |
How many spikes to generate for a fast Poisson source.
[in] | exp_minus_lambda | e^(-mean_rate) |
Definition at line 281 of file spike_source_poisson.c.
|
inlinestatic |
How many time steps until the next spike for a slow Poisson source.
Definition at line 296 of file spike_source_poisson.c.
|
inlinestatic |
Determine the time in timer ticks multiplied by ISI_SCALE_FACTOR until the next spike is to occur given the mean inter-spike interval.
[in] | mean_inter_spike_interval_in_ticks | The mean number of ticks before a spike is expected to occur in a slow process. |
Definition at line 323 of file spike_source_poisson.c.
|
inlinestatic |
Determine how many spikes to transmit this timer tick, for a fast source.
[in] | exp_minus_lambda | exp(-λ), λ is amount of spikes expected to be produced this timer interval (timer tick in real time) |
Definition at line 339 of file spike_source_poisson.c.
|
inlinestatic |
Determine how many spikes to transmit this timer tick, for a faster source (where λ is large enough that a Gaussian can be used instead of a Poisson)
[in] | sqrt_lambda | Square root of the amount of spikes expected to be produced this timer interval (timer tick in real time) |
Definition at line 355 of file spike_source_poisson.c.
void set_spike_source_rate | ( | uint32_t | sub_id, |
UREAL | rate | ||
) |
Set the spike source rate as required.
[in] | id | the ID of the source to be updated |
[in] | rate | the rate in Hz, to be multiplied to get per-tick values |
Definition at line 368 of file spike_source_poisson.c.
|
static |
Writes the provenance data.
[out] | provenance_region | Where to write the provenance |
Definition at line 411 of file spike_source_poisson.c.
|
inlinestatic |
Definition at line 420 of file spike_source_poisson.c.
|
inlinestatic |
Definition at line 424 of file spike_source_poisson.c.
|
inlinestatic |
Set specific spikes for recording.
[in] | n | the spike array index |
Definition at line 456 of file spike_source_poisson.c.
|
inlinestatic |
Reset the spike buffer by clearing the bit field.
Definition at line 461 of file spike_source_poisson.c.
|
static |
Print a spike source.
[in] | s | The spike source ID |
Definition at line 472 of file spike_source_poisson.c.
|
static |
Print all spike sources.
Definition at line 486 of file spike_source_poisson.c.
|
static |
Read the global parameters stored in Poisson parameter region.
[in] | sdram_globals | the absolute SDRAM memory address to which the Poisson parameter region starts. |
Definition at line 497 of file spike_source_poisson.c.
|
inlinestatic |
Get the next chunk of rates read.
[in] | id | The spike source ID |
Definition at line 540 of file spike_source_poisson.c.
|
static |
Read the rates of the Poisson.
[in] | sdram_sources | the configuration in SDRAM |
[in] | rate_changed | whether any rates have actually changed |
[in] | next_time | the time which will be the next timestep to run |
Definition at line 552 of file spike_source_poisson.c.
|
static |
Definition at line 600 of file spike_source_poisson.c.
|
static |
Initialise the recording parts of the model.
[in] | ds_regions | Data specification master descriptor |
Definition at line 649 of file spike_source_poisson.c.
|
inlinestatic |
Expand the space for recording spikes.
[in] | n_spikes | New number of spikes to hold |
Definition at line 662 of file spike_source_poisson.c.
|
static |
Initialise the model by reading in the regions and checking recording data.
Definition at line 691 of file spike_source_poisson.c.
|
static |
Run any functions needed at resume time.
Definition at line 792 of file spike_source_poisson.c.
|
inlinestatic |
records spikes as needed
[in] | neuron_id | the neurons to store spikes from |
[in] | n_spikes | the number of times this neuron has spiked |
Definition at line 831 of file spike_source_poisson.c.
|
inlinestatic |
writing spikes to SDRAM
[in] | time | the time to which these spikes are being recorded |
Definition at line 847 of file spike_source_poisson.c.
|
inlinestatic |
Definition at line 855 of file spike_source_poisson.c.
|
static |
Handle a fast spike source.
s_id | Source ID |
source | Source descriptor |
Definition at line 869 of file spike_source_poisson.c.
|
static |
Handle a slow spike source.
s_id | Source ID |
source | Source descriptor |
Definition at line 915 of file spike_source_poisson.c.
Timer interrupt callback.
[in] | timer_count | the number of times this call back has been executed since start of simulation |
[in] | unused | for consistency sake of the API always returning two parameters, this parameter has no semantics currently and thus is set to 0 |
Definition at line 957 of file spike_source_poisson.c.
Multicast callback used to set rate when injected in a live example.
[in] | key | Received multicast key |
[in] | payload | Received multicast payload |
Definition at line 1048 of file spike_source_poisson.c.
void c_main | ( | void | ) |
The entry point for this model.
Definition at line 1061 of file spike_source_poisson.c.
source_details |
Definition at line 157 of file spike_source_poisson.c.
|
static |
The keys to send spikes with.
Definition at line 160 of file spike_source_poisson.c.
|
static |
The global_parameters for the sub-population.
Definition at line 204 of file spike_source_poisson.c.
|
static |
Array of pointers to sequences of rate data.
Definition at line 207 of file spike_source_poisson.c.
|
static |
The currently applied rate descriptors.
Definition at line 210 of file spike_source_poisson.c.
|
static |
keeps track of which types of recording should be done to this model.
Definition at line 213 of file spike_source_poisson.c.
|
static |
the time interval parameter TODO this variable could be removed and use the timer tick callback timer value.
Definition at line 217 of file spike_source_poisson.c.
|
static |
the number of timer ticks that this model should run for before exiting.
Definition at line 220 of file spike_source_poisson.c.
|
static |
the int that represents the bool for if the run is infinite or not.
Definition at line 223 of file spike_source_poisson.c.
|
static |
The recorded spikes.
Definition at line 226 of file spike_source_poisson.c.
|
static |
The number of recording spike buffers that have been allocated.
Definition at line 229 of file spike_source_poisson.c.
|
static |
The number of words needed for 1 bit per source.
Definition at line 232 of file spike_source_poisson.c.
|
static |
The size of each spike buffer in bytes.
Definition at line 235 of file spike_source_poisson.c.
|
static |
The timer period.
Definition at line 238 of file spike_source_poisson.c.
|
static |
Where synaptic input is to be written.
Definition at line 241 of file spike_source_poisson.c.
|
static |
The inputs to be sent at the end of this timestep.
Definition at line 244 of file spike_source_poisson.c.
|
static |
The timesteps per second.
Definition at line 247 of file spike_source_poisson.c.
|
static |
Buffer for rate change packets.
Definition at line 250 of file spike_source_poisson.c.
|
static |
The colour of the current time step.
Definition at line 253 of file spike_source_poisson.c.
|
static |
The mask to apply to the time to get the colour.
Definition at line 256 of file spike_source_poisson.c.
|
static |
The number of times the sending of spikes saturated the weight buffers (only when doing SDRAM transfers)
Definition at line 260 of file spike_source_poisson.c.