sPyNNaker neural_modelling  development
random_selection_impl.h
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 
19 #ifndef _RANDOM_SELECTION_IMPL_H_
20 #define _RANDOM_SELECTION_IMPL_H_
21 
22 #include "partner.h"
24 
30 static inline void partner_spike_received(
31  UNUSED uint32_t time, UNUSED spike_t spike) {
32 }
33 
44 static inline bool potential_presynaptic_partner(
45  UNUSED uint32_t time, uint32_t *restrict population_id,
46  uint32_t *restrict sub_population_id, uint32_t *restrict neuron_id,
47  spike_t *restrict spike, uint32_t *restrict m_pop_index) {
50 
51  uint32_t pop_id = ulrbits(mars_kiss64_seed(rewiring_data.local_seed)) *
52  pre_info.no_pre_pops;
53  *population_id = pop_id;
54  pre_info_t *preapppop_info = pre_info.prepop_info[pop_id];
55 
56  // Select presynaptic sub-population
57  uint32_t n_id = ulrbits(mars_kiss64_seed(rewiring_data.local_seed)) *
58  preapppop_info->total_no_atoms;
59  uint32_t subpop_id = 0;
60  uint32_t sum = 0;
61  for (uint32_t i = 0; i < preapppop_info->no_pre_vertices; i++) {
62  sum += preapppop_info->key_atom_info[i].n_atoms;
63  if (sum >= n_id) {
64  subpop_id = i;
65  break;
66  }
67  }
68  *sub_population_id = subpop_id;
69  key_atom_info_t *kai = &preapppop_info->key_atom_info[subpop_id];
70 
71  // Select a presynaptic neuron ID
72  n_id = ulrbits(mars_kiss64_seed(rewiring_data.local_seed)) * kai->n_atoms;
73 
74  *neuron_id = n_id;
75  *spike = kai->key | (n_id << kai->n_colour_bits);
76  *m_pop_index = kai->m_pop_index;
77  return true;
78 }
79 
80 #endif // _RANDOM_SELECTION_IMPL_H_
static void sum(weight_t *syns)
Add up all the synaptic contributions into a global buffer.
static uint32_t time
Simulation time.
uint32_t spike_t
The type of a spike.
Partner selection rule common API.
static void partner_spike_received(uint32_t time, spike_t spike)
Notifies the rule that a spike has been received.
static bool potential_presynaptic_partner(uint32_t time, uint32_t *restrict population_id, uint32_t *restrict sub_population_id, uint32_t *restrict neuron_id, spike_t *restrict spike, uint32_t *restrict m_pop_index)
Choose the potential (remote) synaptic partner.
information per atom
Definition: sp_structs.h:48
individual pre-synaptic sub-population information
Definition: sp_structs.h:58
table of individual pre-synaptic information
Definition: sp_structs.h:70
parameters of the synaptic rewiring model
Definition: sp_structs.h:76
Spike processing API.
rewiring_data_t rewiring_data
the instantiation of the rewiring data
pre_pop_info_table_t pre_info
pre-population information table