[SciPy-user] parallelizing cKDTRee

Sturla Molden sturla@molden...
Wed Jan 7 08:58:41 CST 2009

Speed is very important when searching kd-trees; otherwise we should not 
be using kd-trees but brute force. Thus exploiting multiple processors 
are important as well.

1. Multiprocessing:
Must add support for pickling and unpickling to cKDTree (i.e. __reduce__ 
and __setstate__ methods). This would be useful for saving to disk as well.

2. Multithreading (Python):
cKDTree.query calls cKDTree.__query with the GIL released (i.e. a 'with 
nogil:' block). I think this will be safe.

3. Multithreading (Cython):
We could simply call cKDTree.__query in parallel using OpenMP pragmas. 
It would be a simple and quite portable hack.

Which do you prefer? All three?

(Forgive me for cross-posting. I did not know which list is the more 

Sturla Molden

More information about the SciPy-user mailing list