Skip to content

Conversation

leandrolcampos
Copy link
Contributor

This patch enhances the GPU support documentation page (support.html) by adding a new, detailed section for math.h. This new section presents the results of the GPU math conformance tests, providing quantitative data on the accuracy of the supported higher math functions.

@llvmbot llvmbot added the libc label Aug 31, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 31, 2025

@llvm/pr-subscribers-libc

Author: Leandro Lacerda (leandrolcampos)

Changes

This patch enhances the GPU support documentation page (support.html) by adding a new, detailed section for math.h. This new section presents the results of the GPU math conformance tests, providing quantitative data on the accuracy of the supported higher math functions.


Patch is 22.44 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/156263.diff

1 Files Affected:

  • (modified) libc/docs/gpu/support.rst (+166)
diff --git a/libc/docs/gpu/support.rst b/libc/docs/gpu/support.rst
index 3fb2df8e6f2ca..4243900fb81d4 100644
--- a/libc/docs/gpu/support.rst
+++ b/libc/docs/gpu/support.rst
@@ -281,3 +281,169 @@ Function Name  Available  RPC Required
 assert         |check|    |check|
 __assert_fail  |check|    |check|
 =============  =========  ============
+
+math.h
+------
+
+The following table presents the conformance test results for higher math functions on the GPU. The results show the maximum observed ULP (Units in the Last Place) distance when comparing the GPU implementation against a correctly rounded reference computed on the host CPU. In addition to the C standard math library (LLVM-libm), these tests are conducted against CUDA Math and HIP Math, for comparison only.
+
++------------------------+-------------+---------------+-----------------------------------------------------------------------------------+
+| Function               | Test Method | ULP Tolerance | Max ULP Distance                                                                  |
+|                        |             |               +--------------------+--------------------+--------------------+--------------------+
+|                        |             |               | llvm-libm          | llvm-libm          | cuda-math          | hip-math           |
+|                        |             |               | (AMDGPU)           | (CUDA)             | (CUDA)             | (AMDGPU)           |
++========================+=============+===============+====================+====================+====================+====================+
+| acos                   | Randomized  | 4             | 6 (FAILED)         | 6 (FAILED)         | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| acosf                  | Exhaustive  | 4             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| acosf16                | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| acoshf                 | Exhaustive  | 4             | 1                  | 1                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| acoshf16               | Exhaustive  | 2             | 0                  | 0                  |                    | 0                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| acospif16              | Exhaustive  | 2             | 0                  | 0                  |                    |                    |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| asin                   | Randomized  | 4             | 6 (FAILED)         | 6 (FAILED)         | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| asinf                  | Exhaustive  | 4             | 1                  | 1                  | 1                  | 3                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| asinf16                | Exhaustive  | 2             | 0                  | 0                  |                    | 2                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| asinhf                 | Exhaustive  | 4             | 1                  | 1                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| asinhf16               | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| atanf                  | Exhaustive  | 5             | 0                  | 0                  | 1                  | 2                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| atanf16                | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| atan2f                 | Randomized  | 6             | 1                  | 1                  | 2                  | 3                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| atanhf                 | Exhaustive  | 5             | 0                  | 0                  | 3                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| atanhf16               | Exhaustive  | 2             | 0                  | 0                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| cbrt                   | Randomized  | 2             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| cbrtf                  | Exhaustive  | 2             | 0                  | 0                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| cos                    | Randomized  | 4             | 1                  | 1                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| cosf                   | Exhaustive  | 4             | 1                  | 1                  | 2                  | 2                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| cosf16                 | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| coshf                  | Exhaustive  | 4             | 0                  | 0                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| coshf16                | Exhaustive  | 2             | 1                  | 0                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| cospif                 | Exhaustive  | 4             | 0                  | 0                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| cospif16               | Exhaustive  | 2             | 0                  | 0                  |                    |                    |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| erff                   | Exhaustive  | 16            | 0                  | 0                  | 1                  | 2                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| exp                    | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| expf                   | Exhaustive  | 3             | 0                  | 0                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| expf16                 | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| exp10                  | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| exp10f                 | Exhaustive  | 3             | 0                  | 0                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| exp10f16               | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| exp2                   | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| exp2f                  | Exhaustive  | 3             | 1                  | 1                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| exp2f16                | Exhaustive  | 2             | 1                  | 1                  |                    | 0                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| expm1                  | Randomized  | 3             | 0                  | 0                  | 1                  | 2                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| expm1f                 | Exhaustive  | 3             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| expm1f16               | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| hypot                  | Randomized  | 4             | 0                  | 0                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| hypotf                 | Randomized  | 4             | 0                  | 0                  | 1                  | 2                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| hypotf16               | Exhaustive  | 2             | 0                  | 0                  |                    |                    |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| log                    | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| logf                   | Exhaustive  | 3             | 1                  | 1                  | 1                  | 2                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| logf16                 | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| log10                  | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| log10f                 | Exhaustive  | 3             | 1                  | 1                  | 2                  | 2                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| log10f16               | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| log1p                  | Randomized  | 2             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| log1pf                 | Exhaustive  | 2             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| log2                   | Randomized  | 3             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| log2f                  | Exhaustive  | 3             | 0                  | 0                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| log2f16                | Exhaustive  | 2             | 1                  | 1                  |                    | 0                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| powf (integer exp.)    | Randomized  | 16            | 0                  | 0                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| powf (real exp.)       | Randomized  | 16            | 0                  | 0                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| sin                    | Randomized  | 4             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| sinf                   | Exhaustive  | 4             | 1                  | 1                  | 1                  | 2                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| sinf16                 | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| sincos (cos part)      | Randomized  | 4             | 1                  | 1                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| sincos (sin part)      | Randomized  | 4             | 1                  | 1                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| sincosf (cos part)     | Exhaustive  | 4             | 1                  | 1                  | 2                  | 2                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| sincosf (sin part)     | Exhaustive  | 4             | 1                  | 1                  | 1                  | 2                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| sinhf                  | Exhaustive  | 4             | 1                  | 1                  | 3                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| sinhf16                | Exhaustive  | 2             | 1                  | 1                  |                    | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| sinpif                 | Exhaustive  | 4             | 0                  | 0                  | 1                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| sinpif16               | Exhaustive  | 2             | 0                  | 0                  |                    |                    |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| tan                    | Randomized  | 5             | 2                  | 2                  | 2                  | 1                  |
++------------------------+-------------+---------------+--------------------+--------------------+--------------------+--------------------+
+| tanf                   | Exhaustive  | 5             | 0                  | 0                  | 3      ...
[truncated]

@jhuber6 jhuber6 requested a review from lntue August 31, 2025 20:11
Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The support is just for functions that you can call, we'd want a new directory for these types of results similar to the ones listed for the CPU.

@leandrolcampos
Copy link
Contributor Author

The support is just for functions that you can call, we'd want a new directory for these types of results similar to the ones listed for the CPU.

I followed this suggestion from @lntue.

@lntue
Copy link
Contributor

lntue commented Sep 2, 2025

The list of math functions will be quite big later, so probably they could be in a separate page to make other headers accessible. Also include the config that the GPU math functions are built with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants