I only just now realized that random number generation on C++ standalone is slow compared to Cython/numpy. E.g., with a trivial example like:
G = NeuronGroup(10000, 'x : 1')
G.run_regularly('x = rand()')
the run_regularly code object uses ~2.5s on Cython and numpy, and ~7s on C++ standalone. My hunch was that this is because in Cython/numpy, we create a buffer of random numbers at once using numpy's rand function, whereas in C++ standalone, we call rk_double for each number we need. But it might be more fundamental: numpy switched to a different random number generator a couple of years ago, while in C++ standalone, we are still using the Mersenne-Twister "legacy code"…
Not sure how feasible/easy it is to switch to the same generator in C++ standalone.
This could also be the time to tackle #19, but I don't see any obvious/simple solution.
I only just now realized that random number generation on C++ standalone is slow compared to Cython/numpy. E.g., with a trivial example like:
the
run_regularly
code object uses ~2.5s on Cython and numpy, and ~7s on C++ standalone. My hunch was that this is because in Cython/numpy, we create a buffer of random numbers at once usingnumpy
'srand
function, whereas in C++ standalone, we callrk_double
for each number we need. But it might be more fundamental: numpy switched to a different random number generator a couple of years ago, while in C++ standalone, we are still using the Mersenne-Twister "legacy code"…Not sure how feasible/easy it is to switch to the same generator in C++ standalone.
This could also be the time to tackle #19, but I don't see any obvious/simple solution.