[libc-commits] [libc] [libc] Enable new float math functions on the GPU (PR #151841)

Leandro Lacerda via libc-commits libc-commits at lists.llvm.org
Sat Aug 2 18:35:21 PDT 2025


https://github.com/leandrolcampos created https://github.com/llvm/llvm-project/pull/151841

This patch adds the `exp10m1f` and `tanpif` math functions to the GPU build. These should all pass except `exp10m1f` on NVPTX for some reason. We need to investigate that later.

It also adds the `cospif` and `sinpif` math functions to the `math.h` header.

>From 969f57461620797bfdb6d7ef53744b5d145b5f82 Mon Sep 17 00:00:00 2001
From: Leandro Augusto Lacerda Campos <leandrolcampos at yahoo.com.br>
Date: Sat, 2 Aug 2025 22:21:46 -0300
Subject: [PATCH] Enable all float math functions on the GPU

---
 libc/config/gpu/amdgpu/entrypoints.txt |  2 ++
 libc/config/gpu/nvptx/entrypoints.txt  |  2 ++
 libc/include/math.yaml                 | 12 ++++++++++++
 3 files changed, 16 insertions(+)

diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index e39819dd85b72..2f909e2e38026 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -314,6 +314,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.exp
     libc.src.math.exp10
     libc.src.math.exp10f
+    libc.src.math.exp10m1f
     libc.src.math.exp2
     libc.src.math.exp2f
     libc.src.math.exp2m1f
@@ -489,6 +490,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.tan
     libc.src.math.tanf
     libc.src.math.tanhf
+    libc.src.math.tanpif
     libc.src.math.tgamma
     libc.src.math.tgammaf
     libc.src.math.totalorder
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 26e3b1547c98a..9d0200eb6dbe2 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -314,6 +314,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.exp
     libc.src.math.exp10
     libc.src.math.exp10f
+    # libc.src.math.exp10m1f
     libc.src.math.exp2
     libc.src.math.exp2f
     libc.src.math.exp2m1f
@@ -490,6 +491,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.tan
     libc.src.math.tanf
     libc.src.math.tanhf
+    libc.src.math.tanpif
     libc.src.math.tgamma
     libc.src.math.tgammaf
     libc.src.math.totalorder
diff --git a/libc/include/math.yaml b/libc/include/math.yaml
index 007be235f4380..e8ac7ee5033db 100644
--- a/libc/include/math.yaml
+++ b/libc/include/math.yaml
@@ -283,6 +283,12 @@ functions:
     return_type: float
     arguments:
       - type: float
+  - name: cospif
+    standards:
+      - stdc
+    return_type: float
+    arguments:
+      - type: float
   - name: cospif16
     standards:
       - stdc
@@ -2453,6 +2459,12 @@ functions:
     arguments:
       - type: _Float16
     guard: LIBC_TYPES_HAS_FLOAT16
+  - name: sinpif
+    standards:
+      - stdc
+    return_type: float
+    arguments:
+      - type: float
   - name: sinpif16
     standards:
       - stdc



More information about the libc-commits mailing list