File: summed_variable.cpp

package info (click to toggle)
brian 2.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,872 kB
  • sloc: python: 51,820; cpp: 2,033; makefile: 108; sh: 72
file content (29 lines) | stat: -rw-r--r-- 985 bytes parent folder | download | duplicates (4)
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
{# USES_VARIABLES { N } #}
{% extends 'common_group.cpp' %}

{% block maincode %}
    {% set _target_var_array = get_array_name(_target_var) %}
    {% set _index_array = get_array_name(_index_var) %}
    //// MAIN CODE ////////////
    {# This enables summed variables for connections to a synapse #}
    const int _target_size = {{constant_or_scalar(_target_size_name, variables[_target_size_name])}};

    // Set all the target variable values to zero
    {{ openmp_pragma('parallel-static') }}
    for (int _target_idx=0; _target_idx<_target_size; _target_idx++)
    {
        {{_target_var_array}}[_target_idx + {{_target_start}}] = 0;
    }

    // scalar code
    const size_t _vectorisation_idx = -1;
    {{scalar_code|autoindent}}

    for(int _idx=0; _idx<{{N}}; _idx++)
    {
        // vector code
        const size_t _vectorisation_idx = _idx;
        {{vector_code|autoindent}}
        {{_target_var_array}}[{{_index_array}}[_idx]] += _synaptic_var;
    }
{% endblock %}