[clang-tools-extra] [libc][libm][GPU] Add missing vendor entrypoints to the GPU version of `libm` (PR #66034)
Anton Rydahl via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 19 10:43:24 PDT 2023
https://github.com/AntonRydahl updated https://github.com/llvm/llvm-project/pull/66034
>From 7a357059d3ca78afcb02e33a6afce225029a3836 Mon Sep 17 00:00:00 2001
From: antonrydahl <rydahl2610 at gmail.com>
Date: Mon, 11 Sep 2023 17:06:41 -0700
Subject: [PATCH 1/6] [libc][libm][GPU] Add missing vendor entrypoints to the
GPU version of `libm`
There are a number of entry-points in `libm` for which no target-agnostic implementations exist and the built-ins do not lower correctly on either AMDGPU or NVPTX targets. This patch adds the vendor entry-points as a temporary solution.
---
libc/config/gpu/entrypoints.txt | 37 ++++-
libc/src/math/CMakeLists.txt | 15 ++
libc/src/math/acos.h | 18 +++
libc/src/math/acosh.h | 18 +++
libc/src/math/asin.h | 18 +++
libc/src/math/asinh.h | 18 +++
libc/src/math/atan.h | 18 +++
libc/src/math/atan2.h | 18 +++
libc/src/math/atan2f.h | 18 +++
libc/src/math/atanh.h | 18 +++
libc/src/math/erf.h | 18 +++
libc/src/math/expm1.h | 18 +++
libc/src/math/gpu/vendor/CMakeLists.txt | 143 ++++++++++++++++++
libc/src/math/gpu/vendor/acos.cpp | 18 +++
libc/src/math/gpu/vendor/acosh.cpp | 18 +++
libc/src/math/gpu/vendor/amdgpu/amdgpu.h | 25 +++
.../src/math/gpu/vendor/amdgpu/declarations.h | 34 ++++-
libc/src/math/gpu/vendor/asin.cpp | 18 +++
libc/src/math/gpu/vendor/asinh.cpp | 18 +++
libc/src/math/gpu/vendor/atan.cpp | 18 +++
libc/src/math/gpu/vendor/atan2.cpp | 20 +++
libc/src/math/gpu/vendor/atan2f.cpp | 21 +++
libc/src/math/gpu/vendor/atanh.cpp | 18 +++
libc/src/math/gpu/vendor/erf.cpp | 18 +++
libc/src/math/gpu/vendor/erff.cpp | 18 +++
libc/src/math/gpu/vendor/exp.cpp | 18 +++
libc/src/math/gpu/vendor/exp10.cpp | 18 +++
libc/src/math/gpu/vendor/exp2.cpp | 18 +++
libc/src/math/gpu/vendor/expm1.cpp | 18 +++
libc/src/math/gpu/vendor/log.cpp | 18 +++
libc/src/math/gpu/vendor/log10.cpp | 18 +++
libc/src/math/gpu/vendor/log10f.cpp | 19 +++
libc/src/math/gpu/vendor/log1p.cpp | 18 +++
libc/src/math/gpu/vendor/log1pf.cpp | 18 +++
libc/src/math/gpu/vendor/log2.cpp | 18 +++
libc/src/math/gpu/vendor/log2f.cpp | 18 +++
libc/src/math/gpu/vendor/logb.cpp | 18 +++
libc/src/math/gpu/vendor/logbf.cpp | 19 +++
libc/src/math/gpu/vendor/logf.cpp | 18 +++
libc/src/math/gpu/vendor/lrint.cpp | 18 +++
libc/src/math/gpu/vendor/lrintf.cpp | 18 +++
libc/src/math/gpu/vendor/lround.cpp | 18 +++
libc/src/math/gpu/vendor/lroundf.cpp | 20 +++
libc/src/math/gpu/vendor/nvptx/declarations.h | 25 +++
libc/src/math/gpu/vendor/nvptx/nvptx.h | 25 +++
libc/src/math/gpu/vendor/tgamma.cpp | 18 +++
libc/src/math/gpu/vendor/tgammaf.cpp | 18 +++
libc/src/math/sincos.h | 18 +++
libc/src/math/tgamma.h | 18 +++
libc/src/math/tgammaf.h | 18 +++
50 files changed, 1081 insertions(+), 6 deletions(-)
create mode 100644 libc/src/math/acos.h
create mode 100644 libc/src/math/acosh.h
create mode 100644 libc/src/math/asin.h
create mode 100644 libc/src/math/asinh.h
create mode 100644 libc/src/math/atan.h
create mode 100644 libc/src/math/atan2.h
create mode 100644 libc/src/math/atan2f.h
create mode 100644 libc/src/math/atanh.h
create mode 100644 libc/src/math/erf.h
create mode 100644 libc/src/math/expm1.h
create mode 100644 libc/src/math/gpu/vendor/acos.cpp
create mode 100644 libc/src/math/gpu/vendor/acosh.cpp
create mode 100644 libc/src/math/gpu/vendor/asin.cpp
create mode 100644 libc/src/math/gpu/vendor/asinh.cpp
create mode 100644 libc/src/math/gpu/vendor/atan.cpp
create mode 100644 libc/src/math/gpu/vendor/atan2.cpp
create mode 100644 libc/src/math/gpu/vendor/atan2f.cpp
create mode 100644 libc/src/math/gpu/vendor/atanh.cpp
create mode 100644 libc/src/math/gpu/vendor/erf.cpp
create mode 100644 libc/src/math/gpu/vendor/erff.cpp
create mode 100644 libc/src/math/gpu/vendor/exp.cpp
create mode 100644 libc/src/math/gpu/vendor/exp10.cpp
create mode 100644 libc/src/math/gpu/vendor/exp2.cpp
create mode 100644 libc/src/math/gpu/vendor/expm1.cpp
create mode 100644 libc/src/math/gpu/vendor/log.cpp
create mode 100644 libc/src/math/gpu/vendor/log10.cpp
create mode 100644 libc/src/math/gpu/vendor/log10f.cpp
create mode 100644 libc/src/math/gpu/vendor/log1p.cpp
create mode 100644 libc/src/math/gpu/vendor/log1pf.cpp
create mode 100644 libc/src/math/gpu/vendor/log2.cpp
create mode 100644 libc/src/math/gpu/vendor/log2f.cpp
create mode 100644 libc/src/math/gpu/vendor/logb.cpp
create mode 100644 libc/src/math/gpu/vendor/logbf.cpp
create mode 100644 libc/src/math/gpu/vendor/logf.cpp
create mode 100644 libc/src/math/gpu/vendor/lrint.cpp
create mode 100644 libc/src/math/gpu/vendor/lrintf.cpp
create mode 100644 libc/src/math/gpu/vendor/lround.cpp
create mode 100644 libc/src/math/gpu/vendor/lroundf.cpp
create mode 100644 libc/src/math/gpu/vendor/tgamma.cpp
create mode 100644 libc/src/math/gpu/vendor/tgammaf.cpp
create mode 100644 libc/src/math/sincos.h
create mode 100644 libc/src/math/tgamma.h
create mode 100644 libc/src/math/tgammaf.h
diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 0e314c60870c6ae..730f76cbd6fbb9c 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -113,11 +113,19 @@ set(TARGET_LIBC_ENTRYPOINTS
set(TARGET_LIBM_ENTRYPOINTS
# math.h entrypoints
+ libc.src.math.acos
libc.src.math.acosf
+ libc.src.math.acosh
libc.src.math.acoshf
+ libc.src.math.asin
libc.src.math.asinf
+ libc.src.math.asinh
libc.src.math.asinhf
+ libc.src.math.atan
libc.src.math.atanf
+ libc.src.math.atan2
+ libc.src.math.atan2f
+ libc.src.math.atanh
libc.src.math.atanhf
libc.src.math.ceil
libc.src.math.ceilf
@@ -127,9 +135,15 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.cosf
libc.src.math.cosh
libc.src.math.coshf
+ libc.src.math.erf
+ libc.src.math.erff
+ libc.src.math.exp10
libc.src.math.exp10f
+ libc.src.math.exp2
libc.src.math.exp2f
+ libc.src.math.exp
libc.src.math.expf
+ libc.src.math.expm1
libc.src.math.expm1f
libc.src.math.fabs
libc.src.math.fabsf
@@ -157,15 +171,26 @@ set(TARGET_LIBM_ENTRYPOINTS
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.log10
+ libc.src.math.log10f
+ libc.src.math.log1p
+ libc.src.math.log1pf
+ libc.src.math.log2
+ libc.src.math.log2f
+ libc.src.math.log
+ libc.src.math.logf
+ libc.src.math.lrint
+ libc.src.math.lrintf
+ libc.src.math.lround
+ libc.src.math.lroundf
libc.src.math.modf
libc.src.math.modff
libc.src.math.nearbyint
libc.src.math.nearbyintf
libc.src.math.nextafter
libc.src.math.nextafterf
+ libc.src.math.pow
+ libc.src.math.powf
libc.src.math.remainder
libc.src.math.remainderf
libc.src.math.remquo
@@ -176,6 +201,10 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.roundf
libc.src.math.scalbn
libc.src.math.scalbnf
+ libc.src.math.sin
+ libc.src.math.sinf
+ libc.src.math.sincos
+ libc.src.math.sincosf
libc.src.math.sinh
libc.src.math.sinhf
libc.src.math.sqrt
@@ -184,6 +213,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.tanf
libc.src.math.tanh
libc.src.math.tanhf
+ libc.src.math.tgamma
+ libc.src.math.tgammaf
libc.src.math.trunc
libc.src.math.truncf
)
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 8b2021cac8239fe..f1f72714981a9e5 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -54,14 +54,23 @@ function(add_math_entrypoint_object name)
)
endfunction()
+add_math_entrypoint_object(acos)
add_math_entrypoint_object(acosf)
+add_math_entrypoint_object(acosh)
add_math_entrypoint_object(acoshf)
+add_math_entrypoint_object(asin)
add_math_entrypoint_object(asinf)
+add_math_entrypoint_object(asinh)
add_math_entrypoint_object(asinhf)
+add_math_entrypoint_object(atan)
add_math_entrypoint_object(atanf)
+add_math_entrypoint_object(atan2)
+add_math_entrypoint_object(atan2f)
+
+add_math_entrypoint_object(atanh)
add_math_entrypoint_object(atanhf)
add_math_entrypoint_object(ceil)
@@ -77,6 +86,7 @@ add_math_entrypoint_object(cosf)
add_math_entrypoint_object(cosh)
add_math_entrypoint_object(coshf)
+add_math_entrypoint_object(erf)
add_math_entrypoint_object(erff)
add_math_entrypoint_object(exp)
@@ -88,6 +98,7 @@ add_math_entrypoint_object(exp2f)
add_math_entrypoint_object(exp10)
add_math_entrypoint_object(exp10f)
+add_math_entrypoint_object(expm1)
add_math_entrypoint_object(expm1f)
add_math_entrypoint_object(fabs)
@@ -198,6 +209,7 @@ add_math_entrypoint_object(scalbn)
add_math_entrypoint_object(scalbnf)
add_math_entrypoint_object(scalbnl)
+add_math_entrypoint_object(sincos)
add_math_entrypoint_object(sincosf)
add_math_entrypoint_object(sin)
@@ -216,6 +228,9 @@ add_math_entrypoint_object(tanf)
add_math_entrypoint_object(tanh)
add_math_entrypoint_object(tanhf)
+add_math_entrypoint_object(tgamma)
+add_math_entrypoint_object(tgammaf)
+
add_math_entrypoint_object(trunc)
add_math_entrypoint_object(truncf)
add_math_entrypoint_object(truncl)
diff --git a/libc/src/math/acos.h b/libc/src/math/acos.h
new file mode 100644
index 000000000000000..53b299f1da8902e
--- /dev/null
+++ b/libc/src/math/acos.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for acos --------------------------*- 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_ACOS_H
+#define LLVM_LIBC_SRC_MATH_ACOS_H
+
+namespace __llvm_libc {
+
+double acos(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ACOS_H
diff --git a/libc/src/math/acosh.h b/libc/src/math/acosh.h
new file mode 100644
index 000000000000000..851c619fdb9f799
--- /dev/null
+++ b/libc/src/math/acosh.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for acosh -------------------------*- 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_ACOSH_H
+#define LLVM_LIBC_SRC_MATH_ACOSH_H
+
+namespace __llvm_libc {
+
+double acosh(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ACOSH_H
diff --git a/libc/src/math/asin.h b/libc/src/math/asin.h
new file mode 100644
index 000000000000000..d8f3f191a357856
--- /dev/null
+++ b/libc/src/math/asin.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for asin --------------------------*- 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_ASIN_H
+#define LLVM_LIBC_SRC_MATH_ASIN_H
+
+namespace __llvm_libc {
+
+double asin(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ASIN_H
diff --git a/libc/src/math/asinh.h b/libc/src/math/asinh.h
new file mode 100644
index 000000000000000..098880f26ecc80c
--- /dev/null
+++ b/libc/src/math/asinh.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for asinh -------------------------*- 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_ASINH_H
+#define LLVM_LIBC_SRC_MATH_ASINH_H
+
+namespace __llvm_libc {
+
+double asinh(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ASINH_H
diff --git a/libc/src/math/atan.h b/libc/src/math/atan.h
new file mode 100644
index 000000000000000..73d67e526d7d5a5
--- /dev/null
+++ b/libc/src/math/atan.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for atan --------------------------*- 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_ATAN_H
+#define LLVM_LIBC_SRC_MATH_ATAN_H
+
+namespace __llvm_libc {
+
+double atan(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ATAN_H
diff --git a/libc/src/math/atan2.h b/libc/src/math/atan2.h
new file mode 100644
index 000000000000000..cac5b7ddfbb62c1
--- /dev/null
+++ b/libc/src/math/atan2.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for atan2 -------------------------*- 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_ATAN2_H
+#define LLVM_LIBC_SRC_MATH_ATAN2_H
+
+namespace __llvm_libc {
+
+double atan2(double x, double y);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ATAN2_H
diff --git a/libc/src/math/atan2f.h b/libc/src/math/atan2f.h
new file mode 100644
index 000000000000000..d3e81a2b8d5f2d4
--- /dev/null
+++ b/libc/src/math/atan2f.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for atan2f ------------------------*- 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_ATAN2F_H
+#define LLVM_LIBC_SRC_MATH_ATAN2F_H
+
+namespace __llvm_libc {
+
+float atan2f(float x, float y);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ATAN2F_H
diff --git a/libc/src/math/atanh.h b/libc/src/math/atanh.h
new file mode 100644
index 000000000000000..de854451e7a281f
--- /dev/null
+++ b/libc/src/math/atanh.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for atanh -------------------------*- 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_ATANH_H
+#define LLVM_LIBC_SRC_MATH_ATANH_H
+
+namespace __llvm_libc {
+
+double atanh(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ATANH_H
diff --git a/libc/src/math/erf.h b/libc/src/math/erf.h
new file mode 100644
index 000000000000000..86a146182b4f729
--- /dev/null
+++ b/libc/src/math/erf.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for erf ---------------------------*- 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_ERF_H
+#define LLVM_LIBC_SRC_MATH_ERF_H
+
+namespace __llvm_libc {
+
+double erf(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_ERF_H
diff --git a/libc/src/math/expm1.h b/libc/src/math/expm1.h
new file mode 100644
index 000000000000000..7ae354e459feb1f
--- /dev/null
+++ b/libc/src/math/expm1.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for expm1 -------------------------*- 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_EXPM1_H
+#define LLVM_LIBC_SRC_MATH_EXPM1_H
+
+namespace __llvm_libc {
+
+double expm1(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_EXPM1_H
diff --git a/libc/src/math/gpu/vendor/CMakeLists.txt b/libc/src/math/gpu/vendor/CMakeLists.txt
index 2ee74a06a02d461..58910ac517bdc97 100644
--- a/libc/src/math/gpu/vendor/CMakeLists.txt
+++ b/libc/src/math/gpu/vendor/CMakeLists.txt
@@ -29,6 +29,17 @@ endif()
# will link in identity metadata from both libraries. This silences the warning.
list(APPEND bitcode_link_flags "-Wno-linker-warnings")
+add_entrypoint_object(
+ acos
+ SRCS
+ acos.cpp
+ HDRS
+ ../../acos.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
acosf
SRCS
@@ -40,6 +51,17 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ acosh
+ SRCS
+ acosh.cpp
+ HDRS
+ ../../acosh.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
acoshf
SRCS
@@ -51,6 +73,17 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ asin
+ SRCS
+ asin.cpp
+ HDRS
+ ../../asin.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
asinf
SRCS
@@ -62,6 +95,17 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ asinh
+ SRCS
+ asinh.cpp
+ HDRS
+ ../../asinh.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
asinhf
SRCS
@@ -73,6 +117,17 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ atan
+ SRCS
+ atan.cpp
+ HDRS
+ ../../atan.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
atanf
SRCS
@@ -84,6 +139,39 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ atan2
+ SRCS
+ atan2.cpp
+ HDRS
+ ../../atan2.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ atan2f
+ SRCS
+ atan2f.cpp
+ HDRS
+ ../../atan2f.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ atanh
+ SRCS
+ atanh.cpp
+ HDRS
+ ../../atanh.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
atanhf
SRCS
@@ -139,6 +227,28 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ erf
+ SRCS
+ erf.cpp
+ HDRS
+ ../../erf.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ erff
+ SRCS
+ erff.cpp
+ HDRS
+ ../../erff.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
exp10f
SRCS
@@ -172,6 +282,17 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ expm1
+ SRCS
+ expm1.cpp
+ HDRS
+ ../../expm1.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
expm1f
SRCS
@@ -515,6 +636,28 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ tgamma
+ SRCS
+ tgamma.cpp
+ HDRS
+ ../../tgamma.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ tgammaf
+ SRCS
+ tgammaf.cpp
+ HDRS
+ ../../tgammaf.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
frexp
SRCS
diff --git a/libc/src/math/gpu/vendor/acos.cpp b/libc/src/math/gpu/vendor/acos.cpp
new file mode 100644
index 000000000000000..7e6d00be3c3e589
--- /dev/null
+++ b/libc/src/math/gpu/vendor/acos.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU acos function ---------------------------===//
+//
+// 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/acos.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, acos, (double x)) { return internal::acos(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/acosh.cpp b/libc/src/math/gpu/vendor/acosh.cpp
new file mode 100644
index 000000000000000..2ea150dcf78e03a
--- /dev/null
+++ b/libc/src/math/gpu/vendor/acosh.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU acosh function --------------------------===//
+//
+// 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/acosh.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, acosh, (double x)) { return internal::acosh(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 7755174e445b222..a763f2e3d0f53f1 100644
--- a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
+++ b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
@@ -16,19 +16,30 @@
namespace __llvm_libc {
namespace internal {
+LIBC_INLINE double acos(double x) { return __ocml_acos_f64(x); }
LIBC_INLINE float acosf(float x) { return __ocml_acos_f32(x); }
+LIBC_INLINE double acosh(double x) { return __ocml_acosh_f64(x); }
LIBC_INLINE float acoshf(float x) { return __ocml_acosh_f32(x); }
+LIBC_INLINE double asin(double x) { return __ocml_asin_f64(x); }
LIBC_INLINE float asinf(float x) { return __ocml_asin_f32(x); }
+LIBC_INLINE double asinh(double x) { return __ocml_asinh_f64(x); }
LIBC_INLINE float asinhf(float x) { return __ocml_asinh_f32(x); }
+LIBC_INLINE double atan(double x) { return __ocml_atan_f64(x); }
LIBC_INLINE float atanf(float x) { return __ocml_atan_f32(x); }
+LIBC_INLINE double atan2(double x, double y) { return __ocml_atan2_f64(x, y); }
+LIBC_INLINE float atan2f(float x, float y) { return __ocml_atan2_f32(x, y); }
+LIBC_INLINE double atanh(double x) { return __ocml_atanh_f64(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 double erf(double x) { return __ocml_erf_f64(x); }
+LIBC_INLINE float erff(float x) { return __ocml_erf_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 double expm1(double x) { return __ocml_expm1_f64(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); }
@@ -50,6 +61,18 @@ LIBC_INLINE long long llround(double x) {
LIBC_INLINE long long llroundf(float x) {
return static_cast<long long>(__builtin_roundf(x));
}
+LIBC_INLINE double log10(double x) { return __ocml_log10_f64(x); }
+LIBC_INLINE float log10f(float x) { return __ocml_log10_f32(x); }
+LIBC_INLINE double log1p(double x) { return __ocml_log1p_f64(x); }
+LIBC_INLINE float log1pf(float x) { return __ocml_log1p_f32(x); }
+LIBC_INLINE double log2(double x) { return __ocml_log2_f64(x); }
+LIBC_INLINE float log2f(float x) { return __ocml_log2_f32(x); }
+LIBC_INLINE double log(double x) { return __ocml_log_f64(x); }
+LIBC_INLINE float logf(float x) { return __ocml_log_f32(x); }
+LIBC_INLINE long lrint(double x) { return (long)__ocml_rint_f64(x); }
+LIBC_INLINE long lrintf(float x) { return (long)__ocml_rint_f32(x); }
+LIBC_INLINE long lround(double x) { return (long)__ocml_round_f64(x); }
+LIBC_INLINE long lroundf(float x) { return (long)__ocml_round_f32(x); }
LIBC_INLINE double nextafter(double x, double y) {
return __ocml_nextafter_f64(x, y);
}
@@ -96,6 +119,8 @@ LIBC_INLINE float remquof(float x, float y, int *q) {
*q = tmp;
return r;
}
+LIBC_INLINE double tgamma(double x) { return __ocml_tgamma_f64(x); }
+LIBC_INLINE float tgammaf(float x) { return __ocml_tgamma_f32(x); }
} // namespace internal
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/amdgpu/declarations.h b/libc/src/math/gpu/vendor/amdgpu/declarations.h
index 7219d5a7dfa6d73..84214edb6624bc8 100644
--- a/libc/src/math/gpu/vendor/amdgpu/declarations.h
+++ b/libc/src/math/gpu/vendor/amdgpu/declarations.h
@@ -15,35 +15,61 @@ namespace __llvm_libc {
extern "C" {
float __ocml_acos_f32(float);
+double __ocml_acos_f64(double);
float __ocml_acosh_f32(float);
+double __ocml_acosh_f64(double);
float __ocml_asin_f32(float);
+double __ocml_asin_f64(double);
float __ocml_asinh_f32(float);
+double __ocml_asinh_f64(double);
float __ocml_atan_f32(float);
+double __ocml_atan_f64(double);
+float __ocml_atan2_f32(float, float);
+double __ocml_atan2_f64(double, double);
float __ocml_atanh_f32(float);
+double __ocml_atanh_f64(double);
float __ocml_cos_f32(float);
double __ocml_cos_f64(double);
float __ocml_cosh_f32(float);
double __ocml_cosh_f64(double);
+float __ocml_erf_f32(float);
+double __ocml_erf_f64(double);
float __ocml_exp_f32(float);
+double __ocml_exp_f64(double);
float __ocml_exp2_f32(float);
+double __ocml_exp2_f64(double);
float __ocml_exp10_f32(float);
+double __ocml_exp2_f64(double);
float __ocml_expm1_f32(float);
+double __ocml_expm1_f64(double);
float __ocml_fdim_f32(float, float);
double __ocml_fdim_f64(double, double);
-double __ocml_hypot_f64(double, double);
float __ocml_hypot_f32(float, float);
+double __ocml_hypot_f64(double, double);
int __ocml_ilogb_f64(double);
int __ocml_ilogb_f32(float);
float __ocml_ldexp_f32(float, int);
double __ocml_ldexp_f64(double, int);
+float __ocml_log10_f32(float);
+double __ocml_log10_f64(double);
+float __ocml_log1p_f32(float);
+double __ocml_log1p_f64(double);
+float __ocml_log2_f32(float);
+double __ocml_log2_f64(double);
+float __ocml_log_f32(float);
+double __ocml_log_f64(double);
+long __ocml_lrint_f32(float);
+long __ocml_lrint_f64(double);
+long __ocml_lround_f32(float);
+long __ocml_lround_f64(double);
float __ocml_nextafter_f32(float, float);
double __ocml_nextafter_f64(double, double);
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);
+double __ocml_rint_f64(double);
float __ocml_round_f32(float);
+double __ocml_round_f64(double);
float __ocml_sin_f32(float);
double __ocml_sin_f64(double);
float __ocml_sincos_f32(float, float *);
@@ -56,6 +82,8 @@ float __ocml_tanh_f32(float);
double __ocml_tanh_f64(double);
float __ocml_remquo_f32(float, float, gpu::Private<int> *);
double __ocml_remquo_f64(double, double, gpu::Private<int> *);
+double __ocml_tgamma_f64(double);
+float __ocml_tgamma_f32(float);
}
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/asin.cpp b/libc/src/math/gpu/vendor/asin.cpp
new file mode 100644
index 000000000000000..eaf7253ad1ecaff
--- /dev/null
+++ b/libc/src/math/gpu/vendor/asin.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU asin function ---------------------------===//
+//
+// 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/asin.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, asin, (double x)) { return internal::asin(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/asinh.cpp b/libc/src/math/gpu/vendor/asinh.cpp
new file mode 100644
index 000000000000000..ddb33ebae3a590a
--- /dev/null
+++ b/libc/src/math/gpu/vendor/asinh.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU asinh function --------------------------===//
+//
+// 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/asinh.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, asinh, (double x)) { return internal::asinh(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/atan.cpp b/libc/src/math/gpu/vendor/atan.cpp
new file mode 100644
index 000000000000000..88452dc60188a59
--- /dev/null
+++ b/libc/src/math/gpu/vendor/atan.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU atan function ---------------------------===//
+//
+// 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/atan.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, atan, (double x)) { return internal::atan(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/atan2.cpp b/libc/src/math/gpu/vendor/atan2.cpp
new file mode 100644
index 000000000000000..9f5736f7c30e1f8
--- /dev/null
+++ b/libc/src/math/gpu/vendor/atan2.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the GPU atan2 function --------------------------===//
+//
+// 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/atan2.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, atan2, (double x, double y)) {
+ return internal::atan2(x, y);
+}
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/atan2f.cpp b/libc/src/math/gpu/vendor/atan2f.cpp
new file mode 100644
index 000000000000000..897bd5d26527763
--- /dev/null
+++ b/libc/src/math/gpu/vendor/atan2f.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of the GPU atan2f function
+//--------------------------===//
+//
+// 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/atan2f.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, atan2f, (float x, float y)) {
+ return internal::atan2f(x, y);
+}
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/atanh.cpp b/libc/src/math/gpu/vendor/atanh.cpp
new file mode 100644
index 000000000000000..97246bf195ff77c
--- /dev/null
+++ b/libc/src/math/gpu/vendor/atanh.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU atanh function --------------------------===//
+//
+// 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/atanh.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, atanh, (double x)) { return internal::atanh(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/erf.cpp b/libc/src/math/gpu/vendor/erf.cpp
new file mode 100644
index 000000000000000..f06ab8121ebd669
--- /dev/null
+++ b/libc/src/math/gpu/vendor/erf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU erf function ----------------------------===//
+//
+// 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/erf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, erf, (double x)) { return internal::erf(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/erff.cpp b/libc/src/math/gpu/vendor/erff.cpp
new file mode 100644
index 000000000000000..78c31383d86acb1
--- /dev/null
+++ b/libc/src/math/gpu/vendor/erff.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU erff function ---------------------------===//
+//
+// 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/erff.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, erff, (float x)) { return internal::erff(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/exp.cpp b/libc/src/math/gpu/vendor/exp.cpp
new file mode 100644
index 000000000000000..dc315d9555b422a
--- /dev/null
+++ b/libc/src/math/gpu/vendor/exp.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU exp function ----------------------------===//
+//
+// 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/exp.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, exp, (double x)) { return internal::exp(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/exp10.cpp b/libc/src/math/gpu/vendor/exp10.cpp
new file mode 100644
index 000000000000000..1bb746bfdcac260
--- /dev/null
+++ b/libc/src/math/gpu/vendor/exp10.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU exp10 function --------------------------===//
+//
+// 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/exp10.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, exp10, (double x)) { return internal::exp10(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/exp2.cpp b/libc/src/math/gpu/vendor/exp2.cpp
new file mode 100644
index 000000000000000..0dbea3837cbdd0d
--- /dev/null
+++ b/libc/src/math/gpu/vendor/exp2.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU exp2 function ---------------------------===//
+//
+// 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/exp2.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, exp2, (double x)) { return internal::exp2(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/expm1.cpp b/libc/src/math/gpu/vendor/expm1.cpp
new file mode 100644
index 000000000000000..528daab22e14cfd
--- /dev/null
+++ b/libc/src/math/gpu/vendor/expm1.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU expm1 function --------------------------===//
+//
+// 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/expm1.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, expm1, (double x)) { return internal::expm1(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/log.cpp b/libc/src/math/gpu/vendor/log.cpp
new file mode 100644
index 000000000000000..fe44d78724a4ca2
--- /dev/null
+++ b/libc/src/math/gpu/vendor/log.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU log function ----------------------------===//
+//
+// 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/log.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, log, (double x)) { return internal::log(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/log10.cpp b/libc/src/math/gpu/vendor/log10.cpp
new file mode 100644
index 000000000000000..6666dae827646da
--- /dev/null
+++ b/libc/src/math/gpu/vendor/log10.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU log10 function --------------------------===//
+//
+// 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/log10.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, log10, (double x)) { return internal::log10(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/log10f.cpp b/libc/src/math/gpu/vendor/log10f.cpp
new file mode 100644
index 000000000000000..5e938a32895128e
--- /dev/null
+++ b/libc/src/math/gpu/vendor/log10f.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the GPU log10f function
+//---------------------------===//
+//
+// 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/log10f.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, log10f, (float x)) { return internal::log10f(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/log1p.cpp b/libc/src/math/gpu/vendor/log1p.cpp
new file mode 100644
index 000000000000000..e2781bfbab1ceba
--- /dev/null
+++ b/libc/src/math/gpu/vendor/log1p.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU log1p function --------------------------===//
+//
+// 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/log1p.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, log1p, (double x)) { return internal::log1p(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/log1pf.cpp b/libc/src/math/gpu/vendor/log1pf.cpp
new file mode 100644
index 000000000000000..3cdde90d94b132f
--- /dev/null
+++ b/libc/src/math/gpu/vendor/log1pf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU log1pf function -------------------------===//
+//
+// 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/log1pf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, log1pf, (float x)) { return internal::log1pf(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/log2.cpp b/libc/src/math/gpu/vendor/log2.cpp
new file mode 100644
index 000000000000000..45d2200d269009d
--- /dev/null
+++ b/libc/src/math/gpu/vendor/log2.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU log2 function ---------------------------===//
+//
+// 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/log2.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, log2, (double x)) { return internal::log2(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/log2f.cpp b/libc/src/math/gpu/vendor/log2f.cpp
new file mode 100644
index 000000000000000..2378bc1bacb47a5
--- /dev/null
+++ b/libc/src/math/gpu/vendor/log2f.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU log2f function --------------------------===//
+//
+// 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/log2f.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, log2f, (float x)) { return internal::log2f(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/logb.cpp b/libc/src/math/gpu/vendor/logb.cpp
new file mode 100644
index 000000000000000..d7aa9a1d1517e6a
--- /dev/null
+++ b/libc/src/math/gpu/vendor/logb.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU logb function ---------------------------===//
+//
+// 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/logb.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, logb, (double x)) { return internal::logb(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/logbf.cpp b/libc/src/math/gpu/vendor/logbf.cpp
new file mode 100644
index 000000000000000..021bed06c69032c
--- /dev/null
+++ b/libc/src/math/gpu/vendor/logbf.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of the GPU logbf function
+//---------------------------===//
+//
+// 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/logbf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, logbf, (float x)) { return internal::logbf(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/logf.cpp b/libc/src/math/gpu/vendor/logf.cpp
new file mode 100644
index 000000000000000..6f0c5d5c144ea96
--- /dev/null
+++ b/libc/src/math/gpu/vendor/logf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU logf function ---------------------------===//
+//
+// 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/logf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, logf, (float x)) { return internal::logf(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/lrint.cpp b/libc/src/math/gpu/vendor/lrint.cpp
new file mode 100644
index 000000000000000..15316f02ebf871e
--- /dev/null
+++ b/libc/src/math/gpu/vendor/lrint.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU lrint function --------------------------===//
+//
+// 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/lrint.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(long, lrint, (double x)) { return internal::lrint(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/lrintf.cpp b/libc/src/math/gpu/vendor/lrintf.cpp
new file mode 100644
index 000000000000000..5cbd212e0c999ca
--- /dev/null
+++ b/libc/src/math/gpu/vendor/lrintf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU lrintf function -------------------------===//
+//
+// 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/lrintf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(long, lrintf, (float x)) { return internal::lrintf(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/lround.cpp b/libc/src/math/gpu/vendor/lround.cpp
new file mode 100644
index 000000000000000..cb268104d94b99d
--- /dev/null
+++ b/libc/src/math/gpu/vendor/lround.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU lround function -------------------------===//
+//
+// 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/lround.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(long int, lround, (double x)) { return internal::lround(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/lroundf.cpp b/libc/src/math/gpu/vendor/lroundf.cpp
new file mode 100644
index 000000000000000..175c6a2561b27de
--- /dev/null
+++ b/libc/src/math/gpu/vendor/lroundf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of the GPU lroundf function ------------------------===//
+//
+// 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/lroundf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(long int, lroundf, (float x)) {
+ return internal::lroundf(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 8b6702834a04cf4..b8bb90f3bf585c2 100644
--- a/libc/src/math/gpu/vendor/nvptx/declarations.h
+++ b/libc/src/math/gpu/vendor/nvptx/declarations.h
@@ -12,19 +12,30 @@
namespace __llvm_libc {
extern "C" {
+double __nv_acos(double);
float __nv_acosf(float);
+double __nv_acosh(double);
float __nv_acoshf(float);
+double __nv_asin(double);
float __nv_asinf(float);
+double __nv_asinh(double);
float __nv_asinhf(float);
+double __nv_atan(double);
float __nv_atanf(float);
+double __nv_atan2(double, double);
+float __nv_atan2f(float, float);
+double __nv_atanh(double);
float __nv_atanhf(float);
double __nv_cos(double);
float __nv_cosf(float);
double __nv_cosh(double);
float __nv_coshf(float);
+double __nv_erf(double);
+float __nv_erff(float);
float __nv_expf(float);
float __nv_exp2f(float);
float __nv_exp10f(float);
+double __nv_expm1(double);
float __nv_expm1f(float);
double __nv_fdim(double, double);
float __nv_fdimf(float, float);
@@ -38,6 +49,18 @@ long long __nv_llrint(double);
long long __nv_llrintf(float);
long long __nv_llround(double);
long long __nv_llroundf(float);
+double __nv_log10(double);
+float __nv_log10f(float);
+double __nv_log1p(double);
+float __nv_log1pf(float);
+double __nv_log2(double);
+float __nv_log2f(float);
+double __nv_log(double);
+float __nv_logf(float);
+long __nv_lrint(double);
+long __nv_lrintf(float);
+long __nv_lround(double);
+long __nv_lroundf(float);
double __nv_nextafter(double, double);
float __nv_nextafterf(float, float);
double __nv_pow(double, double);
@@ -58,6 +81,8 @@ double __nv_scalbn(double, int);
float __nv_scalbnf(float, int);
double __nv_remquo(double, double, int *);
float __nv_remquof(float, float, int *);
+double __nv_tgamma(double);
+float __nv_tgammaf(float);
}
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/nvptx/nvptx.h b/libc/src/math/gpu/vendor/nvptx/nvptx.h
index 6ea1743cf7a6f3e..4a2e8d7ab8debea 100644
--- a/libc/src/math/gpu/vendor/nvptx/nvptx.h
+++ b/libc/src/math/gpu/vendor/nvptx/nvptx.h
@@ -15,19 +15,30 @@
namespace __llvm_libc {
namespace internal {
+LIBC_INLINE double acos(double x) { return __nv_acos(x); }
LIBC_INLINE float acosf(float x) { return __nv_acosf(x); }
+LIBC_INLINE double acosh(double x) { return __nv_acosh(x); }
LIBC_INLINE float acoshf(float x) { return __nv_acoshf(x); }
+LIBC_INLINE double asin(double x) { return __nv_asin(x); }
LIBC_INLINE float asinf(float x) { return __nv_asinf(x); }
+LIBC_INLINE double asinh(double x) { return __nv_asinh(x); }
LIBC_INLINE float asinhf(float x) { return __nv_asinhf(x); }
+LIBC_INLINE double atan2(double x, double y) { return __nv_atan2(x, y); }
+LIBC_INLINE float atan2f(float x, float y) { return __nv_atan2f(x, y); }
+LIBC_INLINE double atan(double x) { return __nv_atan(x); }
LIBC_INLINE float atanf(float x) { return __nv_atanf(x); }
+LIBC_INLINE double atanh(double x) { return __nv_atanh(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 double erf(double x) { return __nv_erf(x); }
+LIBC_INLINE float erff(float x) { return __nv_erff(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 double expm1(double x) { return __nv_expm1(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); }
@@ -41,6 +52,18 @@ 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 log10(double x) { return __nv_log10(x); }
+LIBC_INLINE float log10f(float x) { return __nv_log10f(x); }
+LIBC_INLINE double log1p(double x) { return __nv_log1p(x); }
+LIBC_INLINE float log1pf(float x) { return __nv_log1pf(x); }
+LIBC_INLINE double log2(double x) { return __nv_log2(x); }
+LIBC_INLINE float log2f(float x) { return __nv_log2f(x); }
+LIBC_INLINE double log(double x) { return __nv_log(x); }
+LIBC_INLINE float logf(float x) { return __nv_logf(x); }
+LIBC_INLINE long lrint(double x) { return __nv_lrint(x); }
+LIBC_INLINE long lrintf(float x) { return __nv_lrintf(x); }
+LIBC_INLINE long lround(double x) { return __nv_lround(x); }
+LIBC_INLINE long lroundf(float x) { return __nv_lroundf(x); }
LIBC_INLINE double nextafter(double x, double y) {
return __nv_nextafter(x, y);
}
@@ -71,6 +94,8 @@ LIBC_INLINE double remquo(double x, double y, int *i) {
LIBC_INLINE float remquof(float x, float y, int *i) {
return __nv_remquof(x, y, i);
}
+LIBC_INLINE double tgamma(double x) { return __nv_tgamma(x); }
+LIBC_INLINE float tgammaf(float x) { return __nv_tgammaf(x); }
} // namespace internal
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/tgamma.cpp b/libc/src/math/gpu/vendor/tgamma.cpp
new file mode 100644
index 000000000000000..9895c4bfcf55926
--- /dev/null
+++ b/libc/src/math/gpu/vendor/tgamma.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU tgamma function -------------------------===//
+//
+// 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/tgamma.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(double, tgamma, (double x)) { return internal::tgamma(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/tgammaf.cpp b/libc/src/math/gpu/vendor/tgammaf.cpp
new file mode 100644
index 000000000000000..9e86dacf36083a9
--- /dev/null
+++ b/libc/src/math/gpu/vendor/tgammaf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the GPU tgammaf function ------------------------===//
+//
+// 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/tgammaf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(float, tgammaf, (float x)) { return internal::tgammaf(x); }
+
+} // namespace __llvm_libc
diff --git a/libc/src/math/sincos.h b/libc/src/math/sincos.h
new file mode 100644
index 000000000000000..2e3d0673935193f
--- /dev/null
+++ b/libc/src/math/sincos.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for sincos ------------------------*- 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_SINCOS_H
+#define LLVM_LIBC_SRC_MATH_SINCOS_H
+
+namespace __llvm_libc {
+
+void sincos(double x, double *sinx, double *cosx);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_SINCOS_H
diff --git a/libc/src/math/tgamma.h b/libc/src/math/tgamma.h
new file mode 100644
index 000000000000000..295070383f3950c
--- /dev/null
+++ b/libc/src/math/tgamma.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for tgamma ------------------------*- 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_TGAMMA_H
+#define LLVM_LIBC_SRC_MATH_TGAMMA_H
+
+namespace __llvm_libc {
+
+double tgamma(double x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_TGAMMA_H
diff --git a/libc/src/math/tgammaf.h b/libc/src/math/tgammaf.h
new file mode 100644
index 000000000000000..c098dae4b7ec6bd
--- /dev/null
+++ b/libc/src/math/tgammaf.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for tgammaf -----------------------*- 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_TGAMMAF_H
+#define LLVM_LIBC_SRC_MATH_TGAMMAF_H
+
+namespace __llvm_libc {
+
+float tgammaf(float x);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_MATH_TGAMMAF_H
>From 14ce71e71827c310a609bb7ff617d02eb65bc9ea Mon Sep 17 00:00:00 2001
From: antonrydahl <rydahl2610 at gmail.com>
Date: Thu, 14 Sep 2023 20:59:19 -0700
Subject: [PATCH 2/6] Replacing vendor rint and round functions with
corresponding LLVM intrinsics
---
libc/src/math/gpu/CMakeLists.txt | 80 +++++++++++++++++++
libc/src/math/gpu/{vendor => }/llrint.cpp | 6 +-
libc/src/math/gpu/{vendor => }/llrintf.cpp | 6 +-
libc/src/math/gpu/{vendor => }/llround.cpp | 6 +-
libc/src/math/gpu/{vendor => }/llroundf.cpp | 6 +-
libc/src/math/gpu/{vendor => }/lrint.cpp | 4 +-
libc/src/math/gpu/{vendor => }/lrintf.cpp | 4 +-
libc/src/math/gpu/{vendor => }/lround.cpp | 4 +-
libc/src/math/gpu/{vendor => }/lroundf.cpp | 9 +--
libc/src/math/gpu/vendor/CMakeLists.txt | 45 -----------
libc/src/math/gpu/vendor/amdgpu/amdgpu.h | 16 ----
.../src/math/gpu/vendor/amdgpu/declarations.h | 8 --
libc/src/math/gpu/vendor/nvptx/declarations.h | 8 --
libc/src/math/gpu/vendor/nvptx/nvptx.h | 8 --
14 files changed, 94 insertions(+), 116 deletions(-)
rename libc/src/math/gpu/{vendor => }/llrint.cpp (80%)
rename libc/src/math/gpu/{vendor => }/llrintf.cpp (80%)
rename libc/src/math/gpu/{vendor => }/llround.cpp (80%)
rename libc/src/math/gpu/{vendor => }/llroundf.cpp (80%)
rename libc/src/math/gpu/{vendor => }/lrint.cpp (85%)
rename libc/src/math/gpu/{vendor => }/lrintf.cpp (85%)
rename libc/src/math/gpu/{vendor => }/lround.cpp (82%)
rename libc/src/math/gpu/{vendor => }/lroundf.cpp (68%)
diff --git a/libc/src/math/gpu/CMakeLists.txt b/libc/src/math/gpu/CMakeLists.txt
index cee7b7d9db476f2..fbf7f9da7f501c3 100644
--- a/libc/src/math/gpu/CMakeLists.txt
+++ b/libc/src/math/gpu/CMakeLists.txt
@@ -183,6 +183,86 @@ add_math_entrypoint_gpu_object(
-O2
)
+add_math_entrypoint_gpu_object(
+ lrint
+ SRCS
+ lrint.cpp
+ HDRS
+ ../lrint.h
+ COMPILE_OPTIONS
+ -O2
+)
+
+add_math_entrypoint_gpu_object(
+ lrintf
+ SRCS
+ lrintf.cpp
+ HDRS
+ ../lrintf.h
+ COMPILE_OPTIONS
+ -O2
+)
+
+add_math_entrypoint_gpu_object(
+ lround
+ SRCS
+ lround.cpp
+ HDRS
+ ../lround.h
+ COMPILE_OPTIONS
+ -O2
+)
+
+add_math_entrypoint_gpu_object(
+ lroundf
+ SRCS
+ lroundf.cpp
+ HDRS
+ ../lroundf.h
+ COMPILE_OPTIONS
+ -O2
+)
+
+add_math_entrypoint_gpu_object(
+ llrint
+ SRCS
+ llrint.cpp
+ HDRS
+ ../llrint.h
+ COMPILE_OPTIONS
+ -O2
+)
+
+add_math_entrypoint_gpu_object(
+ llrintf
+ SRCS
+ llrintf.cpp
+ HDRS
+ ../llrintf.h
+ COMPILE_OPTIONS
+ -O2
+)
+
+add_math_entrypoint_gpu_object(
+ llround
+ SRCS
+ llround.cpp
+ HDRS
+ ../llround.h
+ COMPILE_OPTIONS
+ -O2
+)
+
+add_math_entrypoint_gpu_object(
+ llroundf
+ SRCS
+ llroundf.cpp
+ HDRS
+ ../llroundf.h
+ COMPILE_OPTIONS
+ -O2
+)
+
add_math_entrypoint_gpu_object(
modf
SRCS
diff --git a/libc/src/math/gpu/vendor/llrint.cpp b/libc/src/math/gpu/llrint.cpp
similarity index 80%
rename from libc/src/math/gpu/vendor/llrint.cpp
rename to libc/src/math/gpu/llrint.cpp
index 064d2775460edc1..26acdda8a727182 100644
--- a/libc/src/math/gpu/vendor/llrint.cpp
+++ b/libc/src/math/gpu/llrint.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation of the llrint function for GPU ---------------------===//
+//===-- Implementation of the GPU llrint function -------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,12 +9,10 @@
#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);
+ return __builtin_llrint(x);
}
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/llrintf.cpp b/libc/src/math/gpu/llrintf.cpp
similarity index 80%
rename from libc/src/math/gpu/vendor/llrintf.cpp
rename to libc/src/math/gpu/llrintf.cpp
index d1befb67c9788b0..50516f3940a1b03 100644
--- a/libc/src/math/gpu/vendor/llrintf.cpp
+++ b/libc/src/math/gpu/llrintf.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation of the llrintf function for GPU --------------------===//
+//===-- Implementation of the GPU llrintf function ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,12 +9,10 @@
#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);
+ return __builtin_llrintf(x);
}
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/llround.cpp b/libc/src/math/gpu/llround.cpp
similarity index 80%
rename from libc/src/math/gpu/vendor/llround.cpp
rename to libc/src/math/gpu/llround.cpp
index 51b8370759e9805..f41852f52023909 100644
--- a/libc/src/math/gpu/vendor/llround.cpp
+++ b/libc/src/math/gpu/llround.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation of the llround function for GPU --------------------===//
+//===-- Implementation of the GPU llround function ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,12 +9,10 @@
#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);
+ return __builtin_llround(x);
}
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/llroundf.cpp b/libc/src/math/gpu/llroundf.cpp
similarity index 80%
rename from libc/src/math/gpu/vendor/llroundf.cpp
rename to libc/src/math/gpu/llroundf.cpp
index 0131d278020029a..86d060e6e57b135 100644
--- a/libc/src/math/gpu/vendor/llroundf.cpp
+++ b/libc/src/math/gpu/llroundf.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation of the llroundf function for GPU -------------------===//
+//===-- Implementation of the GPU llroundf function -----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,12 +9,10 @@
#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);
+ return __builtin_lroundf(x);
}
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/lrint.cpp b/libc/src/math/gpu/lrint.cpp
similarity index 85%
rename from libc/src/math/gpu/vendor/lrint.cpp
rename to libc/src/math/gpu/lrint.cpp
index 15316f02ebf871e..acdade0f2dd4fd3 100644
--- a/libc/src/math/gpu/vendor/lrint.cpp
+++ b/libc/src/math/gpu/lrint.cpp
@@ -9,10 +9,8 @@
#include "src/math/lrint.h"
#include "src/__support/common.h"
-#include "common.h"
-
namespace __llvm_libc {
-LLVM_LIBC_FUNCTION(long, lrint, (double x)) { return internal::lrint(x); }
+LLVM_LIBC_FUNCTION(long, lrint, (double x)) { return __builtin_lrint(x); }
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/lrintf.cpp b/libc/src/math/gpu/lrintf.cpp
similarity index 85%
rename from libc/src/math/gpu/vendor/lrintf.cpp
rename to libc/src/math/gpu/lrintf.cpp
index 5cbd212e0c999ca..7d8d65644b34f6e 100644
--- a/libc/src/math/gpu/vendor/lrintf.cpp
+++ b/libc/src/math/gpu/lrintf.cpp
@@ -9,10 +9,8 @@
#include "src/math/lrintf.h"
#include "src/__support/common.h"
-#include "common.h"
-
namespace __llvm_libc {
-LLVM_LIBC_FUNCTION(long, lrintf, (float x)) { return internal::lrintf(x); }
+LLVM_LIBC_FUNCTION(long, lrintf, (float x)) { return __builtin_lrintf(x); }
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/lround.cpp b/libc/src/math/gpu/lround.cpp
similarity index 82%
rename from libc/src/math/gpu/vendor/lround.cpp
rename to libc/src/math/gpu/lround.cpp
index cb268104d94b99d..ced70a495e5a198 100644
--- a/libc/src/math/gpu/vendor/lround.cpp
+++ b/libc/src/math/gpu/lround.cpp
@@ -9,10 +9,8 @@
#include "src/math/lround.h"
#include "src/__support/common.h"
-#include "common.h"
-
namespace __llvm_libc {
-LLVM_LIBC_FUNCTION(long int, lround, (double x)) { return internal::lround(x); }
+LLVM_LIBC_FUNCTION(long, lround, (double x)) { return __builtin_lround(x); }
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/lroundf.cpp b/libc/src/math/gpu/lroundf.cpp
similarity index 68%
rename from libc/src/math/gpu/vendor/lroundf.cpp
rename to libc/src/math/gpu/lroundf.cpp
index 175c6a2561b27de..ef0d114ce0562ff 100644
--- a/libc/src/math/gpu/vendor/lroundf.cpp
+++ b/libc/src/math/gpu/lroundf.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation of the GPU lroundf function ------------------------===//
+//===-- Implementation of the GPU lroundf function
+//-------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,12 +10,8 @@
#include "src/math/lroundf.h"
#include "src/__support/common.h"
-#include "common.h"
-
namespace __llvm_libc {
-LLVM_LIBC_FUNCTION(long int, lroundf, (float x)) {
- return internal::lroundf(x);
-}
+LLVM_LIBC_FUNCTION(long, lroundf, (float x)) { return __builtin_lroundf(x); }
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/CMakeLists.txt b/libc/src/math/gpu/vendor/CMakeLists.txt
index 58910ac517bdc97..963249bcc245021 100644
--- a/libc/src/math/gpu/vendor/CMakeLists.txt
+++ b/libc/src/math/gpu/vendor/CMakeLists.txt
@@ -392,28 +392,6 @@ add_entrypoint_object(
-O2
)
-add_entrypoint_object(
- llrint
- SRCS
- llrint.cpp
- HDRS
- ../../llrint.h
- COMPILE_OPTIONS
- ${bitcode_link_flags}
- -O2
-)
-
-add_entrypoint_object(
- llrintf
- SRCS
- llrintf.cpp
- HDRS
- ../../llrintf.h
- COMPILE_OPTIONS
- ${bitcode_link_flags}
- -O2
-)
-
add_entrypoint_object(
remquo
SRCS
@@ -436,29 +414,6 @@ add_entrypoint_object(
-O2
)
-
-add_entrypoint_object(
- llround
- SRCS
- llround.cpp
- HDRS
- ../../llround.h
- COMPILE_OPTIONS
- ${bitcode_link_flags}
- -O2
-)
-
-add_entrypoint_object(
- llroundf
- SRCS
- llroundf.cpp
- HDRS
- ../../llroundf.h
- COMPILE_OPTIONS
- ${bitcode_link_flags}
- -O2
-)
-
add_entrypoint_object(
scalbn
SRCS
diff --git a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
index a763f2e3d0f53f1..ba4aced183194a5 100644
--- a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
+++ b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
@@ -49,18 +49,6 @@ 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 static_cast<long long>(__builtin_rint(x));
-}
-LIBC_INLINE long long llrintf(float x) {
- return static_cast<long long>(__builtin_rintf(x));
-}
-LIBC_INLINE long long llround(double x) {
- return static_cast<long long>(__builtin_round(x));
-}
-LIBC_INLINE long long llroundf(float x) {
- return static_cast<long long>(__builtin_roundf(x));
-}
LIBC_INLINE double log10(double x) { return __ocml_log10_f64(x); }
LIBC_INLINE float log10f(float x) { return __ocml_log10_f32(x); }
LIBC_INLINE double log1p(double x) { return __ocml_log1p_f64(x); }
@@ -69,10 +57,6 @@ LIBC_INLINE double log2(double x) { return __ocml_log2_f64(x); }
LIBC_INLINE float log2f(float x) { return __ocml_log2_f32(x); }
LIBC_INLINE double log(double x) { return __ocml_log_f64(x); }
LIBC_INLINE float logf(float x) { return __ocml_log_f32(x); }
-LIBC_INLINE long lrint(double x) { return (long)__ocml_rint_f64(x); }
-LIBC_INLINE long lrintf(float x) { return (long)__ocml_rint_f32(x); }
-LIBC_INLINE long lround(double x) { return (long)__ocml_round_f64(x); }
-LIBC_INLINE long lroundf(float x) { return (long)__ocml_round_f32(x); }
LIBC_INLINE double nextafter(double x, double y) {
return __ocml_nextafter_f64(x, y);
}
diff --git a/libc/src/math/gpu/vendor/amdgpu/declarations.h b/libc/src/math/gpu/vendor/amdgpu/declarations.h
index 84214edb6624bc8..0c4fc351097931d 100644
--- a/libc/src/math/gpu/vendor/amdgpu/declarations.h
+++ b/libc/src/math/gpu/vendor/amdgpu/declarations.h
@@ -58,18 +58,10 @@ float __ocml_log2_f32(float);
double __ocml_log2_f64(double);
float __ocml_log_f32(float);
double __ocml_log_f64(double);
-long __ocml_lrint_f32(float);
-long __ocml_lrint_f64(double);
-long __ocml_lround_f32(float);
-long __ocml_lround_f64(double);
float __ocml_nextafter_f32(float, float);
double __ocml_nextafter_f64(double, double);
float __ocml_pow_f32(float, float);
double __ocml_pow_f64(double, double);
-float __ocml_rint_f32(float);
-double __ocml_rint_f64(double);
-float __ocml_round_f32(float);
-double __ocml_round_f64(double);
float __ocml_sin_f32(float);
double __ocml_sin_f64(double);
float __ocml_sincos_f32(float, float *);
diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/vendor/nvptx/declarations.h
index b8bb90f3bf585c2..c388837b346537d 100644
--- a/libc/src/math/gpu/vendor/nvptx/declarations.h
+++ b/libc/src/math/gpu/vendor/nvptx/declarations.h
@@ -45,10 +45,6 @@ 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_log10(double);
float __nv_log10f(float);
double __nv_log1p(double);
@@ -57,10 +53,6 @@ double __nv_log2(double);
float __nv_log2f(float);
double __nv_log(double);
float __nv_logf(float);
-long __nv_lrint(double);
-long __nv_lrintf(float);
-long __nv_lround(double);
-long __nv_lroundf(float);
double __nv_nextafter(double, double);
float __nv_nextafterf(float, float);
double __nv_pow(double, double);
diff --git a/libc/src/math/gpu/vendor/nvptx/nvptx.h b/libc/src/math/gpu/vendor/nvptx/nvptx.h
index 4a2e8d7ab8debea..b87a86d56342f0f 100644
--- a/libc/src/math/gpu/vendor/nvptx/nvptx.h
+++ b/libc/src/math/gpu/vendor/nvptx/nvptx.h
@@ -48,10 +48,6 @@ 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 log10(double x) { return __nv_log10(x); }
LIBC_INLINE float log10f(float x) { return __nv_log10f(x); }
LIBC_INLINE double log1p(double x) { return __nv_log1p(x); }
@@ -60,10 +56,6 @@ LIBC_INLINE double log2(double x) { return __nv_log2(x); }
LIBC_INLINE float log2f(float x) { return __nv_log2f(x); }
LIBC_INLINE double log(double x) { return __nv_log(x); }
LIBC_INLINE float logf(float x) { return __nv_logf(x); }
-LIBC_INLINE long lrint(double x) { return __nv_lrint(x); }
-LIBC_INLINE long lrintf(float x) { return __nv_lrintf(x); }
-LIBC_INLINE long lround(double x) { return __nv_lround(x); }
-LIBC_INLINE long lroundf(float x) { return __nv_lroundf(x); }
LIBC_INLINE double nextafter(double x, double y) {
return __nv_nextafter(x, y);
}
>From f0c5395d4e5e14e5f855cfb529fe281861826544 Mon Sep 17 00:00:00 2001
From: antonrydahl <rydahl2610 at gmail.com>
Date: Thu, 14 Sep 2023 21:23:31 -0700
Subject: [PATCH 3/6] Replaced vendor logf, log10f, and log2f with
corresponding LLVM intrinsics in GPU libm
---
libc/src/math/gpu/CMakeLists.txt | 30 +++++++++++++++++++
libc/src/math/gpu/{vendor => }/log10f.cpp | 7 ++---
libc/src/math/gpu/{vendor => }/log2f.cpp | 4 +--
libc/src/math/gpu/{vendor => }/logf.cpp | 4 +--
libc/src/math/gpu/vendor/amdgpu/amdgpu.h | 3 --
.../src/math/gpu/vendor/amdgpu/declarations.h | 3 --
libc/src/math/gpu/vendor/nvptx/declarations.h | 3 --
libc/src/math/gpu/vendor/nvptx/nvptx.h | 3 --
8 files changed, 34 insertions(+), 23 deletions(-)
rename libc/src/math/gpu/{vendor => }/log10f.cpp (71%)
rename libc/src/math/gpu/{vendor => }/log2f.cpp (85%)
rename libc/src/math/gpu/{vendor => }/logf.cpp (85%)
diff --git a/libc/src/math/gpu/CMakeLists.txt b/libc/src/math/gpu/CMakeLists.txt
index fbf7f9da7f501c3..94bc518378d77c1 100644
--- a/libc/src/math/gpu/CMakeLists.txt
+++ b/libc/src/math/gpu/CMakeLists.txt
@@ -183,6 +183,36 @@ add_math_entrypoint_gpu_object(
-O2
)
+add_math_entrypoint_gpu_object(
+ log10f
+ SRCS
+ log10f.cpp
+ HDRS
+ ../log10f.h
+ COMPILE_OPTIONS
+ -O2
+)
+
+add_math_entrypoint_gpu_object(
+ log2f
+ SRCS
+ log2f.cpp
+ HDRS
+ ../log2f.h
+ COMPILE_OPTIONS
+ -O2
+)
+
+add_math_entrypoint_gpu_object(
+ logf
+ SRCS
+ logf.cpp
+ HDRS
+ ../logf.h
+ COMPILE_OPTIONS
+ -O2
+)
+
add_math_entrypoint_gpu_object(
lrint
SRCS
diff --git a/libc/src/math/gpu/vendor/log10f.cpp b/libc/src/math/gpu/log10f.cpp
similarity index 71%
rename from libc/src/math/gpu/vendor/log10f.cpp
rename to libc/src/math/gpu/log10f.cpp
index 5e938a32895128e..2718ed2a9aa5e61 100644
--- a/libc/src/math/gpu/vendor/log10f.cpp
+++ b/libc/src/math/gpu/log10f.cpp
@@ -1,5 +1,4 @@
-//===-- Implementation of the GPU log10f function
-//---------------------------===//
+//===-- Implementation of the GPU log10f function -------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,10 +9,8 @@
#include "src/math/log10f.h"
#include "src/__support/common.h"
-#include "common.h"
-
namespace __llvm_libc {
-LLVM_LIBC_FUNCTION(float, log10f, (float x)) { return internal::log10f(x); }
+LLVM_LIBC_FUNCTION(float, log10f, (float x)) { return __builtin_log10f(x); }
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/log2f.cpp b/libc/src/math/gpu/log2f.cpp
similarity index 85%
rename from libc/src/math/gpu/vendor/log2f.cpp
rename to libc/src/math/gpu/log2f.cpp
index 2378bc1bacb47a5..563c73ee807589c 100644
--- a/libc/src/math/gpu/vendor/log2f.cpp
+++ b/libc/src/math/gpu/log2f.cpp
@@ -9,10 +9,8 @@
#include "src/math/log2f.h"
#include "src/__support/common.h"
-#include "common.h"
-
namespace __llvm_libc {
-LLVM_LIBC_FUNCTION(float, log2f, (float x)) { return internal::log2f(x); }
+LLVM_LIBC_FUNCTION(float, log2f, (float x)) { return __builtin_log2f(x); }
} // namespace __llvm_libc
diff --git a/libc/src/math/gpu/vendor/logf.cpp b/libc/src/math/gpu/logf.cpp
similarity index 85%
rename from libc/src/math/gpu/vendor/logf.cpp
rename to libc/src/math/gpu/logf.cpp
index 6f0c5d5c144ea96..23918a8a1422b6d 100644
--- a/libc/src/math/gpu/vendor/logf.cpp
+++ b/libc/src/math/gpu/logf.cpp
@@ -9,10 +9,8 @@
#include "src/math/logf.h"
#include "src/__support/common.h"
-#include "common.h"
-
namespace __llvm_libc {
-LLVM_LIBC_FUNCTION(float, logf, (float x)) { return internal::logf(x); }
+LLVM_LIBC_FUNCTION(float, logf, (float x)) { return __builtin_logf(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 ba4aced183194a5..a4ccae17b728a70 100644
--- a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
+++ b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
@@ -50,13 +50,10 @@ 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 double log10(double x) { return __ocml_log10_f64(x); }
-LIBC_INLINE float log10f(float x) { return __ocml_log10_f32(x); }
LIBC_INLINE double log1p(double x) { return __ocml_log1p_f64(x); }
LIBC_INLINE float log1pf(float x) { return __ocml_log1p_f32(x); }
LIBC_INLINE double log2(double x) { return __ocml_log2_f64(x); }
-LIBC_INLINE float log2f(float x) { return __ocml_log2_f32(x); }
LIBC_INLINE double log(double x) { return __ocml_log_f64(x); }
-LIBC_INLINE float logf(float x) { return __ocml_log_f32(x); }
LIBC_INLINE double nextafter(double x, double y) {
return __ocml_nextafter_f64(x, y);
}
diff --git a/libc/src/math/gpu/vendor/amdgpu/declarations.h b/libc/src/math/gpu/vendor/amdgpu/declarations.h
index 0c4fc351097931d..2e4ad9fe87fd16e 100644
--- a/libc/src/math/gpu/vendor/amdgpu/declarations.h
+++ b/libc/src/math/gpu/vendor/amdgpu/declarations.h
@@ -50,13 +50,10 @@ int __ocml_ilogb_f64(double);
int __ocml_ilogb_f32(float);
float __ocml_ldexp_f32(float, int);
double __ocml_ldexp_f64(double, int);
-float __ocml_log10_f32(float);
double __ocml_log10_f64(double);
float __ocml_log1p_f32(float);
double __ocml_log1p_f64(double);
-float __ocml_log2_f32(float);
double __ocml_log2_f64(double);
-float __ocml_log_f32(float);
double __ocml_log_f64(double);
float __ocml_nextafter_f32(float, float);
double __ocml_nextafter_f64(double, double);
diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/vendor/nvptx/declarations.h
index c388837b346537d..43e42c42c3361f7 100644
--- a/libc/src/math/gpu/vendor/nvptx/declarations.h
+++ b/libc/src/math/gpu/vendor/nvptx/declarations.h
@@ -46,13 +46,10 @@ int __nv_ilogbf(float);
double __nv_ldexp(double, int);
float __nv_ldexpf(float, int);
double __nv_log10(double);
-float __nv_log10f(float);
double __nv_log1p(double);
float __nv_log1pf(float);
double __nv_log2(double);
-float __nv_log2f(float);
double __nv_log(double);
-float __nv_logf(float);
double __nv_nextafter(double, double);
float __nv_nextafterf(float, float);
double __nv_pow(double, double);
diff --git a/libc/src/math/gpu/vendor/nvptx/nvptx.h b/libc/src/math/gpu/vendor/nvptx/nvptx.h
index b87a86d56342f0f..d685f50a5a33871 100644
--- a/libc/src/math/gpu/vendor/nvptx/nvptx.h
+++ b/libc/src/math/gpu/vendor/nvptx/nvptx.h
@@ -49,13 +49,10 @@ 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 double log10(double x) { return __nv_log10(x); }
-LIBC_INLINE float log10f(float x) { return __nv_log10f(x); }
LIBC_INLINE double log1p(double x) { return __nv_log1p(x); }
LIBC_INLINE float log1pf(float x) { return __nv_log1pf(x); }
LIBC_INLINE double log2(double x) { return __nv_log2(x); }
-LIBC_INLINE float log2f(float x) { return __nv_log2f(x); }
LIBC_INLINE double log(double x) { return __nv_log(x); }
-LIBC_INLINE float logf(float x) { return __nv_logf(x); }
LIBC_INLINE double nextafter(double x, double y) {
return __nv_nextafter(x, y);
}
>From b11a1c38101f656b8820bfc914df44dda46ee0e6 Mon Sep 17 00:00:00 2001
From: AntonRydahl <rydahl2610 at gmail.com>
Date: Wed, 18 Oct 2023 10:49:24 -0700
Subject: [PATCH 4/6] Updated namespace __llvm_libc to namespace LIBC_NAMESPACE
The change could be done with this command:
```
for file in `grep -rn libc/src/math -e "namespace.*libc" -l`; do echo "updating $file"; sed -i -e 's/__llvm_libc/LIBC_NAMESPACE/g' $file; done
```
---
libc/src/math/acos.h | 4 ++--
libc/src/math/acosh.h | 4 ++--
libc/src/math/asin.h | 4 ++--
libc/src/math/asinh.h | 4 ++--
libc/src/math/atan.h | 4 ++--
libc/src/math/atan2.h | 4 ++--
libc/src/math/atan2f.h | 4 ++--
libc/src/math/atanh.h | 4 ++--
libc/src/math/erf.h | 4 ++--
libc/src/math/gpu/llrint.cpp | 2 +-
libc/src/math/gpu/llrintf.cpp | 2 +-
libc/src/math/gpu/llround.cpp | 2 +-
libc/src/math/gpu/llroundf.cpp | 2 +-
libc/src/math/gpu/log10f.cpp | 4 ++--
libc/src/math/gpu/log2f.cpp | 4 ++--
libc/src/math/gpu/logf.cpp | 4 ++--
libc/src/math/gpu/lrint.cpp | 4 ++--
libc/src/math/gpu/lrintf.cpp | 4 ++--
libc/src/math/gpu/lround.cpp | 4 ++--
libc/src/math/gpu/lroundf.cpp | 4 ++--
libc/src/math/gpu/vendor/acos.cpp | 4 ++--
libc/src/math/gpu/vendor/acosh.cpp | 4 ++--
libc/src/math/gpu/vendor/asin.cpp | 4 ++--
libc/src/math/gpu/vendor/asinh.cpp | 4 ++--
libc/src/math/gpu/vendor/atan.cpp | 4 ++--
libc/src/math/gpu/vendor/atan2.cpp | 4 ++--
libc/src/math/gpu/vendor/atan2f.cpp | 4 ++--
libc/src/math/gpu/vendor/atanh.cpp | 4 ++--
libc/src/math/gpu/vendor/erf.cpp | 4 ++--
libc/src/math/gpu/vendor/erff.cpp | 4 ++--
libc/src/math/gpu/vendor/exp.cpp | 4 ++--
libc/src/math/gpu/vendor/exp10.cpp | 4 ++--
libc/src/math/gpu/vendor/exp2.cpp | 4 ++--
libc/src/math/gpu/vendor/expm1.cpp | 4 ++--
libc/src/math/gpu/vendor/log.cpp | 4 ++--
libc/src/math/gpu/vendor/log10.cpp | 4 ++--
libc/src/math/gpu/vendor/log1p.cpp | 4 ++--
libc/src/math/gpu/vendor/log1pf.cpp | 4 ++--
libc/src/math/gpu/vendor/log2.cpp | 4 ++--
libc/src/math/gpu/vendor/logb.cpp | 4 ++--
libc/src/math/gpu/vendor/logbf.cpp | 4 ++--
libc/src/math/gpu/vendor/tgamma.cpp | 4 ++--
libc/src/math/gpu/vendor/tgammaf.cpp | 4 ++--
libc/src/math/sincos.h | 4 ++--
libc/src/math/tgamma.h | 4 ++--
libc/src/math/tgammaf.h | 4 ++--
46 files changed, 88 insertions(+), 88 deletions(-)
diff --git a/libc/src/math/acos.h b/libc/src/math/acos.h
index 53b299f1da8902e..da89a9dd3d9d484 100644
--- a/libc/src/math/acos.h
+++ b/libc/src/math/acos.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_ACOS_H
#define LLVM_LIBC_SRC_MATH_ACOS_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
double acos(double x);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ACOS_H
diff --git a/libc/src/math/acosh.h b/libc/src/math/acosh.h
index 851c619fdb9f799..a5bbd82c120b8c4 100644
--- a/libc/src/math/acosh.h
+++ b/libc/src/math/acosh.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_ACOSH_H
#define LLVM_LIBC_SRC_MATH_ACOSH_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
double acosh(double x);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ACOSH_H
diff --git a/libc/src/math/asin.h b/libc/src/math/asin.h
index d8f3f191a357856..e443776e507d963 100644
--- a/libc/src/math/asin.h
+++ b/libc/src/math/asin.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_ASIN_H
#define LLVM_LIBC_SRC_MATH_ASIN_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
double asin(double x);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ASIN_H
diff --git a/libc/src/math/asinh.h b/libc/src/math/asinh.h
index 098880f26ecc80c..418bf9617984113 100644
--- a/libc/src/math/asinh.h
+++ b/libc/src/math/asinh.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_ASINH_H
#define LLVM_LIBC_SRC_MATH_ASINH_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
double asinh(double x);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ASINH_H
diff --git a/libc/src/math/atan.h b/libc/src/math/atan.h
index 73d67e526d7d5a5..bcbc97a52ee6d85 100644
--- a/libc/src/math/atan.h
+++ b/libc/src/math/atan.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_ATAN_H
#define LLVM_LIBC_SRC_MATH_ATAN_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
double atan(double x);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ATAN_H
diff --git a/libc/src/math/atan2.h b/libc/src/math/atan2.h
index cac5b7ddfbb62c1..024bbfb5fe9cb84 100644
--- a/libc/src/math/atan2.h
+++ b/libc/src/math/atan2.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_ATAN2_H
#define LLVM_LIBC_SRC_MATH_ATAN2_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
double atan2(double x, double y);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ATAN2_H
diff --git a/libc/src/math/atan2f.h b/libc/src/math/atan2f.h
index d3e81a2b8d5f2d4..25d2de09342fa59 100644
--- a/libc/src/math/atan2f.h
+++ b/libc/src/math/atan2f.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_ATAN2F_H
#define LLVM_LIBC_SRC_MATH_ATAN2F_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
float atan2f(float x, float y);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ATAN2F_H
diff --git a/libc/src/math/atanh.h b/libc/src/math/atanh.h
index de854451e7a281f..dc84d07c02a0ab2 100644
--- a/libc/src/math/atanh.h
+++ b/libc/src/math/atanh.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_ATANH_H
#define LLVM_LIBC_SRC_MATH_ATANH_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
double atanh(double x);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ATANH_H
diff --git a/libc/src/math/erf.h b/libc/src/math/erf.h
index 86a146182b4f729..a38c92410de1358 100644
--- a/libc/src/math/erf.h
+++ b/libc/src/math/erf.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_ERF_H
#define LLVM_LIBC_SRC_MATH_ERF_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
double erf(double x);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ERF_H
diff --git a/libc/src/math/gpu/llrint.cpp b/libc/src/math/gpu/llrint.cpp
index f6d70cf698754f1..30ab5335d8b15cc 100644
--- a/libc/src/math/gpu/llrint.cpp
+++ b/libc/src/math/gpu/llrint.cpp
@@ -9,7 +9,7 @@
#include "src/math/llrint.h"
#include "src/__support/common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long long, llrint, (double x)) {
return __builtin_llrint(x);
diff --git a/libc/src/math/gpu/llrintf.cpp b/libc/src/math/gpu/llrintf.cpp
index 2f78ebd4cd8d988..b7bc7a7024777d5 100644
--- a/libc/src/math/gpu/llrintf.cpp
+++ b/libc/src/math/gpu/llrintf.cpp
@@ -9,7 +9,7 @@
#include "src/math/llrintf.h"
#include "src/__support/common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long long, llrintf, (float x)) {
return __builtin_llrintf(x);
diff --git a/libc/src/math/gpu/llround.cpp b/libc/src/math/gpu/llround.cpp
index d58b14645d28546..afd98308730a620 100644
--- a/libc/src/math/gpu/llround.cpp
+++ b/libc/src/math/gpu/llround.cpp
@@ -9,7 +9,7 @@
#include "src/math/llround.h"
#include "src/__support/common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long long, llround, (double x)) {
return __builtin_llround(x);
diff --git a/libc/src/math/gpu/llroundf.cpp b/libc/src/math/gpu/llroundf.cpp
index ba09976c568f7cf..897ed15b692848e 100644
--- a/libc/src/math/gpu/llroundf.cpp
+++ b/libc/src/math/gpu/llroundf.cpp
@@ -9,7 +9,7 @@
#include "src/math/llroundf.h"
#include "src/__support/common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long long, llroundf, (float x)) {
return __builtin_lroundf(x);
diff --git a/libc/src/math/gpu/log10f.cpp b/libc/src/math/gpu/log10f.cpp
index 2718ed2a9aa5e61..7bdfac7fa800410 100644
--- a/libc/src/math/gpu/log10f.cpp
+++ b/libc/src/math/gpu/log10f.cpp
@@ -9,8 +9,8 @@
#include "src/math/log10f.h"
#include "src/__support/common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(float, log10f, (float x)) { return __builtin_log10f(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/log2f.cpp b/libc/src/math/gpu/log2f.cpp
index 563c73ee807589c..9994f0a84e5178f 100644
--- a/libc/src/math/gpu/log2f.cpp
+++ b/libc/src/math/gpu/log2f.cpp
@@ -9,8 +9,8 @@
#include "src/math/log2f.h"
#include "src/__support/common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(float, log2f, (float x)) { return __builtin_log2f(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/logf.cpp b/libc/src/math/gpu/logf.cpp
index 23918a8a1422b6d..ef6e2111fa0aa18 100644
--- a/libc/src/math/gpu/logf.cpp
+++ b/libc/src/math/gpu/logf.cpp
@@ -9,8 +9,8 @@
#include "src/math/logf.h"
#include "src/__support/common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(float, logf, (float x)) { return __builtin_logf(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/lrint.cpp b/libc/src/math/gpu/lrint.cpp
index acdade0f2dd4fd3..aa81a343e9d8e91 100644
--- a/libc/src/math/gpu/lrint.cpp
+++ b/libc/src/math/gpu/lrint.cpp
@@ -9,8 +9,8 @@
#include "src/math/lrint.h"
#include "src/__support/common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long, lrint, (double x)) { return __builtin_lrint(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/lrintf.cpp b/libc/src/math/gpu/lrintf.cpp
index 7d8d65644b34f6e..dbe9c7ac682acf0 100644
--- a/libc/src/math/gpu/lrintf.cpp
+++ b/libc/src/math/gpu/lrintf.cpp
@@ -9,8 +9,8 @@
#include "src/math/lrintf.h"
#include "src/__support/common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long, lrintf, (float x)) { return __builtin_lrintf(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/lround.cpp b/libc/src/math/gpu/lround.cpp
index ced70a495e5a198..51e8f2245af8ea3 100644
--- a/libc/src/math/gpu/lround.cpp
+++ b/libc/src/math/gpu/lround.cpp
@@ -9,8 +9,8 @@
#include "src/math/lround.h"
#include "src/__support/common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long, lround, (double x)) { return __builtin_lround(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/lroundf.cpp b/libc/src/math/gpu/lroundf.cpp
index ef0d114ce0562ff..585a47aaee5b9bf 100644
--- a/libc/src/math/gpu/lroundf.cpp
+++ b/libc/src/math/gpu/lroundf.cpp
@@ -10,8 +10,8 @@
#include "src/math/lroundf.h"
#include "src/__support/common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long, lroundf, (float x)) { return __builtin_lroundf(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/acos.cpp b/libc/src/math/gpu/vendor/acos.cpp
index 7e6d00be3c3e589..83b674fa6ae3b7c 100644
--- a/libc/src/math/gpu/vendor/acos.cpp
+++ b/libc/src/math/gpu/vendor/acos.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, acos, (double x)) { return internal::acos(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/acosh.cpp b/libc/src/math/gpu/vendor/acosh.cpp
index 2ea150dcf78e03a..cc1b8b572b3db7d 100644
--- a/libc/src/math/gpu/vendor/acosh.cpp
+++ b/libc/src/math/gpu/vendor/acosh.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, acosh, (double x)) { return internal::acosh(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/asin.cpp b/libc/src/math/gpu/vendor/asin.cpp
index eaf7253ad1ecaff..24a8a136e88eb2c 100644
--- a/libc/src/math/gpu/vendor/asin.cpp
+++ b/libc/src/math/gpu/vendor/asin.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, asin, (double x)) { return internal::asin(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/asinh.cpp b/libc/src/math/gpu/vendor/asinh.cpp
index ddb33ebae3a590a..f417d9fd8c1f733 100644
--- a/libc/src/math/gpu/vendor/asinh.cpp
+++ b/libc/src/math/gpu/vendor/asinh.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, asinh, (double x)) { return internal::asinh(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/atan.cpp b/libc/src/math/gpu/vendor/atan.cpp
index 88452dc60188a59..45d7f02c02cd636 100644
--- a/libc/src/math/gpu/vendor/atan.cpp
+++ b/libc/src/math/gpu/vendor/atan.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, atan, (double x)) { return internal::atan(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/atan2.cpp b/libc/src/math/gpu/vendor/atan2.cpp
index 9f5736f7c30e1f8..94e215e52ca6028 100644
--- a/libc/src/math/gpu/vendor/atan2.cpp
+++ b/libc/src/math/gpu/vendor/atan2.cpp
@@ -11,10 +11,10 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, atan2, (double x, double y)) {
return internal::atan2(x, y);
}
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/atan2f.cpp b/libc/src/math/gpu/vendor/atan2f.cpp
index 897bd5d26527763..f29b97cf3d096c2 100644
--- a/libc/src/math/gpu/vendor/atan2f.cpp
+++ b/libc/src/math/gpu/vendor/atan2f.cpp
@@ -12,10 +12,10 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(float, atan2f, (float x, float y)) {
return internal::atan2f(x, y);
}
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/atanh.cpp b/libc/src/math/gpu/vendor/atanh.cpp
index 97246bf195ff77c..07a75fcbbfc7c6a 100644
--- a/libc/src/math/gpu/vendor/atanh.cpp
+++ b/libc/src/math/gpu/vendor/atanh.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, atanh, (double x)) { return internal::atanh(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/erf.cpp b/libc/src/math/gpu/vendor/erf.cpp
index f06ab8121ebd669..190321ca25992ed 100644
--- a/libc/src/math/gpu/vendor/erf.cpp
+++ b/libc/src/math/gpu/vendor/erf.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, erf, (double x)) { return internal::erf(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/erff.cpp b/libc/src/math/gpu/vendor/erff.cpp
index 78c31383d86acb1..a5a08be54b0756b 100644
--- a/libc/src/math/gpu/vendor/erff.cpp
+++ b/libc/src/math/gpu/vendor/erff.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(float, erff, (float x)) { return internal::erff(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/exp.cpp b/libc/src/math/gpu/vendor/exp.cpp
index dc315d9555b422a..ee5a22019f6a54e 100644
--- a/libc/src/math/gpu/vendor/exp.cpp
+++ b/libc/src/math/gpu/vendor/exp.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, exp, (double x)) { return internal::exp(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/exp10.cpp b/libc/src/math/gpu/vendor/exp10.cpp
index 1bb746bfdcac260..8557a33f0188449 100644
--- a/libc/src/math/gpu/vendor/exp10.cpp
+++ b/libc/src/math/gpu/vendor/exp10.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, exp10, (double x)) { return internal::exp10(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/exp2.cpp b/libc/src/math/gpu/vendor/exp2.cpp
index 0dbea3837cbdd0d..ffa23d810a9b1e3 100644
--- a/libc/src/math/gpu/vendor/exp2.cpp
+++ b/libc/src/math/gpu/vendor/exp2.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, exp2, (double x)) { return internal::exp2(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/expm1.cpp b/libc/src/math/gpu/vendor/expm1.cpp
index 528daab22e14cfd..6ac5f753b9e4df1 100644
--- a/libc/src/math/gpu/vendor/expm1.cpp
+++ b/libc/src/math/gpu/vendor/expm1.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, expm1, (double x)) { return internal::expm1(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/log.cpp b/libc/src/math/gpu/vendor/log.cpp
index fe44d78724a4ca2..a97689abcc21717 100644
--- a/libc/src/math/gpu/vendor/log.cpp
+++ b/libc/src/math/gpu/vendor/log.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, log, (double x)) { return internal::log(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/log10.cpp b/libc/src/math/gpu/vendor/log10.cpp
index 6666dae827646da..c7a917a75cc969f 100644
--- a/libc/src/math/gpu/vendor/log10.cpp
+++ b/libc/src/math/gpu/vendor/log10.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, log10, (double x)) { return internal::log10(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/log1p.cpp b/libc/src/math/gpu/vendor/log1p.cpp
index e2781bfbab1ceba..720d23e2f952b8f 100644
--- a/libc/src/math/gpu/vendor/log1p.cpp
+++ b/libc/src/math/gpu/vendor/log1p.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, log1p, (double x)) { return internal::log1p(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/log1pf.cpp b/libc/src/math/gpu/vendor/log1pf.cpp
index 3cdde90d94b132f..96ad48b529cf6fb 100644
--- a/libc/src/math/gpu/vendor/log1pf.cpp
+++ b/libc/src/math/gpu/vendor/log1pf.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(float, log1pf, (float x)) { return internal::log1pf(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/log2.cpp b/libc/src/math/gpu/vendor/log2.cpp
index 45d2200d269009d..9fc8a81e7e7570d 100644
--- a/libc/src/math/gpu/vendor/log2.cpp
+++ b/libc/src/math/gpu/vendor/log2.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, log2, (double x)) { return internal::log2(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/logb.cpp b/libc/src/math/gpu/vendor/logb.cpp
index d7aa9a1d1517e6a..5dea57d41b08b1d 100644
--- a/libc/src/math/gpu/vendor/logb.cpp
+++ b/libc/src/math/gpu/vendor/logb.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, logb, (double x)) { return internal::logb(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/logbf.cpp b/libc/src/math/gpu/vendor/logbf.cpp
index 021bed06c69032c..5a9580cd06be596 100644
--- a/libc/src/math/gpu/vendor/logbf.cpp
+++ b/libc/src/math/gpu/vendor/logbf.cpp
@@ -12,8 +12,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(float, logbf, (float x)) { return internal::logbf(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/tgamma.cpp b/libc/src/math/gpu/vendor/tgamma.cpp
index 9895c4bfcf55926..e86116a2b0abea0 100644
--- a/libc/src/math/gpu/vendor/tgamma.cpp
+++ b/libc/src/math/gpu/vendor/tgamma.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(double, tgamma, (double x)) { return internal::tgamma(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/tgammaf.cpp b/libc/src/math/gpu/vendor/tgammaf.cpp
index 9e86dacf36083a9..552919bae446957 100644
--- a/libc/src/math/gpu/vendor/tgammaf.cpp
+++ b/libc/src/math/gpu/vendor/tgammaf.cpp
@@ -11,8 +11,8 @@
#include "common.h"
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(float, tgammaf, (float x)) { return internal::tgammaf(x); }
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/sincos.h b/libc/src/math/sincos.h
index 2e3d0673935193f..6235a7c5c04546b 100644
--- a/libc/src/math/sincos.h
+++ b/libc/src/math/sincos.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_SINCOS_H
#define LLVM_LIBC_SRC_MATH_SINCOS_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
void sincos(double x, double *sinx, double *cosx);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_SINCOS_H
diff --git a/libc/src/math/tgamma.h b/libc/src/math/tgamma.h
index 295070383f3950c..24590ed1a467695 100644
--- a/libc/src/math/tgamma.h
+++ b/libc/src/math/tgamma.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_TGAMMA_H
#define LLVM_LIBC_SRC_MATH_TGAMMA_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
double tgamma(double x);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_TGAMMA_H
diff --git a/libc/src/math/tgammaf.h b/libc/src/math/tgammaf.h
index c098dae4b7ec6bd..d28e4c325152abe 100644
--- a/libc/src/math/tgammaf.h
+++ b/libc/src/math/tgammaf.h
@@ -9,10 +9,10 @@
#ifndef LLVM_LIBC_SRC_MATH_TGAMMAF_H
#define LLVM_LIBC_SRC_MATH_TGAMMAF_H
-namespace __llvm_libc {
+namespace LIBC_NAMESPACE {
float tgammaf(float x);
-} // namespace __llvm_libc
+} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_TGAMMAF_H
>From 153a982644105a6e4e91bfde10096b3156cf7b76 Mon Sep 17 00:00:00 2001
From: AntonRydahl <rydahl2610 at gmail.com>
Date: Wed, 18 Oct 2023 14:25:08 -0700
Subject: [PATCH 5/6] Passing all tests on gfx906 and sm_60 with and without
vendor math enabled
---
libc/src/math/gpu/CMakeLists.txt | 100 ----------
libc/src/math/gpu/vendor/CMakeLists.txt | 176 ++++++++++++++++--
libc/src/math/gpu/vendor/amdgpu/amdgpu.h | 20 +-
.../src/math/gpu/vendor/amdgpu/declarations.h | 4 +
libc/src/math/gpu/vendor/llrint.cpp | 20 ++
libc/src/math/gpu/vendor/llrintf.cpp | 20 ++
libc/src/math/gpu/{ => vendor}/log10f.cpp | 4 +-
.../math/gpu/{tanf.cpp => vendor/log2f.cpp} | 8 +-
.../math/gpu/{sinhf.cpp => vendor/logf.cpp} | 8 +-
.../math/gpu/{tanhf.cpp => vendor/lrint.cpp} | 8 +-
libc/src/math/gpu/vendor/lrintf.cpp | 18 ++
libc/src/math/gpu/vendor/nvptx/declarations.h | 10 +
libc/src/math/gpu/vendor/nvptx/nvptx.h | 10 +
13 files changed, 284 insertions(+), 122 deletions(-)
create mode 100644 libc/src/math/gpu/vendor/llrint.cpp
create mode 100644 libc/src/math/gpu/vendor/llrintf.cpp
rename libc/src/math/gpu/{ => vendor}/log10f.cpp (85%)
rename libc/src/math/gpu/{tanf.cpp => vendor/log2f.cpp} (68%)
rename libc/src/math/gpu/{sinhf.cpp => vendor/logf.cpp} (68%)
rename libc/src/math/gpu/{tanhf.cpp => vendor/lrint.cpp} (68%)
create mode 100644 libc/src/math/gpu/vendor/lrintf.cpp
diff --git a/libc/src/math/gpu/CMakeLists.txt b/libc/src/math/gpu/CMakeLists.txt
index 94bc518378d77c1..75a916e2a0112af 100644
--- a/libc/src/math/gpu/CMakeLists.txt
+++ b/libc/src/math/gpu/CMakeLists.txt
@@ -183,56 +183,6 @@ add_math_entrypoint_gpu_object(
-O2
)
-add_math_entrypoint_gpu_object(
- log10f
- SRCS
- log10f.cpp
- HDRS
- ../log10f.h
- COMPILE_OPTIONS
- -O2
-)
-
-add_math_entrypoint_gpu_object(
- log2f
- SRCS
- log2f.cpp
- HDRS
- ../log2f.h
- COMPILE_OPTIONS
- -O2
-)
-
-add_math_entrypoint_gpu_object(
- logf
- SRCS
- logf.cpp
- HDRS
- ../logf.h
- COMPILE_OPTIONS
- -O2
-)
-
-add_math_entrypoint_gpu_object(
- lrint
- SRCS
- lrint.cpp
- HDRS
- ../lrint.h
- COMPILE_OPTIONS
- -O2
-)
-
-add_math_entrypoint_gpu_object(
- lrintf
- SRCS
- lrintf.cpp
- HDRS
- ../lrintf.h
- COMPILE_OPTIONS
- -O2
-)
-
add_math_entrypoint_gpu_object(
lround
SRCS
@@ -253,26 +203,6 @@ add_math_entrypoint_gpu_object(
-O2
)
-add_math_entrypoint_gpu_object(
- llrint
- SRCS
- llrint.cpp
- HDRS
- ../llrint.h
- COMPILE_OPTIONS
- -O2
-)
-
-add_math_entrypoint_gpu_object(
- llrintf
- SRCS
- llrintf.cpp
- HDRS
- ../llrintf.h
- COMPILE_OPTIONS
- -O2
-)
-
add_math_entrypoint_gpu_object(
llround
SRCS
@@ -393,16 +323,6 @@ add_math_entrypoint_gpu_object(
-O2
)
-add_math_entrypoint_gpu_object(
- sinhf
- SRCS
- sinhf.cpp
- HDRS
- ../sinhf.h
- COMPILE_OPTIONS
- -O2
-)
-
add_math_entrypoint_gpu_object(
sqrt
SRCS
@@ -433,16 +353,6 @@ add_math_entrypoint_gpu_object(
-O2
)
-add_math_entrypoint_gpu_object(
- tanf
- SRCS
- tanf.cpp
- HDRS
- ../tanf.h
- COMPILE_OPTIONS
- -O2
-)
-
add_math_entrypoint_gpu_object(
tanh
SRCS
@@ -453,16 +363,6 @@ add_math_entrypoint_gpu_object(
-O2
)
-add_math_entrypoint_gpu_object(
- tanhf
- SRCS
- tanhf.cpp
- HDRS
- ../tanhf.h
- COMPILE_OPTIONS
- -O2
-)
-
add_math_entrypoint_gpu_object(
trunc
SRCS
diff --git a/libc/src/math/gpu/vendor/CMakeLists.txt b/libc/src/math/gpu/vendor/CMakeLists.txt
index 963249bcc245021..a154c94a7009ada 100644
--- a/libc/src/math/gpu/vendor/CMakeLists.txt
+++ b/libc/src/math/gpu/vendor/CMakeLists.txt
@@ -106,17 +106,6 @@ add_entrypoint_object(
-O2
)
-add_entrypoint_object(
- asinhf
- SRCS
- asinhf.cpp
- HDRS
- ../../asinhf.h
- COMPILE_OPTIONS
- ${bitcode_link_flags}
- -O2
-)
-
add_entrypoint_object(
atan
SRCS
@@ -249,6 +238,28 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ exp
+ SRCS
+ exp.cpp
+ HDRS
+ ../../exp.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ exp10
+ SRCS
+ exp10.cpp
+ HDRS
+ ../../exp10.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
exp10f
SRCS
@@ -260,6 +271,17 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ exp2
+ SRCS
+ exp2.cpp
+ HDRS
+ ../../exp2.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
exp2f
SRCS
@@ -370,6 +392,94 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ log10
+ SRCS
+ log10.cpp
+ HDRS
+ ../../log10.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ log10f
+ SRCS
+ log10f.cpp
+ HDRS
+ ../../log10f.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ log2
+ SRCS
+ log2.cpp
+ HDRS
+ ../../log2.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ log2f
+ SRCS
+ log2f.cpp
+ HDRS
+ ../../log2f.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ log
+ SRCS
+ log.cpp
+ HDRS
+ ../../log.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ logf
+ SRCS
+ logf.cpp
+ HDRS
+ ../../logf.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ lrint
+ SRCS
+ lrint.cpp
+ HDRS
+ ../../lrint.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ lrintf
+ SRCS
+ lrintf.cpp
+ HDRS
+ ../../lrintf.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
ldexp
SRCS
@@ -392,6 +502,50 @@ add_entrypoint_object(
-O2
)
+add_entrypoint_object(
+ log1p
+ SRCS
+ log1p.cpp
+ HDRS
+ ../../log1p.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ log1pf
+ SRCS
+ log1pf.cpp
+ HDRS
+ ../../log1pf.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ llrint
+ SRCS
+ llrint.cpp
+ HDRS
+ ../../llrint.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
+add_entrypoint_object(
+ llrintf
+ SRCS
+ llrintf.cpp
+ HDRS
+ ../../llrintf.h
+ COMPILE_OPTIONS
+ ${bitcode_link_flags}
+ -O2
+)
+
add_entrypoint_object(
remquo
SRCS
diff --git a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
index 9624325b2e79473..43961fc75982abf 100644
--- a/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
+++ b/libc/src/math/gpu/vendor/amdgpu/amdgpu.h
@@ -36,8 +36,11 @@ LIBC_INLINE double cosh(double x) { return __ocml_cosh_f64(x); }
LIBC_INLINE float coshf(float x) { return __ocml_cosh_f32(x); }
LIBC_INLINE double erf(double x) { return __ocml_erf_f64(x); }
LIBC_INLINE float erff(float x) { return __ocml_erf_f32(x); }
+LIBC_INLINE double exp(double x) { return __builtin_exp(x); }
LIBC_INLINE float expf(float x) { return __builtin_expf(x); }
-LIBC_INLINE float exp2f(float x) { return __builtin_exp2f(x); }
+LIBC_INLINE double exp2(double x) { return __ocml_exp2_f64(x); }
+LIBC_INLINE float exp2f(float x) { return __ocml_exp2_f32(x); }
+LIBC_INLINE double exp10(double x) { return __ocml_exp10_f64(x); }
LIBC_INLINE float exp10f(float x) { return __ocml_exp10_f32(x); }
LIBC_INLINE double expm1(double x) { return __ocml_expm1_f64(x); }
LIBC_INLINE float expm1f(float x) { return __ocml_expm1_f32(x); }
@@ -49,11 +52,26 @@ 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 static_cast<long long>(__builtin_rint(x));
+}
+LIBC_INLINE long long llrintf(float x) {
+ return static_cast<long long>(__builtin_rintf(x));
+}
LIBC_INLINE double log10(double x) { return __ocml_log10_f64(x); }
+LIBC_INLINE float log10f(float x) { return __ocml_log10_f32(x); }
LIBC_INLINE double log1p(double x) { return __ocml_log1p_f64(x); }
LIBC_INLINE float log1pf(float x) { return __ocml_log1p_f32(x); }
LIBC_INLINE double log2(double x) { return __ocml_log2_f64(x); }
+LIBC_INLINE float log2f(float x) { return __ocml_log2_f32(x); }
LIBC_INLINE double log(double x) { return __ocml_log_f64(x); }
+LIBC_INLINE float logf(float x) { return __ocml_log_f32(x); }
+LIBC_INLINE long lrint(double x) {
+ return static_cast<long>(__builtin_rint(x));
+}
+LIBC_INLINE long lrintf(float x) {
+ return static_cast<long>(__builtin_rintf(x));
+}
LIBC_INLINE double nextafter(double x, double y) {
return __ocml_nextafter_f64(x, y);
}
diff --git a/libc/src/math/gpu/vendor/amdgpu/declarations.h b/libc/src/math/gpu/vendor/amdgpu/declarations.h
index e68c52b59fa3ccd..7a01cbc6ab19d00 100644
--- a/libc/src/math/gpu/vendor/amdgpu/declarations.h
+++ b/libc/src/math/gpu/vendor/amdgpu/declarations.h
@@ -39,6 +39,7 @@ double __ocml_exp_f64(double);
float __ocml_exp2_f32(float);
double __ocml_exp2_f64(double);
float __ocml_exp10_f32(float);
+double __ocml_exp10_f64(double);
double __ocml_exp2_f64(double);
float __ocml_expm1_f32(float);
double __ocml_expm1_f64(double);
@@ -50,10 +51,13 @@ int __ocml_ilogb_f64(double);
int __ocml_ilogb_f32(float);
float __ocml_ldexp_f32(float, int);
double __ocml_ldexp_f64(double, int);
+float __ocml_log10_f32(float);
double __ocml_log10_f64(double);
float __ocml_log1p_f32(float);
double __ocml_log1p_f64(double);
+float __ocml_log2_f32(float);
double __ocml_log2_f64(double);
+float __ocml_log_f32(float);
double __ocml_log_f64(double);
float __ocml_nextafter_f32(float, float);
double __ocml_nextafter_f64(double, double);
diff --git a/libc/src/math/gpu/vendor/llrint.cpp b/libc/src/math/gpu/vendor/llrint.cpp
new file mode 100644
index 000000000000000..aafd1609002b2b9
--- /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 LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(long long, llrint, (double x)) {
+ return internal::llrint(x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/llrintf.cpp b/libc/src/math/gpu/vendor/llrintf.cpp
new file mode 100644
index 000000000000000..39cd3ad0c021a55
--- /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 LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(long long, llrintf, (float x)) {
+ return internal::llrintf(x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/log10f.cpp b/libc/src/math/gpu/vendor/log10f.cpp
similarity index 85%
rename from libc/src/math/gpu/log10f.cpp
rename to libc/src/math/gpu/vendor/log10f.cpp
index 7bdfac7fa800410..489f5f558be1f59 100644
--- a/libc/src/math/gpu/log10f.cpp
+++ b/libc/src/math/gpu/vendor/log10f.cpp
@@ -9,8 +9,10 @@
#include "src/math/log10f.h"
#include "src/__support/common.h"
+#include "common.h"
+
namespace LIBC_NAMESPACE {
-LLVM_LIBC_FUNCTION(float, log10f, (float x)) { return __builtin_log10f(x); }
+LLVM_LIBC_FUNCTION(float, log10f, (float x)) { return internal::log10f(x); }
} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/tanf.cpp b/libc/src/math/gpu/vendor/log2f.cpp
similarity index 68%
rename from libc/src/math/gpu/tanf.cpp
rename to libc/src/math/gpu/vendor/log2f.cpp
index da7bd54ab08ae30..62df41b69b0bd89 100644
--- a/libc/src/math/gpu/tanf.cpp
+++ b/libc/src/math/gpu/vendor/log2f.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation of the GPU tanf function ---------------------------===//
+//===-- Implementation of the GPU log2f function --------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,11 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "src/math/tanf.h"
+#include "src/math/log2f.h"
#include "src/__support/common.h"
+#include "common.h"
+
namespace LIBC_NAMESPACE {
-LLVM_LIBC_FUNCTION(float, tanf, (float x)) { return __builtin_tanf(x); }
+LLVM_LIBC_FUNCTION(float, log2f, (float x)) { return internal::log2f(x); }
} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/sinhf.cpp b/libc/src/math/gpu/vendor/logf.cpp
similarity index 68%
rename from libc/src/math/gpu/sinhf.cpp
rename to libc/src/math/gpu/vendor/logf.cpp
index ed69dffe3ea831d..527b028e100d5ee 100644
--- a/libc/src/math/gpu/sinhf.cpp
+++ b/libc/src/math/gpu/vendor/logf.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation of the GPU sinhf function --------------------------===//
+//===-- Implementation of the GPU logf function ---------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,11 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "src/math/sinhf.h"
+#include "src/math/logf.h"
#include "src/__support/common.h"
+#include "common.h"
+
namespace LIBC_NAMESPACE {
-LLVM_LIBC_FUNCTION(float, sinhf, (float x)) { return __builtin_sinhf(x); }
+LLVM_LIBC_FUNCTION(float, logf, (float x)) { return internal::logf(x); }
} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/tanhf.cpp b/libc/src/math/gpu/vendor/lrint.cpp
similarity index 68%
rename from libc/src/math/gpu/tanhf.cpp
rename to libc/src/math/gpu/vendor/lrint.cpp
index be666fd9f8740c3..a08996b755b5280 100644
--- a/libc/src/math/gpu/tanhf.cpp
+++ b/libc/src/math/gpu/vendor/lrint.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation of the GPU tanhf function --------------------------===//
+//===-- Implementation of the lrint 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.
@@ -6,11 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include "src/math/tanhf.h"
+#include "src/math/lrint.h"
#include "src/__support/common.h"
+#include "common.h"
+
namespace LIBC_NAMESPACE {
-LLVM_LIBC_FUNCTION(float, tanhf, (float x)) { return __builtin_tanhf(x); }
+LLVM_LIBC_FUNCTION(long, lrint, (double x)) { return internal::lrint(x); }
} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/lrintf.cpp b/libc/src/math/gpu/vendor/lrintf.cpp
new file mode 100644
index 000000000000000..695a9b8202cf4ac
--- /dev/null
+++ b/libc/src/math/gpu/vendor/lrintf.cpp
@@ -0,0 +1,18 @@
+//===-- Implementation of the lrintf 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/lrintf.h"
+#include "src/__support/common.h"
+
+#include "common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(long, lrintf, (float x)) { return internal::lrintf(x); }
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/vendor/nvptx/declarations.h b/libc/src/math/gpu/vendor/nvptx/declarations.h
index 41cbd0b97f55c99..9cb2be67b85b1a9 100644
--- a/libc/src/math/gpu/vendor/nvptx/declarations.h
+++ b/libc/src/math/gpu/vendor/nvptx/declarations.h
@@ -32,8 +32,11 @@ double __nv_cosh(double);
float __nv_coshf(float);
double __nv_erf(double);
float __nv_erff(float);
+double __nv_exp(double);
float __nv_expf(float);
+double __nv_exp2(double);
float __nv_exp2f(float);
+double __nv_exp10(double);
float __nv_exp10f(float);
double __nv_expm1(double);
float __nv_expm1f(float);
@@ -45,11 +48,18 @@ 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 __nv_lrint(double);
+long __nv_lrintf(float);
double __nv_log10(double);
+float __nv_log10f(float);
double __nv_log1p(double);
float __nv_log1pf(float);
double __nv_log2(double);
+float __nv_log2f(float);
double __nv_log(double);
+float __nv_logf(float);
double __nv_nextafter(double, double);
float __nv_nextafterf(float, float);
double __nv_pow(double, double);
diff --git a/libc/src/math/gpu/vendor/nvptx/nvptx.h b/libc/src/math/gpu/vendor/nvptx/nvptx.h
index f68ddc47dcc3383..110d570a84a3930 100644
--- a/libc/src/math/gpu/vendor/nvptx/nvptx.h
+++ b/libc/src/math/gpu/vendor/nvptx/nvptx.h
@@ -35,8 +35,11 @@ LIBC_INLINE double cosh(double x) { return __nv_cosh(x); }
LIBC_INLINE float coshf(float x) { return __nv_coshf(x); }
LIBC_INLINE double erf(double x) { return __nv_erf(x); }
LIBC_INLINE float erff(float x) { return __nv_erff(x); }
+LIBC_INLINE double exp(double x) { return __nv_exp(x); }
LIBC_INLINE float expf(float x) { return __nv_expf(x); }
+LIBC_INLINE double exp2(double x) { return __nv_exp2(x); }
LIBC_INLINE float exp2f(float x) { return __nv_exp2f(x); }
+LIBC_INLINE double exp10(double x) { return __nv_exp10(x); }
LIBC_INLINE float exp10f(float x) { return __nv_exp10f(x); }
LIBC_INLINE double expm1(double x) { return __nv_expm1(x); }
LIBC_INLINE float expm1f(float x) { return __nv_expm1f(x); }
@@ -48,11 +51,18 @@ 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 double log10(double x) { return __nv_log10(x); }
+LIBC_INLINE float log10f(float x) { return __nv_log10f(x); }
LIBC_INLINE double log1p(double x) { return __nv_log1p(x); }
LIBC_INLINE float log1pf(float x) { return __nv_log1pf(x); }
LIBC_INLINE double log2(double x) { return __nv_log2(x); }
+LIBC_INLINE float log2f(float x) { return __nv_log2f(x); }
LIBC_INLINE double log(double x) { return __nv_log(x); }
+LIBC_INLINE float logf(float x) { return __nv_logf(x); }
+LIBC_INLINE long lrint(double x) { return __nv_lrint(x); }
+LIBC_INLINE long lrintf(float x) { return __nv_lrintf(x); }
LIBC_INLINE double nextafter(double x, double y) {
return __nv_nextafter(x, y);
}
>From 7236c024ecff2ac1d782e208e693ae9bcbd5c33f Mon Sep 17 00:00:00 2001
From: AntonRydahl <rydahl2610 at gmail.com>
Date: Wed, 18 Oct 2023 15:58:22 -0700
Subject: [PATCH 6/6] Removing __builtin_logf and __builtin_log2f and unused
files
---
libc/src/math/gpu/llrint.cpp | 18 ------------------
libc/src/math/gpu/llrintf.cpp | 18 ------------------
libc/src/math/gpu/log2f.cpp | 16 ----------------
libc/src/math/gpu/logf.cpp | 16 ----------------
libc/src/math/gpu/lrint.cpp | 16 ----------------
libc/src/math/gpu/lrintf.cpp | 16 ----------------
6 files changed, 100 deletions(-)
delete mode 100644 libc/src/math/gpu/llrint.cpp
delete mode 100644 libc/src/math/gpu/llrintf.cpp
delete mode 100644 libc/src/math/gpu/log2f.cpp
delete mode 100644 libc/src/math/gpu/logf.cpp
delete mode 100644 libc/src/math/gpu/lrint.cpp
delete mode 100644 libc/src/math/gpu/lrintf.cpp
diff --git a/libc/src/math/gpu/llrint.cpp b/libc/src/math/gpu/llrint.cpp
deleted file mode 100644
index 30ab5335d8b15cc..000000000000000
--- a/libc/src/math/gpu/llrint.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-//===-- Implementation of the GPU llrint function -------------------------===//
-//
-// 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"
-
-namespace LIBC_NAMESPACE {
-
-LLVM_LIBC_FUNCTION(long long, llrint, (double x)) {
- return __builtin_llrint(x);
-}
-
-} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/llrintf.cpp b/libc/src/math/gpu/llrintf.cpp
deleted file mode 100644
index b7bc7a7024777d5..000000000000000
--- a/libc/src/math/gpu/llrintf.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-//===-- Implementation of the GPU llrintf function ------------------------===//
-//
-// 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"
-
-namespace LIBC_NAMESPACE {
-
-LLVM_LIBC_FUNCTION(long long, llrintf, (float x)) {
- return __builtin_llrintf(x);
-}
-
-} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/log2f.cpp b/libc/src/math/gpu/log2f.cpp
deleted file mode 100644
index 9994f0a84e5178f..000000000000000
--- a/libc/src/math/gpu/log2f.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-//===-- Implementation of the GPU log2f function --------------------------===//
-//
-// 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/log2f.h"
-#include "src/__support/common.h"
-
-namespace LIBC_NAMESPACE {
-
-LLVM_LIBC_FUNCTION(float, log2f, (float x)) { return __builtin_log2f(x); }
-
-} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/logf.cpp b/libc/src/math/gpu/logf.cpp
deleted file mode 100644
index ef6e2111fa0aa18..000000000000000
--- a/libc/src/math/gpu/logf.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-//===-- Implementation of the GPU logf function ---------------------------===//
-//
-// 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/logf.h"
-#include "src/__support/common.h"
-
-namespace LIBC_NAMESPACE {
-
-LLVM_LIBC_FUNCTION(float, logf, (float x)) { return __builtin_logf(x); }
-
-} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/lrint.cpp b/libc/src/math/gpu/lrint.cpp
deleted file mode 100644
index aa81a343e9d8e91..000000000000000
--- a/libc/src/math/gpu/lrint.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-//===-- Implementation of the GPU lrint function --------------------------===//
-//
-// 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/lrint.h"
-#include "src/__support/common.h"
-
-namespace LIBC_NAMESPACE {
-
-LLVM_LIBC_FUNCTION(long, lrint, (double x)) { return __builtin_lrint(x); }
-
-} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/gpu/lrintf.cpp b/libc/src/math/gpu/lrintf.cpp
deleted file mode 100644
index dbe9c7ac682acf0..000000000000000
--- a/libc/src/math/gpu/lrintf.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-//===-- Implementation of the GPU lrintf function -------------------------===//
-//
-// 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/lrintf.h"
-#include "src/__support/common.h"
-
-namespace LIBC_NAMESPACE {
-
-LLVM_LIBC_FUNCTION(long, lrintf, (float x)) { return __builtin_lrintf(x); }
-
-} // namespace LIBC_NAMESPACE
More information about the cfe-commits
mailing list