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

[WIP] simd-buffers #221

Closed
wants to merge 1 commit into from
Closed

[WIP] simd-buffers #221

wants to merge 1 commit into from

Conversation

tarcieri
Copy link
Member

Implements the following SIMD types, as proposed in RustCrypto/traits#444:

  • U128 (portable)
  • U256 (x86/x86_64 only)
  • U128x8 (portable)

These types are largely "storage only" and don't implement arithmetic (if we needed that, stdsimd/packed_simd would be a better choice)

The implementation does expose optimized XOR intrinsics, however, which seems to be the main thing useful in a portable cryptographic context, at least as far as our current usages of SIMD go.

The x86 backend exposes unsafe target_feature(enable = "...") functions as part of its API, intended to be used/inlined within SIMD backends for particular algorithms.

@tarcieri
Copy link
Member Author

tarcieri commented Jan 22, 2021

Based on my high-level survey in RustCrypto/traits#444 the main SIMD types we need are:

  • U128x8 (AES, POLYVAL/GHASH)
  • U256x4 (ChaCha20, Poly1305)

This PR presently only implements U128x8 as a POC, which is the only one which is reasonably easy to do in a portable manner.

If we decide this approach is actually a good idea I can take a look at adding U256x4 as a follow-up, but it might end up being x86-only unless there's a good reason to have a portable implementation.

@newpavlov
Copy link
Member

I am still not sure if this approach will work well in practice, so before merging this and relevant PRs I would like to see how it will affect the downstream crates, i.e. I suggest prototyping the full chain of changes off the PR branches.

@tarcieri
Copy link
Member Author

@newpavlov yep, that was my plan: prototype it end-to-end on a bunch of branches and see if we can get some meaningful performance wins out of it, then discuss it more

@tarcieri tarcieri force-pushed the simd-buffers branch 8 times, most recently from f9f81c5 to 75682f8 Compare February 5, 2021 17:09
Implements the following SIMD types, as proposed in
RustCrypto/traits#444:

- `U128` (portable)
- `U256` (x86/x86_64 only)
- `U128x8` (portable)

These types are largely "storage only" and don't implement arithmetic
(if we needed that, `stdsimd`/`packed_simd` would be a better choice)

The implementation *does* expose optimized XOR intrinsics, however,
which seems to be the main thing useful in a portable cryptographic
context, at least as far as our current usages of SIMD go.

The `x86` backend exposes unsafe `target_feature(enable = "...")`
functions as part of its API, intended to be used/inlined within SIMD
backends for particular algorithms.
@tarcieri
Copy link
Member Author

Going to go ahead and close this.

I think there are some other ways to address this without introducing an additional crate.

An interesting one would be supporting conversions between certain crypto-bigint types and SIMD registers.

@tarcieri tarcieri closed this Sep 15, 2021
@tarcieri tarcieri deleted the simd-buffers branch September 15, 2021 12:26
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.

2 participants