| 1 |
{% extends 'common_synapses.cpp' %} |
| 2 |
|
| 3 |
{% set _non_synaptic = [] %} |
| 4 |
{% for var in variables %} |
| 5 |
{% if variable_indices[var] not in ('_idx', '0') %} |
| 6 |
{# This is a trick to get around the scoping problem #} |
| 7 |
{% if _non_synaptic.append(1) %}{% endif %} |
| 8 |
{% endif %} |
| 9 |
{% endfor %} |
| 10 |
|
| 11 |
{% block maincode %} |
| 12 |
|
| 13 |
// This is only needed for the _debugmsg function below |
| 14 |
{# USES_VARIABLES { _synaptic_pre } #} |
| 15 |
|
| 16 |
// scalar code |
| 17 |
const size_t _vectorisation_idx = -1; |
| 18 |
{{scalar_code|autoindent}} |
| 19 |
|
| 20 |
{{ openmp_pragma('parallel') }} |
| 21 |
{ |
| 22 |
std::vector<int> *_spiking_synapses = {{pathway.name}}.peek(); |
| 23 |
const int _num_spiking_synapses = _spiking_synapses->size(); |
| 24 |
|
| 25 |
{% if _non_synaptic %} |
| 26 |
{{ openmp_pragma('master') }} |
| 27 |
{ |
| 28 |
for(int _spiking_synapse_idx=0; |
| 29 |
_spiking_synapse_idx<_num_spiking_synapses; |
| 30 |
_spiking_synapse_idx++) |
| 31 |
{ |
| 32 |
const size_t _idx = (*_spiking_synapses)[_spiking_synapse_idx]; |
| 33 |
const size_t _vectorisation_idx = _idx; |
| 34 |
{{vector_code|autoindent}} |
| 35 |
} |
| 36 |
} |
| 37 |
{% else %} |
| 38 |
{{ openmp_pragma('static') }} |
| 39 |
for(int _spiking_synapse_idx=0; |
| 40 |
_spiking_synapse_idx<_num_spiking_synapses; |
| 41 |
_spiking_synapse_idx++) |
| 42 |
{ |
| 43 |
const size_t _idx = (*_spiking_synapses)[_spiking_synapse_idx]; |
| 44 |
const size_t _vectorisation_idx = _idx; |
| 45 |
{{vector_code|autoindent}} |
| 46 |
} |
| 47 |
|
| 48 |
{% endif %} |
| 49 |
} |
| 50 |
{% endblock %} |
| 51 |
|
| 52 |
|
| 53 |
{% block extra_functions_cpp %} |
| 54 |
void _debugmsg_{{codeobj_name}}() |
| 55 |
{ |
| 56 |
using namespace brian; |
| 57 |
std::cout << "Number of synapses: " << {{_dynamic__synaptic_pre}}.size() << endl; |
| 58 |
} |
| 59 |
{% endblock %} |
| 60 |
|
| 61 |
{% block extra_functions_h %} |
| 62 |
void _debugmsg_{{codeobj_name}}(); |
| 63 |
{% endblock %} |
| 64 |
|
| 65 |
{% macro main_finalise() -%} |
| 66 |
#ifdef DEBUG |
| 67 |
_debugmsg_{{codeobj_name}}(); |
| 68 |
#endif |
| 69 |
{% endmacro %} |