sPyNNaker neural_modelling 7.1.1
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
spike_processing.c File Reference

Implementation of non-inlined API in spike_processing.h. More...

#include "spike_processing.h"
#include "population_table/population_table.h"
#include "synapse_row.h"
#include "synapses.h"
#include "structural_plasticity/synaptogenesis_dynamics.h"
#include <simulation.h>
#include <debug.h>
#include <common/in_spikes.h>
#include <recording.h>

Go to the source code of this file.

Data Structures

struct  dma_buffer
 

Macros

#define N_DMA_BUFFERS   2
 The number of DMA Buffers to use.
 

Enumerations

enum  spike_processing_dma_tags { DMA_TAG_READ_SYNAPTIC_ROW , DMA_TAG_WRITE_PLASTIC_REGION }
 DMA tags. More...
 

Functions

static void do_dma_read (spike_t spike, pop_table_lookup_result_t *result)
 Perform a DMA read of a synaptic row.
 
static bool is_something_to_do (spike_t *spike, pop_table_lookup_result_t *result, uint32_t *n_rewire, uint32_t *n_process_spike)
 Check if there is anything to do. If not, DMA is not busy.
 
static bool setup_synaptic_dma_read (dma_buffer *current_buffer, uint32_t *n_rewires, uint32_t *n_synapse_processes)
 Set up a new synaptic DMA read.
 
static void setup_synaptic_dma_write (uint32_t dma_buffer_index, bool plastic_only)
 Set up a DMA write of synaptic data.
 
static void start_dma_loop (void)
 Start the DMA processing loop if not already running.
 
static void multicast_packet_received_callback (uint key, uint unused)
 Called when a multicast packet is received.
 
static void multicast_packet_pl_received_callback (uint key, uint payload)
 Called when a multicast packet is received.
 
static void dma_complete_callback (uint unused, uint tag)
 Called when a DMA completes.
 
void user_event_callback (uint unused0, uint unused1)
 Called when a user event is received.
 
void spike_processing_clear_input_buffer (timer_t time)
 clears the input buffer of packets
 
bool spike_processing_initialise (size_t row_max_n_words, uint mc_packet_callback_priority, uint user_event_priority, uint incoming_spike_buffer_size, bool clear_input_buffers_of_late_packets_init, uint32_t packets_per_timestep_region)
 Initialise the spike processing system.
 
void spike_processing_store_provenance (struct spike_processing_provenance *prov)
 Get provenance data for Spike processing.
 
bool spike_processing_do_rewiring (int number_of_rewires)
 Set the number of times spike_processing has to attempt rewiring.
 

Variables

uint32_t time
 The current timer tick value.
 
static volatile bool dma_busy
 True if the DMA "loop" is currently running.
 
static dma_buffer dma_buffers [N_DMA_BUFFERS]
 The DTCM buffers for the synapse rows.
 
static uint32_t next_buffer_to_fill
 The index of the next buffer to be filled by a DMA.
 
static uint32_t buffer_being_read
 The index of the buffer currently being filled by a DMA read.
 
static volatile uint32_t rewires_to_do = 0
 Number of outstanding synaptogenic rewires.
 
static uint32_t dma_n_rewires
 The number of rewires to do when the DMA completes.
 
static uint32_t dma_n_spikes
 The number of spikes to do when the DMA completes.
 
static uint32_t dma_complete_count
 the number of DMA completes (used in provenance generation)
 
static uint32_t spike_processing_count
 the number of spikes that were processed (used in provenance generation)
 
static uint32_t n_successful_rewires
 The number of successful rewires.
 
static uint32_t count_input_buffer_packets_late
 How many packets were lost from the input buffer because of late arrival.
 
static uint32_t biggest_fill_size_of_input_buffer
 tracker of how full the input buffer got.
 
static bool clear_input_buffers_of_late_packets
 Whether if we should clear packets from the input buffer at the end of a timer tick.
 
struct { 
 
uint32_t time
 
uint32_t packets_this_time_step
 
p_per_ts_struct 
 the number of packets received this time step
 
static uint32_t p_per_ts_region
 the region to record the packets per timestep in
 

Detailed Description

Implementation of non-inlined API in spike_processing.h.

Definition in file spike_processing.c.

Macro Definition Documentation

◆ N_DMA_BUFFERS

#define N_DMA_BUFFERS   2

The number of DMA Buffers to use.

Definition at line 53 of file spike_processing.c.

Enumeration Type Documentation

◆ spike_processing_dma_tags

DMA tags.

Enumerator
DMA_TAG_READ_SYNAPTIC_ROW 

Tag of a DMA read of a full synaptic row.

DMA_TAG_WRITE_PLASTIC_REGION 

Tag of a DMA write of the plastic region of a synaptic row.

Definition at line 56 of file spike_processing.c.

Function Documentation

◆ do_dma_read()

static void do_dma_read ( spike_t  spike,
pop_table_lookup_result_t result 
)
inlinestatic

Perform a DMA read of a synaptic row.

Parameters
[in]spikeThe spike that triggered this read
[in]resultThe result of the lookup

Definition at line 125 of file spike_processing.c.

◆ is_something_to_do()

static bool is_something_to_do ( spike_t spike,
pop_table_lookup_result_t result,
uint32_t *  n_rewire,
uint32_t *  n_process_spike 
)
inlinestatic

Check if there is anything to do. If not, DMA is not busy.

Parameters
[out]spikeThe spike being processed
[out]resultThe result of the pop table lookup
[in,out]n_rewireAccumulator of number of rewires
[in,out]n_process_spikeAccumulator of number of processed spikes
Returns
True if there's something to do

Definition at line 153 of file spike_processing.c.

◆ setup_synaptic_dma_read()

static bool setup_synaptic_dma_read ( dma_buffer current_buffer,
uint32_t *  n_rewires,
uint32_t *  n_synapse_processes 
)
static

Set up a new synaptic DMA read.

If a current_buffer is passed in, any spike found that matches the originating spike of the buffer will increment a count, and the DMA of that row will be skipped. The number of times a row should be rewired and the number of times synaptic processing should be done on a row is returned.

Calls is_something_to_do(), do_direct_row() and do_dma_read()

Parameters
[in]current_bufferThe current buffer, if any.
[in,out]n_rewiresAccumulator of number of rewires
[in,out]n_synapse_processesAccumulator of number of synapses processed
Returns
Whether an actual DMA was set up or not

Definition at line 220 of file spike_processing.c.

◆ setup_synaptic_dma_write()

static void setup_synaptic_dma_write ( uint32_t  dma_buffer_index,
bool  plastic_only 
)
inlinestatic

Set up a DMA write of synaptic data.

Parameters
[in]dma_buffer_indexIndex of DMA buffer to use
[in]plastic_onlyIf false, write the whole synaptic row. If true, only write the plastic data region of the synaptic row.

Definition at line 260 of file spike_processing.c.

◆ start_dma_loop()

static void start_dma_loop ( void  )
inlinestatic

Start the DMA processing loop if not already running.

Definition at line 285 of file spike_processing.c.

◆ multicast_packet_received_callback()

static void multicast_packet_received_callback ( uint  key,
uint  unused 
)
static

Called when a multicast packet is received.

Parameters
[in]keyThe key of the packet. The spike.
[in]unusedOnly specified to match API

Definition at line 301 of file spike_processing.c.

◆ multicast_packet_pl_received_callback()

static void multicast_packet_pl_received_callback ( uint  key,
uint  payload 
)
static

Called when a multicast packet is received.

Parameters
[in]keyThe key of the packet. The spike.
[in]payloadthe payload of the packet. The count.

Definition at line 311 of file spike_processing.c.

◆ dma_complete_callback()

static void dma_complete_callback ( uint  unused,
uint  tag 
)
static

Called when a DMA completes.

Parameters
unusedunused
[in]tagWhat sort of DMA has finished?

Definition at line 327 of file spike_processing.c.

◆ user_event_callback()

void user_event_callback ( uint  unused0,
uint  unused1 
)

Called when a user event is received.

Parameters
unused0unused
unused1unused

Definition at line 396 of file spike_processing.c.

◆ spike_processing_clear_input_buffer()

void spike_processing_clear_input_buffer ( timer_t  time)

clears the input buffer of packets

Parameters
[in]timeThe current timestep

Definition at line 413 of file spike_processing.c.

◆ spike_processing_initialise()

bool spike_processing_initialise ( size_t  row_max_n_bytes,
uint  mc_packet_callback_priority,
uint  user_event_priority,
uint  incoming_spike_buffer_size,
bool  clear_input_buffers_of_late_packets_init,
uint32_t  packets_per_timestep_region 
)

Initialise the spike processing system.

Parameters
[in]row_max_n_bytesThe maximum size of a synaptic row
[in]mc_packet_callback_priorityMulticast packet receive interrupt priority
[in]user_event_priorityUser event interrupt priority
[in]incoming_spike_buffer_sizeSize of buffer for receiving spikes
[in]clear_input_buffers_of_late_packets_initWhether packets that are left at the end of a time step are wiped
[in]packets_per_timestep_regionThe recording region to use for the packets per timestep
Returns
True if initialisation succeeded

Definition at line 430 of file spike_processing.c.

◆ spike_processing_store_provenance()

void spike_processing_store_provenance ( struct spike_processing_provenance prov)

Get provenance data for Spike processing.

Parameters
[in]provThe structure to store the provenance data in

Definition at line 467 of file spike_processing.c.

◆ spike_processing_do_rewiring()

bool spike_processing_do_rewiring ( int  number_of_rewires)

Set the number of times spike_processing has to attempt rewiring.

Parameters
[in]number_of_rewiresThe number of rewires to perform
Returns
currently always true

Definition at line 476 of file spike_processing.c.

Variable Documentation

◆ time

uint32_t time
extern

The current timer tick value.

Declare that time exists.

Definition at line 94 of file c_main.c.

◆ dma_busy

volatile bool dma_busy
static

True if the DMA "loop" is currently running.

Definition at line 67 of file spike_processing.c.

◆ dma_buffers

dma_buffer dma_buffers[N_DMA_BUFFERS]
static

The DTCM buffers for the synapse rows.

Definition at line 70 of file spike_processing.c.

◆ next_buffer_to_fill

uint32_t next_buffer_to_fill
static

The index of the next buffer to be filled by a DMA.

Definition at line 73 of file spike_processing.c.

◆ buffer_being_read

uint32_t buffer_being_read
static

The index of the buffer currently being filled by a DMA read.

Definition at line 76 of file spike_processing.c.

◆ rewires_to_do

volatile uint32_t rewires_to_do = 0
static

Number of outstanding synaptogenic rewires.

Definition at line 79 of file spike_processing.c.

◆ dma_n_rewires

uint32_t dma_n_rewires
static

The number of rewires to do when the DMA completes.

When a DMA is first set up, only this or dma_n_spikes can be 1 with the other being 0.

Definition at line 84 of file spike_processing.c.

◆ dma_n_spikes

uint32_t dma_n_spikes
static

The number of spikes to do when the DMA completes.

When a DMA is first set up, only this or dma_n_rewires can be 1 with the other being 0.

Definition at line 89 of file spike_processing.c.

◆ dma_complete_count

uint32_t dma_complete_count
static

the number of DMA completes (used in provenance generation)

Definition at line 92 of file spike_processing.c.

◆ spike_processing_count

uint32_t spike_processing_count
static

the number of spikes that were processed (used in provenance generation)

Definition at line 95 of file spike_processing.c.

◆ n_successful_rewires

uint32_t n_successful_rewires
static

The number of successful rewires.

Definition at line 98 of file spike_processing.c.

◆ count_input_buffer_packets_late

uint32_t count_input_buffer_packets_late
static

How many packets were lost from the input buffer because of late arrival.

Definition at line 102 of file spike_processing.c.

◆ biggest_fill_size_of_input_buffer

uint32_t biggest_fill_size_of_input_buffer
static

tracker of how full the input buffer got.

Definition at line 105 of file spike_processing.c.

◆ clear_input_buffers_of_late_packets

bool clear_input_buffers_of_late_packets
static

Whether if we should clear packets from the input buffer at the end of a timer tick.

Definition at line 109 of file spike_processing.c.

◆ p_per_ts_region

uint32_t p_per_ts_region
static

the region to record the packets per timestep in

Definition at line 118 of file spike_processing.c.