[SciPy-User] swig and OpenMP

Dag Sverre Seljebotn dagss at student.matnat.uio.no
Fri Feb 12 10:18:55 EST 2010


Christian Meesters wrote:
> Hi,
>
> Sorry for being a bit off-topic, but I thought somebody here might have
> the relevant info for me.
>
> A while ago I already asked about integrating OpenMP-code in C/C++-code
> to be wrapped for python on the swig mailing list. Unfortunately nobody
> there knew an answer to my problem.
>
> Please find a minimal example in this pastebin:
> pi_test.h : http://paste.pocoo.org/show/174174/ 
> pi_test.c: http://paste.pocoo.org/show/174175/ 
> pi_test.i: http://paste.pocoo.org/show/174177/ 
> and my setup.py: http://paste.pocoo.org/show/175890/
>
> When I do
> $ python setup.py build
>
> I get no compiler warnings or error - except for the unused variables.
>
> But when importing the module I get this as a Traceback:
>
> ImportError: ./pi_test.so: undefined symbol: GOMP_parallel_end
>
> So, apparently OpenMP did not make it correctly into the wrapped code.
>
> Any pointers for me? What's going wrong here?
> Does anyone know a working example for OpenMP-code with SWIG (or
> Cython)?
>   

Hmm...you have extra_compile_args=-fopenmp, but not extra_link_args. 
Perhaps the module is only compiled, but not linked, with -fopenmp? I'd 
try to add extra_link_args as well. Inspect the build messages and make 
sure that the OpenMP libraries get linked in.

Dag Sverre



More information about the SciPy-User mailing list