Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/params/smoothing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl<T: Smoothable> Smoother<T> {
/// sole reason that this will always yield a value, and needing to unwrap all of those options
/// is not going to be very fun.
#[inline]
pub fn iter(&self) -> SmootherIter<T> {
pub fn iter(&self) -> SmootherIter<'_, T> {
SmootherIter { smoother: self }
}

Expand Down
41 changes: 31 additions & 10 deletions src/wrapper/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,25 @@ impl ScopedFtz {
{
#[cfg(target_feature = "sse")]
{
let mode = unsafe { std::arch::x86_64::_MM_GET_FLUSH_ZERO_MODE() };
let should_disable_again = mode != std::arch::x86_64::_MM_FLUSH_ZERO_ON;
const X86_FTZ_BIT: u32 = 1 << 15;
let mut mxcsr: u32 = 0;
unsafe {
std::arch::asm!(
"stmxcsr [{p}]",
p = in(reg) &mut mxcsr,
options(nostack, preserves_flags),
);
}
let should_disable_again = (mxcsr & X86_FTZ_BIT) == 0;
if should_disable_again {
let new_mxcsr = mxcsr | X86_FTZ_BIT;
unsafe {
std::arch::x86_64::_MM_SET_FLUSH_ZERO_MODE(
std::arch::x86_64::_MM_FLUSH_ZERO_ON,
)
};
std::arch::asm!(
"ldmxcsr [{p}]",
p = in(reg) &new_mxcsr,
options(nostack, preserves_flags),
);
}
}

return Self {
Expand Down Expand Up @@ -257,11 +268,21 @@ impl Drop for ScopedFtz {
if self.should_disable_again {
#[cfg(target_feature = "sse")]
{
const X86_FTZ_BIT: u32 = 1 << 15;
let mut mxcsr: u32 = 0;
unsafe {
std::arch::x86_64::_MM_SET_FLUSH_ZERO_MODE(
std::arch::x86_64::_MM_FLUSH_ZERO_OFF,
)
};
std::arch::asm!(
"stmxcsr [{p}]",
p = in(reg) &mut mxcsr,
options(nostack, preserves_flags),
);
let new_mxcsr = mxcsr & !X86_FTZ_BIT;
std::arch::asm!(
"ldmxcsr [{p}]",
p = in(reg) &new_mxcsr,
options(nostack, preserves_flags),
);
}
}

#[cfg(target_arch = "aarch64")]
Expand Down
Loading