-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-structure architecture specific implementations
- Add `arch` folder to group implementations by target arch - Add `cfg-if` to reduce headaches when reading `cfg` compile time feature gates - Rename `[Ii]mp` -> `[Uu]pdate`
- Loading branch information
1 parent
cc3155d
commit 08e7454
Showing
18 changed files
with
685 additions
and
1,080 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,6 @@ criterion = "0.3" | |
# competition | ||
adler = "1.0.2" | ||
adler32 = "1.2.0" | ||
|
||
[dependencies] | ||
cfg-if = "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pub mod scalar; | ||
#[cfg(any(target_arch = "wasm32", target_arch = "wasm64"))] | ||
pub mod wasm; | ||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] | ||
pub mod x86; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const MOD: u32 = 65521; | ||
const NMAX: usize = 5552; | ||
|
||
pub fn update(a: u16, b: u16, data: &[u8]) -> (u16, u16) { | ||
let mut a = a as u32; | ||
let mut b = b as u32; | ||
|
||
let chunks = data.chunks_exact(NMAX); | ||
let remainder = chunks.remainder(); | ||
|
||
for chunk in chunks { | ||
for byte in chunk { | ||
a = a.wrapping_add(*byte as _); | ||
b = b.wrapping_add(a); | ||
} | ||
|
||
a %= MOD; | ||
b %= MOD; | ||
} | ||
|
||
for byte in remainder { | ||
a = a.wrapping_add(*byte as _); | ||
b = b.wrapping_add(a); | ||
} | ||
|
||
a %= MOD; | ||
b %= MOD; | ||
|
||
(a as u16, b as u16) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
pub mod avx2; | ||
pub mod avx512; | ||
pub mod sse2; | ||
pub mod ssse3; | ||
|
||
/// A macro to test whether a CPU feature is available on x86/x86-x64 platforms. | ||
/// | ||
/// This macro will attempt to test at runtime if `std` feature is enabled. Otherwise will | ||
/// fallback to target_feature conditional compilation flags. | ||
#[allow(unused_macros)] | ||
macro_rules! is_x86_feature_detected { | ||
($name:tt) => {{ | ||
#[cfg(feature = "std")] | ||
#[inline(always)] | ||
fn __is_x86_feature_detected() -> bool { | ||
std::is_x86_feature_detected!($name) | ||
} | ||
|
||
#[cfg(all(not(feature = "std"), target_feature = $name))] | ||
#[inline(always)] | ||
fn __is_x86_feature_detected() -> bool { | ||
true | ||
} | ||
|
||
#[cfg(all(not(feature = "std"), not(target_feature = $name)))] | ||
#[inline(always)] | ||
fn __is_x86_feature_detected() -> bool { | ||
false | ||
} | ||
|
||
__is_x86_feature_detected() | ||
}}; | ||
} | ||
|
||
pub(crate) use is_x86_feature_detected; | ||
|
||
#[inline] | ||
#[allow(non_snake_case)] | ||
pub const fn _mm_shuffle(z: u32, y: u32, x: u32, w: u32) -> i32 { | ||
((z << 6) | (y << 4) | (x << 2) | w) as i32 | ||
} |
Oops, something went wrong.