New Cython API for BLAS and LAPACK merged in SciPy :)
Sturla Molden <sturla.molden <at> gmail.com>
2015-03-27 23:33:15 GMT
Thanks to Ian Henriksen, a new Cython API for BLAS and LAPACK is finally
merged in SciPy. It will be included in the next release. (For those who
cannot wait, get SciPy's master branch from Github.)
This makes it possible to use SciPy's BLAS and LAPACK from any 3rd party
Cython module without explicitely linking with the libraries. This means
that projects like scikit-learn and statsmodels do not need to maintain a
separate build dependency on BLAS and LAPACK.
All we need to do is:
cimport scipy.linalg.cython_blas as blas
cimport scipy.linalg.cython_lapack as lapack
Now we can call blas.zgemm(...), lapack.dgelss(...), etc. We do not link
BLAS or LAPACK. It is all taken care of in the generated Cython code.
All of BLAS and almost all of LAPACK is exposed. The new Cython API is much
more comprehensive than the current Python interfaces because it does not
depend on the f2py wrappers. Because f2py wrappers are not used, the Cython
API also does not depend on abusing their _cpointer attribute.
The Cython API can also (with some extra effort) be used from C (or C++ or
Fortran) if Cython is used to generate the Python to C interface. In this
case you need to fill in some global function pointers when the module is
imported and call these from C.
A Cython module using these interfaces will have a build dependency on
NumPy (i.e. similar to cimport numpy). The Cython module will also have
a runtime dependency on NumPy and SciPy.
For future development of SciPy, this means we can use hand-crafted
Cython code instead of relying on f2py wrappers for BLAS and LAPACK.
This makes it much easier to control the overhead, including when copies
and transpositions are made, and lwork queries will not need a separate
f2py wrapper. We also avoid linking in LAPACK and BLAS in multiple
locations and bloating the memory footprint if they are required by native
code. Currently, every extension module which needs BLAS or LAPACK
functions will statically link their own copy.
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.