Debian Codegraph @

brian2/codegen/runtime/cython_rt/templates/synapses_push_spikes.pyx

raw
1 {# USES_VARIABLES { _queue_capsule } #}
2 {% extends 'common_group.pyx' %}
3
4 {% block template_support_code %}
5 from cpython.pycapsule cimport PyCapsule_GetPointer
6 # We declare minimal C++ interface here - only methods we actually want to use
7 # This avoids importing the full SpikeQueue wrapper and its dependencies
8 cdef extern from "spikequeue.h":
9 cdef cppclass CSpikeQueue:
10 void push(int32_t *, int)
11 {% endblock %}
12
13 {% block before_code %}
14 _owner.initialise_queue()
15 {% endblock %}
16
17 {% block maincode %}
18 {% set eventspace=get_array_name(eventspace_variable)%}
19 cdef int spike_count
20 # Get the spike count from the last entry in the spike buffer
21 spike_count = {{eventspace}}[_num{{eventspace}}-1]
22
23 # Recover the C++ spike queue object from the PyCapsule passed at runtime
24 cdef object capsule = _queue_capsule
25 cdef CSpikeQueue* cpp_queue = <CSpikeQueue*>PyCapsule_GetPointer(capsule, "CSpikeQueue")
26
27 if spike_count > 0:
28 # Optimized: avoid the push_spikes method call overhead
29 cpp_queue.push({{eventspace}},spike_count)
30 {% endblock %}