[libc-commits] [libc] 546c9b3 - [libc] Add math functions to AMD/NVPTX libm

Ethan Luis McDonough via libc-commits libc-commits at lists.llvm.org
Wed Jul 26 01:02:17 PDT 2023


Author: Ethan Luis McDonough
Date: 2023-07-26T03:02:24-05:00
New Revision: 546c9b3f6a5463460ea19b4722961aa36a191017

URL: https://github.com/llvm/llvm-project/commit/546c9b3f6a5463460ea19b4722961aa36a191017
DIFF: https://github.com/llvm/llvm-project/commit/546c9b3f6a5463460ea19b4722961aa36a191017.diff

LOG: [libc] Add math functions to AMD/NVPTX libm

Related to D152486.  The following functions are included in this revision: `acosf`, `acoshf`, `asinf`, `asinhf`, `atanf`, `atanhf`, `ceil`, `ceilf`, `copysign`, `copysignf`, `cos`, `cosf`, `cosh`, `coshf`, `exp10f`, `exp2f`, `expf`, `expm1f`, `fabs`, `fabsf`, `fdim`, `fdimf`, `floor`, `floorf`, `fma`, `fmaf`, `fmax`, `fmaxf`, `fmin`, `fminf`, `fmod`, `fmodf`, `frexp`, `frexpf`, `hypot`, `hypotf`, `ilogb`, `ilogbf`, `ldexp`, `ldexpf`, `llrint`, `llrintf`, `llround`, `llroundf`, `pow`, and `powf`.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D152603

Added: 
    libc/src/math/cosh.h
    libc/src/math/gpu/ceil.cpp
    libc/src/math/gpu/ceilf.cpp
    libc/src/math/gpu/copysign.cpp
    libc/src/math/gpu/copysignf.cpp
    libc/src/math/gpu/fabs.cpp
    libc/src/math/gpu/fabsf.cpp
    libc/src/math/gpu/floor.cpp
    libc/src/math/gpu/floorf.cpp
    libc/src/math/gpu/fma.cpp
    libc/src/math/gpu/fmaf.cpp
    libc/src/math/gpu/fmax.cpp
    libc/src/math/gpu/fmaxf.cpp
    libc/src/math/gpu/fmin.cpp
    libc/src/math/gpu/fminf.cpp
    libc/src/math/gpu/fmod.cpp
    libc/src/math/gpu/fmodf.cpp
    libc/src/math/gpu/frexp.cpp
    libc/src/math/gpu/frexpf.cpp
    libc/src/math/gpu/vendor/acosf.cpp
    libc/src/math/gpu/vendor/acoshf.cpp
    libc/src/math/gpu/vendor/asinf.cpp
    libc/src/math/gpu/vendor/asinhf.cpp
    libc/src/math/gpu/vendor/atanf.cpp
    libc/src/math/gpu/vendor/atanhf.cpp
    libc/src/math/gpu/vendor/cos.cpp
    libc/src/math/gpu/vendor/cosf.cpp
    libc/src/math/gpu/vendor/cosh.cpp
    libc/src/math/gpu/vendor/coshf.cpp
    libc/src/math/gpu/vendor/exp10f.cpp
    libc/src/math/gpu/vendor/exp2f.cpp
    libc/src/math/gpu/vendor/expf.cpp
    libc/src/math/gpu/vendor/expm1f.cpp
    libc/src/math/gpu/vendor/fdim.cpp
    libc/src/math/gpu/vendor/fdimf.cpp
    libc/src/math/gpu/vendor/hypot.cpp
    libc/src/math/gpu/vendor/hypotf.cpp
    libc/src/math/gpu/vendor/ilogb.cpp
    libc/src/math/gpu/vendor/ilogbf.cpp
    libc/src/math/gpu/vendor/ldexp.cpp
    libc/src/math/gpu/vendor/ldexpf.cpp
    libc/src/math/gpu/vendor/llrint.cpp
    libc/src/math/gpu/vendor/llrintf.cpp
    libc/src/math/gpu/vendor/llround.cpp
    libc/src/math/gpu/vendor/llroundf.cpp
    libc/src/math/gpu/vendor/pow.cpp
    libc/src/math/gpu/vendor/powf.cpp
    libc/src/math/pow.h
    libc/src/math/powf.h

Modified: 
    libc/config/gpu/entrypoints.txt
    libc/src/math/CMakeLists.txt
    libc/src/math/gpu/CMakeLists.txt
    libc/src/math/gpu/vendor/CMakeLists.txt
    libc/src/math/gpu/vendor/amdgpu/amdgpu.h
    libc/src/math/gpu/vendor/amdgpu/declarations.h
    libc/src/math/gpu/vendor/nvptx/declarations.h
    libc/src/math/gpu/vendor/nvptx/nvptx.h

Removed: 
    


################################################################################
diff  --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 6202e70f6570536..e0a15cbe89f2f96 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -102,8 +102,52 @@ set(TARGET_LIBC_ENTRYPOINTS
 
 set(TARGET_LIBM_ENTRYPOINTS
     # math.h entrypoints
+    libc.src.math.acosf
+    libc.src.math.acoshf
+    libc.src.math.asinf
+    libc.src.math.asinhf
+    libc.src.math.atanf
+    libc.src.math.atanhf
+    libc.src.math.ceil
+    libc.src.math.ceilf
+    libc.src.math.copysign
+    libc.src.math.copysignf
+    libc.src.math.cos
+    libc.src.math.cosf
+    libc.src.math.cosh
+    libc.src.math.coshf
+    libc.src.math.exp10f
+    libc.src.math.exp2f
+    libc.src.math.expf
+    libc.src.math.expm1f
+    libc.src.math.fabs
+    libc.src.math.fabsf
+    libc.src.math.fdim
+    libc.src.math.fdimf
+    libc.src.math.floor
+    libc.src.math.floorf
     libc.src.math.fma
     libc.src.math.fmaf
+    libc.src.math.fmax
+    libc.src.math.fmaxf
+    libc.src.math.fmin
+    libc.src.math.fminf
+    libc.src.math.fmod
+    libc.src.math.fmodf
+    libc.src.math.frexp
+    libc.src.math.frexpf
+    libc.src.math.hypot
+    libc.src.math.hypotf
+    libc.src.math.ilogb
+    libc.src.math.ilogbf
+    libc.src.math.ldexp
+    libc.src.math.ldexpf
+    libc.src.math.llrint
+    libc.src.math.llrintf
+    libc.src.math.llround
+    libc.src.math.llroundf
+    libc.src.math.pow
+    libc.src.math.powf
     libc.src.math.sin
     libc.src.math.round
     libc.src.math.roundf

diff  --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 6b3d056da481217..1de511e9155fd69 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -73,6 +73,7 @@ add_math_entrypoint_object(copysignl)
 
 add_math_entrypoint_object(cos)
 add_math_entrypoint_object(cosf)
+add_math_entrypoint_object(cosh)
 add_math_entrypoint_object(coshf)
 
 add_math_entrypoint_object(erff)
@@ -170,6 +171,9 @@ add_math_entrypoint_object(nextafter)
 add_math_entrypoint_object(nextafterf)
 add_math_entrypoint_object(nextafterl)
 
+add_math_entrypoint_object(pow)
+add_math_entrypoint_object(powf)
+
 add_math_entrypoint_object(remainder)
 add_math_entrypoint_object(remainderf)
 add_math_entrypoint_object(remainderl)

diff  --git a/libc/src/math/cosh.h b/libc/src/math/cosh.h
new file mode 100644
index 000000000000000..c7a911b79ac2dc5
--- /dev/null
+++ b/libc/src/math/cosh.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for cosh --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_COSH_H
+#define LLVM_LIBC_SRC_MATH_COSH_H
+
+namespace __llvm_libc {
+
+double cosh(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_COSH_H

diff  --git a/libc/src/math/gpu/CMakeLists.txt b/libc/src/math/gpu/CMakeLists.txt
index 775a58478c3d822..58b0f01f22a6d61 100644
--- a/libc/src/math/gpu/CMakeLists.txt
+++ b/libc/src/math/gpu/CMakeLists.txt
@@ -23,6 +23,186 @@ function(add_math_entrypoint_gpu_object name)
   )
 endfunction()
 
+add_math_entrypoint_gpu_object(
+  ceil
+  SRCS
+    ceil.cpp
+  HDRS
+    ../ceil.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  ceilf
+  SRCS
+    ceilf.cpp
+  HDRS
+    ../ceilf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  copysign
+  SRCS
+    copysign.cpp
+  HDRS
+    ../copysign.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  copysignf
+  SRCS
+    copysignf.cpp
+  HDRS
+    ../copysignf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  fabs
+  SRCS
+    fabs.cpp
+  HDRS
+    ../fabs.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  fabsf
+  SRCS
+    fabsf.cpp
+  HDRS
+    ../fabsf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  floor
+  SRCS
+    floor.cpp
+  HDRS
+    ../floor.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  floorf
+  SRCS
+    floorf.cpp
+  HDRS
+    ../floorf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  fma
+  SRCS
+    fma.cpp
+  HDRS
+    ../fma.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  fmaf
+  SRCS
+    fmaf.cpp
+  HDRS
+    ../fmaf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  fmax
+  SRCS
+    fmax.cpp
+  HDRS
+    ../fmax.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  fmaxf
+  SRCS
+    fmaxf.cpp
+  HDRS
+    ../fmaxf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  fmin
+  SRCS
+    fmin.cpp
+  HDRS
+    ../fmin.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  fminf
+  SRCS
+    fminf.cpp
+  HDRS
+    ../fminf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  fmod
+  SRCS
+    fmod.cpp
+  HDRS
+    ../fmod.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  fmodf
+  SRCS
+    fmodf.cpp
+  HDRS
+    ../fmodf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  frexp
+  SRCS
+    frexp.cpp
+  HDRS
+    ../frexp.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_math_entrypoint_gpu_object(
+  frexpf
+  SRCS
+    frexpf.cpp
+  HDRS
+    ../frexpf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
 add_math_entrypoint_gpu_object(
   round
   SRCS

diff  --git a/libc/src/math/gpu/ceil.cpp b/libc/src/math/gpu/ceil.cpp
new file mode 100644
index 000000000000000..1e84f7acd6a31b9
--- /dev/null
+++ b/libc/src/math/gpu/ceil.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the ceil function for GPU -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/ceil.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, ceil, (double x)) { return __builtin_ceil(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/ceilf.cpp b/libc/src/math/gpu/ceilf.cpp
new file mode 100644
index 000000000000000..4979116d47f81b2
--- /dev/null
+++ b/libc/src/math/gpu/ceilf.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the ceilf function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/ceilf.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, ceilf, (float x)) { return __builtin_ceilf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/copysign.cpp b/libc/src/math/gpu/copysign.cpp
new file mode 100644
index 000000000000000..b09c3e64cb5f14b
--- /dev/null
+++ b/libc/src/math/gpu/copysign.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the copysign function for GPU -------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/copysign.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, copysign, (double x, double y)) {
+  return __builtin_copysign(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/copysignf.cpp b/libc/src/math/gpu/copysignf.cpp
new file mode 100644
index 000000000000000..fe3f451c47a5901
--- /dev/null
+++ b/libc/src/math/gpu/copysignf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the copysignf function for GPU ------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/copysignf.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, copysignf, (float x, float y)) {
+  return __builtin_copysignf(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/fabs.cpp b/libc/src/math/gpu/fabs.cpp
new file mode 100644
index 000000000000000..d8b0a54867bf3f0
--- /dev/null
+++ b/libc/src/math/gpu/fabs.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the fabs function for GPU -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fabs.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, fabs, (double x)) { return __builtin_fabs(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/fabsf.cpp b/libc/src/math/gpu/fabsf.cpp
new file mode 100644
index 000000000000000..64d7058eaa485e0
--- /dev/null
+++ b/libc/src/math/gpu/fabsf.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the fabsf function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fabsf.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, fabsf, (float x)) { return __builtin_fabsf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/floor.cpp b/libc/src/math/gpu/floor.cpp
new file mode 100644
index 000000000000000..850c4ee6592ceb6
--- /dev/null
+++ b/libc/src/math/gpu/floor.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the floor function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/floor.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, floor, (double x)) { return __builtin_floor(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/floorf.cpp b/libc/src/math/gpu/floorf.cpp
new file mode 100644
index 000000000000000..22c8b731068d9d0
--- /dev/null
+++ b/libc/src/math/gpu/floorf.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation of the floorf function for GPU ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/floorf.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, floorf, (float x)) { return __builtin_floorf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/fma.cpp b/libc/src/math/gpu/fma.cpp
new file mode 100644
index 000000000000000..f3803af1ceb0bec
--- /dev/null
+++ b/libc/src/math/gpu/fma.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the fma function for GPU ------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fma.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, fma, (double x, double y, double z)) {
+  return __builtin_fma(x, y, z);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/fmaf.cpp b/libc/src/math/gpu/fmaf.cpp
new file mode 100644
index 000000000000000..48b52a84537e230
--- /dev/null
+++ b/libc/src/math/gpu/fmaf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the fmaf function for GPU -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fmaf.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, fmaf, (float x, float y, float z)) {
+  return __builtin_fmaf(x, y, z);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/fmax.cpp b/libc/src/math/gpu/fmax.cpp
new file mode 100644
index 000000000000000..f3c255f61c09ee4
--- /dev/null
+++ b/libc/src/math/gpu/fmax.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the fmax function for GPU -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fmax.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, fmax, (double x, double y)) {
+  return __builtin_fmax(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/fmaxf.cpp b/libc/src/math/gpu/fmaxf.cpp
new file mode 100644
index 000000000000000..f540b4c8a11c15c
--- /dev/null
+++ b/libc/src/math/gpu/fmaxf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the fmaxf function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fmaxf.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, fmaxf, (float x, float y)) {
+  return __builtin_fmaxf(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/fmin.cpp b/libc/src/math/gpu/fmin.cpp
new file mode 100644
index 000000000000000..d6e9859d7810efa
--- /dev/null
+++ b/libc/src/math/gpu/fmin.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the fmin function for GPU -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fmin.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, fmin, (double x, double y)) {
+  return __builtin_fmin(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/fminf.cpp b/libc/src/math/gpu/fminf.cpp
new file mode 100644
index 000000000000000..67b1862cdd4fd92
--- /dev/null
+++ b/libc/src/math/gpu/fminf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the fminf function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fminf.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, fminf, (float x, float y)) {
+  return __builtin_fminf(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/fmod.cpp b/libc/src/math/gpu/fmod.cpp
new file mode 100644
index 000000000000000..2ae5142722671ae
--- /dev/null
+++ b/libc/src/math/gpu/fmod.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the fmod function for GPU -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fmod.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, fmod, (double x, double y)) {
+  return __builtin_fmod(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/fmodf.cpp b/libc/src/math/gpu/fmodf.cpp
new file mode 100644
index 000000000000000..ad1db4906e3bc82
--- /dev/null
+++ b/libc/src/math/gpu/fmodf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the fmodf function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fmodf.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, fmodf, (float x, float y)) {
+  return __builtin_fmodf(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/frexp.cpp b/libc/src/math/gpu/frexp.cpp
new file mode 100644
index 000000000000000..eaaf1753a433a80
--- /dev/null
+++ b/libc/src/math/gpu/frexp.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the frexp function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/frexp.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, frexp, (double x, int *p)) {
+  return __builtin_frexp(x, p);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/frexpf.cpp b/libc/src/math/gpu/frexpf.cpp
new file mode 100644
index 000000000000000..b600f650da00c2b
--- /dev/null
+++ b/libc/src/math/gpu/frexpf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the frexpf function for GPU ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/frexpf.h"
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, frexpf, (float x, int *p)) {
+  return __builtin_frexpf(x, p);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/CMakeLists.txt b/libc/src/math/gpu/vendor/CMakeLists.txt
index 3783c005aba85f7..17234fe94a9e286 100644
--- a/libc/src/math/gpu/vendor/CMakeLists.txt
+++ b/libc/src/math/gpu/vendor/CMakeLists.txt
@@ -29,6 +29,304 @@ endif()
 # will link in identity metadata from both libraries. This silences the warning.
 list(APPEND bitcode_link_flags "-Wno-linker-warnings")
 
+add_entrypoint_object(
+  acosf
+  SRCS
+    acosf.cpp
+  HDRS
+    ../../acosf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  acoshf
+  SRCS
+    acoshf.cpp
+  HDRS
+    ../../acoshf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  asinf
+  SRCS
+    asinf.cpp
+  HDRS
+    ../../asinf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  asinhf
+  SRCS
+    asinhf.cpp
+  HDRS
+    ../../asinhf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  atanf
+  SRCS
+    atanf.cpp
+  HDRS
+    ../../atanf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  atanhf
+  SRCS
+    atanhf.cpp
+  HDRS
+    ../../atanhf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  cos
+  SRCS
+    cos.cpp
+  HDRS
+    ../../cos.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_entrypoint_object(
+  cosf
+  SRCS
+    cosf.cpp
+  HDRS
+    ../../cosf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_entrypoint_object(
+  cosh
+  SRCS
+    cosh.cpp
+  HDRS
+    ../../cosh.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  coshf
+  SRCS
+    coshf.cpp
+  HDRS
+    ../../coshf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  exp10f
+  SRCS
+    exp10f.cpp
+  HDRS
+    ../../exp10f.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  exp2f
+  SRCS
+    exp2f.cpp
+  HDRS
+    ../../exp2f.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  expf
+  SRCS
+    expf.cpp
+  HDRS
+    ../../expf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  expm1f
+  SRCS
+    expm1f.cpp
+  HDRS
+    ../../expm1f.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  fdim
+  SRCS
+    fdim.cpp
+  HDRS
+    ../../fdim.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  fdimf
+  SRCS
+    fdimf.cpp
+  HDRS
+    ../../fdimf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  hypot
+  SRCS
+    hypot.cpp
+  HDRS
+    ../../hypot.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  hypotf
+  SRCS
+    hypotf.cpp
+  HDRS
+    ../../hypotf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  ilogb
+  SRCS
+    ilogb.cpp
+  HDRS
+    ../../ilogb.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  ilogbf
+  SRCS
+    ilogbf.cpp
+  HDRS
+    ../../ilogbf.h
+  COMPILE_OPTIONS
+    ${bitcode_link_flags}
+    -O2
+)
+
+add_entrypoint_object(
+  ldexp
+  SRCS
+    ldexp.cpp
+  HDRS
+    ../../ldexp.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_entrypoint_object(
+  ldexpf
+  SRCS
+    ldexpf.cpp
+  HDRS
+    ../../ldexpf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_entrypoint_object(
+  llrint
+  SRCS
+    llrint.cpp
+  HDRS
+    ../../llrint.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_entrypoint_object(
+  llrintf
+  SRCS
+    llrintf.cpp
+  HDRS
+    ../../llrintf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_entrypoint_object(
+  llround
+  SRCS
+    llround.cpp
+  HDRS
+    ../../llround.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_entrypoint_object(
+  llroundf
+  SRCS
+    llroundf.cpp
+  HDRS
+    ../../llroundf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_entrypoint_object(
+  pow
+  SRCS
+    pow.cpp
+  HDRS
+    ../../pow.h
+  COMPILE_OPTIONS
+    -O2
+)
+
+add_entrypoint_object(
+  powf
+  SRCS
+    powf.cpp
+  HDRS
+    ../../powf.h
+  COMPILE_OPTIONS
+    -O2
+)
+
 add_entrypoint_object(
   sin
   SRCS

diff  --git a/libc/src/math/gpu/vendor/acosf.cpp b/libc/src/math/gpu/vendor/acosf.cpp
new file mode 100644
index 000000000000000..7ae0811a3c3b5f6
--- /dev/null
+++ b/libc/src/math/gpu/vendor/acosf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the acosf function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/acosf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, acosf, (float x)) { return internal::acosf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/acoshf.cpp b/libc/src/math/gpu/vendor/acoshf.cpp
new file mode 100644
index 000000000000000..fa0dd58cde51de5
--- /dev/null
+++ b/libc/src/math/gpu/vendor/acoshf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the acoshf function for GPU ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/acoshf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, acoshf, (float x)) { return internal::acoshf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
index 88b727f1047168d..659f47c6face2c4 100644
--- a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
+++ b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
@@ -16,7 +16,34 @@
 
 namespace __llvm_libc {
 namespace internal {
-
+LIBC_INLINE float acosf(float x) { return __ocml_acos_f32(x); }
+LIBC_INLINE float acoshf(float x) { return __ocml_acosh_f32(x); }
+LIBC_INLINE float asinf(float x) { return __ocml_asin_f32(x); }
+LIBC_INLINE float asinhf(float x) { return __ocml_asinh_f32(x); }
+LIBC_INLINE float atanf(float x) { return __ocml_atan_f32(x); }
+LIBC_INLINE float atanhf(float x) { return __ocml_atanh_f32(x); }
+LIBC_INLINE double cos(double x) { return __ocml_cos_f64(x); }
+LIBC_INLINE float cosf(float x) { return __ocml_cos_f32(x); }
+LIBC_INLINE double cosh(double x) { return __ocml_cosh_f64(x); }
+LIBC_INLINE float coshf(float x) { return __ocml_cosh_f32(x); }
+LIBC_INLINE float expf(float x) { return __builtin_expf(x); }
+LIBC_INLINE float exp2f(float x) { return __builtin_exp2f(x); }
+LIBC_INLINE float exp10f(float x) { return __ocml_exp10_f32(x); }
+LIBC_INLINE float expm1f(float x) { return __ocml_expm1_f32(x); }
+LIBC_INLINE double fdim(double x, double y) { return __ocml_fdim_f64(x, y); }
+LIBC_INLINE float fdimf(float x, float y) { return __ocml_fdim_f32(x, y); }
+LIBC_INLINE double hypot(double x, double y) { return __ocml_hypot_f64(x, y); }
+LIBC_INLINE float hypotf(float x, float y) { return __ocml_hypot_f32(x, y); }
+LIBC_INLINE int ilogb(double x) { return __ocml_ilogb_f64(x); }
+LIBC_INLINE int ilogbf(float x) { return __ocml_ilogb_f32(x); }
+LIBC_INLINE double ldexp(double x, int i) { return __builtin_ldexp(x, i); }
+LIBC_INLINE float ldexpf(float x, int i) { return __builtin_ldexpf(x, i); }
+LIBC_INLINE long long llrint(double x) { return __builtin_rint(x); }
+LIBC_INLINE long long llrintf(float x) { return __builtin_rintf(x); }
+LIBC_INLINE long long llround(double x) { return __builtin_round(x); }
+LIBC_INLINE long long llroundf(float x) { return __builtin_roundf(x); }
+LIBC_INLINE double pow(double x, double y) { return __ocml_pow_f64(x, y); }
+LIBC_INLINE float powf(float x, float y) { return __ocml_pow_f32(x, y); }
 LIBC_INLINE double sin(double x) { return __ocml_sin_f64(x); }
 
 } // namespace internal

diff  --git a/libc/src/math/gpu/vendor/amdgpu/declarations.h b/libc/src/math/gpu/vendor/amdgpu/declarations.h
index 41bc0c7a35d900f..76c0e0f032051f3 100644
--- a/libc/src/math/gpu/vendor/amdgpu/declarations.h
+++ b/libc/src/math/gpu/vendor/amdgpu/declarations.h
@@ -12,6 +12,34 @@
 namespace __llvm_libc {
 
 extern "C" {
+float __ocml_acos_f32(float);
+float __ocml_acosh_f32(float);
+float __ocml_asin_f32(float);
+float __ocml_asinh_f32(float);
+float __ocml_atan_f32(float);
+float __ocml_atanh_f32(float);
+float __ocml_cos_f32(float);
+double __ocml_cos_f64(double);
+float __ocml_cosh_f32(float);
+double __ocml_cosh_f64(double);
+float __ocml_exp_f32(float);
+float __ocml_exp2_f32(float);
+float __ocml_exp10_f32(float);
+float __ocml_expm1_f32(float);
+float __ocml_fdim_f32(float, float);
+double __ocml_fdim_f64(double, double);
+double __ocml_hypot_f64(double, double);
+float __ocml_hypot_f32(float, float);
+int __ocml_ilogb_f64(double);
+int __ocml_ilogb_f32(float);
+float __ocml_ldexp_f32(float, int);
+double __ocml_ldexp_f64(double, int);
+float __ocml_pow_f32(float, float);
+double __ocml_pow_f64(double, double);
+double __ocml_rint_f64(double);
+float __ocml_rint_f32(float);
+double __ocml_round_f64(double);
+float __ocml_round_f32(float);
 double __ocml_sin_f64(double);
 }
 

diff  --git a/libc/src/math/gpu/vendor/asinf.cpp b/libc/src/math/gpu/vendor/asinf.cpp
new file mode 100644
index 000000000000000..9a9ffb23a7cbee3
--- /dev/null
+++ b/libc/src/math/gpu/vendor/asinf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the asinf function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/asinf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, asinf, (float x)) { return internal::asinf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/asinhf.cpp b/libc/src/math/gpu/vendor/asinhf.cpp
new file mode 100644
index 000000000000000..7d1d7e8709e1107
--- /dev/null
+++ b/libc/src/math/gpu/vendor/asinhf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the asinhf function for GPU ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/asinhf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, asinhf, (float x)) { return internal::asinhf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/atanf.cpp b/libc/src/math/gpu/vendor/atanf.cpp
new file mode 100644
index 000000000000000..7193d8cb2a37349
--- /dev/null
+++ b/libc/src/math/gpu/vendor/atanf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the atanf function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/atanf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, atanf, (float x)) { return internal::atanf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/atanhf.cpp b/libc/src/math/gpu/vendor/atanhf.cpp
new file mode 100644
index 000000000000000..b044a735f8777d3
--- /dev/null
+++ b/libc/src/math/gpu/vendor/atanhf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the atanhf function for GPU ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/atanhf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, atanhf, (float x)) { return internal::atanhf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/cos.cpp b/libc/src/math/gpu/vendor/cos.cpp
new file mode 100644
index 000000000000000..a3e2d65b8f98c46
--- /dev/null
+++ b/libc/src/math/gpu/vendor/cos.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the cos function for GPU ------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/cos.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, cos, (double x)) { return internal::cos(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/cosf.cpp b/libc/src/math/gpu/vendor/cosf.cpp
new file mode 100644
index 000000000000000..3ce8fa6361d6eb8
--- /dev/null
+++ b/libc/src/math/gpu/vendor/cosf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the cosf function for GPU -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/cosf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, cosf, (float x)) { return internal::cosf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/cosh.cpp b/libc/src/math/gpu/vendor/cosh.cpp
new file mode 100644
index 000000000000000..3dc5c2b10cbcadb
--- /dev/null
+++ b/libc/src/math/gpu/vendor/cosh.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the cosh function for GPU -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/cosh.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, cosh, (double x)) { return internal::cosh(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/coshf.cpp b/libc/src/math/gpu/vendor/coshf.cpp
new file mode 100644
index 000000000000000..c2933ecff94257c
--- /dev/null
+++ b/libc/src/math/gpu/vendor/coshf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the coshf function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/coshf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, coshf, (float x)) { return internal::coshf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/exp10f.cpp b/libc/src/math/gpu/vendor/exp10f.cpp
new file mode 100644
index 000000000000000..05b753583cd7da0
--- /dev/null
+++ b/libc/src/math/gpu/vendor/exp10f.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the exp10f function for GPU ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/exp10f.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, exp10f, (float x)) { return internal::exp10f(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/exp2f.cpp b/libc/src/math/gpu/vendor/exp2f.cpp
new file mode 100644
index 000000000000000..818c3801b9f11bc
--- /dev/null
+++ b/libc/src/math/gpu/vendor/exp2f.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the exp2f function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/exp2f.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, exp2f, (float x)) { return internal::exp2f(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/expf.cpp b/libc/src/math/gpu/vendor/expf.cpp
new file mode 100644
index 000000000000000..e243385e43fd8e2
--- /dev/null
+++ b/libc/src/math/gpu/vendor/expf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the expf function for GPU -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/expf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, expf, (float x)) { return internal::expf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/expm1f.cpp b/libc/src/math/gpu/vendor/expm1f.cpp
new file mode 100644
index 000000000000000..062e4a760c7c3a4
--- /dev/null
+++ b/libc/src/math/gpu/vendor/expm1f.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the expm1f function for GPU ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/expm1f.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, expm1f, (float x)) { return internal::expm1f(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/fdim.cpp b/libc/src/math/gpu/vendor/fdim.cpp
new file mode 100644
index 000000000000000..b06787cb0865c18
--- /dev/null
+++ b/libc/src/math/gpu/vendor/fdim.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the fdim function for GPU -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fdim.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, fdim, (double x, double y)) {
+  return internal::fdim(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/fdimf.cpp b/libc/src/math/gpu/vendor/fdimf.cpp
new file mode 100644
index 000000000000000..a675d484238c569
--- /dev/null
+++ b/libc/src/math/gpu/vendor/fdimf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the fdimf function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/fdimf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, fdimf, (float x, float y)) {
+  return internal::fdimf(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/hypot.cpp b/libc/src/math/gpu/vendor/hypot.cpp
new file mode 100644
index 000000000000000..5bac6fc76f8ddfc
--- /dev/null
+++ b/libc/src/math/gpu/vendor/hypot.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the hypot function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/hypot.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, hypot, (double x, double y)) {
+  return internal::hypot(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/hypotf.cpp b/libc/src/math/gpu/vendor/hypotf.cpp
new file mode 100644
index 000000000000000..34ce290e37fd9a4
--- /dev/null
+++ b/libc/src/math/gpu/vendor/hypotf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the hypotf function for GPU ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/hypotf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, hypotf, (float x, float y)) {
+  return internal::hypotf(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/ilogb.cpp b/libc/src/math/gpu/vendor/ilogb.cpp
new file mode 100644
index 000000000000000..ea41099c35c0e01
--- /dev/null
+++ b/libc/src/math/gpu/vendor/ilogb.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the ilogb function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/ilogb.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(int, ilogb, (double x)) { return internal::ilogb(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/ilogbf.cpp b/libc/src/math/gpu/vendor/ilogbf.cpp
new file mode 100644
index 000000000000000..e15f4e198c8d7f9
--- /dev/null
+++ b/libc/src/math/gpu/vendor/ilogbf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the ilogbf function for GPU ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/ilogbf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(int, ilogbf, (float x)) { return internal::ilogbf(x); }
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/ldexp.cpp b/libc/src/math/gpu/vendor/ldexp.cpp
new file mode 100644
index 000000000000000..d9988fac0a45dc9
--- /dev/null
+++ b/libc/src/math/gpu/vendor/ldexp.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the ldexp function for GPU ----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/ldexp.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, ldexp, (double x, int y)) {
+  return internal::ldexp(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/ldexpf.cpp b/libc/src/math/gpu/vendor/ldexpf.cpp
new file mode 100644
index 000000000000000..bdd40a6a217c348
--- /dev/null
+++ b/libc/src/math/gpu/vendor/ldexpf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the ldexpf function for GPU ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/ldexpf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, ldexpf, (float x, int y)) {
+  return internal::ldexpf(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/llrint.cpp b/libc/src/math/gpu/vendor/llrint.cpp
new file mode 100644
index 000000000000000..064d2775460edc1
--- /dev/null
+++ b/libc/src/math/gpu/vendor/llrint.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the llrint function for GPU ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/llrint.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(long long, llrint, (double x)) {
+  return internal::llrint(x);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/llrintf.cpp b/libc/src/math/gpu/vendor/llrintf.cpp
new file mode 100644
index 000000000000000..d1befb67c9788b0
--- /dev/null
+++ b/libc/src/math/gpu/vendor/llrintf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the llrintf function for GPU --------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/llrintf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(long long, llrintf, (float x)) {
+  return internal::llrintf(x);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/llround.cpp b/libc/src/math/gpu/vendor/llround.cpp
new file mode 100644
index 000000000000000..51b8370759e9805
--- /dev/null
+++ b/libc/src/math/gpu/vendor/llround.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the llround function for GPU --------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/llround.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(long long, llround, (double x)) {
+  return internal::llround(x);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/llroundf.cpp b/libc/src/math/gpu/vendor/llroundf.cpp
new file mode 100644
index 000000000000000..0131d278020029a
--- /dev/null
+++ b/libc/src/math/gpu/vendor/llroundf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the llroundf function for GPU -------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/llroundf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(long long, llroundf, (float x)) {
+  return internal::llroundf(x);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/vendor/nvptx/declarations.h
index 2faba835650a51b..13b87699989673c 100644
--- a/libc/src/math/gpu/vendor/nvptx/declarations.h
+++ b/libc/src/math/gpu/vendor/nvptx/declarations.h
@@ -12,6 +12,34 @@
 namespace __llvm_libc {
 
 extern "C" {
+float __nv_acosf(float);
+float __nv_acoshf(float);
+float __nv_asinf(float);
+float __nv_asinhf(float);
+float __nv_atanf(float);
+float __nv_atanhf(float);
+double __nv_cos(double);
+float __nv_cosf(float);
+double __nv_cosh(double);
+float __nv_coshf(float);
+float __nv_expf(float);
+float __nv_exp2f(float);
+float __nv_exp10f(float);
+float __nv_expm1f(float);
+double __nv_fdim(double, double);
+float __nv_fdimf(float, float);
+double __nv_hypot(double, double);
+float __nv_hypotf(float, float);
+int __nv_ilogb(double);
+int __nv_ilogbf(float);
+double __nv_ldexp(double, int);
+float __nv_ldexpf(float, int);
+long long __nv_llrint(double);
+long long __nv_llrintf(float);
+long long __nv_llround(double);
+long long __nv_llroundf(float);
+double __nv_pow(double, double);
+float __nv_powf(float, float);
 double __nv_sin(double);
 }
 

diff  --git a/libc/src/math/gpu/vendor/nvptx/nvptx.h b/libc/src/math/gpu/vendor/nvptx/nvptx.h
index 718ac38a96e52e4..4da0dd0d204af4a 100644
--- a/libc/src/math/gpu/vendor/nvptx/nvptx.h
+++ b/libc/src/math/gpu/vendor/nvptx/nvptx.h
@@ -15,7 +15,34 @@
 
 namespace __llvm_libc {
 namespace internal {
-
+LIBC_INLINE float acosf(float x) { return __nv_acosf(x); }
+LIBC_INLINE float acoshf(float x) { return __nv_acoshf(x); }
+LIBC_INLINE float asinf(float x) { return __nv_asinf(x); }
+LIBC_INLINE float asinhf(float x) { return __nv_asinhf(x); }
+LIBC_INLINE float atanf(float x) { return __nv_atanf(x); }
+LIBC_INLINE float atanhf(float x) { return __nv_atanhf(x); }
+LIBC_INLINE double cos(double x) { return __nv_cos(x); }
+LIBC_INLINE float cosf(float x) { return __nv_cosf(x); }
+LIBC_INLINE double cosh(double x) { return __nv_cosh(x); }
+LIBC_INLINE float coshf(float x) { return __nv_coshf(x); }
+LIBC_INLINE float expf(float x) { return __nv_expf(x); }
+LIBC_INLINE float exp2f(float x) { return __nv_exp2f(x); }
+LIBC_INLINE float exp10f(float x) { return __nv_exp10f(x); }
+LIBC_INLINE float expm1f(float x) { return __nv_expm1f(x); }
+LIBC_INLINE double fdim(double x, double y) { return __nv_fdim(x, y); }
+LIBC_INLINE float fdimf(float x, float y) { return __nv_fdimf(x, y); }
+LIBC_INLINE double hypot(double x, double y) { return __nv_hypot(x, y); }
+LIBC_INLINE float hypotf(float x, float y) { return __nv_hypotf(x, y); }
+LIBC_INLINE int ilogb(double x) { return __nv_ilogb(x); }
+LIBC_INLINE int ilogbf(float x) { return __nv_ilogbf(x); }
+LIBC_INLINE double ldexp(double x, int i) { return __nv_ldexp(x, i); }
+LIBC_INLINE float ldexpf(float x, int i) { return __nv_ldexpf(x, i); }
+LIBC_INLINE long long llrint(double x) { return __nv_llrint(x); }
+LIBC_INLINE long long llrintf(float x) { return __nv_llrintf(x); }
+LIBC_INLINE long long llround(double x) { return __nv_llround(x); }
+LIBC_INLINE long long llroundf(float x) { return __nv_llroundf(x); }
+LIBC_INLINE double pow(double x, double y) { return __nv_pow(x, y); }
+LIBC_INLINE float powf(float x, float y) { return __nv_powf(x, y); }
 LIBC_INLINE double sin(double x) { return __nv_sin(x); }
 
 } // namespace internal

diff  --git a/libc/src/math/gpu/vendor/pow.cpp b/libc/src/math/gpu/vendor/pow.cpp
new file mode 100644
index 000000000000000..7945bc096e6656a
--- /dev/null
+++ b/libc/src/math/gpu/vendor/pow.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the pow function for GPU ------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/pow.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, pow, (double x, double y)) {
+  return internal::pow(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/gpu/vendor/powf.cpp b/libc/src/math/gpu/vendor/powf.cpp
new file mode 100644
index 000000000000000..2fd2dcda6e465e7
--- /dev/null
+++ b/libc/src/math/gpu/vendor/powf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the powf function for GPU -----------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/powf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, powf, (float x, float y)) {
+  return internal::powf(x, y);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/math/pow.h b/libc/src/math/pow.h
new file mode 100644
index 000000000000000..26fed175787a92e
--- /dev/null
+++ b/libc/src/math/pow.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for pow ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_POW_H
+#define LLVM_LIBC_SRC_MATH_POW_H
+
+namespace __llvm_libc {
+
+double pow(double x, double y);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_POW_H

diff  --git a/libc/src/math/powf.h b/libc/src/math/powf.h
new file mode 100644
index 000000000000000..ec2d67b8fd639b2
--- /dev/null
+++ b/libc/src/math/powf.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for powf --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_POWF_H
+#define LLVM_LIBC_SRC_MATH_POWF_H
+
+namespace __llvm_libc {
+
+float powf(float x, float y);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_POWF_H


        


More information about the libc-commits mailing list