sPyNNaker neural_modelling 7.3.1
Loading...
Searching...
No Matches
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.
 
static uint32_t round_to_next_pot (uint32_t v)
 Rounds up to the next power of two.
 
static bool read_parameters (struct delay_parameters *params)
 Read the configuration region.
 
static void store_provenance_data (address_t provenance_region)
 Writes the provenance data.
 
static bool initialize (void)
 Read the application configuration.
 
static void incoming_spike_callback (uint key, uint payload)
 Handles incoming spikes (FIQ)
 
static index_t key_n (key_t k)
 Gets the neuron ID of the incoming spike.
 
static void spike_process (void)
 Processes spikes queued by incoming_spike_callback()
 
static void user_callback (uint unused0, uint unused1)
 User event callback.
 
static void background_callback (uint local_time, uint timer_count)
 Background event callback.
 
static void timer_callback (uint timer_count, uint unused1)
 Main timer callback.
 
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.
 
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.

Macro Definition Documentation

◆ IN_BUFFER_SIZE

#define IN_BUFFER_SIZE   256

the size of the circular queue for packets.

Definition at line 32 of file delay_extension.c.

◆ COUNTER_SATURATION_VALUE

#define COUNTER_SATURATION_VALUE   255

the point where the count has saturated.

Definition at line 35 of file delay_extension.c.

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.

◆ spike_process()

static void spike_process ( void  )
inlinestatic

Processes spikes queued by incoming_spike_callback()

Definition at line 360 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.

◆ c_main()

void c_main ( void  )

Entry point.

Definition at line 538 of file delay_extension.c.

Variable Documentation

◆ has_key

bool has_key
static

bool in int form for if there is a key

Definition at line 77 of file delay_extension.c.

◆ key

uint32_t key = 0
static

Base multicast key for sending messages.

Definition at line 79 of file delay_extension.c.

◆ incoming_key

uint32_t incoming_key = 0
static

Key for receiving messages.

Definition at line 81 of file delay_extension.c.

◆ incoming_mask

uint32_t incoming_mask = 0
static

Mask for incoming_key to say which messages are for this program.

Definition at line 83 of file delay_extension.c.

◆ incoming_neuron_mask

uint32_t incoming_neuron_mask = 0
static

Mask for key (that matches incoming_key/incoming_mask) to extract the neuron ID from it.

Definition at line 86 of file delay_extension.c.

◆ num_neurons

uint32_t num_neurons = 0
static

Number of neurons supported.

Definition at line 89 of file delay_extension.c.

◆ max_keys

uint32_t max_keys = 0
static

number of possible keys.

Definition at line 92 of file delay_extension.c.

◆ clear_input_buffers_of_late_packets

bool clear_input_buffers_of_late_packets
static

Whether to clear packets each timestep.

Definition at line 95 of file delay_extension.c.

◆ time

uint32_t time = UINT32_MAX
static

Simulation time.

Definition at line 98 of file delay_extension.c.

◆ simulation_ticks

uint32_t simulation_ticks = 0
static

Simulation speed.

Definition at line 100 of file delay_extension.c.

◆ infinite_run

uint32_t infinite_run
static

True if we're running forever.

Definition at line 102 of file delay_extension.c.

◆ 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.

◆ num_delay_stages

uint32_t num_delay_stages = 0
static

The number of delay stages.

Definition at line 113 of file delay_extension.c.

◆ n_delay_in_a_stage

uint32_t n_delay_in_a_stage = 0
static

The number of delays within a delay stage.

Definition at line 115 of file delay_extension.c.

◆ num_delay_slots

uint32_t num_delay_slots = 0
static

The total number of delay slots.

Definition at line 117 of file delay_extension.c.

◆ num_delay_slots_mask

uint32_t num_delay_slots_mask = 0
static

Mask for converting time into the current delay slot.

Definition at line 119 of file delay_extension.c.

◆ neuron_bit_field_words

uint32_t neuron_bit_field_words = 0
static

Size of each bitfield in ::neuron_delay_stage_config.

Definition at line 121 of file delay_extension.c.

◆ n_in_spikes

uint32_t n_in_spikes = 0
static

Number of input spikes.

Definition at line 124 of file delay_extension.c.

◆ n_processed_spikes

uint32_t n_processed_spikes = 0
static

Number of spikes transferred via queue.

Definition at line 126 of file delay_extension.c.

◆ n_spikes_sent

uint32_t n_spikes_sent = 0
static

Number of spikes sent.

Definition at line 128 of file delay_extension.c.

◆ n_spikes_added

uint32_t n_spikes_added = 0
static

Number of spikes added to delay processing.

Definition at line 130 of file delay_extension.c.

◆ n_delays

uint32_t n_delays = 0
static

Number of times we had to back off because the comms hardware was busy.

Definition at line 133 of file delay_extension.c.

◆ saturation_count

uint32_t saturation_count = 0
static

Number of packets dropped due to count saturation.

Definition at line 136 of file delay_extension.c.

◆ n_packets_dropped_due_to_invalid_neuron_value

uint32_t n_packets_dropped_due_to_invalid_neuron_value = 0
static

number of packets dropped due to invalid neuron id

Definition at line 139 of file delay_extension.c.

◆ n_packets_dropped_due_to_invalid_key

uint32_t n_packets_dropped_due_to_invalid_key = 0
static

number of packets dropped due to invalid key

Definition at line 142 of file delay_extension.c.

◆ count_input_buffer_packets_late

uint32_t count_input_buffer_packets_late
static

number of packets late

Definition at line 145 of file delay_extension.c.

◆ timer_period

uint32_t timer_period = 0
static

Used for configuring the timer hardware.

Definition at line 148 of file delay_extension.c.

◆ spike_processing

bool spike_processing = false
static

Is spike processing happening right now?

Definition at line 151 of file delay_extension.c.

◆ n_backgrounds_queued

uint32_t n_backgrounds_queued = 0
static

The number of background tasks queued / running.

Definition at line 154 of file delay_extension.c.

◆ n_background_overloads

uint32_t n_background_overloads = 0
static

The number of times the background couldn't be added.

Definition at line 157 of file delay_extension.c.

◆ max_backgrounds_queued

uint32_t max_backgrounds_queued = 0
static

The maximum number of background tasks queued.

Definition at line 160 of file delay_extension.c.

◆ n_colour_bits

uint32_t n_colour_bits = 0
static

The number of colour bits (both from source and to send)

Definition at line 163 of file delay_extension.c.

◆ colour_mask

uint32_t colour_mask = 0
static

The mask to apply to get the colour from the current timestep or key.

Definition at line 166 of file delay_extension.c.

◆ colour

uint32_t colour = 0
static

The colour for the current time step.

Definition at line 169 of file delay_extension.c.