-
Notifications
You must be signed in to change notification settings - Fork 48
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
Refactor clmul
to use Union
#73
Refactor clmul
to use Union
#73
Conversation
Thanks for the PR! Would it be possible to remove the This essentially moves the |
Oh, I see. Do you mean declaring |
[Updated after 570d042]So I've benched these both for intrinsics:
soft:
It seems |
Nice results! I think we can avoid depending on You can do: pub struct Clmul {
inner: Inner,
token: mul_instrinsics::InitToken
}
impl Clmul {
pub fn clmul(self, other: Self) -> (Self, Self) {
if self.token.get() {
// self.inner is intrinsics
} else {
// self.inner is soft
}
}
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work!
If you have a moment maybe you could check if inlining helps perf too
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, looks good!!!
Do you plan to add anything else, or can I merge this @000wan ?
I think we can merge this. |
Summary
It resolves #44.
Struct
Clmul
is modified to:with Union type
Inner
:It follows the implementation of polyval using
InitToken
.Results
#73 (comment)
References
https://doc.rust-lang.org/reference/items/unions.html
https://github.com/RustCrypto/universal-hashes/blob/master/polyval/src/backend/autodetect.rs
https://github.com/RustCrypto/utils/blob/master/cpufeatures/src/lib.rs