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

chacha20: Parallelize AVX2 backend #87

Merged
merged 1 commit into from
Jan 16, 2020
Merged

chacha20: Parallelize AVX2 backend #87

merged 1 commit into from
Jan 16, 2020

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Jan 16, 2020

The AVX2 backend was previously computing two ChaCha blocks in parallel, then throwing one away.

This updates the implementation to always compute two blocks in parallel when the AVX2 backend is enabled, resulting in a ~2X speedup.

Unfortunately for cipher.rs, originally adapted from the ctr crate, I deleted the original parallel computation code, and in lieu of that the implementation diverges from what was originally in ctr. See here for a reference:

https://github.com/RustCrypto/stream-ciphers/blob/907e94b/ctr/src/lib.rs#L73

Ideally we can come up with some generic counter management and buffering abstraction in the ctr crate which works in all cases.

Benchmark results:

Screen Shot 2020-01-16 at 7 46 49 AM

The AVX2 backend was previously computing two ChaCha blocks in parallel,
then throwing one away.

This updates the implementation to always compute two blocks in parallel
when the AVX2 backend is enabled, resulting in a ~2X speedup.

Unfortunately for `cipher.rs`, originally adapted from the `ctr` crate,
I deleted the original parallel computation code, and in lieu of that
the implementation diverges from what was originally in `ctr`. See here
for a reference:

https://github.com/RustCrypto/stream-ciphers/blob/907e94b/ctr/src/lib.rs#L73

Ideally we can come up with some generic counter management and
buffering abstraction in the `ctr` crate which works in all cases.
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.

1 participant