SLEEF Vectorized Math Library
Table of contents
Overview
SLEEF stands for SIMD Library for Evaluating Elementary
Functions. It implements vectorized versions of all C99 real
floating point math functions. It can utilize SIMD instructions of
modern processors. SLEEF is designed to fully utilize SIMD
computation by reducing the use of conditional branches and
scatter/gather memory access. Our benchmarks show that the performance of
SLEEF is comparable to that of the best commercial library. Unlike
vendor-tuned libraries, SLEEF is portable : it can be easily ported
to other architectures by writing a helper file, which is a thin
abstraction layer of SIMD intrinsics. SLEEF is also designed to work
with various operating systems and compilers.
The library contains subroutines for all C99 real FP math functions
in double precision and single precision. Different accuracy of the
results can be chosen for a subset of the elementary functions; for
this subset there are versions with up to 1 ulp error (which is the
maximum error, not the average) and versions with a few ulp
error. Obviously, less accurate versions are faster. For non-finite
inputs and outputs, the library should return the same results as
libm as specified in the C99 standard. The library is rigorously
tested if the evaluation error is within the designed limit. The
library is tested against high-precision evaluation
using the libmpfr
library. Especially, we carefully checked the error of the
trigonometric functions when the arguments are close to an integral
multiple of π/2.
SLEEF also includes subroutines for discrete Fourier
transform(DFT). These subroutines are fully vectorized, heavily
unrolled, and parallelized so that modern SIMD instructions and
multiple cores can be utilized for efficient computation. It has
an API similar to that of FFTW for easy migration, and distributed under
BSL, which is a
permissive open source license. The subroutines can utilize long
vectors up to 2048 bits, and even longer vectors can be utilized by
a small modification. The helper files for abstracting SIMD
intrinsics are shared with SLEEF libm, and thus it is easy to port
DFT subroutines to other architectures. Preliminary
results of benchmark are now available.
Supported environments
This library currently supports several SIMD architectures :
In addition to the SIMD implementation, Pure C (scalar) version is
provided. For x86 architecture, the library provides dispatchers
that automatically choose the best subroutines for the computer the
library is run. The supported combinations of the architecture,
operating system and compiler are shown in Table 1.1.
| Table 1.1: Environment support matrix |
|
|
|
|
|
|
|
|
GCC |
Clang |
Intel Compiler |
MSVC |
|
|
|
|
|
|
| x86 (64bit), Linux |
|
Supported |
Supported |
Supported(*1) |
N/A |
| x86 (32bit), Linux |
|
Supported(*2) |
Supported(*2) |
|
N/A |
| AArch64, Linux |
|
Supported |
Supported |
N/A |
N/A |
| AArch32, Linux |
|
Supported(*3) |
Supported(*3) |
N/A |
N/A |
| PowerPC, Linux |
|
|
Supported(*4) |
N/A |
N/A |
| x86 (64bit), FreeBSD |
|
|
Supported |
|
N/A |
| x86 (64bit), OS X |
|
Supported |
Supported |
|
N/A |
| x86 (64bit), Windows |
|
Supported(Cygwin)(*5) |
Supported(Cygwin)(*5) |
|
Supported |
|
The supported compiler versions are as follows.
- GCC : version 5 and later
- Clang : version 3.9 and later
- Intel Compiler : ICC version 17
- MSVC : Visual Studio 2017
*1 FMA4 is not supported by Intel Compiler.
*2 SSE2 is required to run the scalar functions on 32-bit x86
architecture. x87 is not supported.
*3 NEON has only single precision support. The computation results
are not in full accuracy since NEON is not IEEE 754-compliant.
*4 Clang-5.0 and later are supported.
*5 AVX functions are not supported for Cygwin, since AVX is not
supported by Cygwin ABI.
All functions in the library are thread safe unless otherwise noted.
Credit
Partner institutes and corporations
| |
 |
The Mobile
Computing Lab at Division of Information Science of Nara Institute
of Science and Technology participates through Naoki Shibata.
|
| |
| |
| |
 |
As the leading IP company in semiconductors
design, ARM
participates through Francesco Petrogalli.
|
| |
| |
| |
 |
As the leading
company in developing a video game engine, Unity Technologies participates
through Alexandre Mutel.
|
| |
License
SLEEF is distributed under Boost Software License
Version 1.0.
Boost Software License is OSI-certified.
See this page for more
information about Boost Software License.
History
3.4 (Released on Apr 28, 2019)
- Faster and low precision functions are
added(PR #229)
- Functions that return consistent results across platforms are
added (PR #216,
#224)
- Many functions are now faster (PR #239)
- Quad precision math library(libsleefquad) is added
(PR #235,
#237,
#240)
- Testers are now faster (PR #223)
3.3.1 (Released on Aug 21, 2018)
- i386 build problem is fixed
- FreeBSD support is added
- Trigonometric functions now evaluate correctly with full FP
domain. (PR #210)
3.3 (Released on July 6, 2018)
- AArch64 SVE target support is added (PR #180, #182)
- DFT is now faster (PR #186)
- 3.5-ULP hyperbolic functions are added (PR #192)
- PowerPC VSX target support is added (PR #195)
- Modified Payne-Hanek argument reduction is added to the
trigonometric functions in libsleef (PR #197)
3.2 (Released on Feb 26, 2018)
- The whole build system of the project migrated from makefiles to
cmake. The makefile build system is now removed.
- GNUABI version of the library with compatibility tests is
added.
- Benchmarks that compare `libsleef` vs `SVML` on X86 Linux are
available in the project tree under src/libm-benchmarks
directory.
- Extensive upstream testing via Travis CI and Appveyor
- log2 is added.
- The library can be compiled to an LLVM bitcode object
- Added masked interface to the library to support AVX512F masked
vectorization.
- Use native instructions if available for `sqrt`.
- Removed `libm` dependency.
- fmod(FP remainder), asin, acos, log, pow, log10, exp2, exp10 and
log1p functions are now faster.
- Fixed a bug that was making the error of sinpi, cospi, sincospi,
and tgamma functions larger than the specifications on very rare
occasions.
- Fixed a bug that was preventing the dispatcher from choosing the
FMA4 implementation.
3.1 (Released on July 19, 2017)
- Added AArch64 support
- Implemented the remaining C99 math functions : lgamma, tgamma,
erf, erfc, fabs, copysign, fmax, fmin, fdim, trunc, floor, ceil,
round, rint, modf, ldexp, nextafter, frexp, hypot, and fmod.
- Added dispatcher for x86 functions
- Improved reduction of trigonometric functions
- Added support for 32-bit x86, Cygwin, etc.
- Improved tester
- Etc.
3.0 (Released on Feb. 7, 2017)
- New API is defined
- Functions for DFT are added
- sincospi functions are added
- gencoef now supports single, extended and quad precision in addition to double precision
- Linux, Windows and Mac OS X are supported
- GCC, Clang, Intel Compiler, Microsoft Visual C++ are supported
- The library can be compiled as DLLs
- Files needed for creating a debian package are now included
2.120 (Released on Jan. 30, 2017)
- Relicensed to Boost Software License Version 1.0
2.110 (Released on Dec. 11, 2016)
- The valid range of argument is extended for trig functions
- Specification of each functions regarding to the domain and accuracy is added
- A coefficient generation tool is added
- New testing tools are introduced
- Following functions returned incorrect values when the argument is very large or small : exp, pow, asinh, acosh
- SIMD xsin and xcos returned values more than 1 when FMA is enabled
- Pure C cbrt returned incorrect values when the argument is negative
- tan_u1 returned values with more than 1 ulp of error on rare occasions
- Removed support for Java language(because no one seems using this)
Publication
- Francesco Petrogalli and Paul Walker : LLVM and the automatic vectorization of loops invoking math routines: -fsimdmath, 2018 IEEE/ACM 5th Workshop on the LLVM Compiler Infrastructure in HPC (LLVM-HPC), pp. 30-38., DOI:10.1109/LLVM-HPC.2018.8639354 (Nov. 2018). [PDF]