70 changes: 40 additions & 30 deletions libc/src/math/gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,46 @@ add_math_entrypoint_gpu_object(
-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(
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
Expand Down Expand Up @@ -283,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
Expand Down Expand Up @@ -323,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
Expand All @@ -343,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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -9,12 +9,10 @@
#include "src/math/llround.h"
#include "src/__support/common.h"

#include "common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(long long, llround, (double x)) {
return internal::llround(x);
return __builtin_llround(x);
}

} // namespace LIBC_NAMESPACE
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -9,12 +9,10 @@
#include "src/math/llroundf.h"
#include "src/__support/common.h"

#include "common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(long long, llroundf, (float x)) {
return internal::llroundf(x);
return __builtin_lroundf(x);
}

} // namespace LIBC_NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//===-- Implementation of the GPU sinhf function --------------------------===//
//===-- 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/sinhf.h"
#include "src/math/lround.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float, sinhf, (float x)) { return __builtin_sinhf(x); }
LLVM_LIBC_FUNCTION(long, lround, (double x)) { return __builtin_lround(x); }

} // namespace LIBC_NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//===-- Implementation of the GPU tanf 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.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/tanf.h"
#include "src/math/lroundf.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float, tanf, (float x)) { return __builtin_tanf(x); }
LLVM_LIBC_FUNCTION(long, lroundf, (float x)) { return __builtin_lroundf(x); }

} // namespace LIBC_NAMESPACE
296 changes: 274 additions & 22 deletions libc/src/math/gpu/vendor/CMakeLists.txt

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/acos.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, acos, (double x)) { return internal::acos(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/acosh.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, acosh, (double x)) { return internal::acosh(x); }

} // namespace LIBC_NAMESPACE
34 changes: 29 additions & 5 deletions libc/src/math/gpu/vendor/amdgpu/amdgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,33 @@

namespace LIBC_NAMESPACE {
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 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); }
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); }
Expand All @@ -44,11 +58,19 @@ LIBC_INLINE long long llrint(double 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 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 long llroundf(float x) {
return static_cast<long long>(__builtin_roundf(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);
Expand Down Expand Up @@ -96,6 +118,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 LIBC_NAMESPACE
Expand Down
31 changes: 26 additions & 5 deletions libc/src/math/gpu/vendor/amdgpu/declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,54 @@ namespace LIBC_NAMESPACE {

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_exp10_f64(double);
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);
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);
float __ocml_round_f32(float);
float __ocml_sin_f32(float);
double __ocml_sin_f64(double);
float __ocml_sincos_f32(float, float *);
Expand All @@ -56,6 +75,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 LIBC_NAMESPACE
Expand Down
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/asin.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, asin, (double x)) { return internal::asin(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/asinh.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, asinh, (double x)) { return internal::asinh(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/atan.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, atan, (double x)) { return internal::atan(x); }

} // namespace LIBC_NAMESPACE
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/atan2.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, atan2, (double x, double y)) {
return internal::atan2(x, y);
}

} // namespace LIBC_NAMESPACE
20 changes: 20 additions & 0 deletions libc/src/math/gpu/vendor/atan2f.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- 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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float, atan2f, (float x, float y)) {
return internal::atan2f(x, y);
}

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/atanh.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, atanh, (double x)) { return internal::atanh(x); }

} // namespace LIBC_NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
//===-- Implementation of the GPU tanhf function --------------------------===//
//===-- 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/tanhf.h"
#include "src/math/erf.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(double, erf, (double x)) { return internal::erf(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/erff.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float, erff, (float x)) { return internal::erff(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/exp.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, exp, (double x)) { return internal::exp(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/exp10.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, exp10, (double x)) { return internal::exp10(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/exp2.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, exp2, (double x)) { return internal::exp2(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/expm1.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, expm1, (double x)) { return internal::expm1(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/log.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, log, (double x)) { return internal::log(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/log10.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, log10, (double x)) { return internal::log10(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/log10f.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- 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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float, log10f, (float x)) { return internal::log10f(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/log1p.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, log1p, (double x)) { return internal::log1p(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/log1pf.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float, log1pf, (float x)) { return internal::log1pf(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/log2.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, log2, (double x)) { return internal::log2(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/log2f.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float, log2f, (float x)) { return internal::log2f(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/logb.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, logb, (double x)) { return internal::logb(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/logbf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- 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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float, logbf, (float x)) { return internal::logbf(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/logf.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float, logf, (float x)) { return internal::logf(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/lrint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- 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.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/lrint.h"
#include "src/__support/common.h"

#include "common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(long, lrint, (double x)) { return internal::lrint(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/lrintf.cpp
Original file line number Diff line number Diff line change
@@ -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
28 changes: 26 additions & 2 deletions libc/src/math/gpu/vendor/nvptx/declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,33 @@
namespace LIBC_NAMESPACE {

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);
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);
double __nv_fdim(double, double);
float __nv_fdimf(float, float);
Expand All @@ -36,8 +50,16 @@ 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);
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);
Expand All @@ -58,6 +80,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 LIBC_NAMESPACE
Expand Down
28 changes: 26 additions & 2 deletions libc/src/math/gpu/vendor/nvptx/nvptx.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,33 @@

namespace LIBC_NAMESPACE {
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 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); }
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); }
Expand All @@ -39,8 +53,16 @@ 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); }
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);
}
Expand Down Expand Up @@ -71,6 +93,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 LIBC_NAMESPACE
Expand Down
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/tgamma.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(double, tgamma, (double x)) { return internal::tgamma(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/gpu/vendor/tgammaf.cpp
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float, tgammaf, (float x)) { return internal::tgammaf(x); }

} // namespace LIBC_NAMESPACE
18 changes: 18 additions & 0 deletions libc/src/math/sincos.h
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

void sincos(double x, double *sinx, double *cosx);

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_MATH_SINCOS_H
18 changes: 18 additions & 0 deletions libc/src/math/tgamma.h
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

double tgamma(double x);

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_MATH_TGAMMA_H
18 changes: 18 additions & 0 deletions libc/src/math/tgammaf.h
Original file line number Diff line number Diff line change
@@ -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 LIBC_NAMESPACE {

float tgammaf(float x);

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_MATH_TGAMMAF_H