Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
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
João Magalhães
boytacean
Commits
6696b773
Verified
Commit
6696b773
authored
8 months ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: improved aarch64 CRC32 SIMD implementation
This should improved performance by 200%.
parent
75de3b8f
No related branches found
No related tags found
No related merge requests found
Pipeline
#4805
passed
8 months ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
crates/hashing/src/crc32.rs
+36
-13
36 additions, 13 deletions
crates/hashing/src/crc32.rs
with
36 additions
and
13 deletions
crates/hashing/src/crc32.rs
+
36
−
13
View file @
6696b773
...
...
@@ -8,7 +8,10 @@
//! when available.
#[cfg(all(feature
=
"simd"
,
target_arch
=
"aarch64"
))]
use
std
::
arch
::{
aarch64
::
__crc32b
,
is_aarch64_feature_detected
};
use
std
::
arch
::{
aarch64
::{
__crc32b
,
__crc32d
},
is_aarch64_feature_detected
,
};
const
CRC32_TABLE
:
[
u32
;
256
]
=
[
0x00000000
,
0x77073096
,
0xee0e612c
,
0x990951ba
,
0x076dc419
,
0x706af48f
,
0xe963a535
,
0x9e6495a3
,
...
...
@@ -54,16 +57,6 @@ impl Crc32 {
Self
{
value
:
0xffffffff
}
}
#[cfg(all(feature
=
"simd"
,
target_arch
=
"aarch64"
))]
#[target_feature(enable
=
"crc"
)]
unsafe
fn
update_hw_aarch64
(
&
mut
self
,
bytes
:
&
[
u8
])
{
let
mut
value
=
self
.value
;
for
&
byte
in
bytes
{
value
=
__crc32b
(
value
,
byte
);
}
self
.value
=
value
;
}
pub
fn
update
(
&
mut
self
,
bytes
:
&
[
u8
])
{
#[cfg(all(feature
=
"simd"
,
target_arch
=
"aarch64"
))]
{
...
...
@@ -75,6 +68,14 @@ impl Crc32 {
}
}
self
.update_sw
(
bytes
);
}
pub
fn
finalize
(
self
)
->
u32
{
self
.value
^
0xffffffff
}
fn
update_sw
(
&
mut
self
,
bytes
:
&
[
u8
])
{
let
mut
value
=
self
.value
;
for
&
byte
in
bytes
{
let
index
=
(
value
^
byte
as
u32
)
&
0xFF
;
...
...
@@ -83,8 +84,30 @@ impl Crc32 {
self
.value
=
value
;
}
pub
fn
finalize
(
self
)
->
u32
{
self
.value
^
0xffffffff
#[cfg(all(feature
=
"simd"
,
target_arch
=
"aarch64"
))]
#[target_feature(enable
=
"crc"
)]
unsafe
fn
update_hw_aarch64
(
&
mut
self
,
bytes
:
&
[
u8
])
{
let
mut
value
=
self
.value
;
let
mut
i
=
0
;
while
i
+
8
<=
bytes
.len
()
{
let
chunk
=
u64
::
from_ne_bytes
([
bytes
[
i
],
bytes
[
i
+
1
],
bytes
[
i
+
2
],
bytes
[
i
+
3
],
bytes
[
i
+
4
],
bytes
[
i
+
5
],
bytes
[
i
+
6
],
bytes
[
i
+
7
],
]);
value
=
__crc32d
(
value
,
chunk
);
i
+=
8
;
}
while
i
<
bytes
.len
()
{
value
=
__crc32b
(
value
,
bytes
[
i
]);
i
+=
1
;
}
self
.value
=
value
;
}
}
...
...
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