Crates.io | fletcher-simd |
lib.rs | fletcher-simd |
version | 0.4.0 |
source | src |
created_at | 2022-02-15 17:42:39.937194 |
updated_at | 2022-11-08 18:43:20.812544 |
description | A SIMD implementation of the Fletcher's checksum algorithm. |
homepage | |
repository | https://github.com/GodTamIt/fletcher-simd |
max_upload_size | |
id | 532848 |
size | 19,681 |
A SIMD implementation of the Fletcher's checksum algorithm.
Note: This implementation uses a modulus of 2^k
where k
is the checksum block size in bits, as this is fast with wrapping math. Other implementations may use 2^k - 1
.
std::simd
, which currently requires nightly.std::simd
.multiversion
crate.There is one cargo feature, runtime_dispatch
, enabled by default. When enabled, the crate will use CPU feature detection at runtime to dispatch to the appropriate SIMD implementation. Disabling this feature will result in static dispatch only.
use byteorder::{ByteOrder, LittleEndian};
use fletcher_simd::Fletcher128;
fn main() {
const DATA: &str = "abcdefgh";
let mut fletcher = Fletcher128::new();
// Read bytes in little endian. Endianness matters!
fletcher.update_with_iter(
DATA.as_bytes()
.chunks(8)
.map(|chunk| LittleEndian::read_u64(chunk)),
);
assert_eq!(fletcher.value(), 0x68676665646362616867666564636261);
}