diff options
author | Julian Taylor <jtaylor.debian@googlemail.com> | 2014-04-11 01:20:30 +0200 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2014-05-02 13:24:23 +0200 |
commit | 94172e1bbaf48e121f90d0252e33dc9f433b1534 (patch) | |
tree | e242e63d6ad6ed5e9834446984ab1e4a50bc2a77 /numpy/random/mtrand/numpy.pxd | |
parent | 4a2783f28b3270e4d5c79e8d0a8b04b97744ac5d (diff) | |
download | numpy-94172e1bbaf48e121f90d0252e33dc9f433b1534.tar.gz |
ENH: replace GIL of random module with a per state lock
The random module currently relies on the GIL for the state
synchronization which hampers threading performance.
Instead add a lock to the RandomState object and take it for all
operations calling into randomkit while releasing the GIL.
This allows parallizing random number generation using multiple states
or asynchronous generation in a worker thread.
Note that with a large number of threads the standard mersenne twister
used may exhibit overlap if the number of parallel streams is large
compared to the size of the state space, though due to the limited
scalability of Python in regards to threads this is likely not a big
issue.
Diffstat (limited to 'numpy/random/mtrand/numpy.pxd')
-rw-r--r-- | numpy/random/mtrand/numpy.pxd | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/numpy/random/mtrand/numpy.pxd b/numpy/random/mtrand/numpy.pxd index 572b51fdd..6812cc164 100644 --- a/numpy/random/mtrand/numpy.pxd +++ b/numpy/random/mtrand/numpy.pxd @@ -114,12 +114,12 @@ cdef extern from "numpy/arrayobject.h": object PyArray_MultiIterNew(int n, ...) - char *PyArray_MultiIter_DATA(broadcast multi, int i) - void PyArray_MultiIter_NEXTi(broadcast multi, int i) - void PyArray_MultiIter_NEXT(broadcast multi) + char *PyArray_MultiIter_DATA(broadcast multi, int i) nogil + void PyArray_MultiIter_NEXTi(broadcast multi, int i) nogil + void PyArray_MultiIter_NEXT(broadcast multi) nogil object PyArray_IterNew(object arr) - void PyArray_ITER_NEXT(flatiter it) + void PyArray_ITER_NEXT(flatiter it) nogil void import_array() |