The vdt mathematical library
- A collection of fast and inline implementations of mathematical functions.
- The functions can be used in autovectorised loops.
- Double and single precision implementations are available.
- No overhead present, no intrinsics used.
- A scalar (
T(T)) and array signature (
void(const unsigned int,T*,T*)) are provided.
Much of the VDT code is inspired by the well known Cephes mathematical library.
How to get, compile and install it
The vdt functions are inline and contained in header files: they are ready to be used without compilation of an external library. In any case, there is the possibility to compile a shared library containing the array signatures
void(const unsigned int,T*,T*).
The makesystem chosen for vdt is CMake.
export INSTALLDIR=/path/to/mydir git clone https://github.com/dpiparo/vdt.git cd vdt cmake -DCMAKE_INSTALL_PREFIX=$INSTALLDIR . make make install
How to use it
Good examples of vdt functions usage are located in the progs and progs/units directories.
The vdt functions
All vdt functions live in the
vdt namespace. Their names are structured as follows:
- The function name is one of the list in the table below.
fletter stands for the single precision function (
vletter identifies the array function. You may wonder, why prepending
fast_? This is done to allow the user to decide where a fast and approximate implementation of the function is to be used. It is not always obvious where the accuracy can be reduced: all the flexibility is needed.
These are the available functions:
|Function||Scalar double precision||Scalar single precision||Array double precision||Array single precision|
|inverse square root (1/sqrt)||fast_isqrt||fast_isqrtf||fast_isqrtv||fast_isqrtfv|
Other Cmake options
Other options for Cmake are available to steer the creation of the makefile:
- Enable AVX extensions
- Enable NEON extensions on ARM
- Benchmarking tools and unit tests (requires C++11 support by the compiler)
- Build static library
- Prepare the library to be pre-loaded in order to replace the calls to the default math lib at runtime
The vdt functions can be used with every compiler (icc and gcc were tested). To compile the benchmarking tools gcc4.7 (icc12) is at least needed because of the support of c++11. To vectorise the functions gcc4.7 (icc12) is at least needed.
This section is for experts who want to study the details of the functions provided and/or to compare them to other implementations. vdt comes with a complete benchmark suite both for accuracy and speed measurements. To measure the speed of the functions, you should use the ''vdtPerfBenchmark''. To dump on disk the ascii files summarising the accuracy of the functions, you should use ''vdtArithmBenchmark'', while the tool to compare them is ''vdtArithmComparison''. In order to produce the plots of the different bits as a function of input, the script to be used is ''diffhisto.py'' (which depends on ROOT to produce plots).
Example of Performance
Double precision, Intel® Core™ i7-3930K CPU @ 3.20GHz running Scientific Linux 6. Operative interval of the input: [-5000,5000] ((0,5000] for isqrt and [-1,1] for Asin and Acos). Time in ns per call.
|Function||libm||VDT||VDT SSE||VDT AVX|
Accuracy measured in terms of least significant bit. Average difference with respect to libm.
- A full characterisation of the accuracies please refer to this presentation.
If you want to cite vdt, please use your reference: D. Piparo, V.Innocente and T.Hauth 2014 J. Phys.: Conf. Ser. 513 052027 "Speeding up HEP experiment software with a library of fast and auto-vectorisable mathematical functions"
The VDT projects has a mailing list: VDTlibrary-talk at cern ch, linked to an e-group with the same name. The Infrastructure used is the one provided by CERN IT. If you don't have a CERN account, you can obtain an external one [https://simba3.web.cern.ch/simba3/SelfSubscription.aspx?groupName=your-e-group-name here]. Alternatively, feel free to contact Danilo Piparo (danilo_dot_piparo_at_cern_dot_ch).
The VDT mathematical library is licenced under the LGPL3 licence