20#ifndef _NEURON_RECORDING_H_
21#define _NEURON_RECORDING_H_
44 uint32_t element_size;
87#define FLOOR_TO_2 0xFFFFFFFE
98 uint32_t var_index, uint32_t neuron_index,
void *value) {
101 uint32_t p = size * index;
111 uint32_t var_index, uint32_t neuron_index, accum value) {
123 uint32_t var_index, uint32_t neuron_index,
double value) {
135 uint32_t var_index, uint32_t neuron_index,
float value) {
147 uint32_t var_index, uint32_t neuron_index, int32_t value) {
158 uint32_t var_index, uint32_t neuron_index) {
169 for (uint32_t i = N_RECORDED_VARS; i > 0; i--) {
172 if (rec_info->count == rec_info->rate) {
176 rec_info->values->time =
time;
181 rec_info->count += rec_info->increment;
185 for (uint32_t i = N_BITFIELD_VARS; i > 0; i--) {
188 if (bf_info->count == bf_info->rate) {
192 if (empty_bit_field(bf_info->values->bits, bf_info->n_words)) {
196 bf_info->values->time =
time;
201 bf_info->count += bf_info->increment;
209 for (uint32_t i = N_BITFIELD_VARS; i > 0; i--) {
211 if (b_info->count == 1) {
212 clear_bit_field(b_info->values->bits, b_info->n_words);
219 for (uint32_t i = 0; i < N_RECORDED_VARS; i++) {
236 for (uint32_t i = 0; i < N_BITFIELD_VARS; i++) {
267 void *recording_address, uint32_t
n_neurons) {
274 typedef struct neuron_recording_data {
276 uint32_t n_neurons_recording;
277 uint32_t element_size;
278 uint16_t indices[ceil_n_entries];
279 } neuron_recording_data_t;
281 neuron_recording_data_t *data = recording_address;
283 for (uint32_t i = 0; i < N_RECORDED_VARS; i++) {
285 uint32_t n_neurons_rec = data[i].n_neurons_recording;
298 log_error(
"couldn't allocate recording data space %u for %d",
310 typedef struct bitfield_recording_data {
312 uint32_t n_neurons_recording;
313 uint16_t indices[ceil_n_entries];
314 } bitfield_recording_data_t;
316 bitfield_recording_data_t *bitfield_data =
317 (bitfield_recording_data_t *) &data[N_RECORDED_VARS];
319 for (uint32_t i = 0; i < N_BITFIELD_VARS; i++) {
321 uint32_t n_neurons_rec = bitfield_data[i].n_neurons_recording;
331 log_error(
"couldn't allocate bitfield recording data space for %d", i);
336 bitfield_info[i].n_words = get_bit_field_size(n_neurons_rec + 1);
352 log_error(
"failed to reread in the new elements after reset");
364 log_error(
"Could not allocated space for recording_info");
370 spin1_malloc(N_RECORDED_VARS *
sizeof(uint16_t *));
372 log_error(
"Could not allocate space for var_recording_indexes");
378 log_error(
"Could not allocate space for recording_values");
382 for (uint32_t i = 0; i < N_RECORDED_VARS; i++) {
389 log_error(
"failed to allocate memory for recording index %d", i);
404 log_error(
"Failed to allocate space for bitfield_info");
410 spin1_malloc(N_BITFIELD_VARS *
sizeof(uint16_t *));
412 log_error(
"Could not allocate space for bitfield_recording_indexes");
418 log_error(
"Could not allocate space for bitfield_values");
422 for (uint32_t i = 0; i < N_BITFIELD_VARS; i++) {
428 spin1_malloc(
n_neurons *
sizeof(uint16_t));
430 log_error(
"failed to allocate memory for bitfield index %d", i);
440typedef struct neuron_recording_header {
454 void *recording_address, uint32_t
n_neurons,
455 uint32_t *n_rec_regions_used) {
457 void *data_addr = recording_address;
462 log_error(
"Data spec number of recording variables %d != "
463 "neuron implementation number of recorded variables %d",
468 log_error(
"Data spec number of bitfield variables %d != "
469 "neuron implementation number of bitfield variables %d",
475 data_addr = &header[1];
478 log_error(
"failed to allocate DTCM for the neuron recording structs.");
482 log_error(
"failed to allocate DTCM for the bitfield recording structs");
489 log_error(
"failed to read in the elements");
uint32_t time
The current timer tick value.
void log_error(const char *message,...)
Data type definitions for SpiNNaker Neuron-modelling.
static uint32_t n_neurons
The number of neurons on the core.
static void neuron_recording_record_float(uint32_t var_index, uint32_t neuron_index, float value)
stores a recording of a float variable only; this is faster than neuron_recording_record_value for th...
static bitfield_info_t * bitfield_info
An array of bitfield information structures.
#define FLOOR_TO_2
When bitwise anded with a number will floor to the nearest multiple of 2.
static void neuron_recording_record_value(uint32_t var_index, uint32_t neuron_index, void *value)
stores a recording of a value of any type, except bitfield; use the functions below for common types ...
static void reset_record_counter(void)
resets all states back to start state.
static void neuron_recording_record_accum(uint32_t var_index, uint32_t neuron_index, accum value)
stores a recording of an accum variable only; this is faster than neuron_recording_record_value for t...
static volatile uint32_t n_recordings_outstanding
The number of recordings outstanding.
bool neuron_recording_reset(uint32_t n_neurons)
reads recording data from sdram on reset.
static void neuron_recording_setup_for_next_recording(void)
sets up state for next recording.
static uint16_t ** neuron_recording_indexes
The index to record each variable to for each neuron.
static bool allocate_word_dtcm(uint32_t n_neurons)
handles all the DTCM allocations for recording words
static uint16_t ** bitfield_recording_indexes
The index to record each bitfield variable to for each neuron.
static void neuron_recording_record(uint32_t time)
does the recording process of handing over to basic recording
static recording_info_t * recording_info
An array of recording information structures.
#define CEIL_TO_2
Add to a number before applying floor to 2 to turn it into a ceil operation.
static bool neuron_recording_read_in_elements(void *recording_address, uint32_t n_neurons)
reads recording data from SDRAM
static void neuron_recording_record_double(uint32_t var_index, uint32_t neuron_index, double value)
stores a recording of a double variable only; this is faster than neuron_recording_record_value for t...
static uint32_t ** bitfield_values
An array of spaces into which bitfields can be written.
uint32_t n_recorded_vars
The number of word-sized variables to record.
static uint8_t ** recording_values
An array of spaces into which recording values can be written.
static void * reset_address
The address of the recording region to read on reset.
uint32_t n_bitfield_vars
The number of bitfield variables to record.
bool neuron_recording_initialise(void *recording_address, uint32_t n_neurons, uint32_t *n_rec_regions_used)
sets up the recording stuff
static uint32_t bitfield_data_size(uint32_t n_neurons)
the number of bytes used in bitfield recording for n_neurons
static void neuron_recording_record_bit(uint32_t var_index, uint32_t neuron_index)
stores a recording of a set bit; this is the only way to set a bit in a bitfield; neuron_recording_re...
static bool allocate_bitfield_dtcm(uint32_t n_neurons)
handles all the DTCM allocations for recording bitfields
static void neuron_recording_record_int32(uint32_t var_index, uint32_t neuron_index, int32_t value)
stores a recording of an int32_t variable only; this is faster than neuron_recording_record_value for...
A struct for information on a bitfield recording.
A struct for bitfield data.
A struct for information for a non-bitfield recording.
A struct of the different types of recorded data.
bool recording_record(channel_index_t channel, void *data, size_t size_bytes)
void spin1_memcpy(void *dst, void const *src, uint len)