On 06/03/2012 20:57, Sturla Molden wrote:
On 05.03.2012 14:26, "V. Armando Solé" wrote:

In 2009 there was a thread in this mailing list concerning the access to
BLAS from C extension modules.

If I have properly understood the thread:

http://mail.scipy.org/pipermail/numpy-discussion/2009-November/046567.html

the answer by then was that those functions were not exposed (only f2py
functions).

I just wanted to know if the situation has changed since 2009 because it
is not uncommon that to optimize some operations one has to sooner or
later access BLAS functions that are already wrapped in numpy (either
from ATLAS, from the Intel MKL, ...)
Why do you want to do this? It does not make your life easier to use
NumPy or SciPy's Python wrappers from C. Just use BLAS directly from C
instead.

Wow! It certainly makes my life much, much easier. I can compile and distribute my python extension *even without having ATLAS, BLAS or MKL installed*. Please note I am not using the python wrappers from C. That would make no sense. I am using the underlying libraries supplied with python from C.

I had already used the information Robert Kern provided on the 2009 thread and obtained the PyCObject as:

from scipy.linalg.blas import fblas
dgemm = fblas.dgemm._cpointer
sgemm = fblas.sgemm._cpointer

but I did not find a way to obtain those pointers from numpy. That was the goal of my post. My extension needs SciPy installed just to fetch the pointer. It would be very nice to have a way to get similar information from numpy.

I have made a test on a Debian machine with BLAS installed but no ATLAS-> Extension slow but working. Then the system maintainer has installed ATLAS -> The extension flies. So, one can distribute a python extension that works on its own but that can take profit of any advanced library the end user might have installed.

Your point of view is valid if one is not going to distribute the extension module but I *have to* distribute the module for Linux and for windows. To have a proper fortran compiler for windows 64 bit compatible with python is already an issue. If I have to distribute my own ATLAS or MKL then it gets even worse. All those issues are solved just by using the pointer to the function.

Concerning licenses, if the end user has the right to use MKL, then he has the right to use it via my extension. It is not me who is using MKL

Armando
PS. The only issue I see with the whole approach is safety because the extension might be used to call some nasty function.


_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to