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

Nvidia MSM proof of concept (serial) #480

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Nvidia MSM proof of concept (serial) #480

wants to merge 22 commits into from

Conversation

Vindaar
Copy link
Collaborator

@Vindaar Vindaar commented Nov 5, 2024

This implements the bucket method on the LLVM target. In principle it is just a direct port of the reference implementation. However, to make it look mostly identical, I added helper macros for for loops and if statements.

In addition, due to the somewhat tricky nature of dealing with LLVM types (especially with respect to pointer types), I added MutableValue and ConstantValue helpers as well as multiple further array types to deal with the different data types part of the calculation.

While I haven't run any benchmarks (or anything resembling a real MSM, only tested with 2 inputs), this is obviously not going to be fast given that it runs entirely in serial.

This was a (to me at least) useful implementation to see how usable one can make the LLVM IR from Nim macros for more complicated code. At the very least it is noticeable that the more complicated the code becomes, the more helper boilerplate code one needs to write to keep it similar to the CPU implementations.

Otherwise we run into problems if we have two execs in the same scope.
A failure in the check from the destructor almost certainly means that
we destroyed early, due to an exception. We don't want to hide the
exception, hence we don't quit.
Also adds `storePtr` if user really wants to store a pointer
Easy to introduce bugs by thinking one stores, when in fact one just
copies the reference.
- for safer handling of multiple EC points in different coordinates
- separate logic of elements of Fp (`Field`) from those of Fr (`FieldScalar`)
Dealing with ValueRef and the fact that pointers are now opaque in
LLVM is extremely annoying. So here are 2 types that wrap the LLVM
values with their respective underlying types which also provide
easier load / write access.
It _wraps around_ a full if statement.
This implementation is a bit of a proof of concept and playground to
investigate how easily we can generate code on the LLVM target with
the help of Nim macros.
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