ftz 0.0.1
Fast, reproducible floating-point arithmetic
Loading...
Searching...
No Matches
FTZ SIMD values

Topics

 Register-array math

Classes

struct  native::mask_traits<::ftz::basic_ftz32< Hardware > >
 Scalar FTZ comparisons return Boolean masks for either policy. More...
struct  native::simd_traits<::ftz::basic_ftz32< Hardware > >
 Stores either FTZ scalar policy in the architecture's raw float register. More...
struct  native::simd_customization<::ftz::basic_ftz32< Hardware >, V, Self >
 Supplies FTZ arithmetic and typed memory to ::native::simd for any supported architecture. More...

Functions

template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator+ (V a, basic_ftz32< Hardware > b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns its FTZ vector rebind.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator+ (basic_ftz32< Hardware > a, V b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns its FTZ vector rebind.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator- (V a, basic_ftz32< Hardware > b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns its FTZ vector rebind.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator- (basic_ftz32< Hardware > a, V b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns its FTZ vector rebind.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator* (V a, basic_ftz32< Hardware > b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns its FTZ vector rebind.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator* (basic_ftz32< Hardware > a, V b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns its FTZ vector rebind.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator/ (V a, basic_ftz32< Hardware > b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns its FTZ vector rebind.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator/ (basic_ftz32< Hardware > a, V b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns its FTZ vector rebind.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator< (V a, basic_ftz32< Hardware > b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator< (basic_ftz32< Hardware > a, V b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator> (V a, basic_ftz32< Hardware > b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator> (basic_ftz32< Hardware > a, V b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator== (V a, basic_ftz32< Hardware > b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator== (basic_ftz32< Hardware > a, V b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator!= (V a, basic_ftz32< Hardware > b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator!= (basic_ftz32< Hardware > a, V b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator<= (V a, basic_ftz32< Hardware > b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator<= (basic_ftz32< Hardware > a, V b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator>= (V a, basic_ftz32< Hardware > b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr auto ftz::operator>= (basic_ftz32< Hardware > a, V b) noexcept
 Imports the raw register into the scalar operand's FTZ policy and returns the native comparison mask.
template<bool Hardware, detail::raw_register V>
constexpr V & ftz::operator+= (V &a, basic_ftz32< Hardware > b) noexcept
 Evaluates FTZ arithmetic before assigning to the existing raw-register destination.
template<detail::raw_register V, detail::ftz32_vector R>
requires std::same_as<typename R::register_type,V>
constexpr V & ftz::operator+= (V &a, R b) noexcept
 Evaluates FTZ arithmetic before assigning to the existing raw-register destination.
template<bool Hardware, detail::raw_register V>
constexpr V & ftz::operator-= (V &a, basic_ftz32< Hardware > b) noexcept
 Evaluates FTZ arithmetic before assigning to the existing raw-register destination.
template<detail::raw_register V, detail::ftz32_vector R>
requires std::same_as<typename R::register_type,V>
constexpr V & ftz::operator-= (V &a, R b) noexcept
 Evaluates FTZ arithmetic before assigning to the existing raw-register destination.
template<bool Hardware, detail::raw_register V>
constexpr V & ftz::operator*= (V &a, basic_ftz32< Hardware > b) noexcept
 Evaluates FTZ arithmetic before assigning to the existing raw-register destination.
template<detail::raw_register V, detail::ftz32_vector R>
requires std::same_as<typename R::register_type,V>
constexpr V & ftz::operator*= (V &a, R b) noexcept
 Evaluates FTZ arithmetic before assigning to the existing raw-register destination.
template<bool Hardware, detail::raw_register V>
constexpr V & ftz::operator/= (V &a, basic_ftz32< Hardware > b) noexcept
 Evaluates FTZ arithmetic before assigning to the existing raw-register destination.
template<detail::raw_register V, detail::ftz32_vector R>
requires std::same_as<typename R::register_type,V>
constexpr V & ftz::operator/= (V &a, R b) noexcept
 Evaluates FTZ arithmetic before assigning to the existing raw-register destination.
template<class A, class B, class C>
requires detail::ftz32_raw_scalar_fma<A,B,C>
constexpr auto ftz::fma (A a, B b, C c) noexcept(std::is_nothrow_constructible_v< detail::ftz32_simd< detail::raw_family_t< A, B, C >, detail::scalar_family_t< A, B, C > >, A & > &&std::is_nothrow_constructible_v< detail::ftz32_simd< detail::raw_family_t< A, B, C >, detail::scalar_family_t< A, B, C > >, B & > &&std::is_nothrow_constructible_v< detail::ftz32_simd< detail::raw_family_t< A, B, C >, detail::scalar_family_t< A, B, C > >, C & >)
 Imports raw SIMD operands into the FTZ scalar operand's policy and evaluates fused a*b+c. Returns the raw register's matching FTZ vector rebind; operand conversions determine noexcept.
template<detail::ftz32_vector R>
constexpr auto ftz::sincos (R input) noexcept
 Computes sine and cosine in radians with the scalar special-value rules; returns a pair in that order. Both members have type R.
template<detail::ftz32_vector R>
constexpr R ftz::sin (R input) noexcept
 Computes sine in radians with dedicated output reconstruction and the scalar FTZ special-value rules. Returns R.
template<detail::ftz32_vector R>
constexpr R ftz::cos (R input) noexcept
 Computes cosine in radians with dedicated output reconstruction and the scalar FTZ special-value rules. Returns R.
template<unsigned int Degree = 6, detail::ftz32_vector R>
requires (Degree >= 1 && Degree <= 7)
constexpr R ftz::exp (R input) noexcept
 Computes the exponential with the scalar FTZ underflow, overflow and special-value rules. Returns R.
template<detail::ftz32_vector R, bool Flush, unsigned int Degree>
requires (!Flush && Degree >= 1 && Degree <= 7)
constexpr R ftz::exp (R input, std::bool_constant< Flush >, std::integral_constant< unsigned int, Degree >) noexcept
 Delegates native's degree-aware ADL call to the SIMD FTZ exponential.
template<detail::ftz32_vector R>
constexpr R ftz::expm1 (R input) noexcept
 Computes exp(x)-1 with the scalar FTZ graph, preserving signed zero. Returns R.
template<detail::ftz32_vector R>
constexpr R ftz::tanh (R input) noexcept
 Computes hyperbolic tangent with the scalar FTZ graph, preserving signed zero and saturating infinities. Returns R.
template<detail::ftz32_vector R>
constexpr R ftz::log (R input) noexcept
 Computes natural logarithms; either zero gives negative infinity, negative nonzero values give NaN. Returns R.
template<detail::ftz32_vector R>
constexpr R ftz::log1p (R input) noexcept
 Computes log(1+x), preserving signed zero; -1 gives negative infinity and x < -1 gives NaN. Returns R.
template<detail::ftz32_vector R>
constexpr R ftz::atan2 (R y, R x) noexcept
 Computes atan2(y,x) in radians with the scalar FTZ signed-axis and infinity rules. Returns R.
template<detail::ftz32_vector R>
constexpr R::mask ftz::isnan (R value) noexcept
 Returns R::mask for NaN lanes by inspecting words; no FP evaluation or NaN quieting occurs.
template<detail::ftz32_vector R>
constexpr R::mask ftz::isinf (R value) noexcept
 Returns R::mask for either infinity by inspecting lane words.
template<detail::ftz32_vector R>
constexpr R::mask ftz::isfinite (R value) noexcept
 Returns R::mask for finite lanes by inspecting words, without changing FP status.
template<detail::ftz32_vector R>
constexpr R::mask ftz::signbit (R value) noexcept
 Returns R::mask for set sign bits, including negative zero and signed NaNs.
template<detail::ftz32_vector R>
constexpr R ftz::copysign (R magnitude, R sign) noexcept
 Returns magnitude with the sign bits of sign; all other words, including NaN payloads, are preserved. Returns R.
template<detail::ftz32_vector R>
constexpr R ftz::floor (R value) noexcept
 Rounds toward negative infinity, independently of ambient rounding mode; signed zero and infinities survive. Returns R.
template<detail::ftz32_vector R>
constexpr R ftz::ceil (R value) noexcept
 Rounds toward positive infinity, independently of ambient rounding mode; signed zero and infinities survive. Returns R.
template<detail::ftz32_vector R>
constexpr R ftz::trunc (R value) noexcept
 Rounds toward zero, independently of ambient rounding mode; signed zero and infinities survive. Returns R.

Detailed Description

Import ftz and native, then use ::native::simd<ftz::m32,N,Arch> or ::native::simd<ftz::h32,N,Arch>. The element policy applies to every lane; hardware values require an admitted flush environment on the calling thread. The raw register's layout, lane count and mask representation are retained. No operation performs admission. Typed FTZ memory and swizzles transport existing bits; float imports normalize signed subnormals. Unsafe factories transfer this invariant to the caller. The examples instantiate F as m32 and h32; arch is the selected SIMD tag.

using V = ::native::simd<F,4,arch>;
std::array<F,4> input{F(1.f),F(2.f),F(3.f),F(4.f)};
auto value = native::load_simd<V>(input.data());
auto snapshot = value.zyx; // Owning native::simd<F,3,arch>.
value.xy = value.yx; // Materialize before overlapping writes.
std::array<F,4> output{};
native::store_simd(output.data(), value); // Exactly four typed elements.
auto finite = isfinite(value); // V::mask, not a float vector.
static_assert(std::is_same_v<decltype(finite),typename V::mask>);
auto positive = select(value > V(F(0.f)), value, V(F(0.f)));
auto negative = copysign(positive, V(F(-1.f)));

::native::wide lifts these operations through ADL. Its mathematical results keep the wide shape and FTZ element policy; classification returns a wide of masks.

::native::wide<V,2> values{registers};
auto result = expm1(values); // ADL uses FTZ's array kernel.
auto [sine,cosine] = sincos(values); // A pair of wide values.
auto masks = isfinite(result); // One native mask per register.
auto angles = atan2(values,values); // Matching wide operands.
auto integers = floor(values);
static_assert(std::is_same_v<decltype(masks),::native::wide<typename V::mask,2>>);
static_assert(std::is_same_v<decltype(sine),::native::wide<V,2>>);

Function Documentation

◆ exp() [1/2]

template<unsigned int Degree = 6, detail::ftz32_vector R>
requires (Degree >= 1 && Degree <= 7)
R ftz::exp ( R input)
inlinenodiscardconstexprnoexcept

Computes the exponential with the scalar FTZ underflow, overflow and special-value rules. Returns R.

Template Parameters
DegreePolynomial degree in [1,7]; the default is 6.

Definition at line 1026 of file simd.h.

◆ exp() [2/2]

template<detail::ftz32_vector R, bool Flush, unsigned int Degree>
requires (!Flush && Degree >= 1 && Degree <= 7)
R ftz::exp ( R input,
std::bool_constant< Flush > ,
std::integral_constant< unsigned int, Degree >  )
inlinenodiscardconstexprnoexcept

Delegates native's degree-aware ADL call to the SIMD FTZ exponential.

Template Parameters
FlushMust be false; the element type determines the FTZ policy.
DegreePolynomial degree in [1,7].

Definition at line 1035 of file simd.h.