Skip to content

Commit

Permalink
Use _mm256_aesdeclast for compression and finalize laned compression …
Browse files Browse the repository at this point in the history
…in a tree fashion
  • Loading branch information
ogxd committed Oct 7, 2023
1 parent adbaedc commit eb5e90e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion benches/throughput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ criterion_group! {
name = benches;
config = Criterion::default()
.sample_size(1000)
.measurement_time(Duration::from_secs(3));
.measurement_time(Duration::from_secs(5));
targets = gxhash_benchmark,
}
criterion_main!(benches);
12 changes: 8 additions & 4 deletions src/gxhash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ mod platform_defs {

#[inline]
pub unsafe fn compress(a: state, b: state) -> state {
let sum: state = _mm256_add_epi8(a, b);
_mm256_alignr_epi8(sum, sum, 1)
//let sum: state = _mm256_add_epi8(a, b);
//_mm256_alignr_epi8(sum, sum, 1)
_mm256_aesdeclast_epi128(a, b)
}

#[inline]
Expand Down Expand Up @@ -217,7 +218,10 @@ pub fn gxhash(input: &[u8]) -> u32 {
s7 = compress(s7, v7);
}

hash_vector = compress(compress(compress(compress(compress(compress(compress(s0, s1), s2), s3), s4), s5), s6), s7);
//hash_vector = _mm256_aesdeclast_epi128(_mm256_aesdeclast_epi128(_mm256_aesdeclast_epi128(_mm256_aesdeclast_epi128(_mm256_aesdeclast_epi128(_mm256_aesdeclast_epi128(_mm256_aesdeclast_epi128(s0, s1), s2), s3), s4), s5), s6), s7);
let a = compress(compress(s0, s1), compress(s2, s3));
let b = compress(compress(s4, s5), compress(s6, s7));
hash_vector = compress(a, b);

remaining_blocks_count -= unrollable_blocks_count;
}
Expand All @@ -243,7 +247,7 @@ pub fn gxhash(input: &[u8]) -> u32 {
// }
// end_address = v.offset(remaining_blocks_count) as usize;

while (v as usize) < end_address {
while likely((v as usize) < end_address) {
count_for_tests!();
load_unaligned!(v0);
hash_vector = compress(hash_vector, v0);
Expand Down

0 comments on commit eb5e90e

Please sign in to comment.