a752460d73
Implement exp10f function correctly rounded to all rounding modes. Algorithm: perform range reduction to reduce ``` 10^x = 2^(hi + mid) * 10^lo ``` where: ``` hi is an integer, 0 <= mid * 2^5 < 2^5 -log10(2) / 2^6 <= lo <= log10(2) / 2^6 ``` Then `2^mid` is stored in a table of 32 entries and the product `2^hi * 2^mid` is performed by adding `hi` into the exponent field of `2^mid`. `10^lo` is then approximated by a degree-5 minimax polynomials generated by Sollya with: ``` > P = fpminimax((10^x - 1)/x, 4, [|D...|], [-log10(2)/64. log10(2)/64]); ``` Performance benchmark using perf tool from the CORE-MATH project on Ryzen 1700: ``` $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh exp10f GNU libc version: 2.35 GNU libc release: stable CORE-MATH reciprocal throughput : 10.215 System LIBC reciprocal throughput : 7.944 LIBC reciprocal throughput : 38.538 LIBC reciprocal throughput : 12.175 (with `-msse4.2` flag) LIBC reciprocal throughput : 9.862 (with `-mfma` flag) $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh exp10f --latency GNU libc version: 2.35 GNU libc release: stable CORE-MATH latency : 40.744 System LIBC latency : 37.546 BEFORE LIBC latency : 48.989 LIBC latency : 44.486 (with `-msse4.2` flag) LIBC latency : 40.221 (with `-mfma` flag) ``` This patch relies on https://reviews.llvm.org/D134002 Reviewed By: orex, zimmermann6 Differential Revision: https://reviews.llvm.org/D134104 |
||
---|---|---|
.. | ||
entrypoints.txt | ||
README.md |
Building and Testing LLVM libc on Windows
Setting Up Environment
To build LLVM libc on Windows, first build Clang using the following steps.
-
Open Command Prompt in Windows
-
Set TEMP and TMP to a directory. Creating this path is necessary for a successful clang build.
-
Create tmp under your preferred directory or under
C:\src
:cd C:\src mkdir tmp
-
In the start menu, search for "environment variables for your account". Set TEMP and TMP to
C:\src\tmp
or the corresponding path elsewhere.
-
-
Download Visual Studio Community.
-
Install CMake and Ninja. (Optional, included in Visual Studio).
-
Load the Visual Studio environment variables using this command. This is crucial as it allows you to use build tools like CMake and Ninja:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
Note: Rerun this command every time you open a new Command Prompt window.
-
If you have not used Git before, install Git for Windows. Check out the LLVM source tree from Github using:
git clone https://github.com/llvm/llvm-project.git
-
Ensure you have access to Clang, either by downloading from LLVM Download or building it yourself.
Building LLVM libc
In this section, Clang will be used to compile LLVM libc, and finally, build and test the libc.
-
Create a empty build directory in
C:\src
or your preferred directory and cd to it using:mkdir libc-build cd libc-build
-
Run the following CMake command to generate build files. LLVM libc must be built by Clang, so ensure Clang is specified as the C and C++ compiler.
cmake -G Ninja ../llvm-project/llvm -DCMAKE_C_COMPILER=C:/src/clang-build/bin/clang-cl.exe -DCMAKE_CXX_COMPILER=C:/src/clang-build/bin/clang-cl.exe -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_FORCE_BUILD_RUNTIME=libc -DLLVM_ENABLE_PROJECTS=libc -DLLVM_NATIVE_ARCH=x86_64 -DLLVM_HOST_TRIPLE=x86_64-window-x86-gnu
Some LLVM libc math unittests test correctness/accuracy against results from the GNU MPFR library. If you want to run math tests which use MPFR, and if MPFR on your machine is not installed in the default include and linker lookup directories, then you can specify the MPFR install directory by passing an additional CMake option as follows:
-DLLVM_LIBC_MPFR_INSTALL_PATH=<path/mpfr/install/dir>
If the above option is specified, then
${LLVM_LIBC_MPFR_INSTALL_PATH}/include
will be added to the include directories, and${LLVM_LIBC_MPFR_INSTALL_PATH}/lib
will be added to the linker lookup directories.NOTE: The GNU MPFR library depends on the GNU GMP library. If you specify the above option, then it will be assumed that GMP is also installed in the same directory or availabe in the default paths.
-
Build LLVM libc using:
ninja llvmlibc
-
Run tests using:
ninja checklibc