SLEEF Vectorized Math Librarylogo

Table of contents

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. These functions return deterministic values across all architectures. That is, they are designed to return exactly the same value for the same argument even on different architectures.

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 :



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

License

SLEEF is distributed under Boost Software License Version 1.0. Contributions to this project from individual developers and small organizations are accepted under the same license. For contributions from corporate users, please refer to link: CONTRIBUTING.md.

Building a Sustainable Future for Our Open Source Projects

We believe that Free and Open Source Software (FOSS) is a wonderful ecosystem that allows anyone to use software freely. However, to maintain and enhance its value over the long term, continuous maintenance and improvement are essential.


Like many FOSS projects, we face the challenge that long-term sustainability is difficult to achieve through the goodwill and efforts of developers alone. While the outputs of open-source projects are incorporated into the products of many companies and their value is rightfully recognized, the developers who create these outputs are not always treated as equal partners in the business world.


A license guarantees the “freedom to use,” but the spirit of the FOSS ecosystem is based on a culture of mutual respect and contribution built upon that freedom. We believe that accepting the “value” of a project’s output while unilaterally refusing dialogue with its creators simply because they are individuals undermines the sustainability of this ecosystem. Such companies should not turn a blind eye to the reality that someone must bear the costs to make the cycle sustainable.


This issue is not just about corporations; it reflects a deeper cultural expectation within the FOSS ecosystem itself. Over time, we have come to take for granted that everything in open source should be provided for free - not only the code, but also the ongoing effort to maintain and improve it. However, FOSS licenses guarantee the freedom to use and modify software; they do not impose an obligation on developers to offer perpetual, unpaid maintenance. When this distinction is overlooked, maintainers can end up burdened with work that was never meant to be an open-ended personal commitment. Such an imbalance not only discourages openness, but also undermines the sustainability of an ecosystem that has become a vital part of modern society.


To explain the phenomenon occurring across the entire ecosystem: Developers write code they find useful and release it as FOSS. It gains popularity, and soon large corporations incorporate it into their products, reaping substantial profits. Requests for new features and fixes flood in, yet no financial support accompanies them. Eventually, the maintainer realizes there is no personal or professional benefit in responding to these unpaid demands. The skills required to develop popular FOSS are often in high demand in other fields as well. Ultimately, the maintainer burns out and the project is abandoned. This is the unsustainable cycle we are tackling.


Within this unsustainable cycle, adopting FOSS into products while fully aware of this situation is hardly beneficial for either companies or the society at large. To make the cycle sustainable, everyone must recognize the reality that someone must bear the costs, and these costs are equivalent to what companies would need to develop and maintain comparable products. This project specifically requests companies profiting from our deliverables to contribute to maintaining the project.


To be clear, this is not a request for charity; it is a proposal to manage the operational risk. This is a systemic challenge originating not from the developers, but from within the organizations that consume and whose business continuity depends on FOSS. Should a project be abandoned due to this unresolved problem, the primary victims will be you, the company that built its product on top of an unmaintained foundation, not the developers who can move on to other opportunities.

Our Request for Support

We request ongoing financial support from organizations that incorporate our project’s deliverables into their products or services and derive annual revenue exceeding US $1 million from those products and services, to help cover the costs of maintenance and the development of new features. While this support is not a legal obligation, let us be clear: the license is a grant of permission to use our work, not a service contract obligating us to provide perpetual, unpaid labor. We consider it a fundamental business principle that to profit from a critical dependency while contributing nothing to its stability is an extractive and unsustainable practice.


It is also crucial to recognize what “maintenance” truly entails. In a living software project, it is not merely about preserving the status quo of the current version. It is the continuous effort that leads to security patches, compatibility with new environments, and the very features that define future versions. Therefore, to claim satisfaction with an older version as a reason to decline support, while simultaneously benefiting from the ongoing development that produces newer, better versions, is a logically inconsistent position.


This support must not be intended to benefit any particular company, but must support maintaining the project as a shared infrastructure that benefits all users and the broader community. Furthermore, this threshold is designed so that individual developers, small-scale projects, and the majority of our users are not asked to pay, while seeking appropriate support from companies that derive significant value from our project.


We understand that corporate procurement processes were not designed with FOSS sustainability in mind. We are committed to finding a practical path forward, but your partnership is essential in structuring a financial relationship that aligns with your standard corporate procedures. We simply ask for fairness: do not demand contractual terms from maintainers that your own legal department would refuse to accept. Our mutual goal is to treat this partnership as a conventional operational expense, removing your internal barriers and making sustainability a straightforward business practice.


Our goal is to maintain this project stably over the long term and make it even more valuable for all users. In an industry where many projects are forced to abandon FOSS licenses, our preference is to continue offering this project under a true open-source license. However, the long-term viability of this FOSS-first approach depends directly on the willingness of our commercial beneficiaries to invest in the ecosystem they rely on. We hope our collaborative approach can contribute to shaping a more balanced and enduring future for FOSS.


For details, please see our Code of Conduct or its introduction video.


open source logo   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