Description: SLEEF implements vectorized C99 math functions.

# SLEEF Vectorized Math Library

- Download the latest version
- Latest documentation on the web
- GitHub repository
- Discussions
- Wiki pages

## Table of contents

- Introduction
  - Overview
  - Supported environments
  - Credit
  - License
  - History
  - Related projects
  - Publication
- Compiling and installing the library
- Math library reference
- Quad-precision math library reference
- DFT library reference
- Other tools included in the package
- Benchmark results
- Additional notes

## Overview

SLEEF stands for SIMD Library for Evaluating Elementary Functions. It implements manually vectorized versions of all C99 real floating point math functions. It can utilize SIMD instructions that are available on modern processors. SLEEF is designed to effciently perform computation with SIMD instructions 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 closed-source commercial libraries, which are often assembly-optimized, SLEEF is designed to work with various architectures, operating systems and compilers. It is distributed under the Boost Software License, which is a permissive open source license. SLEEF can be easily ported to other architectures by writing a helper file, which is a thin abstraction layer of SIMD intrinsics. SLEEF also provides dispatchers that automatically choose the best subroutines for the computer on which the library is executed. In order to further optimize the application code that calls SLEEF functions, link time optimization(LTO) can be used to reduce the overhead of functions calls, and the build system of SLEEF supports usage of LTO. The library also has a functionality to generate header files in which the library functions are all defined as inline functions. SLEEF can be used for GPGPU and WebAssembly with these header files. In addition to the vectorized functions, SLEEF provides scalar functions. Calls to these scalar SLEEF functions can be auto-vectorized by GCC and Clang.

The library contains implementations of 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 even faster versions with a few ULPs of error bounds. For non-finite inputs and outputs, the functions return correct results as specified in the C99 standard. All the functions in the library are thoroughly tested and confirmed that the evaluation error is within the designed limit by comparing the returned values against high-precision evaluation using the GNU MPFR Library.

SLEEF also includes a quad-precision math library. This library includes fully vectorized IEEE 754 quadruple-precision (QP) functions that correspond to the standard C math functions. I/O functions for converting between QP numbers and strings are also available.

SLEEF includes a library of discrete Fourier transform(DFT). It is fully vectorized, heavily unrolled, and parallelized in such a way that modern SIMD instructions and multiple cores can be utilized, and it can utilize long vectors up to 2048 bits. It has an API similar to that of FFTW for easy migration. The helper files for abstracting SIMD intrinsics are shared with SLEEF libm, and thus it is easy to port the DFT library to other architectures. Benchmark results of the DFT library are now available.

## Supported environments

This library supports the following architectures :

- x86 - SSE2, AVX2, AVX512F
- RISC-V - RVV1, RVV2
- PowerPC64 - VSX (POWER8), VSX-3 (POWER9)
- System/390 - VXE (z14), VXE2 (z15)
- CUDA
- AArch64 - Advanced SIMD, SVE
- WebAssembly - SSE2

The supported combinations of the architecture, operating system and compiler are shown in Table 1.1.

Table 1.1: Environment support matrix
|  | GCC | Clang | MSVC
x86_64, Linux |  | Supported | Experimental | N/A
x86_64, Windows |  | Experimental(Cygwin) | Experimental | Supported
RISC-V (64-bit), Linux |  | Supported | Experimental | N/A
PowerPC (64 bit), Linux |  | Supported | Experimental | N/A
System/390 (64 bit), Linux |  | Supported | Experimental | N/A
AArch64, Linux |  | Supported | Experimental | N/A
AArch64, macOS |  | Experimental | Supported | N/A

Supported compilers are only the latest versions of compilers officially used on the OSes. All functions in the library are thread safe unless otherwise noted.

## Credit

- The main developer is Naoki Shibata ( shibatch@users.sourceforge.net ).
- And many more contributors you can find listed on GitHub.

## 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

See Changelog for a full history of changes to SLEEF.

## Publication

- Naoki Shibata and Francesco Petrogalli : SLEEF: A Portable Vectorized Library of C Standard Mathematical Functions, in IEEE Transactions on Parallel and Distributed Systems, DOI:10.1109/TPDS.2019.2960333 (Dec. 2019). [PDF]