Skip to content

Commit

Permalink
introduce SIMD feature (requires nightly)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-k committed Sep 28, 2024
1 parent 8d36d47 commit 71b56e6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bio-seq/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ rust-version = "1.79"

[dependencies]
bitvec = "1"
bio-seq-derive = { path = "../bio-seq-derive", version="4.0.0" }
bio-seq-derive = { path = "../bio-seq-derive", version="4.0" }
serde = { version = "1", optional = true, features=["derive"] }
serde_derive = { version = "1", optional = true }

[features]
serde = ["dep:serde", "dep:serde_derive", "bitvec/serde"]
translation = []
simd = []

#[[example]]
#name = "aminokmers"

[package.metadata.docs.rs]
all-features = true
#features = ["translation"]
3 changes: 3 additions & 0 deletions bio-seq/src/kmer.rs → bio-seq/src/kmer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ use core::ops::Deref;
use core::ptr;
use core::str::FromStr;

#[cfg(feature = "simd")]
pub mod simd;

//use bitvec::prelude::*;

#[cfg(feature = "serde")]
Expand Down
53 changes: 53 additions & 0 deletions bio-seq/src/kmer/simd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2024 Jeff Knaggs
// Licensed under the MIT license (http://opensource.org/licenses/MIT)
// This file may not be copied, modified, or distributed
// except according to those terms.

//! SIMD kmers
//!
#![feature(portable_simd)]

use crate::codec::Codec;
use crate::kmer::{Kmer, KmerStorage};
use crate::prelude::{Complement, ParseBioError, ReverseComplement};
use crate::seq::{Seq, SeqArray, SeqSlice};
use crate::{Ba, Bs, Bv};

use bitvec::field::BitField;
use bitvec::view::BitView;
use core::fmt;
use core::hash::{Hash, Hasher};
use core::marker::PhantomData;
use core::ops::Deref;
use core::ptr;
use core::str::FromStr;
use std::simd;

impl KmerStorage for simd::Simd<u64, 4> {
const BITS: usize = todo!();

fn new() -> Self {
todo!()
}
}

impl<A: Codec, const K: usize> Kmer<A, K, simd::Simd<u64, 4>> {
fn from_seq(seq: &SeqSlice<A>) -> Self {
todo!()
}
}

impl<A: Codec, const K: usize> Hash for Kmer<A, K, simd::Simd<u64, 4>> {
fn hash<H: Hasher>(&self, state: &mut H) {
todo!()
}
}

impl<A: Codec, const K: usize> TryFrom<&SeqSlice<A>> for Kmer<A, K, simd::Simd<u64, 4>> {
type Error = ParseBioError;

fn try_from(seq: &SeqSlice<A>) -> Result<Self, Self::Error> {
todo!()
}
}
1 change: 1 addition & 0 deletions bio-seq/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
#![allow(clippy::module_name_repetitions)]
// the lint doesn't seem to recognise our implementations
#![allow(clippy::into_iter_without_iter)]
#![cfg_attr(feature = "simd", feature(portable_simd))]

use bitvec::prelude::*;

Expand Down

0 comments on commit 71b56e6

Please sign in to comment.