-
Notifications
You must be signed in to change notification settings - Fork 12
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
StateMonitor idexing with slice syntax doesn't work #50
Comments
The StateMonitor is also not working working for many neurons. Currently the |
And the global memory writes are not coalesced. Currently we have a 2D data structure of dimensions monitor[tid][current_iteration] = ... For coalesced writes we could just "transpose" the monitor data structure so we can use monitor[current_iteration][tid] = ... We might have to resort the monitor in the end though since it might then not fit with the format that Brian expects to read back. |
There also seems to be a problem with the ordering of returned values. Might be related to #46 . In this test, the first assert sums over the not ordered dimension and passes. The second one failes (because of wrong ordering). The monitors return arrays are 2D arrays with shape import os
from numpy.testing.utils import assert_allclose
from brian2 import *
from brian2.devices.device import reinit_devices, set_device
import brian2cuda
directory = os.path.splitext(os.path.basename(__file__))[0]
results = {}
n_cells = 5
n_recorded = 10
delay = np.arange(n_cells) * defaultclock.dt
for devicename in ['cpp_standalone', 'cuda_standalone']:
set_device(devicename, directory=directory + '_' + devicename)
Synapses.__instances__().clear()
reinit_devices()
P = NeuronGroup(n_cells, model='', threshold='True')
S = Synapses(P, P,
model='''w : 1''',
on_pre='''w += 1''')
S.connect(j='i')
S.pre.delay = delay
state_mon = StateMonitor(S, 'w', record=range(n_recorded))
run(defaultclock.dt * (n_cells + 1), report='text')
results[devicename] = state_mon.w.astype(int)
assert_allclose(results['cpp_standalone'].sum(axis=0), results['cuda_standalone'].sum(axis=0))
assert_allclose(results['cpp_standalone'], results['cuda_standalone']) EDIT 13.04.21: This test seems to be passing without issues now (I also added it to our test suite). |
Could this be a similar issue as here: brian-team/brian2#1119? |
Fixes #50. Issue was the same as in PR brian-team/brian2#1119. We need to update the monitor's `N` variable on CUDA side and we need to update the device variable since it is copied to the host variable in `write_arrays()`. And we need to use `WRITES_TO_READ_ONLY_VARIABLES`, otherwise `N` will be cached in brian2 and not loaded after simulation.
This is being fixed in PR #202, follow-up issue for fixing the single block usage and optimizing statemonitor template is #201. There were two problems that needed to be fixed here:
The brian-team/brian2#1119 had a very similar problem, which I also fixed in PR #202. |
Fixes #50. Issue was the same as in PR brian-team/brian2#1119. We need to update the monitor's `N` variable on CUDA side and we need to update the device variable since it is copied to the host variable in `write_arrays()`. And we need to use `WRITES_TO_READ_ONLY_VARIABLES`, otherwise `N` will be cached in brian2 and not loaded after simulation.
Fixes #50. Issue was the same as in PR brian-team/brian2#1119. We need to update the monitor's `N` variable on CUDA side and we need to update the device variable since it is copied to the host variable in `write_arrays()`. And we need to use `WRITES_TO_READ_ONLY_VARIABLES`, otherwise `N` will be cached in brian2 and not loaded after simulation.
Fixes #50. Issue was the same as in PR brian-team/brian2#1119. We need to update the monitor's `N` variable on CUDA side and we need to update the device variable since it is copied to the host variable in `write_arrays()`. And we need to use `WRITES_TO_READ_ONLY_VARIABLES`, otherwise `N` will be cached in brian2 and not loaded after simulation.
For some reason using
[1:]
style indexing for aStateMonitor
returns an empty array while e.g.[1]
indexing returns the correct value.This seems to apply for any kind of
[3:]
style indexing of the StateMonitor.This breaks e.g. brian2.tests.test_monitor.test_state_monitor_indexing.
The text was updated successfully, but these errors were encountered: