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

Defines explicit conversions (with and without saturation), truncation etc. between ESIMD vector types. 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 __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<typename To , typename From , int N>
ESIMD_INLINE simd< To, N > cl::sycl::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 509 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> cl::sycl::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 593 of file math.hpp.

◆ ceil() [2/2]

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.

Definition at line 599 of file math.hpp.

◆ convert()

template<typename To , typename From , int N>
ESIMD_INLINE simd<To, N> cl::sycl::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 183 of file simd.hpp.

◆ 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> cl::sycl::ext::intel::esimd::floor ( const sycl::ext::intel::esimd::simd< float, SZ >  src0,
Sat  sat = {} 
)

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

Definition at line 580 of file math.hpp.

◆ floor() [2/2]

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.

Definition at line 586 of file math.hpp.

◆ rndd() [1/2]

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).

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 544 of file math.hpp.

◆ rndd() [2/2]

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.


Definition at line 544 of file math.hpp.

◆ rnde() [1/2]

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).

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 561 of file math.hpp.

◆ rnde() [2/2]

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.


Definition at line 561 of file math.hpp.

◆ rndu() [1/2]

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).

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 553 of file math.hpp.

◆ rndu() [2/2]

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.


Definition at line 553 of file math.hpp.

◆ rndz() [1/2]

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).

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 569 of file math.hpp.

◆ rndz() [2/2]

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.


Definition at line 569 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> 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).

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 613 of file math.hpp.

◆ trunc() [2/2]

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).

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 625 of file math.hpp.

T