On Sun, Feb 7, 2016 at 4:39 PM, Nils Becker <nilsc.bec...@gmail.com> wrote:
> Hi all,
>
> I wanted to know if there is any sane way to build numpy while linking to a
> different implementation of libm?
> A drop-in replacement for libm (e.g. openlibm) should in principle work, I
> guess, but I did not manage to actually make it work. As far as I understand
> the build code, setting MATHLIB=openlibm should suffice, but it did not. The
> build works fine, but in the end when running numpy apparently the functions
> of the system libm.so are used. I could not verify this directly (as I do
> not know how) but noticed that there is no performance difference between
> the builds - while there is one with pure C programs linked against libm and
> openlibm.
> Using amdlibm would require some work as the functions are prefixed with
> "_amd", I guess? Using intels libimf should work when using intels compiler,
> but I did not try this. With gcc I did not get it to work.
>
> A quite general question: At the moment the performance and the accuracy of
> the base mathematical functions depends on the platform and
> libm-Implementation of the system. Although there are functions defined in
> npy_math, they are only used as fall-backs, if they are not provided by a
> library. (correct me if I am wrong here)
> Is there some plan to change this in the future and provide defined
> behaviour (specified accuracy and/or speed) across platforms? As I
> understood it Julia started openlibm for this reason (which is based on
> fdlibm/msun, same as npy_math).

The npy_math functions are used if otherwise unavailable OR if someone
has at some point noticed that say glibc 2.4-2.10 has a bad quality
tan (or whatever) and added a special case hack that checks for those
particular library versions and uses our built-in version instead.
It's not the most convenient setup to maintain, so there's been some
discussion of trying openlibm instead [1], but AFAIK you're the first
person to find the time to actually sit down and try doing it :-).

You should be able to tell what math library you're linked to by
running ldd (on linux) or otool (on OS X) against the .so / .dylib
files inside your built copy of numpy -- e.g.

  ldd numpy/core/umath.cpython-34m.so

(exact filename and command will vary depending on python version and platform).

-n

[1] https://github.com/numpy/numpy/search?q=openlibm&type=Issues&utf8=%E2%9C%93

-- 
Nathaniel J. Smith -- https://vorpus.org
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to