DPC++ Runtime
Runtime libraries for oneAPI DPC++
native_math_functions.cpp
Go to the documentation of this file.
1 //==------------------- native_math_functions.cpp --------------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include "host_helper_macros.hpp"
12 
13 #include <cmath>
14 
15 namespace sycl {
16 inline namespace _V1 {
17 namespace native {
18 #define BUILTIN_NATIVE_CUSTOM(NUM_ARGS, NAME, IMPL) \
19  HOST_IMPL(NAME, IMPL) \
20  EXPORT_SCALAR_AND_VEC_1_16_NS(NUM_ARGS, NAME, native, float)
21 
22 #define BUILTIN_NATIVE(NUM_ARGS, NAME) \
23  BUILTIN_NATIVE_CUSTOM(NUM_ARGS, NAME, std::NAME)
24 
25 BUILTIN_NATIVE(ONE_ARG, cos)
26 BUILTIN_NATIVE_CUSTOM(TWO_ARGS, divide, [](auto x, auto y) { return x / y; })
27 BUILTIN_NATIVE(ONE_ARG, exp)
28 BUILTIN_NATIVE(ONE_ARG, exp2)
29 BUILTIN_NATIVE_CUSTOM(ONE_ARG, exp10, [](auto x) { return std::pow(10.0f, x); })
30 BUILTIN_NATIVE(ONE_ARG, log)
31 BUILTIN_NATIVE(ONE_ARG, log2)
32 BUILTIN_NATIVE(ONE_ARG, log10)
33 BUILTIN_NATIVE_CUSTOM(TWO_ARGS, powr, [](auto x, auto y) {
34  return (x >= 0 ? std::pow(x, y) : x);
35 })
36 BUILTIN_NATIVE_CUSTOM(ONE_ARG, recip, [](auto x) { return 1.0f / x; })
38  [](auto x) { return 1.0f / std::sqrt(x); })
39 BUILTIN_NATIVE(ONE_ARG, sin)
40 BUILTIN_NATIVE(ONE_ARG, sqrt)
41 BUILTIN_NATIVE(ONE_ARG, tan)
42 } // namespace native
43 } // namespace _V1
44 } // namespace sycl
__ESIMD_API simd< T, N > sqrt(simd< T, N > src, Sat sat={})
Square root.
Definition: math.hpp:402
__ESIMD_API simd< T, N > rsqrt(simd< T, N > src, Sat sat={})
Square root reciprocal - calculates 1/sqrt(x).
Definition: math.hpp:428
__ESIMD_API simd< T, N > pow(simd< T, N > src0, simd< U, N > src1, Sat sat={})
Power - calculates src0 in power of src1.
Definition: math.hpp:495
__ESIMD_API simd< T, N > log2(simd< T, N > src, Sat sat={})
Logarithm base 2.
Definition: math.hpp:394
__ESIMD_API simd< T, N > exp2(simd< T, N > src, Sat sat={})
Exponent base 2.
Definition: math.hpp:398
__DPCPP_SYCL_EXTERNAL _SYCL_EXT_CPLX_INLINE_VISIBILITY std::enable_if_t< is_genfloat< _Tp >::value, complex< _Tp > > tan(const complex< _Tp > &__x)
__DPCPP_SYCL_EXTERNAL _SYCL_EXT_CPLX_INLINE_VISIBILITY std::enable_if_t< is_genfloat< _Tp >::value, complex< _Tp > > log10(const complex< _Tp > &__x)
BUILTIN_NATIVE_CUSTOM(ONE_ARG, exp10, [](auto x) { return std::pow(10.0f, x);}) BUILTIN_NATIVE_CUSTOM(TWO_ARGS
ESIMD_NODEBUG ESIMD_INLINE sycl::ext::intel::esimd::simd< float, SZ > log(sycl::ext::intel::esimd::simd< float, SZ > x) __NOEXC
ESIMD_NODEBUG ESIMD_INLINE sycl::ext::intel::esimd::simd< float, SZ > sin(sycl::ext::intel::esimd::simd< float, SZ > x) __NOEXC
ESIMD_NODEBUG ESIMD_INLINE sycl::ext::intel::esimd::simd< float, SZ > cos(sycl::ext::intel::esimd::simd< float, SZ > x) __NOEXC
ESIMD_NODEBUG ESIMD_INLINE sycl::ext::intel::esimd::simd< float, SZ > exp(sycl::ext::intel::esimd::simd< float, SZ > x) __NOEXC
Definition: access.hpp:18
#define BUILTIN_NATIVE(NUM_ARGS, NAME)