Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Parallelization issues
from brian2 import *
# The following example is very contrived, but writing to a variable that is linked with repeating indices
# might come up in some contexts. It's clearly a cornercase, but one that we should handle.
set_device('cpp_standalone')
prefs.devices.cpp_standalone.openmp_threads = 8 # number of threads
group1 = NeuronGroup(2, 'x : integer')
group2 = NeuronGroup(1000, 'y : integer (linked)')
group2.y = linked_var(group1, 'x', index=np.arange(2).repeat(500))
obj = group2.run_regularly('y += 1')
run(defaultclock.dt)
print(group1.x[:])
# This should print "[500 500]", but will typically print lower numbers if the number of threads set
# above is > 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment