brintos

brintos / llvm-project-archived public Read only

0
0
Text · 89.8 KiB · 51bb17f Raw
639 lines · plain
1.. _math:2 3======4math.h5======6 7.. include:: ../../check.rst8 9.. raw:: html10 11    <style> .green {color:green} </style>12 13.. role:: green14 15.. toctree::16  :hidden:17 18  log.rst19 20 21.. contents:: Table of Contents22  :depth: 423  :local:24 25Source Locations26================27 28- The main source is located at: `libc/src/math <https://github.com/llvm/llvm-project/tree/main/libc/src/math>`_.29- The tests are located at: `libc/test/src/math <https://github.com/llvm/llvm-project/tree/main/libc/test/src/math>`_.30- The floating point utilities are located at: `libc/src/__support/FPUtil <https://github.com/llvm/llvm-project/tree/main/libc/src/__support/FPUtil>`_.31 32Implementation Requirements / Goals33===================================34 35* The highest priority is to be as accurate as possible, according to the C and36  IEEE 754 standards.  By default, we will aim to be correctly rounded for `all rounding modes <https://en.cppreference.com/w/c/numeric/fenv/FE_round>`_.37  The current rounding mode of the floating point environment is used to perform38  computations and produce the final results.39 40  - To test for correctness, we compare the outputs with other correctly rounded41    multiple-precision math libraries such as the `GNU MPFR library <https://www.mpfr.org/>`_42    or the `CORE-MATH library <https://core-math.gitlabpages.inria.fr/>`_.43 44* Our next requirement is that the outputs are consistent across all platforms.45  Notice that the consistency requirement will be satisfied automatically if the46  implementation is correctly rounded.47 48* Our last requirement for the implementations is to have good and predicable49  performance:50 51  - The average performance should be comparable to other ``libc``52    implementations.53  - The worst case performance should be within 10X-20X of the average.54  - Platform-specific implementations or instructions could be added whenever it55    makes sense and provides significant performance boost.56 57* For other use cases that have strict requirements on the code size, memory58  footprint, or latency, such as embedded systems, we will aim to be as accurate59  as possible within the memory or latency budgets, and consistent across all60  platforms.61 62 63Add a new math function to LLVM libc64====================================65 66* To add a new math function, follow the steps at: `libc/src/math/docs/add_math_function.md <https://github.com/llvm/llvm-project/tree/main/libc/src/math/docs/add_math_function.md>`_.67 68Implementation Status69=====================70 71* To check math functions enabled for Linux:72 73  - `linux-x86_64 <https://github.com/llvm/llvm-project/tree/main/libc/config/linux/x86_64/entrypoints.txt>`_74 75  - `linux-aarch64 <https://github.com/llvm/llvm-project/tree/main/libc/config/linux/aarch64/entrypoints.txt>`_76 77  - `linux-aarch32 <https://github.com/llvm/llvm-project/tree/main/libc/config/linux/arm/entrypoints.txt>`_78 79  - `linux-riscv and linux-riscv32 <https://github.com/llvm/llvm-project/tree/main/libc/config/linux/riscv/entrypoints.txt>`_80 81* To check math functions enabled for Windows:82 83  - `windows-x86_64 <https://github.com/llvm/llvm-project/tree/main/libc/config/windows/entrypoints.txt>`_84 85  - windows-aarch64 - to be added86 87* To check math functions enabled for macOS:88 89  - `darwin-x86_64 <https://github.com/llvm/llvm-project/tree/main/libc/config/darwin/x86_64/entrypoints.txt>`_90 91  - `darwin-aarch64 <https://github.com/llvm/llvm-project/tree/main/libc/config/darwin/arm/entrypoints.txt>`_92 93* To check math functions enabled for GPU:94 95  - `gpu-entrypoints <https://github.com/llvm/llvm-project/tree/main/libc/config/gpu/entrypoints.txt>`_96 97* To check math functions enabled for embedded system:98 99  - `baremetal-aarch32 <https://github.com/llvm/llvm-project/tree/main/libc/config/baremetal/arm/entrypoints.txt>`_100 101  - baremetal-riscv32 - to be added102 103 104Basic Operations105================106 107+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+108| <Func>           | <Func_f> (float) | <Func> (double) | <Func_l> (long double) | <Func_f16> (float16) | <Func_f128> (float128) | <Func_bf16> (bfloat16) | C23 Definition Section | C23 Error Handling Section |109+==================+==================+=================+========================+======================+========================+========================+========================+============================+110| ceil             | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.1               | F.10.6.1                   |111+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+112| canonicalize     | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.11.7              | F.10.8.7                   |113+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+114| copysign         | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.11.1              | F.10.8.1                   |115+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+116| dadd             | N/A              | N/A             | |check|                | N/A                  | |check|\*              | N/A                    | 7.12.14.1              | F.10.11                    |117+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+118| ddiv             | N/A              | N/A             | |check|                | N/A                  | |check|\*              | N/A                    | 7.12.14.4              | F.10.11                    |119+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+120| dfma             | N/A              | N/A             | |check|                | N/A                  | |check|\*              | N/A                    | 7.12.14.5              | F.10.11                    |121+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+122| dmul             | N/A              | N/A             | |check|                | N/A                  | |check|\*              | N/A                    | 7.12.14.3              | F.10.11                    |123+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+124| dsub             | N/A              | N/A             | |check|                | N/A                  | |check|\*              | N/A                    | 7.12.14.2              | F.10.11                    |125+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+126| f16add           | |check|\*        | |check|\*       | |check|\*              | N/A                  | |check|                | N/A                    | 7.12.14.1              | F.10.11                    |127+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+128| f16div           | |check|\*        | |check|\*       | |check|\*              | N/A                  | |check|                | N/A                    | 7.12.14.4              | F.10.11                    |129+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+130| f16fma           | |check|\*        | |check|\*       | |check|\*              | N/A                  | |check|                | N/A                    | 7.12.14.5              | F.10.11                    |131+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+132| f16mul           | |check|\*        | |check|\*       | |check|\*              | N/A                  | |check|                | N/A                    | 7.12.14.3              | F.10.11                    |133+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+134| f16sub           | |check|\*        | |check|\*       | |check|\*              | N/A                  | |check|                | N/A                    | 7.12.14.2              | F.10.11                    |135+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+136| bf16add          | |check|\*        | |check|\*       | |check|\*              | N/A                  | |check|                | N/A                    | 7.12.14.1              | F.10.11                    |137+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+138| bf16div          | |check|\*        | |check|\*       | |check|\*              | N/A                  | |check|                | N/A                    | 7.12.14.4              | F.10.11                    |139+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+140| bf16fma          | |check|\*        | |check|\*       | |check|\*              | N/A                  | |check|                | N/A                    | 7.12.14.5              | F.10.11                    |141+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+142| bf16mul          | |check|\*        | |check|\*       | |check|\*              | N/A                  | |check|                | N/A                    | 7.12.14.3              | F.10.11                    |143+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+144| bf16sub          | |check|\*        | |check|\*       | |check|\*              | N/A                  | |check|                | N/A                    | 7.12.14.2              | F.10.11                    |145+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+146| fabs             | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.7.3               | F.10.4.3                   |147+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+148| fadd             | N/A              | |check|         | |check|                | N/A                  | |check|                | N/A                    | 7.12.14.1              | F.10.11                    |149+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+150| fdim             | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.12.1              | F.10.9.1                   |151+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+152| fdiv             | N/A              | |check|         | |check|                | N/A                  | |check|\*              | N/A                    | 7.12.14.4              | F.10.11                    |153+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+154| ffma             | N/A              | |check|         | |check|                | N/A                  | |check|\*              | N/A                    | 7.12.14.5              | F.10.11                    |155+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+156| floor            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.2               | F.10.6.2                   |157+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+158| fmax             | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.12.2              | F.10.9.2                   |159+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+160| fmaximum         | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.12.4              | F.10.9.4                   |161+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+162| fmaximum_mag     | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.12.6              | F.10.9.4                   |163+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+164| fmaximum_mag_num | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.12.10             | F.10.9.5                   |165+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+166| fmaximum_num     | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.12.8              | F.10.9.5                   |167+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+168| fmin             | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.12.3              | F.10.9.3                   |169+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+170| fminimum         | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.12.5              | F.10.9.4                   |171+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+172| fminimum_mag     | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.12.7              | F.10.9.4                   |173+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+174| fminimum_mag_num | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.12.11             | F.10.9.5                   |175+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+176| fminimum_num     | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.12.9              | F.10.9.5                   |177+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+178| fmod             | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.10.1              | F.10.7.1                   |179+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+180| fmul             | N/A              | |check|         | |check|                | N/A                  | |check|\*              | N/A                    | 7.12.14.3              | F.10.11                    |181+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+182| frexp            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.7               | F.10.3.7                   |183+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+184| fromfp           | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.10              | F.10.6.10                  |185+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+186| fromfpx          | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.11              | F.10.6.11                  |187+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+188| fsub             | N/A              | |check|         | |check|                | N/A                  | |check|\*              | N/A                    | 7.12.14.2              | F.10.11                    |189+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+190| getpayload       | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | F.10.13.1              | N/A                        |191+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+192| ilogb            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.8               | F.10.3.8                   |193+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+194| iscanonical      | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.3.2               | N/A                        |195+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+196| issignaling      | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.3.8               | N/A                        |197+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+198| ldexp            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.9               | F.10.3.9                   |199+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+200| llogb            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.10              | F.10.3.10                  |201+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+202| llrint           | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.5               | F.10.6.5                   |203+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+204| llround          | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.7               | F.10.6.7                   |205+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+206| logb             | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.17              | F.10.3.17                  |207+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+208| lrint            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.5               | F.10.6.5                   |209+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+210| lround           | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.7               | F.10.6.7                   |211+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+212| modf             | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.18              | F.10.3.18                  |213+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+214| nan              | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.11.2              | F.10.8.2                   |215+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+216| nearbyint        | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.3               | F.10.6.3                   |217+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+218| nextafter        | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.11.3              | F.10.8.3                   |219+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+220| nextdown         | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.11.6              | F.10.8.6                   |221+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+222| nexttoward       | |check|          | |check|         | |check|                | |check|              | N/A                    | |check|                | 7.12.11.4              | F.10.8.4                   |223+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+224| nextup           | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.11.5              | F.10.8.5                   |225+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+226| remainder        | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.10.2              | F.10.7.2                   |227+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+228| remquo           | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.10.3              | F.10.7.3                   |229+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+230| rint             | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.4               | F.10.6.4                   |231+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+232| round            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.6               | F.10.6.6                   |233+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+234| roundeven        | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.8               | F.10.6.8                   |235+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+236| scalbln          | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.19              | F.10.3.19                  |237+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+238| scalbn           | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.6.19              | F.10.3.19                  |239+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+240| setpayload       | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | F.10.13.2              | N/A                        |241+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+242| setpayloadsig    | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | F.10.13.3              | N/A                        |243+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+244| totalorder       | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | F.10.12.1              | N/A                        |245+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+246| totalordermag    | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | F.10.12.2              | N/A                        |247+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+248| trunc            | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.9               | F.10.6.9                   |249+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+250| ufromfp          | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.10              | F.10.6.10                  |251+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+252| ufromfpx         | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.9.11              | F.10.6.11                  |253+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+254 255Higher Math Functions256=====================257 258 259+-----------+------------------+-----------------+------------------------+----------------------+------------------------+----------++------------+------------------------+----------------------------+260| <Func>    | <Func_f> (float) | <Func> (double) | <Func_l> (long double) | <Func_f16> (float16) | <Func_f128> (float128) | <Func_bf16> (bfloat16) | C23 Definition Section | C23 Error Handling Section |261+===========+==================+=================+========================+======================+========================+========================+========================+============================+262| acos      | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.4.1               | F.10.1.1                   |263+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+264| acosh     | |check|          |                 |                        | |check|              |                        |                        | 7.12.5.1               | F.10.2.1                   |265+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+266| acospi    |                  |                 |                        | |check|              |                        |                        | 7.12.4.8               | F.10.1.8                   |267+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+268| asin      | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.4.2               | F.10.1.2                   |269+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+270| asinh     | |check|          |                 |                        | |check|              |                        |                        | 7.12.5.2               | F.10.2.2                   |271+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+272| asinpi    |                  |                 |                        | |check|              |                        |                        | 7.12.4.9               | F.10.1.9                   |273+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+274| atan      | |check|          | 1 ULP           |                        | |check|              |                        |                        | 7.12.4.3               | F.10.1.3                   |275+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+276| atan2     | |check|          | 1 ULP           |                        |                      | 1 ULP                  |                        | 7.12.4.4               | F.10.1.4                   |277+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+278| atan2pi   |                  |                 |                        |                      |                        |                        | 7.12.4.11              | F.10.1.11                  |279+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+280| atanh     | |check|          |                 |                        | |check|              |                        |                        | 7.12.5.3               | F.10.2.3                   |281+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+282| atanpi    |                  |                 |                        | |check|              |                        |                        | 7.12.4.10              | F.10.1.10                  |283+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+284| cbrt      | |check|          | |check|         |                        |                      |                        |                        | 7.12.7.1               | F.10.4.1                   |285+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+286| compoundn |                  |                 |                        |                      |                        |                        | 7.12.7.2               | F.10.4.2                   |287+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+288| cos       | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.4.5               | F.10.1.5                   |289+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+290| cosh      | |check|          |                 |                        | |check|              |                        |                        | 7.12.5.4               | F.10.2.4                   |291+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+292| cospi     | |check|          |                 |                        | |check|              |                        |                        | 7.12.4.12              | F.10.1.12                  |293+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+294| dsqrt     | N/A              | N/A             |   |check|              | N/A                  |       |check|\*        |                        | 7.12.14.6              | F.10.11                    |295+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+296| erf       | |check|          |                 |                        |                      |                        |                        | 7.12.8.1               | F.10.5.1                   |297+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+298| erfc      |                  |                 |                        |                      |                        |                        | 7.12.8.2               | F.10.5.2                   |299+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+300| exp       | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.6.1               | F.10.3.1                   |301+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+302| exp10     | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.6.2               | F.10.3.2                   |303+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+304| exp10m1   | |check|          |                 |                        | |check|              |                        |                        | 7.12.6.3               | F.10.3.3                   |305+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+306| exp2      | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.6.4               | F.10.3.4                   |307+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+308| exp2m1    | |check|          |                 |                        | |check|              |                        |                        | 7.12.6.5               | F.10.3.5                   |309+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+310| expm1     | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.6.6               | F.10.3.6                   |311+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+312| fma       | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.13.1              | F.10.10.1                  |313+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+314| f16sqrt   | |check|\*        | |check|\*       | |check|\*              | N/A                  | |check|                |                        | 7.12.14.6              | F.10.11                    |315+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+316| fsqrt     | N/A              | |check|         |  |check|               | N/A                  | |check|\*              |                        | 7.12.14.6              | F.10.11                    |317+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+318| hypot     | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.7.4               | F.10.4.4                   |319+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+320| lgamma    |                  |                 |                        |                      |                        |                        | 7.12.8.3               | F.10.5.3                   |321+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+322| log       | |check|          | |check|         |                        | |check|              |                        | |check| ?              | 7.12.6.11              | F.10.3.11                  |323+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+324| log10     | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.6.12              | F.10.3.12                  |325+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+326| log10p1   |                  |                 |                        |                      |                        |                        | 7.12.6.13              | F.10.3.13                  |327+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+328| log1p     | |check|          | |check|         |                        |                      |                        |                        | 7.12.6.14              | F.10.3.14                  |329+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+330| log2      | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.6.15              | F.10.3.15                  |331+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+332| log2p1    |                  |                 |                        |                      |                        |                        | 7.12.6.16              | F.10.3.16                  |333+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+334| logp1     |                  |                 |                        |                      |                        |                        | 7.12.6.14              | F.10.3.14                  |335+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+336| pow       | |check|          | 1 ULP           |                        |                      |                        |                        | 7.12.7.5               | F.10.4.5                   |337+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+338| powi\*    |                  |                 |                        |                      |                        |                        |                        |                            |339+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+340| pown      |                  |                 |                        |                      |                        |                        | 7.12.7.6               | F.10.4.6                   |341+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+342| powr      |                  |                 |                        |                      |                        |                        | 7.12.7.7               | F.10.4.7                   |343+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+344| rootn     |                  |                 |                        |                      |                        |                        | 7.12.7.8               | F.10.4.8                   |345+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+346| rsqrt     | |check|          |                 |                        | |check|              |                        |                        | 7.12.7.9               | F.10.4.9                   |347+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+348| sin       | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.4.6               | F.10.1.6                   |349+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+350| sincos    | |check|          | |check|         |                        |                      |                        |                        |                        |                            |351+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+352| sinh      | |check|          |                 |                        | |check|              |                        |                        | 7.12.5.5               | F.10.2.5                   |353+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+354| sinpi     | |check|          |                 |                        |  |check|             |                        |                        | 7.12.4.13              | F.10.1.13                  |355+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+356| sqrt      | |check|          | |check|         | |check|                | |check|              | |check|                | |check|                | 7.12.7.10              | F.10.4.10                  |357+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+358| tan       | |check|          | |check|         |                        | |check|              |                        |                        | 7.12.4.7               | F.10.1.7                   |359+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+360| tanh      | |check|          |                 |                        | |check|              |                        |                        | 7.12.5.6               | F.10.2.6                   |361+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+362| tanpi     | |check|          |                 |                        | |check|              |                        |                        | 7.12.4.14              | F.10.1.14                  |363+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+364| tgamma    |                  |                 |                        |                      |                        |                        | 7.12.8.4               | F.10.5.4                   |365+-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+366 367 368Legends:369 370* |check| : correctly rounded for all 4 rounding modes.371* CR: correctly rounded for the default rounding mode (round-to-the-nearest,372  tie-to-even).373* x ULPs: largest errors recorded.374* N/A: Not defined in the standard or will not be added.375* \*: LLVM libc extension.376* ? Because of a conflict between float16 logb function and bfloat16 log function, the latter is implemented as `log_bf16`.377 378..379  TODO(lntue): Add a new page to discuss about the algorithms used in the380  implementations and include the link here.381 382GPU Conformance383===============384 385* Conformance tests are located at: `offload/unittests/Conformance <https://github.com/llvm/llvm-project/tree/main/offload/unittests/Conformance>`_.386 387* The math functions for GPUs are compiled with the following optimization options: ``LIBC_MATH_SKIP_ACCURATE_PASS``, ``LIBC_MATH_INTERMEDIATE_COMP_IN_FLOAT``, ``LIBC_MATH_SMALL_TABLES``, ``LIBC_MATH_NO_ERRNO``, and ``LIBC_MATH_NO_EXCEPT``.388 389* The conformance test results for higher math functions on GPUs are reported in the table below. The results show the maximum observed ULP distance when comparing a given GPU implementation against the corresponding correctly rounded implementation from LLVM libc, which is computed on the host CPU and serves as the reference. For comparison purposes, results for CUDA Math and HIP Math against the same reference are also included.390 391+------------------------+-------------+---------------+-----------------------------------------------------------------------------------+392| Function               | Test Method | ULP Tolerance | Max ULP Distance                                                                  |393|                        |             |               +--------------------+--------------------+--------------------+--------------------+394|                        |             |               | LLVM libc          | LLVM libc          | CUDA Math          | HIP Math           |395|                        |             |               | (AMDGPU)           | (CUDA)             | (CUDA)             | (AMDGPU)           |396+========================+=============+===============+====================+====================+====================+====================+397| acos                   | Randomized  | 4             | 6 (FAILED)         | 6 (FAILED)         | 1                  | 1                  |398+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+399| acosf                  | Exhaustive  | 4             | 1                  | 1                  | 1                  | 1                  |400+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+401| acosf16                | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |402+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+403| acoshf                 | Exhaustive  | 4             | 1                  | 1                  | 2                  | 1                  |404+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+405| acoshf16               | Exhaustive  | 2             | 0                  | 0                  |                    | 0                  |406+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+407| acospif16              | Exhaustive  | 2             | 0                  | 0                  |                    |                    |408+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+409| asin                   | Randomized  | 4             | 6 (FAILED)         | 6 (FAILED)         | 2                  | 1                  |410+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+411| asinf                  | Exhaustive  | 4             | 1                  | 1                  | 1                  | 3                  |412+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+413| asinf16                | Exhaustive  | 2             | 0                  | 0                  |                    | 2                  |414+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+415| asinhf                 | Exhaustive  | 4             | 1                  | 1                  | 2                  | 1                  |416+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+417| asinhf16               | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |418+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+419| atanf                  | Exhaustive  | 5             | 0                  | 0                  | 1                  | 2                  |420+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+421| atanf16                | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |422+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+423| atan2f                 | Randomized  | 6             | 1                  | 1                  | 2                  | 3                  |424+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+425| atanhf                 | Exhaustive  | 5             | 0                  | 0                  | 3                  | 1                  |426+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+427| atanhf16               | Exhaustive  | 2             | 0                  | 0                  |                    | 1                  |428+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+429| cbrt                   | Randomized  | 2             | 1                  | 1                  | 1                  | 1                  |430+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+431| cbrtf                  | Exhaustive  | 2             | 0                  | 0                  | 1                  | 1                  |432+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+433| cos                    | Randomized  | 4             | 1                  | 1                  | 2                  | 1                  |434+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+435| cosf                   | Exhaustive  | 4             | 1                  | 1                  | 2                  | 2                  |436+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+437| cosf16                 | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |438+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+439| coshf                  | Exhaustive  | 4             | 0                  | 0                  | 2                  | 1                  |440+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+441| coshf16                | Exhaustive  | 2             | 1                  | 0                  |                    | 1                  |442+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+443| cospif                 | Exhaustive  | 4             | 0                  | 0                  | 1                  | 1                  |444+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+445| cospif16               | Exhaustive  | 2             | 0                  | 0                  |                    |                    |446+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+447| erff                   | Exhaustive  | 16            | 0                  | 0                  | 1                  | 2                  |448+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+449| exp                    | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |450+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+451| expf                   | Exhaustive  | 3             | 0                  | 0                  | 2                  | 1                  |452+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+453| expf16                 | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |454+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+455| exp10                  | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |456+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+457| exp10f                 | Exhaustive  | 3             | 0                  | 0                  | 2                  | 1                  |458+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+459| exp10f16               | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |460+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+461| exp2                   | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |462+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+463| exp2f                  | Exhaustive  | 3             | 1                  | 1                  | 2                  | 1                  |464+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+465| exp2f16                | Exhaustive  | 2             | 1                  | 1                  |                    | 0                  |466+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+467| expm1                  | Randomized  | 3             | 0                  | 0                  | 1                  | 2                  |468+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+469| expm1f                 | Exhaustive  | 3             | 1                  | 1                  | 1                  | 1                  |470+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+471| expm1f16               | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |472+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+473| hypot                  | Randomized  | 4             | 0                  | 0                  | 2                  | 1                  |474+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+475| hypotf                 | Randomized  | 4             | 0                  | 0                  | 1                  | 2                  |476+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+477| hypotf16               | Exhaustive  | 2             | 0                  | 0                  |                    |                    |478+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+479| log                    | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |480+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+481| logf                   | Exhaustive  | 3             | 1                  | 1                  | 1                  | 2                  |482+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+483| logf16                 | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |484+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+485| log10                  | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |486+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+487| log10f                 | Exhaustive  | 3             | 1                  | 1                  | 2                  | 2                  |488+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+489| log10f16               | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |490+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+491| log1p                  | Randomized  | 2             | 1                  | 1                  | 1                  | 1                  |492+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+493| log1pf                 | Exhaustive  | 2             | 1                  | 1                  | 1                  | 1                  |494+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+495| log2                   | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |496+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+497| log2f                  | Exhaustive  | 3             | 0                  | 0                  | 1                  | 1                  |498+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+499| log2f16                | Exhaustive  | 2             | 1                  | 1                  |                    | 0                  |500+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+501| powf (integer exp.)    | Randomized  | 16            | 0                  | 0                  | 2                  | 1                  |502+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+503| powf (real exp.)       | Randomized  | 16            | 0                  | 0                  | 2                  | 1                  |504+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+505| sin                    | Randomized  | 4             | 1                  | 1                  | 1                  | 1                  |506+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+507| sinf                   | Exhaustive  | 4             | 1                  | 1                  | 1                  | 2                  |508+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+509| sinf16                 | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |510+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+511| sincos (cos part)      | Randomized  | 4             | 1                  | 1                  | 2                  | 1                  |512+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+513| sincos (sin part)      | Randomized  | 4             | 1                  | 1                  | 1                  | 1                  |514+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+515| sincosf (cos part)     | Exhaustive  | 4             | 1                  | 1                  | 2                  | 2                  |516+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+517| sincosf (sin part)     | Exhaustive  | 4             | 1                  | 1                  | 1                  | 2                  |518+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+519| sinhf                  | Exhaustive  | 4             | 1                  | 1                  | 3                  | 1                  |520+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+521| sinhf16                | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |522+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+523| sinpif                 | Exhaustive  | 4             | 0                  | 0                  | 1                  | 1                  |524+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+525| sinpif16               | Exhaustive  | 2             | 0                  | 0                  |                    |                    |526+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+527| tan                    | Randomized  | 5             | 2                  | 2                  | 2                  | 1                  |528+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+529| tanf                   | Exhaustive  | 5             | 0                  | 0                  | 3                  | 2                  |530+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+531| tanf16                 | Exhaustive  | 2             | 1                  | 1                  |                    | 2                  |532+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+533| tanhf                  | Exhaustive  | 5             | 0                  | 0                  | 2                  | 1                  |534+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+535| tanhf16                | Exhaustive  | 2             | 0                  | 0                  |                    | 1                  |536+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+537| tanpif                 | Exhaustive  | 6             | 0                  | 0                  |                    |                    |538+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+539| tanpif16               | Exhaustive  | 2             | 1                  | 1                  |                    |                    |540+------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+541 542Notes:543 544* Exhaustive tests check every representable point in the input space. This method is used for half-precision functions and single-precision univariate functions.545* Randomized tests check a large, deterministic subset of the input space, typically using 2\ :sup:`32` samples. This method is used for functions with larger input spaces, such as single-precision bivariate and double-precision functions.546* ULP tolerances are based on The Khronos Group, `The OpenCL C Specification v3.0.19 <https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_C.html>`_, Sec. 7.4, Khronos Registry [July 10, 2025].547* The AMD GPU used for testing is AMD Radeon RX 6950 XT.548* The NVIDIA GPU used for testing is NVIDIA RTX 4000 SFF Ada Generation.549 550Performance551===========552 553* Simple performance testings are located at: `libc/test/src/math/performance_testing <https://github.com/llvm/llvm-project/tree/main/libc/test/src/math/performance_testing>`_.554 555* We also use the *perf* tool from the `CORE-MATH <https://core-math.gitlabpages.inria.fr/>`_556  project: `link <https://gitlab.inria.fr/core-math/core-math/-/tree/master>`_.557  The performance results from the CORE-MATH's perf tool are reported in the558  table below, using the system library as reference (such as the `GNU C library <https://www.gnu.org/software/libc/>`_559  on Linux). Fmod performance results obtained with "performance_testing".560 561+--------------+-------------------------------+-------------------------------+-------------------------------------+----------------------------------------------------------------------+562| <Func>       | Reciprocal throughput (clk)   | Latency (clk)                 | Testing ranges                      | Testing configuration                                                |563|              +-----------+-------------------+-----------+-------------------+                                     +-------------+-------------------------+--------------+---------------+564|              | LLVM libc | Reference (glibc) | LLVM libc | Reference (glibc) |                                     | CPU         | OS                      | Compiler     | Special flags |565+==============+===========+===================+===========+===================+=====================================+=============+=========================+==============+===============+566| acosf        |        24 |                29 |        62 |                77 | :math:`[-1, 1]`                     | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |567+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+568| acoshf       |        18 |                26 |        73 |                74 | :math:`[1, 21]`                     | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |569+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+570| asinf        |        23 |                27 |        62 |                62 | :math:`[-1, 1]`                     | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |571+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+572| asinhf       |        21 |                39 |        77 |                91 | :math:`[-10, 10]`                   | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |573+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+574| atanf        |        27 |                29 |        79 |                68 | :math:`[-10, 10]`                   | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |575+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+576| atanhf       |        18 |                66 |        68 |               133 | :math:`[-1, 1]`                     | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |577+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+578| cosf         |        13 |                32 |        53 |                59 | :math:`[0, 2\pi]`                   | Ryzen 1700  | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 | FMA           |579+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+580| coshf        |        14 |                20 |        50 |                48 | :math:`[-10, 10]`                   | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |581+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+582| expf         |         9 |                 7 |        44 |                38 | :math:`[-10, 10]`                   | Ryzen 1700  | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 | FMA           |583+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+584| exp10f       |        10 |                 8 |        40 |                38 | :math:`[-10, 10]`                   | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |585+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+586| exp2f        |         9 |                 6 |        35 |                31 | :math:`[-10, 10]`                   | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |587+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+588| expm1f       |         9 |                44 |        42 |               121 | :math:`[-10, 10]`                   | Ryzen 1700  | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 | FMA           |589+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+590| fmodf        |        73 |               263 |        -  |                 - | [MIN_NORMAL, MAX_NORMAL]            | i5 mobile   | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 |               |591|              +-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+592|              |         9 |                11 |        -  |                 - | [0, MAX_SUBNORMAL]                  | i5 mobile   | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 |               |593+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+594| fmod         |       595 |              3297 |        -  |                 - | [MIN_NORMAL, MAX_NORMAL]            | i5 mobile   | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 |               |595|              +-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+596|              |        14 |                13 |        -  |                 - | [0, MAX_SUBNORMAL]                  | i5 mobile   | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 |               |597+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+598| hypotf       |        25 |                15 |        64 |                49 | :math:`[-10, 10] \times [-10, 10]`  | Ryzen 1700  | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 |               |599+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+600| logf         |        12 |                10 |        56 |                46 | :math:`[e^{-1}, e]`                 | Ryzen 1700  | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 | FMA           |601+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+602| log10f       |         9 |                17 |        35 |                48 | :math:`[e^{-1}, e]`                 | Ryzen 5900X | Ubuntu 22.04 LTS x86_64 | Clang 15.0.6 | FMA           |603+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+604| log1pf       |        16 |                33 |        61 |                97 | :math:`[e^{-0.5} - 1, e^{0.5} - 1]` | Ryzen 1700  | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 | FMA           |605+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+606| log2f        |        13 |                10 |        57 |                46 | :math:`[e^{-1}, e]`                 | Ryzen 1700  | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 | FMA           |607+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+608| sinf         |        12 |                25 |        51 |                57 | :math:`[-\pi, \pi]`                 | Ryzen 1700  | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 | FMA           |609+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+610| sincosf      |        19 |                30 |        57 |                68 | :math:`[-\pi, \pi]`                 | Ryzen 1700  | Ubuntu 20.04 LTS x86_64 | Clang 12.0.0 | FMA           |611+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+612| sinhf        |        13 |                63 |        48 |               137 | :math:`[-10, 10]`                   | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |613+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+614| tanf         |        16 |                50 |        61 |               107 | :math:`[-\pi, \pi]`                 | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |615+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+616| tanhf        |        13 |                55 |        57 |               123 | :math:`[-10, 10]`                   | Ryzen 1700  | Ubuntu 22.04 LTS x86_64 | Clang 14.0.0 | FMA           |617+--------------+-----------+-------------------+-----------+-------------------+-------------------------------------+-------------+-------------------------+--------------+---------------+618 619Algorithms + Implementation Details620===================================621 622* :doc:`log`623 624Fixed-point Arithmetics625=======================626 627* :doc:`../stdfix`628 629References630==========631 632* `CRLIBM <https://hal-ens-lyon.archives-ouvertes.fr/ensl-01529804/file/crlibm.pdf>`_.633* `RLIBM <https://people.cs.rutgers.edu/~sn349/rlibm/>`_.634* `Sollya <https://www.sollya.org/>`_.635* `The CORE-MATH Project <https://core-math.gitlabpages.inria.fr/>`_.636* `The GNU C Library (glibc) <https://www.gnu.org/software/libc/>`_.637* `The GNU MPFR Library <https://www.mpfr.org/>`_.638* `C++23 Standard <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/n4950.pdf>`_.639* `BFloat16 <https://en.wikipedia.org/wiki/Bfloat16_floating-point_format>`_.