mod naive;
#[cfg(target_arch = "x86_64")]
mod avx;
#[cfg(target_arch = "aarch64")]
mod neon;
pub use crate::Error;
pub fn as_4bit(seq: &[u8]) -> Result<u64, Error> {
#[cfg(all(target_arch = "aarch64", not(feature = "nosimd")))]
if std::arch::is_aarch64_feature_detected!("neon") {
neon::as_4bit(seq)
} else {
naive::as_4bit(seq)
}
#[cfg(all(target_arch = "x86_64", not(feature = "nosimd")))]
if is_x86_feature_detected!("avx2") {
avx::as_4bit(seq)
} else {
naive::as_4bit(seq)
}
#[cfg(any(
feature = "nosimd",
all(not(target_arch = "aarch64"), not(target_arch = "x86_64"),)
))]
naive::as_4bit(seq)
}
pub fn encode(seq: &[u8], ebuf: &mut Vec<u64>) -> Result<(), Error> {
#[cfg(all(target_arch = "aarch64", not(feature = "nosimd")))]
if std::arch::is_aarch64_feature_detected!("neon") {
neon::encode_internal(seq, ebuf)
} else {
naive::encode_internal(seq, ebuf)
}
#[cfg(all(target_arch = "x86_64", not(feature = "nosimd")))]
if is_x86_feature_detected!("avx2") {
avx::encode_internal(seq, ebuf)
} else {
naive::encode_internal(seq, ebuf)
}
#[cfg(any(
feature = "nosimd",
all(not(target_arch = "aarch64"), not(target_arch = "x86_64"),)
))]
naive::encode_internal(seq, ebuf)
}
pub fn encode_alloc(seq: &[u8]) -> Result<Vec<u64>, Error> {
let mut ebuf = Vec::new();
encode(seq, &mut ebuf)?;
Ok(ebuf)
}