[Numpy-discussion] Fast threading solution thoughts

Sturla Molden sturla@molden...
Thu Feb 12 06:44:25 CST 2009

On 2/12/2009 11:30 AM, Dag Sverre Seljebotn wrote:

> It would be interesting to see how a spec would look for integrating 
> OpenMP natively into Cython for these kinds of purposes. Cython is still 
> flexible as a language after all. Avoiding language bloat is also 
> important, but it is difficult to know what kind of balance can be 
> struck before some kind of spec is worked out. Has anyone managed to use 
> OpenMP with Cython code in a nice way already?

Here is an example of SciPy's ckdtree.pyx modified to use OpenMP. It is 
basically twice as fast on my dual-core laptop. But as Cython mangles 
the names in the C code, I had to put the OpenMP part in a separate C file.

OpenMP does not need to be a aprt of the Cython language. It can be 
special comments in the code as in Fortran. After all, "#pragma omp 
parallel" is a comment in Cython.

Sturla Molden

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: parallel_queries.c
Url: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20090212/56b9f764/attachment-0001.c 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ckdtree.pyx
Type: /
Size: 22235 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20090212/56b9f764/attachment-0001.bin 

More information about the Numpy-discussion mailing list