You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Openlibm's pow, hypot, exp and log are considerably slower than Glibc's #234
System Libm is considerably faster than Openlibm on pow (4x) hypot, (1.5x) exp (1.5x) and log (1.7x), while Openlibm outperforms system Libm in almost all trigonometric functions (except cos).
Running on Kubuntu 21.04 (kernel 5.11.0-17-generic) in an Asus Rog Strix G531GT, CPU Intel Core i7-9750H CPU 2.60GHz.
Edit:
GNU libc version: 2.33
GNU libc release: release
maybe you should mention the version of glibc you are comparing to, since starting from 2.28, the slow paths have been removed from some functions, improving their speed at the expense of less accurate results. In the next release (2.34) the slow path will be removed for tan, asin, acos, atan, and atan2 (all for double precision).
maybe you should mention the version of glibc you are comparing to, since starting from 2.28, the slow paths have been removed from some functions, improving their speed at the expense of less accurate results. In the next release (2.34) the slow path will be removed for tan, asin, acos, atan, and atan2 (all for double precision).
What does MPS mean? I usually see speed comparisons reported as microsecond per call or cycles per call. Also, what are the compiler options used in building system libm and openlibm with both compilers?
The benchmark code is test/libm-bench.cpp. MPS means millions (calls) per second (see #36).
What does MPS mean? I usually see speed comparisons reported as microsecond per call or cycles per call. Also, what are the compiler options used in building system libm and openlibm with both compilers?
The benchmark code is test/libm-bench.cpp. MPS means millions (calls) per second (see #36).
Thanks for pointing to the benchmark. What I'm curious about is the compilation options for the libraries and when building the benchmark. For example, the system libm may have been compiled for the lowest common denominator for an X86_64 system while openlibm is compiled with -march=native. In addition, it is important at least with GCC to use the -fno-builtins option when linking against libm to ensure the math library functions are actually called.
Openlibm was built with flags -fno-gnu89-inline -fno-builtin -O3 -fPIC -m64 -std=c99 -Wall and the output of make bench was:
jessica@jessica-Kubuntu-ROG-Strix-G531GT:~/Dev/openlibm-0.7.5$ cd test/
jessica@jessica-Kubuntu-ROG-Strix-G531GT:~/Dev/openlibm-0.7.5/test$ make bench
cc -fno-gnu89-inline -fno-builtin -O3 -fPIC -m64 -std=c99 -Wall -I/home/jessica/Dev/openlibm-0.7.5 -I/home/jessica/Dev/openlibm-0.7.5/include -I/home/jessica/Dev/openlibm-0.7.5/amd64 -I/home/jessica/Dev/openlibm-0.7.5/src -DASSEMBLER -D__BSD_VISIBLE -Wno-implicit-function-declaration -I/home/jessica/Dev/openlibm-0.7.5/ld80 -m64 libm-bench.cpp -lm -o bench-syslibm
cc1plus: warning: command-line option ‘-Wno-implicit-function-declaration’ is valid for C/ObjC but not for C++
cc1plus: warning: command-line option ‘-std=c99’ is valid for C/ObjC but not for C++
cc1plus: warning: command-line option ‘-fno-gnu89-inline’ is valid for C/ObjC but not for C++
cc -fno-gnu89-inline -fno-builtin -O3 -fPIC -m64 -std=c99 -Wall -I/home/jessica/Dev/openlibm-0.7.5 -I/home/jessica/Dev/openlibm-0.7.5/include -I/home/jessica/Dev/openlibm-0.7.5/amd64 -I/home/jessica/Dev/openlibm-0.7.5/src -DASSEMBLER -D__BSD_VISIBLE -Wno-implicit-function-declaration -I/home/jessica/Dev/openlibm-0.7.5/ld80 -m64 libm-bench.cpp -L.. -lopenlibm -Wl,-rpath=/home/jessica/Dev/openlibm-0.7.5 -o bench-openlibm
cc1plus: warning: command-line option ‘-Wno-implicit-function-declaration’ is valid for C/ObjC but not for C++
cc1plus: warning: command-line option ‘-std=c99’ is valid for C/ObjC but not for C++
cc1plus: warning: command-line option ‘-fno-gnu89-inline’ is valid for C/ObjC but not for C++
Do standard functions use other standard functions internally?
no, as far as I know.
Also, should not it be possible to write a wrapper around the double precision worst cases? Will that descrease max error?
I believe the answer is no, since worst cases are in regions where the algorithm used has a bad accuracy. If you add a special case for one input, another one near that input will also give a large error.
BTW, is it possible to fix fdlibm with regards to pow(10, -5) printing 0.000009999999999999999 instead of just 0.0001?
1/10^5 is not exactly representable in binary. I prefer 0.000009999999999999999 which recalls you this fact.
But OpenJDK has now a new algorithm for printing floating-point numbers.
I'm not sure, since for the binary64 pow function, the largest error I get with AMD Libm 4.0 is 0.762 ulp (for x=0x1.00a000205d461p+1 and y=-0x1.fd35c41fc20bbp+9), whereas with Visual Studio 2022 I get 91.3 ulps (with x=0x1.fffff9c61ce40p-1 and y=0x1.c4e304ed4c734p+31).
Activity
zimmermann6 commentedon Jun 2, 2021
maybe you should mention the version of glibc you are comparing to, since starting from 2.28, the slow paths have been removed from some functions, improving their speed at the expense of less accurate results. In the next release (2.34) the slow path will be removed for tan, asin, acos, atan, and atan2 (all for double precision).
jessymilare commentedon Jun 2, 2021
Got this:
GNU libc version: 2.33
GNU libc release: release
jessymilare commentedon Jun 2, 2021
The benchmark code is
test/libm-bench.cpp. MPS means millions (calls) per second (see #36).jessymilare commentedon Jun 3, 2021
Openlibm was built with flags
-fno-gnu89-inline -fno-builtin -O3 -fPIC -m64 -std=c99 -Walland the output ofmake benchwas:t-bltg commentedon Sep 24, 2021
Also reproduced with
glibc 2.34,Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz:zimmermann6 commentedon Mar 13, 2023
see https://members.loria.fr/PZimmermann/papers/accuracy.pdf (which uses Intel's compiler from 2023)
zimmermann6 commentedon Mar 13, 2023
no, as far as I know.
I believe the answer is no, since worst cases are in regions where the algorithm used has a bad accuracy. If you add a special case for one input, another one near that input will also give a large error.
Yes all CRlibm functions have maximal error 0.5 ulp, as do the functions from CORE-MATH (https://core-math.gitlabpages.inria.fr/)
zimmermann6 commentedon Mar 15, 2023
I don't have the knowledge to do that.
the paper is already quite long, feel free to do the same for complex numbers !
we prefer to focus on accuracy
sorry I answered your question about worst cases
zimmermann6 commentedon Mar 15, 2023
yes, the next update of https://members.loria.fr/PZimmermann/papers/accuracy.pdf will include the Microsoft math library
1/10^5 is not exactly representable in binary. I prefer 0.000009999999999999999 which recalls you this fact.
But OpenJDK has now a new algorithm for printing floating-point numbers.
zimmermann6 commentedon Mar 16, 2023
I'm not sure, since for the binary64 pow function, the largest error I get with AMD Libm 4.0 is 0.762 ulp (for x=0x1.00a000205d461p+1 and y=-0x1.fd35c41fc20bbp+9), whereas with Visual Studio 2022 I get 91.3 ulps (with x=0x1.fffff9c61ce40p-1 and y=0x1.c4e304ed4c734p+31).