Skip to content

Commit

Permalink
Update fma target
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Aug 20, 2024
1 parent f585ae9 commit cd2fd56
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ workspace = { members = ["app"] }

[package]
name = "pic-scale"
version = "0.2.6"
version = "0.2.7"
edition = "2021"
description = "High performance image scaling"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions src/math/bartlett.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ where
if x >= 0f32.as_() && x <= 1f32.as_() {
return 2f32.as_() * x;
}
return 2f32.as_() - 2f32.as_() * x;
2f32.as_() - 2f32.as_() * x
}

#[inline(always)]
Expand All @@ -61,5 +61,5 @@ where
let fac = (x / (l - 1.0f32.as_()) - 0.5f32.as_()).abs();
let w = 0.62f32.as_() - 0.4832.as_() * fac
+ 0.38f32.as_() * (2f32.as_() * V::const_pi() * fac).cos();
return w;
w
}
13 changes: 5 additions & 8 deletions src/neon/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,17 @@ pub(crate) unsafe fn prefer_vfmaq_f32(
pub(crate) unsafe fn load_3b_as_u16x4(src_ptr: *const u8) -> uint16x4_t {
let out_reg: uint16x4_t;
asm!("\
ldrb {t1:w}, [{0}]
ldrb {t2:w}, [{0}, #1]
ldrb {t3:w}, [{0}, #2]
ldrh {t1:w}, [{0}]
ldrb {t2:w}, [{0}, #2]
ins {1:v}.h[0], {t1:w}
ins {1:v}.h[1], {t2:w}
ins {1:v}.h[2], {t3:w}
ins {1:v}.s[0], {t1:w}
ins {1:v}.h[2], {t2:w}
\
",
in(reg) src_ptr,
out(vreg) out_reg,
t1 = out(reg) _,
t2 = out(reg) _,
t3 = out(reg) _);
t2 = out(reg) _);
out_reg
}

Expand Down
3 changes: 2 additions & 1 deletion src/sse/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use std::arch::x86::*;
use std::arch::x86_64::*;

#[inline]
#[target_feature(enable = "sse4.1")]
pub unsafe fn _mm_prefer_fma_ps<const FMA: bool>(a: __m128, b: __m128, c: __m128) -> __m128 {
if FMA {
_mm_fma_psx(a, b, c)
Expand All @@ -43,7 +44,7 @@ pub unsafe fn _mm_prefer_fma_ps<const FMA: bool>(a: __m128, b: __m128, c: __m128
}

#[inline]
#[target_feature(enable = "sse4.1")]
#[target_feature(enable = "sse4.1,fma")]
unsafe fn _mm_fma_psx(a: __m128, b: __m128, c: __m128) -> __m128 {
_mm_fmadd_ps(b, c, a)
}
Expand Down

0 comments on commit cd2fd56

Please sign in to comment.