Skip to content

Commit

Permalink
[libc][libm][GPU] Add missing vendor entrypoints to the GPU version o…
Browse files Browse the repository at this point in the history
…f `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`.
  • Loading branch information
AntonRydahl committed Oct 19, 2023
1 parent a91a664 commit c73ad02
Show file tree
Hide file tree
Showing 52 changed files with 1,190 additions and 86 deletions.
37 changes: 34 additions & 3 deletions libc/config/gpu/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
)
Expand Down
14 changes: 14 additions & 0 deletions libc/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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 changes: 18 additions & 0 deletions libc/src/math/acos.h
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions libc/src/math/acosh.h
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions libc/src/math/asin.h
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions libc/src/math/asinh.h
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions libc/src/math/atan.h
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions libc/src/math/atan2.h
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions libc/src/math/atan2f.h
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions libc/src/math/atanh.h
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions libc/src/math/erf.h
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit c73ad02

Please sign in to comment.