[libc][libm][GPU] Add missing vendor entrypoints to the GPU version of libm (#66034)

This patch populates the GPU version of `libm` with missing vendor entrypoints. The vendor math entrypoints are disabled by default but can be enabled with the CMake option `LIBC_GPU_VENDOR_MATH=ON`.
This commit is contained in:
Anton Rydahl 2023-10-19 12:24:50 -07:00 committed by GitHub
parent a91a664839
commit c73ad025b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 1194 additions and 90 deletions

View File

@ -125,11 +125,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
@ -139,9 +147,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
@ -169,15 +183,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
@ -188,6 +213,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
@ -196,6 +225,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
)

View File

@ -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)
@ -199,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)
@ -217,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)

18
libc/src/math/acos.h Normal file
View File

@ -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 LIBC_NAMESPACE {
double acos(double x);
} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ACOS_H

18
libc/src/math/acosh.h Normal file
View File

@ -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 LIBC_NAMESPACE {
double acosh(double x);
} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ACOSH_H

18
libc/src/math/asin.h Normal file
View File

@ -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 LIBC_NAMESPACE {
double asin(double x);
} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ASIN_H

18
libc/src/math/asinh.h Normal file
View File

@ -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 LIBC_NAMESPACE {
double asinh(double x);
} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ASINH_H

18
libc/src/math/atan.h Normal file
View File

@ -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 LIBC_NAMESPACE {
double atan(double x);
} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ATAN_H

18
libc/src/math/atan2.h Normal file
View File

@ -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 LIBC_NAMESPACE {
double atan2(double x, double y);
} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ATAN2_H

18
libc/src/math/atan2f.h Normal file
View File

@ -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 LIBC_NAMESPACE {
float atan2f(float x, float y);
} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ATAN2F_H

18
libc/src/math/atanh.h Normal file
View File

@ -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 LIBC_NAMESPACE {
double atanh(double x);
} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ATANH_H

18
libc/src/math/erf.h Normal file
View File

@ -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 LIBC_NAMESPACE {
double erf(double x);
} // namespace LIBC_NAMESPACE
#endif // LLVM_LIBC_SRC_MATH_ERF_H

View File

@ -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
@ -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
@ -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
@ -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

View File

@ -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 LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long long, llround, (double x)) {
return internal::llround(x);
return __builtin_llround(x);
}
} // namespace LIBC_NAMESPACE

View File

@ -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 LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long long, llroundf, (float x)) {
return internal::llroundf(x);
return __builtin_lroundf(x);
}
} // namespace LIBC_NAMESPACE

View File

@ -1,4 +1,4 @@
//===-- 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.
@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
#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

View File

@ -1,4 +1,4 @@
//===-- 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.
@ -6,11 +6,11 @@
//
//===----------------------------------------------------------------------===//
#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

View File

@ -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
@ -63,11 +96,22 @@ add_entrypoint_object(
)
add_entrypoint_object(
asinhf
asinh
SRCS
asinhf.cpp
asinh.cpp
HDRS
../../asinhf.h
../../asinh.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
)
add_entrypoint_object(
atan
SRCS
atan.cpp
HDRS
../../atan.h
COMPILE_OPTIONS
${bitcode_link_flags}
-O2
@ -84,6 +128,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 +216,50 @@ 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(
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
@ -150,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
@ -172,6 +304,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
@ -249,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
@ -271,6 +502,28 @@ 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
@ -315,29 +568,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
@ -515,6 +745,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

18
libc/src/math/gpu/vendor/acos.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/acosh.cpp vendored Normal file
View File

@ -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

View File

@ -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); }
@ -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);
@ -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

View File

@ -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 *);
@ -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

18
libc/src/math/gpu/vendor/asin.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/asinh.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/atan.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/atan2.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/atan2f.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/atanh.cpp vendored Normal file
View File

@ -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

View File

@ -1,4 +1,4 @@
//===-- 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.
@ -6,11 +6,13 @@
//
//===----------------------------------------------------------------------===//
#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
libc/src/math/gpu/vendor/erff.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/exp.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/exp10.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/exp2.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/expm1.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/log.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/log10.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/log10f.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/log1p.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/log1pf.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/log2.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/log2f.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/logb.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/logbf.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/logf.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/lrint.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/lrintf.cpp vendored Normal file
View File

@ -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

View File

@ -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);
@ -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);
@ -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

View File

@ -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); }
@ -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);
}
@ -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

18
libc/src/math/gpu/vendor/tgamma.cpp vendored Normal file
View File

@ -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
libc/src/math/gpu/vendor/tgammaf.cpp vendored Normal file
View File

@ -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
libc/src/math/sincos.h Normal file
View File

@ -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
libc/src/math/tgamma.h Normal file
View File

@ -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
libc/src/math/tgammaf.h Normal file
View File

@ -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