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