llvm-project/libc/docs
Tue Ly 82d6e77048 [libc] Implement tanf function correctly rounded for all rounding modes.
Implement tanf function correctly rounded for all rounding modes.

We use the range reduction that is shared with `sinf`, `cosf`, and `sincosf`:
```
  k = round(x * 32/pi) and y = x * (32/pi) - k.
```
Then we use the tangent of sum formula:
```
  tan(x) = tan((k + y)* pi/32) = tan((k mod 32) * pi / 32 + y * pi/32)
         = (tan((k mod 32) * pi/32) + tan(y * pi/32)) / (1 - tan((k mod 32) * pi/32) * tan(y * pi/32))
```
We need to make a further reduction when `k mod 32 >= 16` due to the pole at `pi/2` of `tan(x)` function:
```
  if (k mod 32 >= 16): k = k - 31, y = y - 1.0
```
And to compute the final result, we store `tan(k * pi/32)` for `k = -15..15` in a table of 32 double values,
and evaluate `tan(y * pi/32)` with a degree-11 minimax odd polynomial generated by Sollya with:
```
>  P = fpminimax(tan(y * pi/32)/y, [|0, 2, 4, 6, 8, 10|], [|D...|], [0, 1.5]);
```

Performance benchmark using `perf` tool from the CORE-MATH project on Ryzen 1700:
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh tanf
CORE-MATH reciprocal throughput   : 18.586
System LIBC reciprocal throughput : 50.068

LIBC reciprocal throughput        : 33.823
LIBC reciprocal throughput        : 25.161     (with `-msse4.2` flag)
LIBC reciprocal throughput        : 19.157     (with `-mfma` flag)

$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh tanf --latency
GNU libc version: 2.31
GNU libc release: stable
CORE-MATH latency   : 55.630
System LIBC latency : 106.264

LIBC latency        : 96.060
LIBC latency        : 90.727    (with `-msse4.2` flag)
LIBC latency        : 82.361    (with `-mfma` flag)
```

Reviewed By: orex

Differential Revision: https://reviews.llvm.org/D131715
2022-08-12 09:21:05 -04:00
..
_static [libc] Website fixes (sidebar and mobile) 2022-08-08 18:38:01 +00:00
CMakeLists.txt Move LLVM Proposal to doc directory, create index 2022-01-29 00:29:31 +00:00
README.txt Move LLVM Proposal to doc directory, create index 2022-01-29 00:29:31 +00:00
api_test.rst [libc] Rename libc-integration-test to libc-api-test. 2022-03-23 20:25:34 +00:00
build_system.rst
clang_tidy_checks.rst [libc][clang-tidy] fix namespace check for externals 2021-11-30 11:44:24 -08:00
conf.py [libc] Update look and feel of libc.llvm.org 2022-08-05 18:18:40 +00:00
entrypoints.rst
fuzzing.rst [libc][docs] Update the fuzzing doc to better reflect the current state. 2022-04-20 15:33:20 +00:00
ground_truth_specification.rst
header_gen_scheme.svg
header_generation.rst
implementation_standard.rst
index.rst [libc] Website fixes (sidebar and mobile) 2022-08-08 18:38:01 +00:00
layering.rst Rewrite much of the index page for libc 2022-02-16 03:46:20 +00:00
math.rst [libc] Implement tanf function correctly rounded for all rounding modes. 2022-08-12 09:21:05 -04:00
mechanics_of_public_api.rst
redirectors.rst Move LLVM Proposal to doc directory, create index 2022-01-29 00:29:31 +00:00
redirectors_schematic.svg
runtimes_build.rst [libc] Add a doc describing the current status of libc runtimes build. 2022-04-18 06:48:43 +00:00
source_layout.rst [libc][docs] Use same formatting for headers in source_layout 2022-05-23 21:47:22 +00:00
stdio.rst [libc][docs] Add doc for libc stdio functions 2022-05-12 13:02:23 -07:00
strings.rst [libc][docs] Add doc for libc stdio functions 2022-05-12 13:02:23 -07:00

README.txt

libc Documentation
==================

The libc documentation is written using the Sphinx documentation generator. It is
currently tested with Sphinx 1.1.3.

To build the documents into html configure libc with the following cmake options:

  * -DLLVM_ENABLE_SPHINX=ON
  * -DLIBC_INCLUDE_DOCS=ON

After configuring libc with these options the make rule `docs-libc-html`
should be available.