Skip to content

Commit

Permalink
Apply some tricks to make it slightly faster.
Browse files Browse the repository at this point in the history
This commit also removes a lengthy code block in rice.rs for simplicity.
  • Loading branch information
yotarok committed Oct 4, 2023
1 parent 349f266 commit e903242
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
3 changes: 2 additions & 1 deletion flacenc-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ repository = "https://github.com/yotarok/flacenc-rs/"
# This is for enabling use of profilers with a release build.
[profile.release]
debug = 1

panic = "abort"
lto = "fat"

[[bin]]
name = "flacenc"
Expand Down
16 changes: 8 additions & 8 deletions report/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Sources used: wikimedia.i_love_you_california, wikimedia.winter_kiss, wikimedia.

### Average compression speed (inverse RTF)
- Reference
- opt8lax: 259.31730941656474
- opt8: 256.19449736647505
- opt5: 498.1760928807853
- opt8lax: 260.5208675241677
- opt8: 260.4015355192523
- opt5: 496.04988453221785

- Ours
- default: 166.75753155120208
- st: 73.91379462491477
- dmse: 111.56016219091809
- bsbs: 9.53753985075257
- mae: 25.318101362135653
- default: 167.2145640416671
- st: 83.99637957900106
- dmse: 111.79190850520624
- bsbs: 11.622540675983512
- mae: 26.102371937358594


2 changes: 2 additions & 0 deletions src/fakesimd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ macro_rules! def_binop {
type Output = Self;
#[allow(clippy::redundant_closure_call)]
#[inline]
#[allow(clippy::redundant_closure_call)]
fn $fn_name(self, rhs: Self) -> Self::Output {
Self(array::from_fn(|i| ($expr)(self.0[i], rhs.0[i])))
}
Expand All @@ -237,6 +238,7 @@ def_binop!(Sub, sub, |x, y| x - y);
def_binop!(Mul, mul, |x, y| x * y);
def_binop!(Div, div, |x, y| x / y);
def_binop!(BitAnd, bitand, |x, y| x & y);
def_binop!(Shr, shr, |x, y| x >> y);

impl<T, const N: usize> std::convert::AsRef<[T; N]> for Simd<T, N>
where
Expand Down
25 changes: 1 addition & 24 deletions src/rice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,8 @@ impl PrcBitTable {
simd::u32x16::splat(offset as u32) + simd::u32x16::splat(errors.len() as u32) * INDEX1;

for v in errors {
// Below is faster than doing:
// vs = splat(*v) >> INDEX;
// or
// vs = simd::u32x16::from_array(std::array::from_fn(
// |i| v >> i));
// Perhaps due to smaller memory footprint by avoiding `splat`?
let v = *v;
let vs = simd::u32x16::from_array([
v,
v >> 1,
v >> 2,
v >> 3,
v >> 4,
v >> 5,
v >> 6,
v >> 7,
v >> 8,
v >> 9,
v >> 10,
v >> 11,
v >> 12,
v >> 13,
v >> 14,
v >> 15,
]);
let vs = simd::u32x16::splat(v) >> INDEX;
p_to_bits = (vs + p_to_bits) & MAX_P_TO_BITS_VEC;
}
self.p_to_bits = p_to_bits;
Expand Down

0 comments on commit e903242

Please sign in to comment.