Created
March 19, 2020 14:00
-
-
Save mstimberg/fd8ccc63183c1f74e6d771be084f0a9b to your computer and use it in GitHub Desktop.
Parallelization issues
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
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