Skip to content
README.md 8.75 KiB
Newer Older
# SLEEF - Arm's Fork
Pierre Blanchard's avatar
Pierre Blanchard committed
[![DOI:10.1109/TPDS.2019.2960333](http://img.shields.io/badge/DOI-10.1109/TPDS.2019.2960333-blue.svg)](https://ieeexplore.ieee.org/document/8936472)
[![License](https://img.shields.io/badge/License-Boost_1.0-lightblue.svg)](https://www.boost.org/LICENSE_1_0.txt)
![CMake](https://img.shields.io/badge/cmake-v3.18+-yellow.svg)
[![Spack](https://img.shields.io/spack/v/sleef)](https://spack.readthedocs.io/en/v0.16.2/package_list.html#sleef)
[![SourceForge Downloads](https://img.shields.io/sourceforge/dt/sleef)](https://sourceforge.net/projects/sleef/)
SLEEF is a library that implements vectorized versions of C standard math functions. This library also includes DFT subroutines.
Pierre Blanchard's avatar
Pierre Blanchard committed
- **Web Page:** [https://sleef.org/][webpage_url]
- **Upstream Sources:** [https://github.com/shibatch/sleef][repo_url]
- **Arm's Fork Sources:** [https://gitlab.arm.com/libraries/sleef][repo_url]

## Note on Arm's fork

This is a fork of SLEEF's GitHub project. It is currently forking at the SLEEF 3.8 release tag.

The aim of this fork is to provide new features early to the public.

Synchronisation with more recent versions of SLEEF may be considered in the future.
## Supported environment
Pierre Blanchard's avatar
Pierre Blanchard committed
The following table summarises currently supported vector extensions, compilers and OS-es.
Pierre Blanchard's avatar
Pierre Blanchard committed
:green_circle: : Tested extensively in CI.
:yellow_circle: : Tested partially in CI.

Pierre Blanchard's avatar
Pierre Blanchard committed
:x: : Currently failing some tests in CI.
Naoki Shibata's avatar
Naoki Shibata committed

Pierre Blanchard's avatar
Pierre Blanchard committed
:white_circle: : Not tested in CI. Might have passed tests in previous CI framework.

[This issue](https://github.com/shibatch/sleef/issues/481) tracks progress on improving test coverage.
Compilation of SLEEF on previously supported environments might still be safe, we just cannot verify it yet.


Pierre Blanchard's avatar
Pierre Blanchard committed
<table>
<tr>
  <th colspan="2" rowspan="2"></th>
Andarwinux's avatar
Andarwinux committed
  <th colspan="9">OS/Compiler</th>
Pierre Blanchard's avatar
Pierre Blanchard committed
</tr>
<tr>
  <th colspan="3">Linux</br></br>
  <a href="https://github.com/shibatch/sleef/actions/workflows/build_and_test.yml">
    <img src="https://github.com/shibatch/sleef/actions/workflows/build_and_test.yml/badge.svg?event=push&branch=master"></a>
  </th>
  <th colspan="2">macOS</br></br>
  <a href="https://github.com/shibatch/sleef/actions/workflows/build-and-test-macos.yml">
    <img src="https://github.com/shibatch/sleef/actions/workflows/build-and-test-macos.yml/badge.svg?event=push&branch=master"></a>
  </th>
  <th colspan="4">Windows</br></br>
  <a href="https://github.com/shibatch/sleef/actions/workflows/build-and-test-msys2.yml">
    <img src="https://github.com/shibatch/sleef/actions/workflows/build-and-test-msys2.yml/badge.svg?event=push&branch=master"></a>
  </br>
  <a href="https://github.com/shibatch/sleef/actions/workflows/build-cross-llvm-mingw.yml">
    <img src="https://github.com/shibatch/sleef/actions/workflows/build-cross-llvm-mingw.yml/badge.svg?event=push&branch=master"></a>
  </th>
Pierre Blanchard's avatar
Pierre Blanchard committed
</tr>
<tr>
  <th>Arch.</th>
  <th>Vector Extensions</th>
  <th>gcc</th><th>llvm</th><th>icc</th>
  <th>gcc</th><th>llvm</th>
Andarwinux's avatar
Andarwinux committed
  <th>gcc</th><th>llvm-gnu</th><th>llvm-msvc</th><th>msvc</th>
Pierre Blanchard's avatar
Pierre Blanchard committed
</tr>
<tr align="center"><th>x86_64</th><th>SSE2, SSE4,<br>AVX, AVX2, AVX512F</th>
  <td>:green_circle:</td><td>:green_circle:</td><td>:white_circle:</td>
Andarwinux's avatar
Andarwinux committed
  <td>:white_circle:</td><td>:green_circle:</td>
  <td>:white_circle:</td><td>:yellow_circle:</td><td>:white_circle:</td><td>:white_circle:</td>
Pierre Blanchard's avatar
Pierre Blanchard committed
</tr>
<tr align="center"><th>x86 32bit<br>(i386)</th><th>SSE</th>
  <td>:white_circle:</td><td>:white_circle:</td><td>:white_circle:</td>
Andarwinux's avatar
Andarwinux committed
  <td colspan="2">N/A</td>
Andarwinux's avatar
Andarwinux committed
  <td>:white_circle:</td><td>:white_circle:</td><td>:white_circle:</td><td>:white_circle:</td>
Pierre Blanchard's avatar
Pierre Blanchard committed
</tr>
<tr align="center"><th>AArch64<br>(arm)</th><th>Neon, SVE</th>
Pierre Blanchard's avatar
Pierre Blanchard committed
  <td>:green_circle:</td><td>:green_circle:</td><td>N/A</td>
Andarwinux's avatar
Andarwinux committed
  <td colspan="1">N/A</td><td>:green_circle:</td>
Andarwinux's avatar
Andarwinux committed
  <td colspan="1">N/A</td><td>:white_circle:</td><td>:white_circle:</td><td>:white_circle:</td>
Pierre Blanchard's avatar
Pierre Blanchard committed
</tr>
<tr align="center"><th>AArch32<br>(armhf)</th><th>NEON</th>
  <td>:green_circle:</td><td>:green_circle:</td><td>N/A</td>
Andarwinux's avatar
Andarwinux committed
  <td colspan="2">N/A</td>
Andarwinux's avatar
Andarwinux committed
  <td colspan="4">N/A</td>
Pierre Blanchard's avatar
Pierre Blanchard committed
</tr>
<tr align="center"><th>PowerPC<br>(ppc64el)</th><th>VSX, VSX3</th>
  <td>:green_circle:</td><td>:green_circle:</td><td>N/A</td>
  <td colspan="2">N/A</td>
Andarwinux's avatar
Andarwinux committed
  <td colspan="4">N/A</td>
Pierre Blanchard's avatar
Pierre Blanchard committed
</tr>
<tr align="center"><th>IBM/Z<br>(s390x)</th><th>VXE, VXE2</th>
  <td>:green_circle:</td><td>:green_circle:</td><td>N/A</td>
  <td colspan="2">N/A</td>
Andarwinux's avatar
Andarwinux committed
  <td colspan="4">N/A</td>
Pierre Blanchard's avatar
Pierre Blanchard committed
</tr>
<tr align="center"><th>RISC-V<br>(riscv64)</th><th>RVV1, RVV2</th>
  <td>:green_circle:</td><td>:green_circle:</td><td>N/A</td>
Pierre Blanchard's avatar
Pierre Blanchard committed
  <td colspan="2">N/A</td>
Andarwinux's avatar
Andarwinux committed
  <td colspan="4">N/A</td>
Pierre Blanchard's avatar
Pierre Blanchard committed
</tr>
</table>

### Component support

The above table is valid for libm in single, double and quadruple precision, as well as fast Discrete Fourier Transform (DFT).

Generation of inline headers is also supported for most vector extensions.

LTO is not tested in CI yet, except on Windows.
Pierre Blanchard's avatar
Pierre Blanchard committed
### Compiler support

Results are displayed for gcc 14 and llvm 17, the compiler versions used in CI tests with GitHub Actions.
Pierre Blanchard's avatar
Pierre Blanchard committed

Older versions should be supported too, while newer ones are either not tested or have known issues.

Some compiler versions simply do not support certain vector extensions, for instance SVE is only supported for gcc version 9 onwards.

Similarly, the RISC-V interface in SLEEF is based on version 1.0 of the intrinsics, which is only supported from llvm version 17 and gcc version 14 onwards.

Toolchain files provide some information on supported compiler versions.

Pierre Blanchard's avatar
Pierre Blanchard committed
### OS support

Only Linux distributions and macOS are fully tested in CI and thus officially supported.
Pierre Blanchard's avatar
Pierre Blanchard committed

Only AArch64 and x86_64 vector extensions are built and tested natively on Linux and macOS.
Other architectures/vector extensions are cross-compiled on Linux.

Native AArch64 tests on Linux are using gcc 11 (default in Ubuntu 22.04), while native x86_64 and cross-compiled tests use gcc 14.
Building SLEEF for Windows on x86 machines was officially supported ( :white_circle: ), as of 3.5.1,
however it is only partially tested due to [known limitations of the test suite with MinGW or MSYS2](https://github.com/shibatch/sleef/issues/544).
As a result tests for Windows on x86 only include DFT for now (other tests are disabled in build system),
but all components are built.
Pierre Blanchard's avatar
Pierre Blanchard committed

Andarwinux's avatar
Andarwinux committed
Support for iOS and Android is only preliminary on AArch64.
Pierre Blanchard's avatar
Pierre Blanchard committed

SVE is not supported on Darwin-based system and therefore automatically disabled by SLEEF on Darwin.

Pierre Blanchard's avatar
Pierre Blanchard committed
### More on supported environment

Refer to our documentation for [more on supported environment](docs/#environment).
Pierre Blanchard's avatar
Pierre Blanchard committed

## Install SLEEF dependencies

The library itself does not have any additional dependency.

However some tests require:

- libssl and libcrypto, that can be provided by installing openssl.
- libm, libgmp and libmpfr
- libfftw.

These tests can be disabled if necessary.

## How to build SLEEF

We recommend relying on CMake as much as possible in the build process to ensure portability.
**CMake 3.18+** is the minimum required.
Pierre Blanchard's avatar
Pierre Blanchard committed

1. Check out the source code from our GitHub repository

```
git clone https://github.com/shibatch/sleef
```

2. Make a separate directory to create an out-of-source build

```
cd sleef && mkdir build
```

3. Run cmake to configure the project

```
cmake -S . -B build
```

Pierre Blanchard's avatar
Pierre Blanchard committed
By default this will generate shared libraries. In order to generate static libraries, pass option `-DBUILD_SHARED_LIBS=OFF`.

For more verbose output add option `-DSLEEF_SHOW_CONFIG=ON`.

Pierre Blanchard's avatar
Pierre Blanchard committed
4. Run make to build the project

```
cmake --build build -j --clean-first
```

5. Run tests using ctests

```
ctest --test-dir build -j
```

For more detailed build instructions please refer to the [dedicated section on CMake](./docs/1-user-guide/build-with-cmake) or to [our web page](./docs/1-user-guide/#preliminaries).
Pierre Blanchard's avatar
Pierre Blanchard committed

## How to cross-compile SLEEF

For more detailed please refer to [cross-compile SLEEF](./docs/1-user-guide#cross_linux)

Pierre Blanchard's avatar
Pierre Blanchard committed
## Install SLEEF

### From source

Assuming following instructions were followed.

6. Install to specified directory `<prefix>`

```
cmake --install build --prefix=<prefix>
```

### Using Spack

SLEEF can also be directly installed using Spack.

```
spack install sleef@master
```

Pierre Blanchard's avatar
Pierre Blanchard committed
### Uninstall

Pierre Blanchard's avatar
Pierre Blanchard committed
In order to uninstall SLEEF library and headers run
Pierre Blanchard's avatar
Pierre Blanchard committed
sudo xargs rm -v < build/install_manifest.txt
Pierre Blanchard's avatar
Pierre Blanchard committed
## License

The software is distributed under the Boost Software License, Version 1.0.
See accompanying file [LICENSE.txt](./LICENSE.txt) or copy at [http://www.boost.org/LICENSE_1_0.txt][license_url].
Contributions to this project are accepted under the same license.
Naoki Shibata's avatar
Naoki Shibata committed

Copyright &copy; 2010-2025 SLEEF Project, Naoki Shibata and contributors.<br/>
Pierre Blanchard's avatar
Pierre Blanchard committed


<!-- Repository links -->

[webpage_url]: https://sleef.org/
[repo_url]: https://github.com/shibatch/sleef
[fork_url]: https://gitlab.arm.com/libraries/sleef
Pierre Blanchard's avatar
Pierre Blanchard committed
[repo_license_url]: https://github.com/shibatch/sleef/blob/main/LICENSE.txt
[license_url]: http://www.boost.org/LICENSE_1_0.txt