MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::simd::detail::batch_access Struct Reference

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

#include <batch.hpp>

Static Public Member Functions

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)

Detailed Description

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.

Member Function Documentation

◆ clamp_unordered()

template<typename T>
batch< T > mtl::simd::detail::batch_access::clamp_unordered ( batch< T > x,
batch< T > lo,
batch< T > hi )
inlinestatic

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.

◆ pow2()

template<typename T>
batch< T > mtl::simd::detail::batch_access::pow2 ( batch< T > k)
inlinestatic

2^k from the exponent bits, as the Highway variant builds it, for integral k in the normal exponent range of T.

◆ round_nearest()

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.

◆ select_greater()

template<typename T>
batch< T > mtl::simd::detail::batch_access::select_greater ( batch< T > x,
batch< T > t,
batch< T > yes,
batch< T > no )
inlinestatic

◆ select_less()

template<typename T>
batch< T > mtl::simd::detail::batch_access::select_less ( batch< T > x,
batch< T > t,
batch< T > yes,
batch< T > no )
inlinestatic

◆ select_nan()

template<typename T>
batch< T > mtl::simd::detail::batch_access::select_nan ( batch< T > x,
batch< T > yes,
batch< T > no )
inlinestatic

The documentation for this struct was generated from the following file:
  • /home/runner/work/mtl5/mtl5/include/mtl/simd/batch.hpp