Skip to content
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

Add keccak::f1600x{2,4,8} #4

Closed
wants to merge 1 commit into from
Closed

Conversation

bwesterb
Copy link

@bwesterb bwesterb commented Jul 11, 2019

I'm working Rust implementations of hash-based signature schemes. For them it would be great to have parallel (x2, x4, x8) versions of f1600.

This simple PR adds such parallel versions using packed_simd.

On my old Haswell I see

test f1600         ... bench:         425 ns/iter (+/- 25)
test simd::f1600x2 ... bench:         648 ns/iter (+/- 13)
test simd::f1600x4 ... bench:         647 ns/iter (+/- 72)
test simd::f1600x8 ... bench:       1,635 ns/iter (+/- 12)

So f1600x4 takes 161ns for a single f1600, which makes it 2.6x faster than four f1600s.

Some notes

  • packed_simd is still only available for nightly, so I've put these vectorized functions behind a feature gate.
  • The f1600xn functions are created by a macro. We could instead create a trait for all operations we use on u64xn (and even u64) and make f1600x2, ... f1600x8 and f1600 instances of a _f1600<T>.

@dsprenkels
Copy link

dsprenkels commented Jul 11, 2019

On a coffeelake laptop (aang):

test f1600         ... bench:         318 ns/iter (+/- 8)
test simd::f1600x2 ... bench:         440 ns/iter (+/- 1)
test simd::f1600x4 ... bench:         457 ns/iter (+/- 143)
test simd::f1600x8 ... bench:       1,045 ns/iter (+/- 29)

On a skylake-AVX512 host (lilo6):

test f1600         ... bench:       1,052 ns/iter (+/- 14)
test simd::f1600x2 ... bench:         761 ns/iter (+/- 3)
test simd::f1600x4 ... bench:         802 ns/iter (+/- 44)
test simd::f1600x8 ... bench:       1,122 ns/iter (+/- 5)

@newpavlov
Copy link
Member

Sorry for the late reply! I will try to review this PR in near future. Meanwhile can you add test vectors for the added functions?

@bwesterb
Copy link
Author

I've added tests.

@bwesterb
Copy link
Author

bwesterb commented May 7, 2020

Have you taken a look?

@aewag aewag mentioned this pull request May 24, 2022
@tarcieri
Copy link
Member

Obsoleted by #8

@tarcieri tarcieri closed this May 24, 2022
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.

4 participants