A c++-20 template based short vector library with faithfully rounded vectorized elementary functions.
Cftal is a c++-20 template based short vector library with specializations using intrinsic functions. The library contains vectorized elementary and some special functions (erf, erfc, tgamma, lgamma, j0, y0, j1 and y1) which are part of the standard c++ math library for
- double (binary64),
- single (binary32),
- half (binary16) and
- bfloat16 (brain floating point)
precision arguments and results. The functions are probably faithfully rounded for double, single and half precision and bfloat16. The elementary functions for half precision and bfloat16 with one argument are faithfully rounded (if mpfr rounds correctly). Tests for a subset of the numbers for single and double precision show faithfully rounding compared to mpfr.
Specializations for x86 processors with instructions set extensions up to AVX2 are implemented and tested. The specializations for processors with AVX512 extensions are not tested yet. AArch64 code is not tested.
- the reproduction of the used constants in the code requires sollya (https://www.sollya.org), libsollya-dev to build extensions to sollya and the maxima (https://maxima.sourceforge.io) computer algebra system
- the test code uses mpfr (https://www.mpfr.org) and requires libmpfr-dev to compile the programs testing the precision (and speed) of the vectorized elementary and special functions
- the documentation in the doc directory requires pdflatex
- cmake ist the used build system
- only linux as host and target system was tested and
- gcc or clang are the only compilers used to date
create a build directory in the root directory of the project, configure and build
- mkdir build
- cd build
- CC=clang-18 CXX=clang++-18 cmake -DCMAKE_BUILD_TYPE=release ..
You may also use gcc instead of clang:
- CC=gcc-14 CXX=g++-14 cmake -DCMAKE_BUILD_TYPE=release ..
If you want to use vectors of double's for the calculation of some elementary float functions, use -DCFTAL_CONFIG_USE_VF64_FOR_VF32=1 as an additional argument for cmake.
During the build a number of test programs are built in ./test and a pdf is created in ./doc containing some documentation.
This project is licensed under the LGPL v2.1License.