Merge branch 'andrewprograms/master' #230

This commit is contained in:
Robbert van der Helm
2025-09-07 22:40:27 +02:00
2 changed files with 32 additions and 11 deletions

View File

@@ -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 /// sole reason that this will always yield a value, and needing to unwrap all of those options
/// is not going to be very fun. /// is not going to be very fun.
#[inline] #[inline]
pub fn iter(&self) -> SmootherIter<T> { pub fn iter(&self) -> SmootherIter<'_, T> {
SmootherIter { smoother: self } SmootherIter { smoother: self }
} }

View File

@@ -207,14 +207,25 @@ impl ScopedFtz {
{ {
#[cfg(target_feature = "sse")] #[cfg(target_feature = "sse")]
{ {
let mode = unsafe { std::arch::x86_64::_MM_GET_FLUSH_ZERO_MODE() }; const X86_FTZ_BIT: u32 = 1 << 15;
let should_disable_again = mode != std::arch::x86_64::_MM_FLUSH_ZERO_ON; 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 { if should_disable_again {
let new_mxcsr = mxcsr | X86_FTZ_BIT;
unsafe { unsafe {
std::arch::x86_64::_MM_SET_FLUSH_ZERO_MODE( std::arch::asm!(
std::arch::x86_64::_MM_FLUSH_ZERO_ON, "ldmxcsr [{p}]",
) p = in(reg) &new_mxcsr,
}; options(nostack, preserves_flags),
);
}
} }
return Self { return Self {
@@ -257,11 +268,21 @@ impl Drop for ScopedFtz {
if self.should_disable_again { if self.should_disable_again {
#[cfg(target_feature = "sse")] #[cfg(target_feature = "sse")]
{ {
const X86_FTZ_BIT: u32 = 1 << 15;
let mut mxcsr: u32 = 0;
unsafe { unsafe {
std::arch::x86_64::_MM_SET_FLUSH_ZERO_MODE( std::arch::asm!(
std::arch::x86_64::_MM_FLUSH_ZERO_OFF, "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")] #[cfg(target_arch = "aarch64")]