diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt --- a/libc/config/gpu/entrypoints.txt +++ b/libc/config/gpu/entrypoints.txt @@ -83,6 +83,12 @@ set(TARGET_LIBM_ENTRYPOINTS # math.h entrypoints + libc.src.math.acosf + libc.src.math.acoshf + libc.src.math.asinf + libc.src.math.asinhf + libc.src.math.atanf + libc.src.math.atanhf libc.src.math.sin ) diff --git a/libc/src/math/gpu/CMakeLists.txt b/libc/src/math/gpu/CMakeLists.txt --- a/libc/src/math/gpu/CMakeLists.txt +++ b/libc/src/math/gpu/CMakeLists.txt @@ -22,6 +22,80 @@ endif() endif() + +add_entrypoint_object( + acosf + SRCS + acosf.cpp + HDRS + ../acosf.h + COMPILE_OPTIONS + -Wno-linker-warnings + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + acoshf + SRCS + acoshf.cpp + HDRS + ../acoshf.h + COMPILE_OPTIONS + -Wno-linker-warnings + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + asinf + SRCS + asinf.cpp + HDRS + ../asinf.h + COMPILE_OPTIONS + -Wno-linker-warnings + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + asinhf + SRCS + asinhf.cpp + HDRS + ../asinhf.h + COMPILE_OPTIONS + -Wno-linker-warnings + ${bitcode_link_flags} + -O2 +) + +add_entrypoint_object( + atanf + SRCS + atanf.cpp + HDRS + ../atanf.h + COMPILE_OPTIONS + -Wno-linker-warnings + ${bitcode_link_flags} + -O2 +) + + +add_entrypoint_object( + atanhf + SRCS + atanhf.cpp + HDRS + ../atanhf.h + COMPILE_OPTIONS + -Wno-linker-warnings + ${bitcode_link_flags} + -O2 +) + add_entrypoint_object( sin SRCS diff --git a/libc/src/math/gpu/nvptx/declarations.h b/libc/src/math/gpu/acosf.cpp copy from libc/src/math/gpu/nvptx/declarations.h copy to libc/src/math/gpu/acosf.cpp --- a/libc/src/math/gpu/nvptx/declarations.h +++ b/libc/src/math/gpu/acosf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the acosf function for GPU ----------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/acosf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, acosf, (float x)) { return internal::acosf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/nvptx/declarations.h b/libc/src/math/gpu/acoshf.cpp copy from libc/src/math/gpu/nvptx/declarations.h copy to libc/src/math/gpu/acoshf.cpp --- a/libc/src/math/gpu/nvptx/declarations.h +++ b/libc/src/math/gpu/acoshf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the acoshf function for GPU ---------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/acoshf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, acoshf, (float x)) { return internal::acoshf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/amdgpu/amdgpu.h b/libc/src/math/gpu/amdgpu/amdgpu.h --- a/libc/src/math/gpu/amdgpu/amdgpu.h +++ b/libc/src/math/gpu/amdgpu/amdgpu.h @@ -15,11 +15,17 @@ #include "src/__support/macros/attributes.h" namespace __llvm_libc { -namespace vendor { +namespace internal { +LIBC_INLINE float acosf(float x) { return __ocml_acos_f32(x); } +LIBC_INLINE float acoshf(float x) { return __ocml_acosh_f32(x); } +LIBC_INLINE float asinf(float x) { return __ocml_asin_f32(x); } +LIBC_INLINE float asinhf(float x) { return __ocml_asinh_f32(x); } +LIBC_INLINE float atanf(float x) { return __ocml_atan_f32(x); } +LIBC_INLINE float atanhf(float x) { return __ocml_atanh_f32(x); } LIBC_INLINE double sin(double x) { return __ocml_sin_f64(x); } -} // namespace vendor +} // namespace internal } // namespace __llvm_libc #endif // LLVM_LIBC_SRC_MATH_GPU_AMDGPU_H diff --git a/libc/src/math/gpu/amdgpu/declarations.h b/libc/src/math/gpu/amdgpu/declarations.h --- a/libc/src/math/gpu/amdgpu/declarations.h +++ b/libc/src/math/gpu/amdgpu/declarations.h @@ -12,6 +12,12 @@ namespace __llvm_libc { extern "C" { +float __ocml_acos_f32(float); +float __ocml_acosh_f32(float); +float __ocml_asin_f32(float); +float __ocml_asinh_f32(float); +float __ocml_atan_f32(float); +float __ocml_atanh_f32(float); double __ocml_sin_f64(double); } diff --git a/libc/src/math/gpu/nvptx/declarations.h b/libc/src/math/gpu/asinf.cpp copy from libc/src/math/gpu/nvptx/declarations.h copy to libc/src/math/gpu/asinf.cpp --- a/libc/src/math/gpu/nvptx/declarations.h +++ b/libc/src/math/gpu/asinf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the asinf function for GPU ----------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/asinf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, asinf, (float x)) { return internal::asinf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/nvptx/declarations.h b/libc/src/math/gpu/asinhf.cpp copy from libc/src/math/gpu/nvptx/declarations.h copy to libc/src/math/gpu/asinhf.cpp --- a/libc/src/math/gpu/nvptx/declarations.h +++ b/libc/src/math/gpu/asinhf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the asinhf function for GPU ---------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/asinhf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, asinhf, (float x)) { return internal::asinhf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/nvptx/declarations.h b/libc/src/math/gpu/atanf.cpp copy from libc/src/math/gpu/nvptx/declarations.h copy to libc/src/math/gpu/atanf.cpp --- a/libc/src/math/gpu/nvptx/declarations.h +++ b/libc/src/math/gpu/atanf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the atanf function for GPU ----------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/atanf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, atanf, (float x)) { return internal::atanf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/nvptx/declarations.h b/libc/src/math/gpu/atanhf.cpp copy from libc/src/math/gpu/nvptx/declarations.h copy to libc/src/math/gpu/atanhf.cpp --- a/libc/src/math/gpu/nvptx/declarations.h +++ b/libc/src/math/gpu/atanhf.cpp @@ -1,4 +1,4 @@ -//===-- NVPTX specific declarations for math support ----------------------===// +//===-- Implementation of the atanhf function for GPU ---------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H -#define LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H +#include "src/math/atanhf.h" +#include "src/__support/common.h" + +#include "common.h" namespace __llvm_libc { -extern "C" { -double __nv_sin(double); -} +LLVM_LIBC_FUNCTION(float, atanhf, (float x)) { return internal::atanhf(x); } } // namespace __llvm_libc - -#endif // LLVM_LIBC_SRC_MATH_GPU_NVPTX_DECLARATIONS_H diff --git a/libc/src/math/gpu/nvptx/declarations.h b/libc/src/math/gpu/nvptx/declarations.h --- a/libc/src/math/gpu/nvptx/declarations.h +++ b/libc/src/math/gpu/nvptx/declarations.h @@ -12,6 +12,12 @@ namespace __llvm_libc { extern "C" { +float __nv_acosf(float); +float __nv_acoshf(float); +float __nv_asinf(float); +float __nv_asinhf(float); +float __nv_atanf(float); +float __nv_atanhf(float); double __nv_sin(double); } diff --git a/libc/src/math/gpu/nvptx/nvptx.h b/libc/src/math/gpu/nvptx/nvptx.h --- a/libc/src/math/gpu/nvptx/nvptx.h +++ b/libc/src/math/gpu/nvptx/nvptx.h @@ -16,6 +16,12 @@ namespace __llvm_libc { namespace internal { +LIBC_INLINE float acosf(float x) { return __nv_acosf(x); } +LIBC_INLINE float acoshf(float x) { return __nv_acoshf(x); } +LIBC_INLINE float asinf(float x) { return __nv_asinf(x); } +LIBC_INLINE float asinhf(float x) { return __nv_asinhf(x); } +LIBC_INLINE float atanf(float x) { return __nv_atanf(x); } +LIBC_INLINE float atanhf(float x) { return __nv_atanhf(x); } LIBC_INLINE double sin(double x) { return __nv_sin(x); } } // namespace internal