From 9b24165aba663a92936705eeff4fcec52621e9a1 Mon Sep 17 00:00:00 2001 From: Martin Larralde <martin.larralde@embl.de> Date: Sun, 16 Jun 2024 16:19:09 +0200 Subject: [PATCH] Hotfix issue with alignment of data in AVX2 code --- lightmotif/src/pli/platform/avx2.rs | 2 +- lightmotif/src/pwm.rs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lightmotif/src/pli/platform/avx2.rs b/lightmotif/src/pli/platform/avx2.rs index 4baa3d8..7fddb07 100644 --- a/lightmotif/src/pli/platform/avx2.rs +++ b/lightmotif/src/pli/platform/avx2.rs @@ -151,7 +151,7 @@ unsafe fn score_avx2_permute<A>( let x3 = _mm256_shuffle_epi8(x, m3); let x4 = _mm256_shuffle_epi8(x, m4); // load row for current weight matrix position - let t = _mm256_load_ps(pssmptr); + let t = _mm256_loadu_ps(pssmptr); // index A/T/G/C/N lookup table with the bases let b1 = _mm256_permutevar8x32_ps(t, x1); let b2 = _mm256_permutevar8x32_ps(t, x2); diff --git a/lightmotif/src/pwm.rs b/lightmotif/src/pwm.rs index a56cabb..b1f6fc1 100644 --- a/lightmotif/src/pwm.rs +++ b/lightmotif/src/pwm.rs @@ -93,6 +93,12 @@ impl<A: Alphabet> CountMatrix<A> { // } } + /// The length of the motif encoded in this count matrix. + #[inline] + pub const fn len(&self) -> usize { + self.data.rows() + } + /// Create a new count matrix from the given sequences. /// /// # Errors @@ -233,6 +239,12 @@ impl<A: Alphabet> FrequencyMatrix<A> { } } + /// The length of the motif encoded in this frequency matrix. + #[inline] + pub const fn len(&self) -> usize { + self.data.rows() + } + /// Create a new frequency matrix. /// /// The matrix must contain frequency data, i.e. rows should all sum to 1 @@ -331,7 +343,7 @@ impl<A: Alphabet> WeightMatrix<A> { /// The length of the motif encoded in this weight matrix. #[inline] - pub fn len(&self) -> usize { + pub const fn len(&self) -> usize { self.data.rows() } @@ -445,7 +457,7 @@ impl<A: Alphabet> ScoringMatrix<A> { /// The length of the motif encoded in this scoring matrix. #[inline] - pub fn len(&self) -> usize { + pub const fn len(&self) -> usize { self.data.rows() } -- GitLab