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

Vector extension: Carryless multiply. #17

Closed
ben-marshall opened this issue Jun 30, 2020 · 4 comments
Closed

Vector extension: Carryless multiply. #17

ben-marshall opened this issue Jun 30, 2020 · 4 comments
Labels
enhancement New feature or request specification Improvements or additions to the specification

Comments

@ben-marshall
Copy link
Member

ben-marshall commented Jun 30, 2020

A discussion / proposal for a carry-less multiply instruction to be added to the vector cryptography extensions.

  • This is motivated by the GHASH part of GCM.

  • The instructions can work similarly to the existing vector integer multiply instructions, something like:

    vclmul.vv  vd, vs2, vs1, vm // Vector-vector lo
    vclmul.vs  vd, vs2, vs1, vm // Vector-scalar lo
    vclmulh.vv vd, vs2, vs1, vm // Vector-vector hi
    vclmulh.vs vd, vs2, vs1, vm // Vector-scalar hi
    

    Where (for the Crypto extension) SEW=128. Other extensions might want to implement other SEW values, but for Crypto, we only need SEW=128?

  • The reduction operation. Again, based on Markku's analysis for the scalar stuff, this can be done efficiently (in terms of instruction counts at-least) using vclmul[h].vs instructions and vxor, so a dedicated instruction might not be needed?

    I'm not sure how the calculus about reduction by multiplication or reduction by shift/xor applies in the vector world so much? Intuition says that the same calculus for the scalar world will apply to the vectors, in which case, it's up to implementers to optimise for themselves. The background being that the fastest method depends on the speed of the carry-less multiply operation relative to shifts and xors.

@ben-marshall ben-marshall added specification Improvements or additions to the specification enhancement New feature or request labels Jun 30, 2020
@grnewell
Copy link

grnewell commented Jul 1, 2020

Can we separate these topics into different GitHub issues?

@ben-marshall
Copy link
Member Author

Sure, I've split out the bit-reversal stuff into #18. I left the reduction discussion in because I'm not sure how to dis-entangle it. I hope that's alright.

@ben-marshall
Copy link
Member Author

Added an RFC under the supplementary information in the dev/next-release branch.
See https://github.com/scarv/riscv-crypto/blob/dev/next-release/doc/supp/vector-clmul-rfc.md

@ben-marshall
Copy link
Member Author

Closed by commit 9ddd1a
Future specific issues around Vector CLMUL will have new issues raised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request specification Improvements or additions to the specification
Projects
Development

No branches or pull requests

2 participants