sPyNNaker neural_modelling 7.1.1
Loading...
Searching...
No Matches
population_table.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 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
21#ifndef _POPULATION_TABLE_H_
22#define _POPULATION_TABLE_H_
23
25#include <filter_info.h>
26#include <neuron/synapse_row.h>
27#include <debug.h>
28
29
31#define BITS_PER_WORD 32
32
34#define TOP_BIT_IN_WORD 31
35
38#define NOT_IN_MASTER_POP_TABLE_FLAG -1
39
42#define N_ADDRESS_BITS 24
43
47#define INDIRECT_ADDRESS_SHIFT 4
48
52 uint32_t key;
54 uint32_t mask;
56 uint32_t start: 13;
58 uint32_t n_colour_bits: 3;
60 uint32_t count: 16;
62 uint32_t core_mask: 16;
64 uint32_t mask_shift: 16;
66 uint32_t n_neurons: 16;
68 uint32_t n_words: 16;
70
72typedef struct {
74 uint32_t row_length : 8;
78
81#define INVALID_ADDRESS ((1 << N_ADDRESS_BITS) - 1)
82
86typedef struct {
87 uint32_t table_length;
88 uint32_t addr_list_length;
91
93typedef struct {
94 // Updated with the address of the row
95 synaptic_row_t row_address;
96
97 // Updated with the number of bytes to read
98 size_t n_bytes_to_transfer;
99
100 // Updated with the spike colour
101 uint32_t colour;
102
103 // Updated with the spike colour mask
104 uint32_t colour_mask;
106
109
115static inline uint32_t get_offset(address_list_entry entry) {
116 return entry.address << INDIRECT_ADDRESS_SHIFT;
117}
118
122static inline uint32_t get_address(address_list_entry entry, uint32_t addr) {
123 return get_offset(entry) + addr;
124}
125
132static inline uint32_t get_row_length(address_list_entry entry) {
133 return entry.row_length + 1;
134}
135
140static inline uint32_t get_core_index(master_population_table_entry entry, spike_t spike) {
141 return (spike >> entry.mask_shift) & entry.core_mask;
142}
143
148static inline uint32_t get_core_sum(master_population_table_entry entry, spike_t spike) {
149 return get_core_index(entry, spike) * entry.n_neurons;
150}
151
156static inline uint32_t get_neuron_id(
158 return spike & ~entry.mask;
159}
160
166static inline uint32_t get_local_neuron_id(
168 return spike & ~(entry.mask | (entry.core_mask << entry.mask_shift));
169}
170
177 uint32_t synaptic_rows_base_address, uint32_t neuron_id,
179 uint32_t row_length = get_row_length(item);
180 uint32_t block_address = get_address(item, synaptic_rows_base_address);
181 uint32_t stride = (row_length + N_SYNAPSE_ROW_HEADER_WORDS);
182 uint32_t neuron_offset = neuron_id * stride * sizeof(uint32_t);
183
184 result->row_address = (synaptic_row_t) (block_address + neuron_offset);
185 result->n_bytes_to_transfer = stride * sizeof(uint32_t);
186
187 log_debug("neuron_id = %u, block_address = 0x%.8x, "
188 "row_length = %u, row_address = 0x%.8x, n_bytes = %u",
189 neuron_id, block_address, row_length, result->row_address,
190 result->n_bytes_to_transfer);
191}
192
194extern uint32_t ghost_pop_table_searches;
195
197extern uint32_t invalid_master_pop_hits;
198
201extern uint32_t failed_bit_field_reads;
202
205extern uint32_t bit_field_filtered_packets;
206
208extern uint16_t items_to_go;
209
218bool population_table_setup(address_t table_address, uint32_t *row_max_n_words,
219 uint32_t *master_pop_table_length,
220 master_population_table_entry **master_pop_table,
222
231 address_t table_address, address_t synapse_rows_address,
232 uint32_t *row_max_n_words);
233
238
244 spike_t spike, pop_table_lookup_result_t *result);
245
248static inline bool population_table_is_next(void) {
249 return items_to_go > 0;
250}
251
258 spike_t *spike, pop_table_lookup_result_t *result);
259
260#endif // _POPULATION_TABLE_H_
uint32_t * address_t
void log_debug(const char *message,...)
static uint32_t colour_mask
The mask to apply to get the colour from the current timestep or key.
static uint32_t colour
The colour for the current time step.
Data type definitions for SpiNNaker Neuron-modelling.
struct synaptic_row * synaptic_row_t
The type of a synaptic row.
uint32_t spike_t
The type of a spike.
static uint32_t get_offset(address_list_entry entry)
Get the standard address offset out of an entry.
uint32_t key
The key to match against the incoming message.
bool population_table_setup(address_t table_address, uint32_t *row_max_n_words, uint32_t *master_pop_table_length, master_population_table_entry **master_pop_table, address_list_entry **address_list)
Set up and return the table for outside use.
bool population_table_get_next_address(spike_t *spike, pop_table_lookup_result_t *result)
Get the next row data for a previously given spike. If no spike has been given, return False.
uint32_t count
The number of entries in address_list for this entry.
uint32_t n_neurons
The number of neurons per core.
#define N_ADDRESS_BITS
The number of bits of address. This is a constant as it is used more than once below.
static uint32_t get_address(address_list_entry entry, uint32_t addr)
Get the standard address out of an entry.
uint32_t address
the address
uint32_t row_length
the length of the row
#define INDIRECT_ADDRESS_SHIFT
The shift to apply to indirect addresses. The address is in units of four words, so this multiplies b...
uint32_t failed_bit_field_reads
The number of bit fields which were not able to be read in due to DTCM limits.
uint32_t invalid_master_pop_hits
the number of times packet isn't in the master pop table at all!
uint32_t bit_field_filtered_packets
The number of packets dropped because the bitfield filter says they don't hit anything.
static uint32_t get_row_length(address_list_entry entry)
Get the length of the row from the entry.
static void get_row_addr_and_size(address_list_entry item, uint32_t synaptic_rows_base_address, uint32_t neuron_id, pop_table_lookup_result_t *result)
Get the row address and size for a given neuron.
static uint32_t get_local_neuron_id(master_population_table_entry entry, spike_t spike)
Get the neuron id of the neuron on the source core, for a spike with extra info.
bool population_table_load_bitfields(filter_region_t *filter_region)
Initialise the bitfield filtering system.
uint32_t mask
The mask to select the relevant bits of key for matching.
static bool population_table_is_next(void)
Determine if there are more items with the same key.
bool population_table_get_first_address(spike_t spike, pop_table_lookup_result_t *result)
Get the first row data for the given input spike.
uint32_t n_colour_bits
The number of bits of key used for colour (0 if no colour)
static uint32_t get_core_index(master_population_table_entry entry, spike_t spike)
Get the source core index from a spike.
static uint32_t get_neuron_id(master_population_table_entry entry, spike_t spike)
Get the source neuron ID for a spike given its table entry (without extra info)
uint32_t n_words
The number of words for n_neurons.
uint32_t ghost_pop_table_searches
the number of times a DMA resulted in 0 entries
static uint32_t get_core_sum(master_population_table_entry entry, spike_t spike)
Get the total number of neurons on cores which come before this core.
bool population_table_initialise(address_t table_address, address_t synapse_rows_address, uint32_t *row_max_n_words)
Set up the table.
uint32_t core_mask
The mask to apply to the key once shifted to get the core index.
uint16_t items_to_go
The number of addresses from the same spike left to process.
uint32_t mask_shift
The shift to apply to the key to get the core part.
uint32_t start
The index into address_list for this entry.
A packed address and row length (note: same size as extra info)
An entry in the master population table.
The memory layout in SDRAM of the first part of the population table configuration....
A structure to hold a response to a population table lookup.
static uint32_t synaptic_rows_base_address
Base address for the synaptic matrix's indirect rows.
static address_list_entry * address_list
The array of information that points into the synaptic matrix.
implementation for handling the processing of synapse rows.
#define N_SYNAPSE_ROW_HEADER_WORDS
Number of header words per synaptic row.