ftz 0.0.1
Fast, reproducible floating-point arithmetic
Loading...
Searching...
No Matches
CPU environment and admission

Classes

struct  ftz::native_fp_state
 Opaque native control/status snapshot, suitable for exact restoration checks. More...
struct  ftz::native_fp32_scope
 Borrows the calling thread with RNE, masked exceptions and selected denormal controls. Saves and restores complete control/status state. The object and its nested external scopes must be destroyed on their constructing thread. It cannot be copied or moved. Construction throws on invalid/unavailable controls when exceptions are enabled; otherwise it terminates. Destruction is noexcept. More...
struct  ftz::ftz32_cpu_admission
 Results of finite startup witnesses for this scalar compilation and calling thread. These observations are not an exhaustive proof of every arithmetic input. More...

Enumerations

enum class  ftz::native_fp32_mode
 Selects gradual denormals or signed native input/output flushing.
enum class  ftz::ftz32_cpu_failure
 Identifies the first rejected admission requirement.

Functions

template<ftz32_type T = ftz32>
ftz32_cpu_admission ftz::probe_ftz32_cpu ()
 Observes whether this compiled scalar profile meets the requested policy.
bool ftz::native_fp32_environment_available () noexcept
 Reports whether this build can access native CPU FP controls; this is not numerical admission.
native_fp_state ftz::read_native_fp_state () noexcept
 Reads this thread's controls and status without changing them; unsupported hosts return zero fields.
bool ftz::set_native_fp32_mode (native_fp32_mode mode) noexcept
 Initializes an application-owned numerical thread, without restoration or admission.

Detailed Description

Controls are local to the calling CPU thread. They neither enable an ISA nor configure a GPU. Establish the environment on every numerical worker and qualify the compiled profile explicitly; ordinary arithmetic never probes it.

ftz::native_fp32_scope region(ftz::native_fp32_mode::flush);
auto admission = ftz::probe_ftz32_cpu<ftz::h32>();
if (!admission.admitted()) return false;
// Establish this agreement on each numerical thread. Run qualification at startup.
auto value = ftz::h32(2.f) * ftz::h32(3.f);
{
// Call third-party code here under the environment preceding region.
if (ftz::read_native_fp_state() != region.previous()) return false;
}
// The numerical region is restored, including its saved status flags.
return region.controls_match() && value.to_bits() == 0x40c00000u;
if (!ftz::set_native_fp32_mode(ftz::native_fp32_mode::flush)) return false;
// This establishes RNE and masked exceptions, and clears status flags.
// It does not run admission or restore the previous state on return.
return true;

Function Documentation

◆ probe_ftz32_cpu()

template<ftz32_type T = ftz32>
ftz32_cpu_admission ftz::probe_ftz32_cpu ( )
inlinenodiscardexport

Observes whether this compiled scalar profile meets the requested policy.

Template Parameters
Tm32 or h32; the default is the configured compatibility alias. Call at startup in the intended environment. The probe does not change controls or qualify CPU ISA/OS vector state, another thread, a GPU, or every math input. Masked status flags may change; use native_fp32_scope to restore the caller.
Returns
Witness results; admitted() reports the selected policy's admission.
ftz::native_fp32_scope region(ftz::native_fp32_mode::flush);
auto admission = ftz::probe_ftz32_cpu<ftz::h32>();
if (!admission.admitted()) return false;
// Establish this agreement on each numerical thread. Run qualification at startup.
auto value = ftz::h32(2.f) * ftz::h32(3.f);
{
// Call third-party code here under the environment preceding region.
if (ftz::read_native_fp_state() != region.previous()) return false;
}
// The numerical region is restored, including its saved status flags.
return region.controls_match() && value.to_bits() == 0x40c00000u;

Definition at line 706 of file ftz.ccm.