DPC++ Runtime
Runtime libraries for oneAPI DPC++
math.hpp File Reference
Include dependency graph for math.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  cl::sycl::ext::intel::esimd::detail::esimd_apply_sum< T0, T1, SZ >
 
struct  cl::sycl::ext::intel::esimd::detail::esimd_apply_prod< T0, T1, SZ >
 
struct  cl::sycl::ext::intel::esimd::detail::esimd_apply_reduced_max< T0, T1, SZ >
 
struct  cl::sycl::ext::intel::esimd::detail::esimd_apply_reduced_min< T0, T1, SZ >
 

Namespaces

 cl
 We provide new interfaces for matrix muliply in this patch:
 
 cl::sycl
 
 cl::sycl::ext
 
 cl::sycl::ext::intel
 
 cl::sycl::ext::intel::esimd
 
 cl::sycl::ext::intel::esimd::detail
 

Macros

#define __ESIMD_UNARY_INTRINSIC_DEF(COND, name, iname)
 
#define __ESIMD_EMATH_COND   detail::is_generic_floating_point_v<T> && (sizeof(T) <= 4)
 
#define __ESIMD_EMATH_IEEE_COND   detail::is_generic_floating_point_v<T> && (sizeof(T) >= 4)
 
#define __ESIMD_BINARY_INTRINSIC_DEF(COND, name, iname)
 
#define __ESIMD_INTRINSIC_DEF(name)
 

Functions

template<typename T0 , typename T1 , int SZ>
__ESIMD_API std::enable_if_t<!detail::is_generic_floating_point_v< T0 >||std::is_same_v< T1, T0 >, simd< T0, SZ > > cl::sycl::ext::intel::esimd::saturate (simd< T1, SZ > src)
 Conversion of input vector elements of type T1 into vector of elements of type T0 with saturation. More...
 
template<typename T0 , typename T1 , int SZ>
ESIMD_DETAIL __ESIMD_API std::enable_if_t< !std::is_same< std::remove_const_t< T0 >, std::remove_const_t< T1 > >::value, simd< T0, SZ > > cl::sycl::ext::intel::esimd::abs (simd< T1, SZ > src0)
 Get absolute value (vector version) More...
 
template<typename T0 , typename T1 >
__ESIMD_API std::enable_if_t< !std::is_same< std::remove_const_t< T0 >, std::remove_const_t< T1 > >::value &&detail::is_esimd_scalar< T0 >::value &&detail::is_esimd_scalar< T1 >::value, std::remove_const_t< T0 > > cl::sycl::ext::intel::esimd::abs (T1 src0)
 Get absolute value (scalar version) More...
 
template<typename T1 , int SZ>
__ESIMD_API simd< T1, SZ > cl::sycl::ext::intel::esimd::abs (simd< T1, SZ > src0)
 Get absolute value (vector version). More...
 
template<typename T1 >
__ESIMD_API std::enable_if_t< detail::is_esimd_scalar< T1 >::value, std::remove_const_t< T1 > > cl::sycl::ext::intel::esimd::abs (T1 src0)
 Get absolute value (scalar version). More...
 
template<typename T , int SZ, class Sat = saturation_off_tag>
__ESIMD_API simd< T, SZ > cl::sycl::ext::intel::esimd::max (simd< T, SZ > src0, simd< T, SZ > src1, Sat sat={})
 Selects component-wise the maximum of the two vectors. More...
 
template<typename T , int SZ, class Sat = saturation_off_tag>
__ESIMD_API std::enable_if_t< detail::is_esimd_scalar< T >::value, simd< T, SZ > > cl::sycl::ext::intel::esimd::max (simd< T, SZ > src0, T src1, Sat sat={})
 Selects maximums for each element of the input vector and a scalar. More...
 
template<typename T , int SZ, class Sat = saturation_off_tag>
__ESIMD_API std::enable_if_t< detail::is_esimd_scalar< T >::value, simd< T, SZ > > cl::sycl::ext::intel::esimd::max (T src0, simd< T, SZ > src1, Sat sat={})
 Selects maximums for each element of the input scalar and a vector. More...
 
template<typename T , class Sat = saturation_off_tag>
ESIMD_NODEBUG ESIMD_INLINE std::enable_if_t< detail::is_esimd_scalar< T >::value, Tcl::sycl::ext::intel::esimd::max (T src0, T src1, Sat sat={})
 Selects maximum between two scalar values. More...
 
template<typename T , int SZ, class Sat = saturation_off_tag>
__ESIMD_API simd< T, SZ > cl::sycl::ext::intel::esimd::min (simd< T, SZ > src0, simd< T, SZ > src1, Sat sat={})
 Selects component-wise the minimum of the two vectors. More...
 
template<typename T , int SZ, class Sat = saturation_off_tag>
__ESIMD_API std::enable_if_t< detail::is_esimd_scalar< T >::value, simd< T, SZ > > cl::sycl::ext::intel::esimd::min (simd< T, SZ > src0, T src1, Sat sat={})
 Selects minimums for each element of the input vector and a scalar. More...
 
template<typename T , int SZ, class Sat = saturation_off_tag>
__ESIMD_API std::enable_if_t< detail::is_esimd_scalar< T >::value, simd< T, SZ > > cl::sycl::ext::intel::esimd::min (T src0, simd< T, SZ > src1, Sat sat={})
 Selects minimums for each element of the input scalar and a vector. More...
 
template<typename T , class Sat = saturation_off_tag>
ESIMD_NODEBUG ESIMD_INLINE std::enable_if_t< detail::is_esimd_scalar< T >::value, Tcl::sycl::ext::intel::esimd::min (T src0, T src1, Sat sat={})
 Selects minimum between two scalar values. More...
 
template<class T , int N, class Sat = saturation_off_tag, class = std::enable_if_t< detail::is_generic_floating_point_v<T> && (sizeof(T) <= 4) >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::inv (simd< T, N > src, Sat sat={})
 Inversion - calculates (1/x). More...
 
template<typename T , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_COND >>
__ESIMD_API T cl::sycl::ext::intel::esimd::inv (T src, Sat sat={})
 Scalar version. More...
 
template<class T , int N, class Sat = saturation_off_tag, class = std::enable_if_t< detail::is_generic_floating_point_v<T> && (sizeof(T) <= 4) >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::log2 (simd< T, N > src, Sat sat={})
 Logarithm base 2. More...
 
template<typename T , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_COND >>
__ESIMD_API T cl::sycl::ext::intel::esimd::log2 (T src, Sat sat={})
 Scalar version. More...
 
template<class T , int N, class Sat = saturation_off_tag, class = std::enable_if_t< detail::is_generic_floating_point_v<T> && (sizeof(T) <= 4) >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::exp2 (simd< T, N > src, Sat sat={})
 Exponent base 2. More...
 
template<typename T , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_COND >>
__ESIMD_API T cl::sycl::ext::intel::esimd::exp2 (T src, Sat sat={})
 Scalar version. More...
 
template<class T , int N, class Sat = saturation_off_tag, class = std::enable_if_t< detail::is_generic_floating_point_v<T> && (sizeof(T) <= 4) >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::sqrt (simd< T, N > src, Sat sat={})
 Square root. More...
 
template<typename T , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_COND >>
__ESIMD_API T cl::sycl::ext::intel::esimd::sqrt (T src, Sat sat={})
 Scalar version. More...
 
template<class T , int N, class Sat = saturation_off_tag, class = std::enable_if_t< detail::is_generic_floating_point_v<T> && (sizeof(T) >= 4) >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::sqrt_ieee (simd< T, N > src, Sat sat={})
 IEEE754-compliant square root. Supports float and double. More...
 
template<typename T , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_IEEE_COND >>
__ESIMD_API T cl::sycl::ext::intel::esimd::sqrt_ieee (T src, Sat sat={})
 Scalar version. More...
 
template<class T , int N, class Sat = saturation_off_tag, class = std::enable_if_t< detail::is_generic_floating_point_v<T> && (sizeof(T) <= 4) >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::rsqrt (simd< T, N > src, Sat sat={})
 Square root reciprocal - calculates 1/sqrt(x). More...
 
template<typename T , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_COND >>
__ESIMD_API T cl::sycl::ext::intel::esimd::rsqrt (T src, Sat sat={})
 Scalar version. More...
 
template<class T , int N, class Sat = saturation_off_tag, class = std::enable_if_t< detail::is_generic_floating_point_v<T> && (sizeof(T) <= 4) >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::sin (simd< T, N > src, Sat sat={})
 Sine. More...
 
template<typename T , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_COND >>
__ESIMD_API T cl::sycl::ext::intel::esimd::sin (T src, Sat sat={})
 Scalar version. More...
 
template<class T , int N, class Sat = saturation_off_tag, class = std::enable_if_t< detail::is_generic_floating_point_v<T> && (sizeof(T) <= 4) >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::cos (simd< T, N > src, Sat sat={})
 Cosine. More...
 
template<typename T , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_COND >>
__ESIMD_API T cl::sycl::ext::intel::esimd::cos (T src, Sat sat={})
 Scalar version. More...
 
template<class T , int N, class U , class Sat = saturation_off_tag, class = std::enable_if_t< detail::is_generic_floating_point_v<T> && (sizeof(T) <= 4) >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::pow (simd< T, N > src0, simd< U, N > src1, Sat sat={})
 Power - calculates src0 in power of src1. More...
 
template<class T , int N, class U , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_COND >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::pow (simd< T, N > src0, U src1, Sat sat={})
 (vector, scalar) version. More...
 
template<class T , class U , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_COND >>
__ESIMD_API T cl::sycl::ext::intel::esimd::pow (T src0, U src1, Sat sat={})
 (scalar, scalar) version. More...
 
template<class T , int N, class U , class Sat = saturation_off_tag, class = std::enable_if_t< detail::is_generic_floating_point_v<T> && (sizeof(T) >= 4) >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::div_ieee (simd< T, N > src0, simd< U, N > src1, Sat sat={})
 IEEE754-compliant floating-point division. Supports float and double. More...
 
template<class T , int N, class U , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_IEEE_COND >>
__ESIMD_API simd< T, N > cl::sycl::ext::intel::esimd::div_ieee (simd< T, N > src0, U src1, Sat sat={})
 (vector, scalar) version. More...
 
template<class T , class U , class Sat = saturation_off_tag, class = std::enable_if_t< __ESIMD_EMATH_IEEE_COND >>
__ESIMD_API T cl::sycl::ext::intel::esimd::div_ieee (T src0, U src1, Sat sat={})
 (scalar, scalar) version. More...
 
template<class T , int SZ, class Sat = saturation_off_tag>
ESIMD_DETAIL ESIMD_NODEBUG ESIMD_INLINE simd< T, SZ > cl::sycl::ext::intel::esimd::log (simd< T, SZ > src0, Sat sat={})
 Computes the natural logarithm of the given argument. More...
 
template<class T , class Sat = saturation_off_tag>
ESIMD_NODEBUG ESIMD_INLINE T cl::sycl::ext::intel::esimd::log (T src0, Sat sat={})
 
template<class T , int SZ, class Sat = saturation_off_tag>
ESIMD_NODEBUG ESIMD_INLINE simd< T, SZ > cl::sycl::ext::intel::esimd::exp (simd< T, SZ > src0, Sat sat={})
 Computes e raised to the power of the given argument. More...
 
template<class T , class Sat = saturation_off_tag>
ESIMD_NODEBUG ESIMD_INLINE T cl::sycl::ext::intel::esimd::exp (T src0, Sat sat={})
 
template<typename T , int SZ, class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API __ESIMD_NS::simd< T, SZ > cl::sycl::ext::intel::esimd::rndd (__ESIMD_NS::simd< float, SZ > src0, Sat sat={})
 Round-down (also known as floor). More...
 
template<typename T , class Sat = __ESIMD_NS::saturation_off_tag>
__ESIMD_API T cl::sycl::ext::intel::esimd::rndd (float src0, Sat sat={})
 Scalar version. More...
 
template<typename T , int SZ, class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API __ESIMD_NS::simd< T, SZ > cl::sycl::ext::intel::esimd::rndu (__ESIMD_NS::simd< float, SZ > src0, Sat sat={})
 Round-up (also known as ceil). More...
 
template<typename T , class Sat = __ESIMD_NS::saturation_off_tag>
__ESIMD_API T cl::sycl::ext::intel::esimd::rndu (float src0, Sat sat={})
 Scalar version. More...
 
template<typename T , int SZ, class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API __ESIMD_NS::simd< T, SZ > cl::sycl::ext::intel::esimd::rnde (__ESIMD_NS::simd< float, SZ > src0, Sat sat={})
 Round-to-even (also known as round). More...
 
template<typename T , class Sat = __ESIMD_NS::saturation_off_tag>
__ESIMD_API T cl::sycl::ext::intel::esimd::rnde (float src0, Sat sat={})
 Scalar version. More...
 
template<typename T , int SZ, class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API __ESIMD_NS::simd< T, SZ > cl::sycl::ext::intel::esimd::rndz (__ESIMD_NS::simd< float, SZ > src0, Sat sat={})
 Round-to-zero (also known as trunc). More...
 
template<typename T , class Sat = __ESIMD_NS::saturation_off_tag>
__ESIMD_API T cl::sycl::ext::intel::esimd::rndz (float src0, Sat sat={})
 Scalar version. More...
 
template<typename RT , int SZ, class Sat = sycl::ext::intel::esimd::saturation_off_tag>
ESIMD_INLINE sycl::ext::intel::esimd::simd< RT, SZ > cl::sycl::ext::intel::esimd::floor (const sycl::ext::intel::esimd::simd< float, SZ > src0, Sat sat={})
 "Floor" operation, vector version - alias of rndd. More...
 
template<typename RT , class Sat = sycl::ext::intel::esimd::saturation_off_tag>
ESIMD_INLINE RT cl::sycl::ext::intel::esimd::floor (float src0, Sat sat={})
 "Floor" operation, scalar version - alias of rndd. More...
 
template<typename RT , int SZ, class Sat = sycl::ext::intel::esimd::saturation_off_tag>
ESIMD_INLINE sycl::ext::intel::esimd::simd< RT, SZ > cl::sycl::ext::intel::esimd::ceil (const sycl::ext::intel::esimd::simd< float, SZ > src0, Sat sat={})
 "Ceiling" operation, vector version - alias of rndu. More...
 
template<typename RT , class Sat = sycl::ext::intel::esimd::saturation_off_tag>
ESIMD_INLINE RT cl::sycl::ext::intel::esimd::ceil (float src0, Sat sat={})
 "Ceiling" operation, scalar version - alias of rndu. More...
 
template<typename RT , int SZ, class Sat = sycl::ext::intel::esimd::saturation_off_tag>
__ESIMD_API sycl::ext::intel::esimd::simd< RT, SZ > cl::sycl::ext::intel::esimd::trunc (const sycl::ext::intel::esimd::simd< float, SZ > &src0, Sat sat={})
 Round to integral value using the round to zero rounding mode (vector version). More...
 
template<typename RT , class Sat = sycl::ext::intel::esimd::saturation_off_tag>
__ESIMD_API RT cl::sycl::ext::intel::esimd::trunc (float src0, Sat sat={})
 Round to integral value using the round to zero rounding mode (scalar version). More...
 
template<int N>
ESIMD_NODEBUG ESIMD_INLINE std::enable_if_t<(N==8||N==16||N==32), uint > cl::sycl::ext::intel::esimd::pack_mask (simd_mask< N > src0)
 Pack a simd_mask into a single unsigned 32-bit integer value. More...
 
template<int N>
ESIMD_NODEBUG ESIMD_INLINE std::enable_if_t<(N==8||N==16||N==32), simd_mask< N > > cl::sycl::ext::intel::esimd::unpack_mask (uint src0)
 Unpack an unsigned 32-bit integer value into a simd_mask. More...
 
template<int N>
__ESIMD_API std::enable_if_t<(N !=8 &&N !=16 &&N< 32), uint > cl::sycl::ext::intel::esimd::pack_mask (simd_mask< N > src0)
 pack_mask specialization when the number of elements N is not 8, 16 or 32. More...
 
template<typename T , int N>
__ESIMD_API std::enable_if_t< detail::is_type< T, ushort, uint >) &&(N > 0 &&N<=32), uint > cl::sycl::ext::intel::esimd::ballot (simd< T, N > mask)
 Compare source vector elements against zero and return a bitfield combining the comparison result. More...
 
template<typename T , int N>
ESIMD_NODEBUG ESIMD_INLINE std::enable_if_t< std::is_integral< T >::value &&(sizeof(T)<=4), simd< uint32_t, N > > cl::sycl::ext::intel::esimd::cbit (simd< T, N > src)
 Count number of bits set in the source operand per element. More...
 
template<typename T >
__ESIMD_API std::enable_if_t< std::is_integral< T >::value &&(sizeof(T)<=4), uint32_t > cl::sycl::ext::intel::esimd::cbit (T src)
 Scalar version of cbit - both input and output are scalars rather than vectors. More...
 
template<typename BaseTy , typename RegionTy >
__ESIMD_API std::enable_if_t< std::is_integral< typename simd_view< BaseTy, RegionTy >::element_type >::value &&(sizeof(typename simd_view< BaseTy, RegionTy >::element_type)<=4) &&(simd_view< BaseTy, RegionTy >::length==1), uint32_t > cl::sycl::ext::intel::esimd::cbit (simd_view< BaseTy, RegionTy > src)
 Scalar version of cbit, that takes simd_view object as an argument, e.g. More...
 
template<typename T , int N>
__ESIMD_API std::enable_if_t< std::is_integral< T >::value &&(sizeof(T)==4), simd< T, N > > cl::sycl::ext::intel::esimd::fbl (simd< T, N > src)
 Find the per element number of the first bit set in the source operand starting from the least significant bit. More...
 
template<typename T >
__ESIMD_API std::enable_if_t< std::is_integral< T >::value &&(sizeof(T)==4), Tcl::sycl::ext::intel::esimd::fbl (T src)
 Scalar version of fbl - both input and output are scalars rather than vectors. More...
 
template<typename BaseTy , typename RegionTy >
__ESIMD_API std::enable_if_t< std::is_integral< typename simd_view< BaseTy, RegionTy >::element_type >::value &&(sizeof(typename simd_view< BaseTy, RegionTy >::element_type)==4) &&(simd_view< BaseTy, RegionTy >::length==1), typename simd_view< BaseTy, RegionTy >::element_type > cl::sycl::ext::intel::esimd::fbl (simd_view< BaseTy, RegionTy > src)
 Scalar version of fbl, that takes simd_view object as an argument, e.g. More...
 
template<typename T , int N>
__ESIMD_API std::enable_if_t< std::is_integral< T >::value &&std::is_signed< T >::value &&(sizeof(T)==4), simd< T, N > > cl::sycl::ext::intel::esimd::fbh (simd< T, N > src)
 Find the per element number of the first bit set in the source operand starting from the most significant bit (sign bit is skipped). More...
 
template<typename T , int N>
__ESIMD_API std::enable_if_t< std::is_integral< T >::value &&!std::is_signed< T >::value &&(sizeof(T)==4), simd< T, N > > cl::sycl::ext::intel::esimd::fbh (simd< T, N > src)
 Find the per element number of the first bit set in the source operand starting from the most significant bit (sign bit is counted). More...
 
template<typename T >
__ESIMD_API std::enable_if_t< std::is_integral< T >::value &&(sizeof(T)==4), Tcl::sycl::ext::intel::esimd::fbh (T src)
 Scalar version of fbh - both input and output are scalars rather than vectors. More...
 
template<typename BaseTy , typename RegionTy >
__ESIMD_API std::enable_if_t< std::is_integral< typename simd_view< BaseTy, RegionTy >::element_type >::value &&(sizeof(typename simd_view< BaseTy, RegionTy >::element_type)==4) &&(simd_view< BaseTy, RegionTy >::length==1), typename simd_view< BaseTy, RegionTy >::element_type > cl::sycl::ext::intel::esimd::fbh (simd_view< BaseTy, RegionTy > src)
 Scalar version of fbh, that takes simd_view object as an argument, e.g. More...
 
template<typename T1 , typename T2 , typename T3 , typename T4 , int N, class Sat = saturation_off_tag>
__ESIMD_API std::enable_if_t< detail::is_dword_type< T1 >::value &&detail::is_dword_type< T2 >::value &&detail::is_dword_type< T3 >::value &&detail::is_dword_type< T4 >::value, simd< T1, N > > cl::sycl::ext::intel::esimd::dp4a (simd< T2, N > src0, simd< T3, N > src1, simd< T4, N > src2, Sat sat={})
 DP4A. More...
 
template<typename T0 , typename T1 , int SZ, template< typename RT, typename T, int N > class OpType>
T0 cl::sycl::ext::intel::esimd::detail::reduce_single (simd< T1, SZ > v)
 
template<typename T0 , typename T1 , int N1, int N2, template< typename RT, typename T, int N > class OpType>
T0 cl::sycl::ext::intel::esimd::detail::reduce_pair (simd< T1, N1 > v1, simd< T1, N2 > v2)
 
template<typename T0 , typename T1 , int SZ, template< typename RT, typename T, int N > class OpType>
T0 cl::sycl::ext::intel::esimd::detail::reduce (simd< T1, SZ > v)
 
template<typename T0 , typename T1 , int SZ>
ESIMD_INLINE ESIMD_NODEBUG T0 cl::sycl::ext::intel::esimd::detail::sum (simd< T1, SZ > v)
 
template<typename T0 , typename T1 , int SZ>
ESIMD_INLINE ESIMD_NODEBUG T0 cl::sycl::ext::intel::esimd::detail::prod (simd< T1, SZ > v)
 
template<typename T0 , typename T1 , int SZ>
ESIMD_INLINE ESIMD_NODEBUG T0 cl::sycl::ext::intel::esimd::hmax (simd< T1, SZ > v)
 ESIMD_DETAIL. More...
 
template<typename T0 , typename T1 , int SZ>
ESIMD_INLINE ESIMD_NODEBUG T0 cl::sycl::ext::intel::esimd::hmin (simd< T1, SZ > v)
 Performs 'minimum' operation reduction over elements of the input vector, that is, returns the minimal vector element. More...
 
template<typename T0 , typename T1 , int SZ, typename BinaryOperation >
ESIMD_INLINE ESIMD_NODEBUG T0 cl::sycl::ext::intel::esimd::reduce (simd< T1, SZ > v, BinaryOperation op)
 Performs reduction over elements of the input vector. More...