[SciPy-user] scipy.sparse.linalg.cg not thread safe?

Sturla Molden sturla@molden...
Wed Jan 28 05:30:48 CST 2009

On 1/28/2009 5:11 AM, Nathan Bell wrote:

> I don't have an opinion on the locking issue, but the dominant cost in
> most iterative methods for linear systems is the cost of the sparse
> matrix-vector products (for y = A*x for sparse A).  A smaller amount
> of time is spent in level 1 BLAS operations like axpy() and norm().

That is fine then, as long as the heavy lifting is not done in Python.

> In conjunction, we
> ought to add the necessary compiler flags to setuptools so that
> OpenMP-enabled sources are handled correctly.

With GCC 4.3 and 4.4 one must use the compile flag -fopenmp and link 
with -lgomp and -lpthread.

On Windows this makes the extension dependent on pthreadGC2.dll. It is 
only 59 kB so it makes no sence to have this in a DLL. But I cannot find 
a static version of the library.

With f2py and gfortran 4.4 on Windows (mingw binary) I do this:

f2py.py --fcompiler=gnu95 --f90flags=-fopenmp --build-dir ./build \
    -c foobar.pyf foobar.f95 -lgomp -lpthread -lmsvcr71

I am still not sure what this would look like with setuptools though.

Sturla Molden

More information about the SciPy-user mailing list