DPC++ Runtime
Runtime libraries for oneAPI DPC++
Explicit conversions.

Defines explicit conversions (with and without saturation), truncation etc. More...

Collaboration diagram for Explicit conversions.:

Macros

#define __ESIMD_INTRINSIC_DEF(name)
 

Functions

template<typename T , int SZ, class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API sycl::ext::intel::esimd ::simd< T, SZ > sycl::_V1::ext::intel::esimd::rndd (sycl::ext::intel::esimd ::simd< float, SZ > src0, Sat sat={})
 Round-down (also known as floor). More...
 
template<typename T , class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API T sycl::_V1::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 sycl::ext::intel::esimd ::simd< T, SZ > sycl::_V1::ext::intel::esimd::rndu (sycl::ext::intel::esimd ::simd< float, SZ > src0, Sat sat={})
 Round-up (also known as ceil). More...
 
template<typename T , class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API T sycl::_V1::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 sycl::ext::intel::esimd ::simd< T, SZ > sycl::_V1::ext::intel::esimd::rnde (sycl::ext::intel::esimd ::simd< float, SZ > src0, Sat sat={})
 Round-to-even (also known as round). More...
 
template<typename T , class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API T sycl::_V1::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 sycl::ext::intel::esimd ::simd< T, SZ > sycl::_V1::ext::intel::esimd::rndz (sycl::ext::intel::esimd ::simd< float, SZ > src0, Sat sat={})
 Round-to-zero (also known as trunc). More...
 
template<typename T , class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API T sycl::_V1::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 > sycl::_V1::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 sycl::_V1::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 > sycl::_V1::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 sycl::_V1::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 > sycl::_V1::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 sycl::_V1::ext::intel::esimd::trunc (float src0, Sat sat={})
 Round to integral value using the round to zero rounding mode (scalar version). More...
 
template<typename To , typename From , int N>
ESIMD_INLINE simd< To, N > sycl::_V1::ext::intel::esimd::convert (const simd< From, N > &val)
 Covert from a simd object with element type From to a simd object with element type To. More...
 

Detailed Description

Defines explicit conversions (with and without saturation), truncation etc.

between ESIMD vector types.

Macro Definition Documentation

◆ __ESIMD_INTRINSIC_DEF

#define __ESIMD_INTRINSIC_DEF (   name)
Value:
\ \ \ \ \ \
template <typename T, int SZ, class Sat = __ESIMD_NS::saturation_off_tag> \
__ESIMD_API __ESIMD_NS::simd<T, SZ> name(__ESIMD_NS::simd<float, SZ> src0, \
Sat sat = {}) { \
__ESIMD_NS::simd<float, SZ> Result = __esimd_##name<SZ>(src0.data()); \
if constexpr (std::is_same_v<Sat, __ESIMD_NS::saturation_off_tag>) \
return Result; \
else if constexpr (!std::is_same_v<float, T>) { \
auto RawRes = __ESIMD_NS::saturate<float>(Result).data(); \
return __ESIMD_DNS::convert_vector<T, float, SZ>(std::move(RawRes)); \
} else { \
return __ESIMD_NS::saturate<T>(Result); \
} \
} \ \
template <typename T, class Sat = __ESIMD_NS::saturation_off_tag> \
__ESIMD_API T name(float src0, Sat sat = {}) { \
__ESIMD_NS::simd<float, 1> Src0 = src0; \
__ESIMD_NS::simd<T, 1> Result = name<T>(Src0, sat); \
return Result[0]; \
}

Definition at line 510 of file math.hpp.

Function Documentation

◆ ceil() [1/2]

template<typename RT , int SZ, class Sat = sycl::ext::intel::esimd::saturation_off_tag>
ESIMD_INLINE sycl::ext::intel::esimd::simd<RT, SZ> sycl::_V1::ext::intel::esimd::ceil ( const sycl::ext::intel::esimd::simd< float, SZ >  src0,
Sat  sat = {} 
)

"Ceiling" operation, vector version - alias of rndu.

Definition at line 594 of file math.hpp.

Referenced by sycl::_V1::detail::convertImpl(), and __host_std::sycl_host_ceil().

◆ ceil() [2/2]

template<typename RT , class Sat = sycl::ext::intel::esimd::saturation_off_tag>
ESIMD_INLINE RT sycl::_V1::ext::intel::esimd::ceil ( float  src0,
Sat  sat = {} 
)

"Ceiling" operation, scalar version - alias of rndu.

Definition at line 600 of file math.hpp.

◆ convert()

template<typename To , typename From , int N>
ESIMD_INLINE simd<To, N> sycl::_V1::ext::intel::esimd::convert ( const simd< From, N > &  val)

Covert from a simd object with element type From to a simd object with element type To.

Definition at line 184 of file simd.hpp.

References sycl::_V1::ext::intel::esimd::detail::simd_obj_impl< RawTy, N, Derived, SFINAE >::data().

◆ floor() [1/2]

template<typename RT , int SZ, class Sat = sycl::ext::intel::esimd::saturation_off_tag>
ESIMD_INLINE sycl::ext::intel::esimd::simd<RT, SZ> sycl::_V1::ext::intel::esimd::floor ( const sycl::ext::intel::esimd::simd< float, SZ >  src0,
Sat  sat = {} 
)

◆ floor() [2/2]

template<typename RT , class Sat = sycl::ext::intel::esimd::saturation_off_tag>
ESIMD_INLINE RT sycl::_V1::ext::intel::esimd::floor ( float  src0,
Sat  sat = {} 
)

"Floor" operation, scalar version - alias of rndd.

Definition at line 587 of file math.hpp.

◆ rndd() [1/2]

template<typename T , class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API T sycl::_V1::ext::intel::esimd::rndd ( float  src0,
Sat  sat = {} 
)

Scalar version.


Definition at line 545 of file math.hpp.

◆ rndd() [2/2]

template<typename T , int SZ, class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API sycl::ext::intel::esimd ::simd<T, SZ> sycl::_V1::ext::intel::esimd::rndd ( sycl::ext::intel::esimd ::simd< float, SZ >  src0,
Sat  sat = {} 
)

Round-down (also known as floor).

Supports only float. Corner cases:

_ _ _ _ _ _ _ _
src0 -inf -denorm -0 +0 +denorm +inf NaN
dst -inf * -0 +0 +0 +inf NaN
  • * -1 or -0 depending on the Single Precision Denorm Mode.
    Template Parameters
    TElement type.
    SZNumber of elements in the input vector.
    SatSaturation control. Default is * __ESIMD_NS::saturation_off_tag
    Parameters
    src0The argument to perform rounding on.
    satThe type tag object to auto-deduce saturation control.
    can be saturation_off or saturation_on

Definition at line 545 of file math.hpp.

◆ rnde() [1/2]

template<typename T , class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API T sycl::_V1::ext::intel::esimd::rnde ( float  src0,
Sat  sat = {} 
)

Scalar version.


Definition at line 562 of file math.hpp.

◆ rnde() [2/2]

template<typename T , int SZ, class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API sycl::ext::intel::esimd ::simd<T, SZ> sycl::_V1::ext::intel::esimd::rnde ( sycl::ext::intel::esimd ::simd< float, SZ >  src0,
Sat  sat = {} 
)

Round-to-even (also known as round).

Supports only float. Corner cases:

_ _ _ _ _ _ _ _
src0 -inf -denorm -0 +0 +denorm +inf NaN
dst -inf -0 -0 +0 +0 +inf NaN
Template Parameters
TElement type.
SZNumber of elements in the input vector.
SatSaturation control. Default is * __ESIMD_NS::saturation_off_tag
Parameters
src0The argument to perform rounding on.
satThe type tag object to auto-deduce saturation control.
can be saturation_off or saturation_on

Definition at line 562 of file math.hpp.

◆ rndu() [1/2]

template<typename T , class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API T sycl::_V1::ext::intel::esimd::rndu ( float  src0,
Sat  sat = {} 
)

Scalar version.


Definition at line 554 of file math.hpp.

◆ rndu() [2/2]

template<typename T , int SZ, class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API sycl::ext::intel::esimd ::simd<T, SZ> sycl::_V1::ext::intel::esimd::rndu ( sycl::ext::intel::esimd ::simd< float, SZ >  src0,
Sat  sat = {} 
)

Round-up (also known as ceil).

Supports only float. Corner cases:

_ _ _ _ _ _ _ _
src0 -inf -denorm -0 +0 +denorm +inf NaN
dst -inf -0 -0 +0 * +inf NaN
  • * +1 or +0 depending on the Single Precision Denorm Mode.
    Template Parameters
    TElement type.
    SZNumber of elements in the input vector.
    SatSaturation control. Default is * __ESIMD_NS::saturation_off_tag
    Parameters
    src0The argument to perform rounding on.
    satThe type tag object to auto-deduce saturation control.
    can be saturation_off or saturation_on

Definition at line 554 of file math.hpp.

◆ rndz() [1/2]

template<typename T , class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API T sycl::_V1::ext::intel::esimd::rndz ( float  src0,
Sat  sat = {} 
)

Scalar version.


Definition at line 570 of file math.hpp.

◆ rndz() [2/2]

template<typename T , int SZ, class Sat = sycl::ext::intel::esimd ::saturation_off_tag>
__ESIMD_API sycl::ext::intel::esimd ::simd<T, SZ> sycl::_V1::ext::intel::esimd::rndz ( sycl::ext::intel::esimd ::simd< float, SZ >  src0,
Sat  sat = {} 
)

Round-to-zero (also known as trunc).

Supports only float. Corner cases:

_ _ _ _ _ _ _ _
src0 -inf -denorm -0 +0 +denorm +inf NaN
dst -inf -0 -0 +0 +0 +inf NaN
Template Parameters
TElement type.
SZNumber of elements in the input vector.
SatSaturation control. Default is * __ESIMD_NS::saturation_off_tag
Parameters
src0The argument to perform rounding on.
satThe type tag object to auto-deduce saturation control.
can be saturation_off or saturation_on

Definition at line 570 of file math.hpp.

◆ trunc() [1/2]

template<typename RT , int SZ, class Sat = sycl::ext::intel::esimd::saturation_off_tag>
__ESIMD_API sycl::ext::intel::esimd::simd<RT, SZ> sycl::_V1::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).

Alias of rndz.

Template Parameters
RTelement type of the return vector.
SZsize of the input and returned vectors.
Parameters
src0the input vector.
satenables/disables the saturation (off by default). Possible values: saturation_on/saturation_off.
Returns
vector of rounded values.

Definition at line 614 of file math.hpp.

Referenced by sycl::_V1::detail::convertImpl().

◆ trunc() [2/2]

template<typename RT , class Sat = sycl::ext::intel::esimd::saturation_off_tag>
__ESIMD_API RT sycl::_V1::ext::intel::esimd::trunc ( float  src0,
Sat  sat = {} 
)

Round to integral value using the round to zero rounding mode (scalar version).

Alias of rndz.

Template Parameters
RTtype of the return value.
Parameters
src0the input operand.
satenables/disables the saturation (off by default). Possible values: saturation_on/saturation_off.
Returns
rounded value.

Definition at line 626 of file math.hpp.