Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LightMotif
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Larralde
LightMotif
Commits
72f42705
Commit
72f42705
authored
9 months ago
by
Martin Larralde
Browse files
Options
Downloads
Patches
Plain Diff
Fix default alignment used for x86-64 and Aarch64
parent
8aab22de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lightmotif/src/dense.rs
+17
-16
17 additions, 16 deletions
lightmotif/src/dense.rs
lightmotif/src/pli/platform/avx2.rs
+3
-0
3 additions, 0 deletions
lightmotif/src/pli/platform/avx2.rs
with
20 additions
and
16 deletions
lightmotif/src/dense.rs
+
17
−
16
View file @
72f42705
...
...
@@ -15,11 +15,16 @@ use crate::num::Unsigned;
// --- DefaultAlignment --------------------------------------------------------
#[cfg(target_arch
=
"x86_64"
)]
type
_DefaultAlignment
=
typenum
::
consts
::
U64
;
#[cfg(target_arch
=
"x86"
)]
type
_DefaultAlignment
=
typenum
::
consts
::
U32
;
#[cfg(
not(
any(target_arch
=
"x86"
,
target_arch
=
"
x86_
64"
))
)
]
#[cfg(any(target_arch
=
"x86"
,
target_arch
=
"
arm"
,
target_arch
=
"aarch
64"
))]
type
_DefaultAlignment
=
typenum
::
consts
::
U16
;
#[cfg(not(any(
target_arch
=
"x86"
,
target_arch
=
"x86_64"
,
target_arch
=
"arm"
,
target_arch
=
"aarch64"
)))]
type
_DefaultAlignment
=
typenum
::
consts
::
U1
;
/// The default alignment used in dense matrices.
pub
type
DefaultAlignment
=
_DefaultAlignment
;
...
...
@@ -70,28 +75,24 @@ impl<T: Default + Copy, C: Unsigned, A: Unsigned + PowerOfTwo> DenseMatrix<T, C,
/// Create a new *uninitialized* matrix with the given number of rows.
pub
unsafe
fn
uninitialized
(
rows
:
usize
)
->
Self
{
// Always over-allocate columns to avoid alignment issues.
let
c
=
C
::
USIZE
+
(
A
::
USIZE
-
C
::
USIZE
%
A
::
USIZE
)
*
(
C
::
USIZE
%
A
::
USIZE
>
0
)
as
usize
;
let
mut
m
=
Self
::
new
(
0
);
let
c
=
m
.stride
();
// NOTE: this is unsafe but given that we require `T` to be
// copy, this should be fine, as `Copy` prevents the
// type to be `Drop` as well.
// reserve the vector without initializing the data
let
mut
data
=
Vec
::
with_capacity
((
rows
+
1
)
*
c
);
data
.set_len
((
rows
+
1
)
*
c
);
m
.data
.reserve
((
rows
+
1
)
*
c
);
m
.
data
.set_len
((
rows
+
1
)
*
c
);
// compute offset to aligned memory
let
mut
offset
=
0
;
while
data
[
offset
..
]
.as_ptr
()
as
usize
%
c
>
0
{
offset
+=
1
m
.
offset
=
0
;
while
m
.
data
[
m
.
offset
..
]
.as_ptr
()
as
usize
%
c
>
0
{
m
.
offset
+=
1
}
Self
{
data
,
offset
,
rows
,
_columns
:
std
::
marker
::
PhantomData
,
_alignment
:
std
::
marker
::
PhantomData
,
}
m
.rows
=
rows
;
m
}
/// Create a new dense matrix from an iterable of rows.
...
...
This diff is collapsed.
Click to expand it.
lightmotif/src/pli/platform/avx2.rs
+
3
−
0
View file @
72f42705
...
...
@@ -145,12 +145,14 @@ unsafe fn score_avx2_permute<A>(
// advance position in the position weight matrix
for
_
in
0
..
pssm
.len
()
{
// load sequence row and broadcast to f32
debug_assert_eq!
(
seqptr
as
usize
&
0x1f
,
0
);
let
x
=
_mm256_load_si256
(
seqptr
as
*
const
__m256i
);
let
x1
=
_mm256_shuffle_epi8
(
x
,
m1
);
let
x2
=
_mm256_shuffle_epi8
(
x
,
m2
);
let
x3
=
_mm256_shuffle_epi8
(
x
,
m3
);
let
x4
=
_mm256_shuffle_epi8
(
x
,
m4
);
// load row for current weight matrix position
// debug_assert_eq!(pssmptr as usize & 0x1f, 0);
let
t
=
_mm256_loadu_ps
(
pssmptr
);
// index A/T/G/C/N lookup table with the bases
let
b1
=
_mm256_permutevar8x32_ps
(
t
,
x1
);
...
...
@@ -227,6 +229,7 @@ unsafe fn score_avx2_gather<A>(
// advance position in the position weight matrix
for
_
in
0
..
pssm
.len
()
{
// load sequence row and broadcast to f32
debug_assert_eq!
(
seqptr
as
usize
&
0x1f
,
0
);
let
x
=
_mm256_load_si256
(
seqptr
as
*
const
__m256i
);
let
x1
=
_mm256_shuffle_epi8
(
x
,
m1
);
let
x2
=
_mm256_shuffle_epi8
(
x
,
m2
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment