sPyNNaker neural_modelling  development
Data Structures | Macros | Enumerations | Functions | Variables
delay_extension.c File Reference

Implementation of delay extensions. More...

#include "delay_extension.h"
#include <common/neuron-typedefs.h>
#include <common/in_spikes.h>
#include <bit_field.h>
#include <data_specification.h>
#include <debug.h>
#include <simulation.h>
#include <spin1_api.h>
#include <common/send_mc.h>

Go to the source code of this file.

Data Structures

struct  delay_extension_provenance
 Structure of the provenance data. More...
 

Macros

#define IN_BUFFER_SIZE   256
 the size of the circular queue for packets.
 
#define COUNTER_SATURATION_VALUE   255
 the point where the count has saturated.
 

Enumerations

enum  delay_extension_callback_priorities {
  MC_PACKET = -1 , TIMER = 0 , USER = 0 , SDP = 1 ,
  BACKGROUND = 1 , DMA = 2
}
 values for the priority for each callback More...
 

Functions

static void zero_spike_counters (uint8_t *counters, uint32_t num_items)
 Sets an array of counters to zero. More...
 
static uint32_t round_to_next_pot (uint32_t v)
 Rounds up to the next power of two. More...
 
static bool read_parameters (struct delay_parameters *params)
 Read the configuration region. More...
 
static void store_provenance_data (address_t provenance_region)
 Writes the provenance data. More...
 
static bool initialize (void)
 Read the application configuration. More...
 
static void incoming_spike_callback (uint key, uint payload)
 Handles incoming spikes (FIQ) More...
 
static index_t key_n (key_t k)
 Gets the neuron ID of the incoming spike. More...
 
static void spike_process (void)
 Processes spikes queued by incoming_spike_callback()
 
static void user_callback (uint unused0, uint unused1)
 User event callback. More...
 
static void background_callback (uint local_time, uint timer_count)
 Background event callback. More...
 
static void timer_callback (uint timer_count, uint unused1)
 Main timer callback. More...
 
void c_main (void)
 Entry point.
 

Variables

static bool has_key
 bool in int form for if there is a key
 
static uint32_t key = 0
 Base multicast key for sending messages.
 
static uint32_t incoming_key = 0
 Key for receiving messages.
 
static uint32_t incoming_mask = 0
 Mask for incoming_key to say which messages are for this program.
 
static uint32_t incoming_neuron_mask = 0
 Mask for key (that matches incoming_key/incoming_mask) to extract the neuron ID from it.
 
static uint32_t num_neurons = 0
 Number of neurons supported.
 
static uint32_t max_keys = 0
 number of possible keys.
 
static bool clear_input_buffers_of_late_packets
 Whether to clear packets each timestep.
 
static uint32_t time = UINT32_MAX
 Simulation time.
 
static uint32_t simulation_ticks = 0
 Simulation speed.
 
static uint32_t infinite_run
 True if we're running forever.
 
static uint8_t ** spike_counters = NULL
 The spike counters, as a 2D array. More...
 
static uint32_t num_delay_stages = 0
 The number of delay stages.
 
static uint32_t n_delay_in_a_stage = 0
 The number of delays within a delay stage.
 
static uint32_t num_delay_slots = 0
 The total number of delay slots.
 
static uint32_t num_delay_slots_mask = 0
 Mask for converting time into the current delay slot.
 
static uint32_t neuron_bit_field_words = 0
 Size of each bitfield in ::neuron_delay_stage_config.
 
static uint32_t n_in_spikes = 0
 Number of input spikes.
 
static uint32_t n_processed_spikes = 0
 Number of spikes transferred via queue.
 
static uint32_t n_spikes_sent = 0
 Number of spikes sent.
 
static uint32_t n_spikes_added = 0
 Number of spikes added to delay processing.
 
static uint32_t n_delays = 0
 Number of times we had to back off because the comms hardware was busy.
 
static uint32_t saturation_count = 0
 Number of packets dropped due to count saturation.
 
static uint32_t n_packets_dropped_due_to_invalid_neuron_value = 0
 number of packets dropped due to invalid neuron id
 
static uint32_t n_packets_dropped_due_to_invalid_key = 0
 number of packets dropped due to invalid key
 
static uint32_t count_input_buffer_packets_late
 number of packets late
 
static uint32_t timer_period = 0
 Used for configuring the timer hardware.
 
static bool spike_processing = false
 Is spike processing happening right now?
 
static uint32_t n_backgrounds_queued = 0
 The number of background tasks queued / running.
 
static uint32_t n_background_overloads = 0
 The number of times the background couldn't be added.
 
static uint32_t max_backgrounds_queued = 0
 The maximum number of background tasks queued.
 
static uint32_t n_colour_bits = 0
 The number of colour bits (both from source and to send)
 
static uint32_t colour_mask = 0
 The mask to apply to get the colour from the current timestep or key.
 
static uint32_t colour = 0
 The colour for the current time step.
 

Detailed Description

Implementation of delay extensions.

Definition in file delay_extension.c.


Data Structure Documentation

◆ delay_extension_provenance

struct delay_extension_provenance

Structure of the provenance data.

Definition at line 48 of file delay_extension.c.

Data Fields
uint32_t n_packets_received Number of input spikes.
uint32_t n_packets_processed Number of spikes transferred via queue.
uint32_t n_packets_added Number of spikes added to delay processing.
uint32_t n_packets_sent Number of spikes sent.
uint32_t n_buffer_overflows Number of circular buffer overflows (spikes internally dropped)
uint32_t n_delays Number of times we had to back off because the comms hardware was busy.
uint32_t n_packets_lost_due_to_count_saturation number of packets lost due to count saturation of uint8
uint32_t n_packets_dropped_due_to_invalid_neuron_value number of packets dropped due to invalid neuron value
uint32_t n_packets_dropped_due_to_invalid_key number of packets dropped due to invalid key
uint32_t count_input_buffer_packets_late number of packets dropped due to out of time
uint32_t max_backgrounds_queued Maximum backgrounds queued.
uint32_t n_background_queue_overloads Background queue overloads.

Enumeration Type Documentation

◆ delay_extension_callback_priorities

values for the priority for each callback

Enumerator
MC_PACKET 

multicast packet reception uses FIQ

TIMER 

Call timer at 0 to keep it quick.

USER 

Call user at 0 as well; will be behind timer.

SDP 

SDP handling is queued.

BACKGROUND 

Background processing.

DMA 

DMA is not actually used.

Definition at line 38 of file delay_extension.c.

Function Documentation

◆ zero_spike_counters()

static void zero_spike_counters ( uint8_t *  counters,
uint32_t  num_items 
)
inlinestatic

Sets an array of counters to zero.

This is basically just bzero()

Parameters
[out]countersThe array to zero
[in]num_itemsThe size of the array

Definition at line 179 of file delay_extension.c.

◆ round_to_next_pot()

static uint32_t round_to_next_pot ( uint32_t  v)
inlinestatic

Rounds up to the next power of two.

Parameters
[in]vThe value to round up
Returns
The minimum power of two that is no smaller than the argument

Definition at line 189 of file delay_extension.c.

◆ read_parameters()

static bool read_parameters ( struct delay_parameters params)
static

Read the configuration region.

Parameters
[in]paramsThe configuration region.
Returns
True if successful

Definition at line 203 of file delay_extension.c.

◆ store_provenance_data()

static void store_provenance_data ( address_t  provenance_region)
static

Writes the provenance data.

Parameters
[out]provenance_regionWhere to write the provenance

Definition at line 265 of file delay_extension.c.

◆ initialize()

static bool initialize ( void  )
static

Read the application configuration.

Returns
True if initialisation succeeded.

Definition at line 289 of file delay_extension.c.

◆ incoming_spike_callback()

static void incoming_spike_callback ( uint  key,
uint  payload 
)
static

Handles incoming spikes (FIQ)

Adds the spikes to the circular buffer handling spikes for later handling by spike_process()

Parameters
[in]keythe key of the multicast message
payloadignored

Definition at line 333 of file delay_extension.c.

◆ key_n()

static index_t key_n ( key_t  k)
inlinestatic

Gets the neuron ID of the incoming spike.

Parameters
[in]kThe key
Returns
the neuron ID

Definition at line 355 of file delay_extension.c.

◆ user_callback()

static void user_callback ( uint  unused0,
uint  unused1 
)
static

User event callback.

Delegates to spike_process()

Parameters
[in]unused0unused
[in]unused1unused

Definition at line 414 of file delay_extension.c.

◆ background_callback()

static void background_callback ( uint  local_time,
uint  timer_count 
)
static

Background event callback.

Handles sending delayed spikes at the right time.

Parameters
[in]local_timecurrent simulation time
[in]timer_countunused

Definition at line 422 of file delay_extension.c.

◆ timer_callback()

static void timer_callback ( uint  timer_count,
uint  unused1 
)
static

Main timer callback.

Parameters
[in]timer_countThe current time
unused1unused

Definition at line 482 of file delay_extension.c.

Variable Documentation

◆ spike_counters

uint8_t** spike_counters = NULL
static

The spike counters, as a 2D array.

spike_counters[time_slot][neuron_id]
static uint8_t ** spike_counters
The spike counters, as a 2D array.

Time slots are the time of reception of the spike, masked by num_delay_slots_mask, and neuron IDs are extracted from the spike key by masking with incoming_neuron_mask

Definition at line 111 of file delay_extension.c.