[SciPy-user] Python on Intel Xeon Dual Core Machine

Nathan Bell wnbell at gmail.com
Fri Feb 8 02:41:01 EST 2008


On Feb 8, 2008 12:39 AM, David Cournapeau <david at ar.media.kyoto-u.ac.jp> wrote:

> FWIW, I could dynamically load a trivial openmp shared library through
> the dlopen machinery, which is what ctypes uses (to be exact, all python
> extensions which are not static use it at some point). I tried with
> centos 5.0 gcc, and then with one directly built from sources (4.2.1),
> both with success.
>
> Which compiler (version of gcc) are you using ? Do you have the code
> which fails ?

That's interesting.  I'd like to parallelize scipy.sparse.sparsetools,
so that was my experiment.

Here's what I did:

(1) Added a single OpenMP pragma to one of the sparsetools functions

void csr_diagonal(const I n_row,
<SNIP>
    const I N = std::min(n_row, n_col);

    #pragma omp parallel for
    for(I i = 0; i < N; i++){
        I row_start = Ap[i];

(2) Compile with g++-4.2

$ g++-4.2 --version
g++-4.2 (GCC) 4.2.1 (Ubuntu 4.2.1-5ubuntu4)

g++-4.2 -Wall -ansi -c -O2 -fPIC -fopenmp sparsetools_wrap.cxx -I
/usr/include/python2.5/ -I
/usr/lib/python2.5/site-packages/numpy/core/include/
g++-4.2 -shared sparsetools_wrap.o -o _sparsetools.so -lgomp

(3) Import into Python

$ python
Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _sparsetools
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libgomp.so.1: shared object cannot be dlopen()ed


The .so seems OK

$ ldd ./_sparsetools.so
        linux-gate.so.1 =>  (0xffffe000)
        libgomp.so.1 => /usr/lib/libgomp.so.1 (0xb7d06000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7c13000)
        libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7bed000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7be2000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7a98000)
        librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7a8f000)
        libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7a77000)
        /lib/ld-linux.so.2 (0x80000000)


Here's a thread about the issue:
http://gcc.gnu.org/ml/gcc-help/2007-04/msg00300.html

Here's the GCC bug report:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28482

-- 
Nathan Bell wnbell at gmail.com
http://graphics.cs.uiuc.edu/~wnbell/



More information about the SciPy-User mailing list