-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Free memory for delay (in sec) on device in synapse init
That array in device memory is not used. This allows simulation of higher network sizes for our benchmarks, but introduces a bug when trying to change delays between multiple `run()` statements, see #83. The commit includes tests, which should pass as soon as #83 and #86 are fixed.
- Loading branch information
1 parent
688c14f
commit 335c42a
Showing
4 changed files
with
85 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from nose import with_setup | ||
from nose.plugins.attrib import attr | ||
from numpy.testing.utils import assert_allclose, assert_equal, assert_raises | ||
|
||
from brian2 import * | ||
from brian2.devices.device import reinit_devices | ||
|
||
import brian2cuda | ||
|
||
|
||
@attr('standalone-compatible', 'multiple-runs') | ||
@with_setup(teardown=reinit_devices) | ||
def test_changing_delay_scalar(): | ||
|
||
set_device('cuda_standalone', directory=None, build_on_run=False) | ||
inG = NeuronGroup(1, 'v : 1', threshold='True') | ||
G = NeuronGroup(1, 'v : 1') | ||
G.v[:] = 0 | ||
S = Synapses(inG, G, on_pre='v += 1') | ||
S.connect() | ||
S.delay[:] = 1*defaultclock.dt | ||
mon = StateMonitor(G, 'v', record=True) | ||
|
||
run(1*defaultclock.dt) | ||
S.delay[:] = 2*defaultclock.dt | ||
run(5*defaultclock.dt) | ||
|
||
device.build(direct_call=False, **device.build_options) | ||
|
||
# mon.v[i, t] | ||
assert_allclose(mon.v[:], [[0, 0, 1, 1, 2, 3]]) | ||
|
||
|
||
@attr('standalone-compatible', 'multiple-runs') | ||
@with_setup(teardown=reinit_devices) | ||
def test_changing_delay_heterogeneous(): | ||
|
||
set_device('cuda_standalone', directory=None, build_on_run=False) | ||
inG = NeuronGroup(1, 'v : 1', threshold='True') | ||
G = NeuronGroup(2, 'v : 1') | ||
G.v[:] = 0 | ||
S = Synapses(inG, G, on_pre='v += 1') | ||
S.connect() | ||
S.delay[:] = '1*j*dt' | ||
mon = StateMonitor(G, 'v', record=True) | ||
|
||
run(1*defaultclock.dt) | ||
S.delay[:] = '2*j*dt' | ||
run(5*defaultclock.dt) | ||
|
||
device.build(direct_call=False, **device.build_options) | ||
|
||
# mon.v[i, t] | ||
assert_allclose(mon.v[0, :], [0, 1, 2, 3, 4, 5]) | ||
assert_allclose(mon.v[1, :], [0, 0, 1, 1, 2, 3]) | ||
|
||
if __name__ == '__main__': | ||
#test_changing_delay_scalar() | ||
test_changing_delay_heterogeneous() |