Crates.io | no_denormals |
lib.rs | no_denormals |
version | 0.1.3 |
source | src |
created_at | 2023-06-11 22:52:53.632582 |
updated_at | 2024-10-07 19:50:21.511942 |
description | Temporarily turn off floating point denormals. |
homepage | https://github.com/Sin-tel/no_denormals |
repository | https://github.com/Sin-tel/no_denormals |
max_upload_size | |
id | 887614 |
size | 8,174 |
Temporarily turn off floating point denormals.
Internally, this uses a RAII-style guard to manage the state of certain processor flags.
On x86
and x86_64
, this sets the flush-to-zero and denormals-are-zero flags in the MXCSR register.
On aarch64
this sets the flush-to-zero flag in the FPCR register.
In all cases, the register will be reset to its initial state when the guard is dropped.
Note that according to the Rust docs "modifying the masking flags, rounding mode, or denormals-are-zero mode flags leads to immediate Undefined Behavior: Rust assumes that these are always in their default state and will optimize accordingly." So use this at your own risk.
use no_denormals::no_denormals;
no_denormals(|| {
// your DSP code here.
});