-
Notifications
You must be signed in to change notification settings - Fork 12
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
ZIR-153: Introduce directive to manually alias layouts #24
Conversation
ac3e692
to
69adf72
Compare
104312d
to
cfd3ff4
Compare
Added some performance enhancements that go a long way in counteracting the performance hit of adding this feature on the current draft of the Keccak accelerator. These are the numbers I ended up with on my machine for the "small test" (2897 cycles) in the interpreter: Before: 106 s I think there's a good deal more "easy" performance work, which I'd like to poke at next. I hope it might be possible to get another 2x from further parallelizing the compilation pipeline, but I'd like to move towards merging this soon. |
Since the bulk of the time was spent canonicalizing for the interpreter, I just tried turning off that step which presumably results in us interpreting a lot more instructions, but skips that apparently expensive pass. On my machine, I just ran the short Keccak test in the interpreter in 74 seconds, which is about ~25% faster than before. |
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.
Neat!
71af6f8
to
67532b5
Compare
Pushed one more commit that fixes a regression in the v2 circuit; talked with Nils about an alternative approach, but we're going to merge now anyway and I'll follow up. |
* Introduce CheckLayoutFuncOp aspect * Implement AliasLayout compiler directive * AliasLayout directive on arrays with non-array supers * Pass layouts to constructors * Remove noisy warning for mismatched types on AliasLayout directive * Layout calculation for MapOp/BlockOp/ArrayOp * Fix segfault when lowering ConstructOp to ZHLT * Code review feedback, clang-format * coerce arrays with maps instead of unrolling * Parallelize passes that prepare IR to be run in interpreter * Prune unneeded code when preparing IR to run in interpreter * Clang format; update generated code * Turn off canonicalization for interpreter * Fix regression on rv32im
Introduce a new "compiler directive" language feature. These:
!
(like Rust macros) to make them stand out in the source codeThe first directive, introduced in this PR, is the alias layout directive, which takes as input any two components of the same type (coercing along super chains if necessary), and causes the compiler to ensure that they are laid out in the same columns of the STARK trace.
For example (from
alias_layout_hint_5.zir
):The
Concatenate<N, M>
component concatenates two arrays of registerized values. Without theAliasLayout
directives, it places the concatenation in new columns, and thus requires 16 columns (4 fora
, 4 forb
, and 8 forresult
). With the directives, though,result
shares the first 4 columns witha
and the last 4 columns withb
, for a total of 8.Changes in this PR:
CheckLayoutFuncOp
aspect which collects layout constraints (this conveniently also simplifies the data flow analysis that we need to do to generate correct layouts)AliasLayout
directiveasLayout
,lookup
, andsubscript
utilities toZhlComponent.cpp