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

class  syclcompat::detail::vectorized_binary< VecT, BinaryOperation, class >
 
struct  syclcompat::abs
 A sycl::abs wrapper functors. More...
 
struct  syclcompat::abs_diff
 A sycl::abs_diff wrapper functors. More...
 
struct  syclcompat::add_sat
 A sycl::add_sat wrapper functors. More...
 
struct  syclcompat::rhadd
 A sycl::rhadd wrapper functors. More...
 
struct  syclcompat::hadd
 A sycl::hadd wrapper functors. More...
 
struct  syclcompat::maximum
 A sycl::max wrapper functors. More...
 
struct  syclcompat::minimum
 A sycl::min wrapper functors. More...
 
struct  syclcompat::sub_sat
 A sycl::sub_sat wrapper functors. More...
 
struct  syclcompat::detail::shift_left
 
struct  syclcompat::detail::shift_right
 

Namespaces

 syclcompat
 
 syclcompat::detail
 Atomic extension to implement standard APIs in std::atomic.
 

Macros

#define SYCL_EXT_ONEAPI_COMPLEX
 

Typedefs

template<typename ValueT >
using syclcompat::detail::complex_type = detail::complex_namespace::complex< ValueT >
 

Functions

template<typename ValueT >
ValueT syclcompat::detail::clamp (ValueT val, ValueT min_val, ValueT max_val)
 
template<typename ValueT >
int64_t syclcompat::detail::zero_or_signed_extent (ValueT val, unsigned bit)
 Extend the 'val' to 'bit' size, zero extend for unsigned int and signed extend for signed int. More...
 
template<typename RetT , bool needSat, typename AT , typename BT , typename BinaryOperation >
constexpr RetT syclcompat::detail::extend_binary (AT a, BT b, BinaryOperation binary_op)
 
template<typename RetT , bool needSat, typename AT , typename BT , typename CT , typename BinaryOperation1 , typename BinaryOperation2 >
constexpr RetT syclcompat::detail::extend_binary (AT a, BT b, CT c, BinaryOperation1 binary_op, BinaryOperation2 second_op)
 
template<typename ValueT >
bool syclcompat::detail::isnan (const ValueT a)
 
unsigned int syclcompat::funnelshift_l (unsigned int low, unsigned int high, unsigned int shift)
 Emulated function for __funnelshift_l. More...
 
unsigned int syclcompat::funnelshift_lc (unsigned int low, unsigned int high, unsigned int shift)
 Emulated function for __funnelshift_lc. More...
 
unsigned int syclcompat::funnelshift_r (unsigned int low, unsigned int high, unsigned int shift)
 Emulated function for __funnelshift_r. More...
 
unsigned int syclcompat::funnelshift_rc (unsigned int low, unsigned int high, unsigned int shift)
 Emulated function for __funnelshift_rc. More...
 
float syclcompat::fast_length (const float *a, int len)
 Compute fast_length for variable-length array. More...
 
template<typename ValueT >
ValueT syclcompat::length (const ValueT *a, const int len)
 Calculate the square root of the input array. More...
 
template<typename ValueT , class BinaryOperation >
std::enable_if_t< std::is_same_v< std::invoke_result_t< BinaryOperation, ValueT, ValueT >, bool >, bool > syclcompat::compare (const ValueT a, const ValueT b, const BinaryOperation binary_op)
 Performs comparison. More...
 
template<typename ValueT >
std::enable_if_t< std::is_same_v< std::invoke_result_t< std::not_equal_to<>, ValueT, ValueT >, bool >, bool > syclcompat::compare (const ValueT a, const ValueT b, const std::not_equal_to<> binary_op)
 
template<typename ValueT , class BinaryOperation >
std::enable_if_t< ValueT::size()==2, ValueT > syclcompat::compare (const ValueT a, const ValueT b, const BinaryOperation binary_op)
 Performs 2 element comparison. More...
 
template<typename ValueT , class BinaryOperation >
std::enable_if_t< std::is_same_v< std::invoke_result_t< BinaryOperation, ValueT, ValueT >, bool >, bool > syclcompat::unordered_compare (const ValueT a, const ValueT b, const BinaryOperation binary_op)
 Performs unordered comparison. More...
 
template<typename ValueT , class BinaryOperation >
std::enable_if_t< ValueT::size()==2, ValueT > syclcompat::unordered_compare (const ValueT a, const ValueT b, const BinaryOperation binary_op)
 Performs 2 element unordered comparison. More...
 
template<typename ValueT , class BinaryOperation >
std::enable_if_t< ValueT::size()==2, bool > syclcompat::compare_both (const ValueT a, const ValueT b, const BinaryOperation binary_op)
 Performs 2 element comparison and return true if both results are true. More...
 
template<typename ValueT , class BinaryOperation >
std::enable_if_t< ValueT::size()==2, bool > syclcompat::unordered_compare_both (const ValueT a, const ValueT b, const BinaryOperation binary_op)
 Performs 2 element unordered comparison and return true if both results are true. More...
 
template<typename ValueT , class BinaryOperation >
unsigned syclcompat::compare_mask (const sycl::vec< ValueT, 2 > a, const sycl::vec< ValueT, 2 > b, const BinaryOperation binary_op)
 Performs 2 elements comparison, compare result of each element is 0 (false) or 0xffff (true), returns an unsigned int by composing compare result of two elements. More...
 
template<typename ValueT , class BinaryOperation >
unsigned syclcompat::unordered_compare_mask (const sycl::vec< ValueT, 2 > a, const sycl::vec< ValueT, 2 > b, const BinaryOperation binary_op)
 Performs 2 elements unordered comparison, compare result of each element is 0 (false) or 0xffff (true), returns an unsigned int by composing compare result of two elements. More...
 
template<typename S , typename T >
syclcompat::vectorized_max (T a, T b)
 Compute vectorized max for two values, with each value treated as a vector type S. More...
 
template<typename S , typename T >
syclcompat::vectorized_min (T a, T b)
 Compute vectorized min for two values, with each value treated as a vector type S. More...
 
template<typename VecT , class UnaryOperation >
unsigned syclcompat::vectorized_unary (unsigned a, const UnaryOperation unary_op)
 Compute vectorized unary operation for a value, with the value treated as a vector type VecT. More...
 
template<typename VecT >
unsigned syclcompat::vectorized_sum_abs_diff (unsigned a, unsigned b)
 Compute vectorized absolute difference for two values without modulo overflow, with each value treated as a vector type VecT. More...
 
template<typename S , typename T >
syclcompat::vectorized_isgreater (T a, T b)
 Compute vectorized isgreater for two values, with each value treated as a vector type S. More...
 
template<>
unsigned syclcompat::vectorized_isgreater< sycl::ushort2, unsigned > (unsigned a, unsigned b)
 Compute vectorized isgreater for two unsigned int values, with each value treated as a vector of two unsigned short. More...
 
template<typename ValueT >
ValueT syclcompat::clamp (ValueT val, ValueT min_val, ValueT max_val)
 Returns min(max(val, min_val), max_val) More...
 
template<typename ValueT >
std::enable_if_t< ValueT::size()==2, ValueT > syclcompat::isnan (const ValueT a)
 Determine whether 2 element value is NaN. More...
 
template<typename ValueT >
std::enable_if_t< std::is_floating_point_v< ValueT >||std::is_same_v< sycl::half, ValueT >, ValueT > syclcompat::cbrt (ValueT val)
 cbrt function wrapper. More...
 
template<typename ValueT , typename ValueU >
std::enable_if_t< std::is_integral_v< ValueT > &&std::is_integral_v< ValueU >, std::common_type_t< ValueT, ValueU > > syclcompat::min (ValueT a, ValueU b)
 
template<typename ValueT , typename ValueU >
std::enable_if_t< std::is_floating_point_v< ValueT > &&std::is_floating_point_v< ValueU >, std::common_type_t< ValueT, ValueU > > syclcompat::min (ValueT a, ValueU b)
 
sycl::half syclcompat::min (sycl::half a, sycl::half b)
 
template<typename ValueT , typename ValueU >
std::enable_if_t< std::is_integral_v< ValueT > &&std::is_integral_v< ValueU >, std::common_type_t< ValueT, ValueU > > syclcompat::max (ValueT a, ValueU b)
 
template<typename ValueT , typename ValueU >
std::enable_if_t< std::is_floating_point_v< ValueT > &&std::is_floating_point_v< ValueU >, std::common_type_t< ValueT, ValueU > > syclcompat::max (ValueT a, ValueU b)
 
sycl::half syclcompat::max (sycl::half a, sycl::half b)
 
template<typename ValueT , typename ValueU >
std::common_type_t< ValueT, ValueU > syclcompat::fmax_nan (const ValueT a, const ValueU b)
 Performs 2 elements comparison and returns the bigger one. More...
 
template<typename ValueT , typename ValueU >
sycl::vec< std::common_type_t< ValueT, ValueU >, 2 > syclcompat::fmax_nan (const sycl::vec< ValueT, 2 > a, const sycl::vec< ValueU, 2 > b)
 
template<typename ValueT , typename ValueU >
std::common_type_t< ValueT, ValueU > syclcompat::fmin_nan (const ValueT a, const ValueU b)
 Performs 2 elements comparison and returns the smaller one. More...
 
template<typename ValueT , typename ValueU >
sycl::vec< std::common_type_t< ValueT, ValueU >, 2 > syclcompat::fmin_nan (const sycl::vec< ValueT, 2 > a, const sycl::vec< ValueU, 2 > b)
 
float syclcompat::pow (const float a, const int b)
 
double syclcompat::pow (const double a, const int b)
 
template<typename ValueT , typename ValueU >
std::enable_if_t< std::is_floating_point_v< ValueT >, ValueT > syclcompat::pow (const ValueT a, const ValueU b)
 
template<typename ValueT , typename ValueU >
std::enable_if_t<!std::is_floating_point_v< ValueT >, double > syclcompat::pow (const ValueT a, const ValueU b)
 
template<typename ValueT >
std::enable_if_t< std::is_floating_point_v< ValueT >||std::is_same_v< sycl::half, ValueT >, ValueT > syclcompat::relu (const ValueT a)
 Performs relu saturation. More...
 
template<class ValueT >
std::enable_if_t< std::is_floating_point_v< ValueT >||std::is_same_v< sycl::half, ValueT >, sycl::vec< ValueT, 2 > > syclcompat::relu (const sycl::vec< ValueT, 2 > a)
 
template<class ValueT >
std::enable_if_t< std::is_floating_point_v< ValueT >||std::is_same_v< sycl::half, ValueT >, sycl::marray< ValueT, 2 > > syclcompat::relu (const sycl::marray< ValueT, 2 > a)
 
template<typename T >
sycl::vec< T, 2 > syclcompat::cmul (sycl::vec< T, 2 > x, sycl::vec< T, 2 > y)
 Computes the multiplication of two complex numbers. More...
 
template<typename T >
sycl::vec< T, 2 > syclcompat::cdiv (sycl::vec< T, 2 > x, sycl::vec< T, 2 > y)
 Computes the division of two complex numbers. More...
 
template<typename T >
syclcompat::cabs (sycl::vec< T, 2 > x)
 Computes the magnitude of a complex number. More...
 
template<typename T >
sycl::vec< T, 2 > syclcompat::conj (sycl::vec< T, 2 > x)
 Computes the complex conjugate of a complex number. More...
 
template<typename ValueT >
sycl::vec< ValueT, 2 > syclcompat::cmul_add (const sycl::vec< ValueT, 2 > a, const sycl::vec< ValueT, 2 > b, const sycl::vec< ValueT, 2 > c)
 Performs complex number multiply addition. More...
 
template<typename ValueT >
sycl::marray< ValueT, 2 > syclcompat::cmul_add (const sycl::marray< ValueT, 2 > a, const sycl::marray< ValueT, 2 > b, const sycl::marray< ValueT, 2 > c)
 
template<typename VecT , class BinaryOperation >
unsigned syclcompat::vectorized_binary (unsigned a, unsigned b, const BinaryOperation binary_op)
 Compute vectorized binary operation value for two values, with each value treated as a vector type VecT. More...
 
template<typename RetT , typename AT , typename BT >
constexpr RetT syclcompat::extend_add (AT a, BT b)
 Extend a and b to 33 bit and add them. More...
 
template<typename RetT , typename AT , typename BT , typename CT , typename BinaryOperation >
constexpr RetT syclcompat::extend_add (AT a, BT b, CT c, BinaryOperation second_op)
 Extend Inputs to 33 bit, add a, b, then do second_op with c. More...
 
template<typename RetT , typename AT , typename BT >
constexpr RetT syclcompat::extend_add_sat (AT a, BT b)
 Extend a and b to 33 bit and add them with saturation. More...
 
template<typename RetT , typename AT , typename BT , typename CT , typename BinaryOperation >
constexpr RetT syclcompat::extend_add_sat (AT a, BT b, CT c, BinaryOperation second_op)
 Extend Inputs to 33 bit, add a, b with saturation, then do second_op with c. More...
 
template<typename RetT , typename AT , typename BT >
constexpr RetT syclcompat::extend_sub (AT a, BT b)
 Extend a and b to 33 bit and minus them. More...
 
template<typename RetT , typename AT , typename BT , typename CT , typename BinaryOperation >
constexpr RetT syclcompat::extend_sub (AT a, BT b, CT c, BinaryOperation second_op)
 Extend Inputs to 33 bit, minus a, b, then do second_op with c. More...
 
template<typename RetT , typename AT , typename BT >
constexpr RetT syclcompat::extend_sub_sat (AT a, BT b)
 Extend a and b to 33 bit and minus them with saturation. More...
 
template<typename RetT , typename AT , typename BT , typename CT , typename BinaryOperation >
constexpr RetT syclcompat::extend_sub_sat (AT a, BT b, CT c, BinaryOperation second_op)
 Extend Inputs to 33 bit, minus a, b with saturation, then do second_op with c. More...
 
template<typename RetT , typename AT , typename BT >
constexpr RetT syclcompat::extend_absdiff (AT a, BT b)
 Extend a and b to 33 bit and do abs_diff. More...
 
template<typename RetT , typename AT , typename BT , typename CT , typename BinaryOperation >
constexpr RetT syclcompat::extend_absdiff (AT a, BT b, CT c, BinaryOperation second_op)
 Extend Inputs to 33 bit, abs_diff a, b, then do second_op with c. More...
 
template<typename RetT , typename AT , typename BT >
constexpr RetT syclcompat::extend_absdiff_sat (AT a, BT b)
 Extend a and b to 33 bit and do abs_diff with saturation. More...
 
template<typename RetT , typename AT , typename BT , typename CT , typename BinaryOperation >
constexpr RetT syclcompat::extend_absdiff_sat (AT a, BT b, CT c, BinaryOperation second_op)
 Extend Inputs to 33 bit, abs_diff a, b with saturation, then do second_op with c. More...
 
template<typename RetT , typename AT , typename BT >
constexpr RetT syclcompat::extend_min (AT a, BT b)
 Extend a and b to 33 bit and return smaller one. More...
 
template<typename RetT , typename AT , typename BT , typename CT , typename BinaryOperation >
constexpr RetT syclcompat::extend_min (AT a, BT b, CT c, BinaryOperation second_op)
 Extend Inputs to 33 bit, find the smaller one in a, b, then do second_op with c. More...
 
template<typename RetT , typename AT , typename BT >
constexpr RetT syclcompat::extend_min_sat (AT a, BT b)
 Extend a and b to 33 bit and return smaller one with saturation. More...
 
template<typename RetT , typename AT , typename BT , typename CT , typename BinaryOperation >
constexpr RetT syclcompat::extend_min_sat (AT a, BT b, CT c, BinaryOperation second_op)
 Extend Inputs to 33 bit, find the smaller one in a, b with saturation, then do second_op with c. More...
 
template<typename RetT , typename AT , typename BT >
constexpr RetT syclcompat::extend_max (AT a, BT b)
 Extend a and b to 33 bit and return bigger one. More...
 
template<typename RetT , typename AT , typename BT , typename CT , typename BinaryOperation >
constexpr RetT syclcompat::extend_max (AT a, BT b, CT c, BinaryOperation second_op)
 Extend Inputs to 33 bit, find the bigger one in a, b, then do second_op with c. More...
 
template<typename RetT , typename AT , typename BT >
constexpr RetT syclcompat::extend_max_sat (AT a, BT b)
 Extend a and b to 33 bit and return bigger one with saturation. More...
 
template<typename RetT , typename AT , typename BT , typename CT , typename BinaryOperation >
constexpr RetT syclcompat::extend_max_sat (AT a, BT b, CT c, BinaryOperation second_op)
 Extend Inputs to 33 bit, find the bigger one in a, b with saturation, then do second_op with c. More...
 
template<typename RetT , typename T >
constexpr RetT syclcompat::extend_shl_clamp (T a, uint32_t b)
 Extend a and b to 33 bit and return a << clamp(b, 0, 32). More...
 
template<typename RetT , typename T , typename BinaryOperation >
constexpr RetT syclcompat::extend_shl_clamp (T a, uint32_t b, uint32_t c, BinaryOperation second_op)
 Extend Inputs to 33 bit, and return second_op(a << clamp(b, 0, 32), c). More...
 
template<typename RetT , typename T >
constexpr RetT syclcompat::extend_shl_sat_clamp (T a, uint32_t b)
 Extend a and b to 33 bit and return sat(a << clamp(b, 0, 32)). More...
 
template<typename RetT , typename T , typename BinaryOperation >
constexpr RetT syclcompat::extend_shl_sat_clamp (T a, uint32_t b, uint32_t c, BinaryOperation second_op)
 Extend Inputs to 33 bit, and return second_op(sat(a << clamp(b, 0, 32)), c). More...
 
template<typename RetT , typename T >
constexpr RetT syclcompat::extend_shl_wrap (T a, uint32_t b)
 Extend a and b to 33 bit and return a << (b & 0x1F). More...
 
template<typename RetT , typename T , typename BinaryOperation >
constexpr RetT syclcompat::extend_shl_wrap (T a, uint32_t b, uint32_t c, BinaryOperation second_op)
 Extend Inputs to 33 bit, and return second_op(a << (b & 0x1F), c). More...
 
template<typename RetT , typename T >
constexpr RetT syclcompat::extend_shl_sat_wrap (T a, uint32_t b)
 Extend a and b to 33 bit and return sat(a << (b & 0x1F)). More...
 
template<typename RetT , typename T , typename BinaryOperation >
constexpr RetT syclcompat::extend_shl_sat_wrap (T a, uint32_t b, uint32_t c, BinaryOperation second_op)
 Extend Inputs to 33 bit, and return second_op(sat(a << (b & 0x1F)), c). More...
 
template<typename RetT , typename T >
constexpr RetT syclcompat::extend_shr_clamp (T a, uint32_t b)
 Extend a and b to 33 bit and return a >> clamp(b, 0, 32). More...
 
template<typename RetT , typename T , typename BinaryOperation >
constexpr RetT syclcompat::extend_shr_clamp (T a, uint32_t b, uint32_t c, BinaryOperation second_op)
 Extend Inputs to 33 bit, and return second_op(a >> clamp(b, 0, 32), c). More...
 
template<typename RetT , typename T >
constexpr RetT syclcompat::extend_shr_sat_clamp (T a, uint32_t b)
 Extend a and b to 33 bit and return sat(a >> clamp(b, 0, 32)). More...
 
template<typename RetT , typename T , typename BinaryOperation >
constexpr RetT syclcompat::extend_shr_sat_clamp (T a, uint32_t b, uint32_t c, BinaryOperation second_op)
 Extend Inputs to 33 bit, and return second_op(sat(a >> clamp(b, 0, 32)), c). More...
 
template<typename RetT , typename T >
constexpr RetT syclcompat::extend_shr_wrap (T a, uint32_t b)
 Extend a and b to 33 bit and return a >> (b & 0x1F). More...
 
template<typename RetT , typename T , typename BinaryOperation >
constexpr RetT syclcompat::extend_shr_wrap (T a, uint32_t b, uint32_t c, BinaryOperation second_op)
 Extend Inputs to 33 bit, and return second_op(a >> (b & 0x1F), c). More...
 
template<typename RetT , typename T >
constexpr RetT syclcompat::extend_shr_sat_wrap (T a, uint32_t b)
 Extend a and b to 33 bit and return sat(a >> (b & 0x1F)). More...
 
template<typename RetT , typename T , typename BinaryOperation >
constexpr RetT syclcompat::extend_shr_sat_wrap (T a, uint32_t b, uint32_t c, BinaryOperation second_op)
 Extend Inputs to 33 bit, and return second_op(sat(a >> (b & 0x1F)), c). More...
 

Macro Definition Documentation

◆ SYCL_EXT_ONEAPI_COMPLEX

#define SYCL_EXT_ONEAPI_COMPLEX

Definition at line 35 of file math.hpp.