Skip to content

Add AArch64 sha1 and sha2 extensions support #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from

Conversation

linkmauve
Copy link
Contributor

@linkmauve linkmauve commented Jan 3, 2020

Enables RustCrypto/asm-hashes#10

getauxval() is extremely cheap, as it is just a pointer to the beginning of the stack, so it doesn’t make much sense to use a lazy_static!() to remember the flags (at least I can’t see any difference while profiling).

Here are some benchmarks on my Nintendo Switch:

Without this patch (or without `--features=asm`):
```
test bench1_10    ... bench:          66 ns/iter (+/- 0) = 151 MB/s
test bench2_100   ... bench:         497 ns/iter (+/- 1) = 201 MB/s
test bench3_1000  ... bench:       4,799 ns/iter (+/- 16) = 208 MB/s
test bench4_10000 ... bench:      47,646 ns/iter (+/- 134) = 209 MB/s
```

With this patch:
```
test bench1_10    ... bench:          32 ns/iter (+/- 1) = 312 MB/s
test bench2_100   ... bench:         165 ns/iter (+/- 1) = 606 MB/s
test bench3_1000  ... bench:       1,480 ns/iter (+/- 5) = 675 MB/s
test bench4_10000 ... bench:      14,246 ns/iter (+/- 26) = 701 MB/s
```

There are probably scheduling fixes to be made, I haven’t paid any attention to latency.
Here are some benchmarks on my Nintendo Switch:

Without this patch (or without `--features=asm`):
```
test bench1_10    ... bench:          98 ns/iter (+/- 0) = 102 MB/s
test bench2_100   ... bench:         815 ns/iter (+/- 4) = 122 MB/s
test bench3_1000  ... bench:       7,980 ns/iter (+/- 76) = 125 MB/s
test bench4_10000 ... bench:      79,373 ns/iter (+/- 793) = 125 MB/s
```

With this patch:
```
test bench1_10    ... bench:          30 ns/iter (+/- 0) = 333 MB/s
test bench2_100   ... bench:         167 ns/iter (+/- 0) = 598 MB/s
test bench3_1000  ... bench:       1,554 ns/iter (+/- 7) = 643 MB/s
test bench4_10000 ... bench:      15,231 ns/iter (+/- 88) = 656 MB/s
```

Only the SHA-256 function is implemented, my console doesn’t support the
sha512 extension.
tarcieri and others added 2 commits January 3, 2020 18:07
Add AArch64 sha1 and sha2 extension support
It isn’t implemented yet.
@linkmauve linkmauve changed the title Add AArch64 sha1 extension support Add AArch64 sha1 and sha2 extensions support Jan 4, 2020
@tarcieri
Copy link
Member

tarcieri commented Jan 4, 2020

it doesn’t make much sense to use a lazy_static!()

Agreed, IMO lazy_static is effectively obsolete at this point

In the AArch64 ABI, v8-v15 are callee-saved, but only their lower
64 bits, which means we were inadvertantly overwriting part of their
values.

This patch entirely removes the usage of these registers, we have plenty
of them to work with!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants