-
Notifications
You must be signed in to change notification settings - Fork 251
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
Merge celo/zexe w/ arkworks #127
Conversation
ff/src/fields/arithmetic.rs
Outdated
// Checking the modulus at compile time | ||
let first_bit_set = P::MODULUS.0[$limbs - 1] >> 63 != 0; | ||
let mut all_bits_set = P::MODULUS.0[$limbs - 1] == !0 - (1 << 63); | ||
for i in 1..$limbs { | ||
all_bits_set &= P::MODULUS.0[$limbs - i - 1] == core::u64::MAX; | ||
all_bits_set &= P::MODULUS.0[$limbs - i - 1] == !0u64; |
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.
all_bits_set &= P::MODULUS.0[$limbs - i - 1] == !0u64; | |
all_bits_set &= P::MODULUS.0[$limbs - i - 1] == core::u64::MAX; |
Thanks for the PR and adapting it to arkworks! Quick question: is the GPU scalar multiplication used to implement any operations (fixed/variable base MSMs/batch subgroup checks/batch muls)? I couldn't figure it out at a quick glance. Also, I'd really appreciate it if you could you could point out the parts that need the closest review. (Since this is a large PR, if you could suggest a "review plan" so that I can figure out how to navigate the PR, that would also be great.) |
Thanks for working on adapting these great changes to arkworks and upstreaming them! I'd like to ideally split this PR into many smaller PR's for easier review, would you like me to take a stab at doing this, or would you like to? To start with, I'd like to move the ark-serialize changes into its own PR, since that should be modular |
Ah sorry, didn't see the comment regarding not being willing to split up this PR. Is it fine if Pratyush and I go through and split up this into smaller PRs, and review/merge the smaller ones accordingly? |
@@ -0,0 +1,181 @@ | |||
// void modadd768(const uint64_t x[12], const uint64_t y[12], const uint64_t m[13], uint64_t z[12]) |
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.
Was there any automated process for how you got this assembly, or was it hand-written?
If there was an automated process, which was then edited for optimizations, could you share it please?
If it was hand-written, would it be possible to add some comments for how you derived whats going on?
(And also what features its doing, that leads it to be faster than native in expectation)
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.
I believe that there was automatic process, and we eventually want to convert all the asm code to using .S, I think, as personally I really dislike inline ASM and also its the wrong usecase, since inline asm is meant for very short segments of code that one does indeed intend to be "inlined". Further, this would, at least notionally, remove the use of unsafe
for asm, although, extern "C" technically is also unsafe, is it not?
@kobigurk should know more details on the automated process done by dag arne.
Hi thanks all for the comments. I apologise that I have been feeling rather fatigued wrt to the PR due to the tediousness and also its size. With regards to areas about which I have some doubts,
To be continued. |
So, this is specifically for batch multiplication. One thing I would like to improve is to create a more general framework for incorporating GPU kernels of all sorts, (including variablebaseMSM etc), which require instantiation at the parameter level due to needing to compile for specific curves without generics. In the future, perhaps something so ugly will not have to be relied upon, e.g. if something like EmbarkStudios/rust-gpu#387 comes to be.
I will do this. |
a613ac8
to
fe7faef
Compare
Currently I'm restarting this PR and will break into 4 components:
Number 4 is low priority as the code is spaghetti and also the API is very uncertain. This PR is considered number 4, and I will stage the PRs so they build atop one another. Since this introduces breaking changes with curves, the corresponding curves changes will also be made. I've decided I will complete this PR, as sickening as it is. I've already wasted enough time on porting this to arkworks that I decided I should waste even more time to at least get it done. I'm very sickened that instead of having to write code and get things done, I have to waste time doing stupid refactoring and changing things everywhere. What a useless waste of time. |
fe7faef
to
4328859
Compare
I'm thinking of migrating the GPU segments of the code towards rust-gpu, partly because
So there you have it. The timeline for rust-gpu to become mature enough coincides with my imagined timeline for the development of a robust gpu component to arkworks. The major targets are compute intensive workloads like proving (MSM), batch scalar muls (currently implemented), batch verifications (on curve checks, signatures). Currently, such functionality centers around small number of functions. Other potential things are FFTs. Something else I would like to look into is how to combine something like rayon with rust-gpu. |
Features:
2D test matrix feature-gating with axes (curve, test type)Refactor tests to use common templateCode timing instrumentation with fine grained control of functions and callersCombined speedup (with w-NAF) for:
Speedup for subgroup verification:
Spec sheet (also included in code comments): https://hackmd.io/@celo/S10UeWUBD
I am not willing to break this PR into smaller PRs as that was already done in Zexe, and now I have had to repeat work to merge again to arkworks, so it's too much work, no thank you.
TODOs:
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Pending
section inCHANGELOG.md
Files changed
in the Github PR explorer