13 #define _USE_MATH_DEFINES
22 inline namespace _V1 {
23 #define BUILTIN_GENF_CUSTOM(NUM_ARGS, NAME, IMPL) \
24 HOST_IMPL(NAME, IMPL) \
25 EXPORT_SCALAR_AND_VEC_1_16(NUM_ARGS, NAME, FP_TYPES)
30 #define BUILTIN_GENF(NUM_ARGS, NAME) \
31 BUILTIN_GENF_CUSTOM(NUM_ARGS, NAME, [](NUM_ARGS##_AUTO_ARG) -> decltype(x) { \
32 return std::NAME(NUM_ARGS##_ARG); \
38 [](auto
x) -> decltype(
x) {
return std::acos(
x) / M_PI; })
42 [](auto
x) -> decltype(
x) {
return std::asin(
x) / M_PI; })
46 [](auto
x) -> decltype(
x) {
return std::atan(
x) / M_PI; })
49 return std::atan2(
x,
y) / M_PI;
64 [](auto
x) -> decltype(
x) {
return std::pow(10,
x); })
88 return std::fmax(
x,
y);
95 return std::fmin(
x,
y);
99 using T = decltype(
x);
111 [](auto
x) -> decltype(
x) {
return std::sin(M_PI *
x); })
117 [](auto
x) -> decltype(
x) {
125 if constexpr (!std::is_same_v<decltype(
x),
half>) {
137 uint16_t x_bits = sycl::bit_cast<uint16_t>(
x);
138 uint16_t x_sign = x_bits & 0x8000;
139 int16_t movement = (
x >
y ? -1 : 1) * (x_sign ? -1 : 1);
140 if (x_bits == x_sign && movement == -1) {
148 return sycl::bit_cast<half>(x_bits);
153 __SYCL_EXPORT
float frexp_impl(
float x,
int *p) {
return std::frexp(
x, p); }
154 __SYCL_EXPORT
double frexp_impl(
double x,
int *p) {
return std::frexp(
x, p); }
155 __SYCL_EXPORT
half frexp_impl(
half x,
int *p) {
return std::frexp(
x, p); }
159 template <
typename T>
static inline T __lgamma_r_impl(T x,
int *signp) {
160 T g = std::tgamma(x);
165 __SYCL_EXPORT
float lgamma_r_impl(
float x,
int *p) {
166 return __lgamma_r_impl(x, p);
168 __SYCL_EXPORT
double lgamma_r_impl(
double x,
int *p) {
169 return __lgamma_r_impl(x, p);
171 __SYCL_EXPORT
half lgamma_r_impl(
half x,
int *p) {
172 return __lgamma_r_impl(x, p);
180 __SYCL_EXPORT
float modf_impl(
float x,
float *p) {
return std::modf(x, p); }
181 __SYCL_EXPORT
double modf_impl(
double x,
double *p) {
return std::modf(x, p); }
184 auto ret = std::modf(x, &val);
191 template <
typename T>
static inline T __sincos(T x, T *cosval) {
196 __SYCL_EXPORT
float sincos_impl(
float x,
float *p) {
return __sincos(x, p); }
197 __SYCL_EXPORT
double sincos_impl(
double x,
double *p) {
return __sincos(x, p); }
198 __SYCL_EXPORT
half sincos_impl(
half x,
half *p) {
return __sincos(x, p); }
201 #define EXPORT_VEC_LAST_INT(NAME, TYPE, VL) \
202 vec<TYPE, VL> __SYCL_EXPORT __##NAME##_impl(vec<TYPE, VL> x, \
204 return NAME##_host_impl(x, y); \
206 #define EXPORT_VEC_LAST_INT_1_16(NAME, TYPE) \
207 FOR_VEC_1_16(EXPORT_VEC_LAST_INT, NAME, TYPE)
209 #define BUILTIN_MATH_LAST_INT(NAME, IMPL) \
210 __SYCL_EXPORT float __##NAME##_impl(float x, int y) { return IMPL(x, y); } \
211 __SYCL_EXPORT double __##NAME##_impl(double x, int y) { return IMPL(x, y); } \
212 __SYCL_EXPORT half __##NAME##_impl(half x, int y) { return IMPL(x, y); } \
213 HOST_IMPL(NAME, NAME ) \
214 FOR_EACH1(EXPORT_VEC_LAST_INT_1_16, NAME, FP_TYPES)
223 template <
typename T>
auto __remquo_impl(T
x, T
y,
int *
z) {
224 T rem = std::remainder(
x,
y);
225 *
z =
static_cast<int>(std::round((
x - rem) /
y));
230 __SYCL_EXPORT
float remquo_impl(
float x,
float y,
int *z) {
231 return __remquo_impl(x, y, z);
233 __SYCL_EXPORT
double remquo_impl(
double x,
double y,
int *z) {
234 return __remquo_impl(x, y, z);
236 __SYCL_EXPORT
half remquo_impl(
half x,
half y,
int *z) {
237 return __remquo_impl(x, y, z);
__ESIMD_API simd< T, N > sqrt(simd< T, N > src, Sat sat={})
Square root.
__ESIMD_API simd< T, N > rsqrt(simd< T, N > src, Sat sat={})
Square root reciprocal - calculates 1/sqrt(x).
__ESIMD_API simd< T, N > pow(simd< T, N > src0, simd< U, N > src1, Sat sat={})
Power - calculates src0 in power of src1.
__ESIMD_API simd< T, N > log2(simd< T, N > src, Sat sat={})
Logarithm base 2.
__ESIMD_API simd< T, N > exp2(simd< T, N > src, Sat sat={})
Exponent base 2.
ESIMD_DETAIL __ESIMD_API std::enable_if_t< !std::is_same< std::remove_const_t< TRes >, std::remove_const_t< TArg > >::value, simd< TRes, SZ > > abs(simd< TArg, SZ > src0)
Get absolute value (vector version)
#define EXPORT_SCALAR_AND_VEC_1_16(NUM_ARGS, NAME,...)
#define HOST_IMPL(NAME,...)
#define BUILTIN_GENF(NUM_ARGS, NAME)
#define BUILTIN_MATH_LAST_INT(NAME, IMPL)
T cast_if_host_half(T val)
std::enable_if_t< std::is_same_v< Tp, float >, float > copysign(Tp x, Tp y)
__SYCL_ALWAYS_INLINE std::enable_if_t< sycl::detail::is_svgenfloatf_v< T >||sycl::detail::is_svgenfloath_v< T >, T > tanh(T x) __NOEXC
__DPCPP_SYCL_EXTERNAL _SYCL_EXT_CPLX_INLINE_VISIBILITY std::enable_if_t< is_genfloat< _Tp >::value, complex< _Tp > > atanh(const complex< _Tp > &__x)
__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 > > asin(const complex< _Tp > &__x)
__DPCPP_SYCL_EXTERNAL _SYCL_EXT_CPLX_INLINE_VISIBILITY std::enable_if_t< is_genfloat< _Tp >::value, complex< _Tp > > cosh(const complex< _Tp > &__x)
__DPCPP_SYCL_EXTERNAL _SYCL_EXT_CPLX_INLINE_VISIBILITY std::enable_if_t< is_genfloat< _Tp >::value, complex< _Tp > > asinh(const complex< _Tp > &__x)
std::enable_if_t< std::is_same_v< T, bfloat16 >, bool > isnan(T x)
__DPCPP_SYCL_EXTERNAL _SYCL_EXT_CPLX_INLINE_VISIBILITY std::enable_if_t< is_genfloat< _Tp >::value, complex< _Tp > > acos(const complex< _Tp > &__x)
__DPCPP_SYCL_EXTERNAL _SYCL_EXT_CPLX_INLINE_VISIBILITY std::enable_if_t< is_genfloat< _Tp >::value, complex< _Tp > > acosh(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)
__DPCPP_SYCL_EXTERNAL _SYCL_EXT_CPLX_INLINE_VISIBILITY std::enable_if_t< is_genfloat< _Tp >::value, complex< _Tp > > atan(const complex< _Tp > &__x)
__DPCPP_SYCL_EXTERNAL _SYCL_EXT_CPLX_INLINE_VISIBILITY std::enable_if_t< is_genfloat< _Tp >::value, complex< _Tp > > sinh(const complex< _Tp > &__x)
std::enable_if_t< detail::is_bf16_storage_type< T >::value, T > fabs(T x)
return(x >=T(0)) ? T(std sinpi
ESIMD_NODEBUG ESIMD_INLINE sycl::ext::intel::esimd::simd< float, SZ > log(sycl::ext::intel::esimd::simd< float, SZ > x) __NOEXC
BUILTIN_GENF_CUSTOM(ONE_ARG, acospi, [](auto x) -> decltype(x) { return std::acos(x)/M_PI;}) BUILTIN_GENF_CUSTOM(ONE_ARG
auto auto autodecltype(x) z
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
sycl::detail::half_impl::half half
std::enable_if_t< std::is_floating_point_v< ValueT >||std::is_same_v< sycl::half, ValueT >, ValueT > cbrt(ValueT val)
cbrt function wrapper.