The lane operations the vector math functions are built on (#654), kept out of the public batch API: round to nearest, 2^k from integral lanes, and selects on a comparison.
More...
|
| template<typename T> |
| static batch< T > | clamp_unordered (batch< T > x, batch< T > lo, batch< T > hi) |
| | x clamped to [lo, hi]; a NaN lane becomes lo, so that no NaN reaches the integer conversion in pow2, which would be undefined behaviour here.
|
| template<typename T> |
| static batch< T > | round_nearest (batch< T > x) |
| | Round to the nearest integer, ties to even, for |x| < 2^(digits - 2): adding and subtracting 1.5 2^(digits - 1) leaves the integer part, rounded by the addition itself in the default rounding mode.
|
| template<typename T> |
| static batch< T > | pow2 (batch< T > k) |
| | 2^k from the exponent bits, as the Highway variant builds it, for integral k in the normal exponent range of T.
|
| template<typename T> |
| static batch< T > | select_greater (batch< T > x, batch< T > t, batch< T > yes, batch< T > no) |
| template<typename T> |
| static batch< T > | select_less (batch< T > x, batch< T > t, batch< T > yes, batch< T > no) |
| template<typename T> |
| static batch< T > | select_nan (batch< T > x, batch< T > yes, batch< T > no) |
The lane operations the vector math functions are built on (#654), kept out of the public batch API: round to nearest, 2^k from integral lanes, and selects on a comparison.
Each has one definition per backend, and the two give the same lanes, so a function written on them runs the same sequence of operations on Highway and on the scalar fallback.
template<typename T>
| batch< T > mtl::simd::detail::batch_access::round_nearest |
( |
batch< T > | x | ) |
|
|
inlinestatic |
Round to the nearest integer, ties to even, for |x| < 2^(digits - 2): adding and subtracting 1.5 2^(digits - 1) leaves the integer part, rounded by the addition itself in the default rounding mode.
Equal to Highway's Round on that range, and inlined, where std::nearbyint is a library call on baseline x86-64 (a vector exp's scalar build ran 5 times slower than std::exp with it). The vector math functions use it for k with |k| < 1100.