sPyNNaker neural_modelling 7.3.1
Loading...
Searching...
No Matches
c_main_synapses.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
35#include "c_main_synapse_common.h"
36#include "c_main_common.h"
39#include <spin1_api_params.h>
40
42typedef enum callback_priorities {
43 MC = -1, DMA = -2, TIMER = 0, SDP = 0
45
48 struct synapse_provenance synapse_prov;
49 struct spike_processing_fast_provenance spike_processing_prov;
50};
51
53enum regions {
55 PROVENANCE_DATA_REGION,
56 PROFILER_REGION,
57 RECORDING_REGION,
58 SYNAPSE_PARAMS_REGION,
59 SYNAPTIC_MATRIX_REGION,
60 POPULATION_TABLE_REGION,
61 SYNAPSE_DYNAMICS_REGION,
62 STRUCTURAL_DYNAMICS_REGION,
63 BIT_FIELD_FILTER_REGION,
64 SDRAM_PARAMS_REGION,
65 KEY_REGION
66};
67
71 .provenance = PROVENANCE_DATA_REGION,
72 .profiler = PROFILER_REGION,
73 .recording = RECORDING_REGION
74};
75
78 .sdp = SDP,
79 .dma = DMA,
80 .timer = TIMER
81};
82
85 .synapse_params = SYNAPSE_PARAMS_REGION,
86 .synaptic_matrix = SYNAPTIC_MATRIX_REGION,
87 .pop_table = POPULATION_TABLE_REGION,
88 .synapse_dynamics = SYNAPSE_DYNAMICS_REGION,
89 .structural_dynamics = STRUCTURAL_DYNAMICS_REGION,
90 .bitfield_filter = BIT_FIELD_FILTER_REGION
91};
92
94// the timer tick callback returning the same value.
95uint32_t time;
96
98static uint32_t timer_period;
99
101static uint32_t simulation_ticks = 0;
102
104static uint32_t infinite_run;
105
107static uint32_t recording_flags = 0;
108
111static void store_provenance_data(address_t provenance_region) {
112 struct provenance_data *prov = (void *) provenance_region;
113 store_synapse_provenance(&prov->synapse_prov);
114 spike_processing_fast_store_provenance(&prov->spike_processing_prov);
115}
116
118void resume_callback(void) {
119
120 // Reset recording
122
123 // Resume synapses
124 // NOTE: at reset, time is set to UINT_MAX ahead of timer_callback(...)
126}
127
131void timer_callback(UNUSED uint unused0, UNUSED uint unused1) {
132 time++;
134 // Enter pause and resume state to avoid another tick
136
137 // Pause common functions
138 common_pause(recording_flags);
139
141 return;
142 }
143
144 uint32_t n_rewires = synaptogenesis_n_updates();
145 spike_processing_fast_time_step_loop(time, n_rewires);
146}
147
151static bool initialise(void) {
153 if (!initialise_common_regions(
156 COMMON_REGIONS, COMMON_PRIORITIES, &ds_regions)) {
157 return false;
158 }
159
160 // Setup synapses
161 uint32_t incoming_spike_buffer_size;
162 uint32_t row_max_n_words;
163 bool clear_input_buffer_of_late_packets;
164 weight_t *ring_buffers;
165 uint32_t n_rec_regions_used = 0;
166 if (!initialise_synapse_regions(
167 ds_regions, SYNAPSE_REGIONS, &ring_buffers, &row_max_n_words,
168 &incoming_spike_buffer_size,
169 &clear_input_buffer_of_late_packets, &n_rec_regions_used)) {
170 return false;
171 }
172
173 // Setup for writing synaptic inputs at the end of each run
174 struct sdram_config *sdram_config = data_specification_get_region(
175 SDRAM_PARAMS_REGION, ds_regions);
176 struct key_config *key_config = data_specification_get_region(
177 KEY_REGION, ds_regions);
178
180 row_max_n_words, incoming_spike_buffer_size,
181 clear_input_buffer_of_late_packets, n_rec_regions_used, MC,
183 return false;
184 }
185
186 // Do bitfield configuration last to only use any unused memory
187 if (!population_table_load_bitfields(data_specification_get_region(
188 SYNAPSE_REGIONS.bitfield_filter, ds_regions))) {
189 return false;
190 }
191
192 // Set timer tick (in microseconds)
193 log_debug("setting timer tick callback for %d microseconds", timer_period);
194 spin1_set_timer_tick(timer_period);
195
197
198 return true;
199}
200
202void c_main(void) {
203
204 // initialise the model
205 if (!initialise()) {
207 }
208
210}
static weight_t * ring_buffers
The ring buffers to be used in the simulation.
Definition c_main.c:118
static uint32_t simulation_ticks
The number of timer ticks to run for before being expected to exit.
callback_priorities
values for the priority for each callback
static void store_provenance_data(address_t provenance_region)
Callback to store provenance data (format: neuron_provenance).
void resume_callback(void)
the function to call when resuming a simulation
static uint32_t recording_flags
The recording flags indicating if anything is recording.
static uint32_t infinite_run
Determines if this model should run for infinite time.
void c_main(void)
The entry point for this model.
const struct synapse_regions SYNAPSE_REGIONS
From the regions, select those that are used for synapse-specific things.
const struct common_priorities COMMON_PRIORITIES
Identify the priority of common tasks.
static bool initialise(void)
Initialises the model by reading in the regions and checking recording data.
static uint32_t timer_period
timer tick period (in microseconds)
const struct common_regions COMMON_REGIONS
From the regions, select those that are common.
void timer_callback(uint unused0, uint unused1)
Timer event callback.
uint32_t time
The current timer tick value.
Provenance data region layout.
TIMER
DMA
SDP
callback_priorities
SYSTEM_REGION
uint32_t * address_t
void log_debug(const char *message,...)
bool population_table_load_bitfields(filter_region_t *filter_region)
Initialise the bitfield filtering system.
void recording_reset(void)
RTE_API
void rt_error(uint code,...)
void simulation_handle_pause_resume(resume_callback_t callback)
bool simulation_is_finished(void)
void simulation_ready_to_read(void)
void simulation_run(void)
Spike processing fast API.
bool spike_processing_fast_initialise(uint32_t row_max_n_words, uint32_t spike_buffer_size, bool discard_late_packets, uint32_t pkts_per_ts_rec_region, uint32_t multicast_priority, struct sdram_config sdram_inputs_param, struct key_config key_config_param, weight_t *ring_buffers_param)
Set up spike processing.
Provenance for spike processing.
@ SDRAM_PARAMS_REGION
SDRAM transfer parameters region.
A region of SDRAM used to transfer synapses.
unsigned int uint
The callback priorities used by all simulation cores.
uint32_t sdp
The SDP callback priority.
The identifiers of the regions used by all simulation cores.
uint32_t system
Data for general simulation setup.
The provenance information for synaptic processing.
The region IDs used by synapse processing.
uint32_t bitfield_filter
The filters to avoid DMA transfers of empty rows.
uint32_t synapse_params
The parameters of the synapse processing.
void synapses_resume(timer_t time)
Resume processing of synapses after a pause.
Definition synapses.c:410
This file contains the main interface for structural plasticity.
uint32_t synaptogenesis_n_updates(void)
Number of updates to do of synaptogenesis this time step.