| 1 |
{# USES_VARIABLES { N, _clock_t, count, |
| 2 |
_source_start, _source_stop} #} |
| 3 |
{# WRITES_TO_READ_ONLY_VARIABLES { N, count } #} |
| 4 |
{% extends 'common_group.cpp' %} |
| 5 |
|
| 6 |
{% block maincode %} |
| 7 |
//// MAIN CODE //////////// |
| 8 |
{# Get the name of the array that stores these events (e.g. the spikespace array) #} |
| 9 |
{% set _eventspace = get_array_name(eventspace_variable) %} |
| 10 |
|
| 11 |
int32_t _num_events = {{_eventspace}}[_num{{eventspace_variable.name}}-1]; |
| 12 |
|
| 13 |
if (_num_events > 0) |
| 14 |
{ |
| 15 |
size_t _start_idx = _num_events; |
| 16 |
size_t _end_idx = _num_events; |
| 17 |
for(size_t _j=0; _j<_num_events; _j++) |
| 18 |
{ |
| 19 |
const int _idx = {{_eventspace}}[_j]; |
| 20 |
if (_idx >= _source_start) { |
| 21 |
_start_idx = _j; |
| 22 |
break; |
| 23 |
} |
| 24 |
} |
| 25 |
for(size_t _j=_num_events-1; _j>=_start_idx; _j--) |
| 26 |
{ |
| 27 |
const int _idx = {{_eventspace}}[_j]; |
| 28 |
if (_idx < _source_stop) { |
| 29 |
break; |
| 30 |
} |
| 31 |
_end_idx = _j; |
| 32 |
} |
| 33 |
_num_events = _end_idx - _start_idx; |
| 34 |
if (_num_events > 0) { |
| 35 |
const size_t _vectorisation_idx = 1; |
| 36 |
{{scalar_code|autoindent}} |
| 37 |
for(size_t _j=_start_idx; _j<_end_idx; _j++) |
| 38 |
{ |
| 39 |
const size_t _idx = {{_eventspace}}[_j]; |
| 40 |
const size_t _vectorisation_idx = _idx; |
| 41 |
{{vector_code|autoindent}} |
| 42 |
{% for varname, var in record_variables | dictsort %} |
| 43 |
{{get_array_name(var, access_data=False)}}.push_back(_to_record_{{varname}}); |
| 44 |
{% endfor %} |
| 45 |
{{count}}[_idx-_source_start]++; |
| 46 |
} |
| 47 |
{{N}} += _num_events; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
{% endblock %} |
| 52 |
|
| 53 |
{% block extra_functions_cpp %} |
| 54 |
void _debugmsg_{{codeobj_name}}() |
| 55 |
{ |
| 56 |
using namespace brian; |
| 57 |
{# We need the pointers and constants here to get the access to N working #} |
| 58 |
%CONSTANTS% |
| 59 |
{{pointers_lines|autoindent}} |
| 60 |
std::cout << "Number of spikes: " << {{N}} << endl; |
| 61 |
} |
| 62 |
{% endblock %} |
| 63 |
|
| 64 |
{% block extra_functions_h %} |
| 65 |
void _debugmsg_{{codeobj_name}}(); |
| 66 |
{% endblock %} |
| 67 |
|
| 68 |
{% macro main_finalise() %} |
| 69 |
#ifdef DEBUG |
| 70 |
_debugmsg_{{codeobj_name}}(); |
| 71 |
#endif |
| 72 |
{% endmacro %} |