-
Notifications
You must be signed in to change notification settings - Fork 20
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
masm: added procedure to load exemption points #320
Conversation
Relevant previous comment: #316 (comment) |
Based on this discussion, should we update the approach? If I'm understanding things correctly, we'd need to do the following:
|
We can use the binary-search based approach that @hackaugusto came up with in order to look-up the LDE domain generator |
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.
Looks great @hackaugusto , I like the binary search based approach and I wonder if we can apply it to the LDE domain (Low-degree extension domain i.e. it has size equal to the trace domain times a blow-up factor of
codegen/masm/src/codegen.rs
Outdated
/// This procedure handles two power using conditional drops, instead of control flow with if | ||
/// statements, since the former is slightly faster for the small number of instructions used. The | ||
/// emitted code assumes the trace_length is at the top of the stack, and afer executing it will | ||
/// leave leave the stack as follows: |
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.
minor nit: leave (single)
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.
fixed
codegen/masm/src/codegen.rs
Outdated
|
||
/// Generate code to push the exemptions point to the top of the stack. | ||
/// | ||
/// This procedure handles two power using conditional drops, instead of control flow with if |
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.
minor nit: "... handles two powers"
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.
fixed
codegen/masm/src/codegen.rs
Outdated
@@ -287,6 +365,140 @@ impl<'ast> CodeGenerator<'ast> { | |||
Ok(()) | |||
} | |||
|
|||
/// Emits code for the procedure `get_exemptions_points`. | |||
/// | |||
/// The generated procedure contains the precomputed exeption points to be used when computing |
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.
minor nit: exception
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.
or exemption (first time I notice they are close in Hamming distance 😄)
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.
fixed
codegen/masm/src/codegen.rs
Outdated
fn gen_get_exemptions_points(&mut self) -> Result<(), CodegenError> { | ||
// Notes: | ||
// - Computing the exemption points on the fly would require 1 exponentiation to find the | ||
// root-of-unity from the two-adacity, followed by another exponetiation to compute the |
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.
minor nit: adicity
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.
fixed
// - For the range from powers 3 to 32 there are 30 unique values, which requires 8 words | ||
// of data. Storing the data to memory requires pushing the 4 elements of a word to the |
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 think the ranges need to be update, either for the current approach or the other proposed one.
f67b5ef
to
8c98c00
Compare
@bobbinth @Al-Kindi-0 to clarify. Is the idea is to the following?
|
8c98c00
to
4ad8636
Compare
@bobbinth @Al-Kindi-0 anything else needs to be done on this PR? This procedure is a dependency for the rest of the divisor code |
The generated procedure takes the approach of pre-computing the values during compilations, and then searching for the correct exemption points during runtime, doing a binary search on the runtime trace length to find the correct points. The alternative of computing the points during runtime or creating a lookup table would have worked, but both approaches would be sligthly slower in comparison. The data is kept in the stack for 1. testability 2. performance, since mem load/stores are no longer necessary.
4ad8636
to
5172df4
Compare
Yes, it makes sense to me. The main work of the procedure is getting the the LDE domain generator corresponding to the LDE domain using the binary search approach. Once that is found, we can get the other 3 by multiplications and an inversion. The trace domain generator is just the LDE domain generator to the power |
I guess one question for me is whether there is significant benefit for doing binary search. If we are saving something like a dozen of cycles or so, I'd still probably prefer a simple exponentiation because it make the output much easier to reason about. |
It is probably less than 100 cycles. Changing to the exponentiation approach |
The generated procedure takes the approach of pre-computing the values during compilations, and then searching for the correct exemption points during runtime, doing a binary search on the runtime trace length to find the correct points.
The alternative of computing the points during runtime or creating a lookup table would have worked, but both approaches would be sligthly slower in comparison.
The data is kept in the stack for 1. testability 2. performance, since mem load/stores are no longer necessary.