New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: `SpikeGeneratorGroup` not producing all the spikes for Cython and C++ standalone #429

Closed
mstimberg opened this Issue Mar 19, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@mstimberg
Member

mstimberg commented Mar 19, 2015

This seems to be a regression introduced by the SpikeGeneratorGroup rewrite. The following code works correctly under 2.0beta but fails for cython and cpp_standalone on my machine:

from brian2 import *
targets = [('runtime', 'numpy'),
           ('runtime', 'weave'),
           ('runtime', 'cython'),
           ('cpp_standalone', 'weave')  # codegen target does not matter
           ]
for dev, target in targets:
    print dev, target
    set_device(dev)
    prefs.codegen.target = target
    n_spikes = 100000
    spike_gen = SpikeGeneratorGroup(1, np.zeros(n_spikes),
                                    np.arange(n_spikes)*defaultclock.dt)
    target = NeuronGroup(1, 'counter : integer')
    count_mon = StateMonitor(target, 'counter', record=0)
    syn = Synapses(spike_gen, target, pre='counter+=1', connect=True)
    spike_mon = SpikeMonitor(spike_gen)
    run(n_spikes*defaultclock.dt)
    device.build(compile=True, run=True)
    print 'Simulating for ', n_spikes*defaultclock.dt
    print 'Expected', n_spikes, 'spikes, got', spike_mon.count[0]
    print '1 spike every time step',
    print all(np.diff(np.round(spike_mon.t[:]/defaultclock.dt)) == 1)
    print 'NeuronGroup received one spike per time step',
    print all(np.diff(count_mon[0].counter) == 1)
    print
runtime numpy
Simulating for  10. s
Expected 100000 spikes, got 100000
1 spike every time step True
NeuronGroup received one spike per time step True

runtime weave
Simulating for  10. s
Expected 100000 spikes, got 100000
1 spike every time step True
NeuronGroup received one spike per time step True

runtime cython
Simulating for  10. s
Expected 100000 spikes, got 84160
1 spike every time step False
NeuronGroup received one spike per time step False

cpp_standalone weave
Number of synapses: 1
Number of spikes: 84160
Simulating for  10. s
Expected 100000 spikes, got 84160
1 spike every time step False
NeuronGroup received one spike per time step False

@mstimberg mstimberg self-assigned this Mar 19, 2015

@mstimberg mstimberg added this to the 2.0beta3 milestone Mar 19, 2015

mstimberg added a commit that referenced this issue Mar 19, 2015

@mstimberg

This comment has been minimized.

Show comment
Hide comment
@mstimberg

mstimberg Mar 19, 2015

Member

It turned out that the above issue is due to the fact that cython and C++ standalone used float instead of double for the padding_before and padding_after variables. I fixed this in master but I guess this only makes the problem less likely to occur, maybe there's a better principle way to do the comparisons?

Member

mstimberg commented Mar 19, 2015

It turned out that the above issue is due to the fact that cython and C++ standalone used float instead of double for the padding_before and padding_after variables. I fixed this in master but I guess this only makes the problem less likely to occur, maybe there's a better principle way to do the comparisons?

@thesamovar

This comment has been minimized.

Show comment
Hide comment
@thesamovar

thesamovar Mar 21, 2015

Member

This SpikeGeneratorGroup turns out to be so much more complicated than it should be.

Member

thesamovar commented Mar 21, 2015

This SpikeGeneratorGroup turns out to be so much more complicated than it should be.

@mstimberg

This comment has been minimized.

Show comment
Hide comment
@mstimberg

mstimberg Mar 23, 2015

Member

I implemented a change that fixes all the issues I encountered, I opened a pull request for it: #432

Member

mstimberg commented Mar 23, 2015

I implemented a change that fixes all the issues I encountered, I opened a pull request for it: #432

@mstimberg mstimberg closed this in 294d42f Mar 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment