-
Notifications
You must be signed in to change notification settings - Fork 187
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
[xls][mlir] Support XLS fifo properties/config in MLIR channels. #1916
Conversation
FWIW, the I/O flopping configuration values are important to many FIFO libraries - they change the way the FIFOs are instantiated. You can see one example of how it's relevant here, in our own FIFO generator: https://github.com/google/xls/blob/main/xls/codegen/materialize_fifos_pass.cc#L162 They don't need to be in v1 of this, but they should probably be added at some point! (EDIT: And if they are here, they should almost certainly stay.) |
Got it - I was not sure so I implemented them while I was at it so they are good to go :)
Just for my own understanding - I was digging around this part of codegen (also for #1896) and I still don't quite understand how As far as I can tell only Are those values somehow constructed from The only other reference I can find to those values is during the "Convert IR to Blocks" pass, which seems to construct registers on the proc blocks the channels are attached to? 1 I am asking because I have been working on a project that relies on precisely how XLS instantiates buffers, so I am trying to make sure I really understand it :) Footnotes |
I believe This is why the materialize_fifo_pass doesn't deal with FlopKinds- it only concerns itself with FIFO configurations, as FIFOs are used for internal channels, not boundary channels. The pass doesn't need access to the whole |
Another way to think of it - the FIFO config describes the FIFO that you'll need to instantiate if the channel is internal (between two XLS procs, or from a proc back to itself). The rest of the ChannelConfig describes how the proc will interact with the channel, regardless of what the FIFO actually is... e.g., whether to insert registers on the proc side of the I/O path, and how. We've had a lot of confusion around channels because of this naming issue - in different contexts, "a channel" can refer to any of:
I've been starting to think we should have disambiguating names for these. |
Thanks you two for the explaination. That really clears it up. I was very confused why the flopping was not relevant for the fifo instantiation directly. To make sure I get this right: For input(output) boundary channels:
For internal channels:
In other words - the input and output flopping is relevant for both internal and boundary channels? |
That's correct! |
f62bc6f
to
f78fff6
Compare
rebased. |
f78fff6
to
0f4e000
Compare
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.
Nice, sorry got delayed with CGO/C4ML prep. Looks good and nice mapping retaining the core info. One could also do a roundtrip test (in one lit test convert back and forth and diff) to easily test both paths.
Thanks for the review :)Traveling today, will get to this tomorrow.
Is there a LIT-specific mechanism for this, or would you just do an |
38b7d51
to
dbc4a4b
Compare
Pretty much the latter yes. One can diff with the output of opt tool which would strip the comments (and then you don't need explicit CHECK lines), but often just checking some local invariant is fine for the lit one (it at least verifies nothing failed and specific information retained). Having a more complete diff tool that understands what can safely be ignored is better, and then could be run uniformly over all tests even. |
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 good to me, thanks!
This also adds support for converting these properties to/from XLS, and updates different passes (array_to_bits, index_type_conversion) to ensure these attributes are maintained when channels are modified. Finally, these properties are also exposed for sproc channels, and the proc elaboration pass is updated to assign said properties to all eproc channels that are generated from an sproc channel.
dbc4a4b
to
7cf46ef
Compare
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.
Approving again as seems workflows didn't start (else I may manually go and poke)
Ah I was quickly writing the round-trip test if you want to hold off for another 20min or so :) I ping you when done. |
@jpienaar Actually it seems that nobody every did a MLIR -> IR -> MLIR roundtrip and this is broken because of some loc-related bugs. I have it mostly fixed but won't wrap it up today. Feel free to merge this and I open a PR for the location-based bugs and round-trip test of fifo props tomorrow, or feel free to hold off merging this :) |
I'll submit this one. For locations: remember to enable printing locations, else parsing will go south/drop it :) |
As discussed via email.
Support XLS fifo properties/config in MLIR channels.
This also adds support for converting these properties to/from XLS, and updates different passes (array_to_bits, index_type_conversion) to ensure these attributes are maintained when channels are modified.
Finally, these properties are also exposed for sproc channels, and the proc elaboration pass is updated to assign said properties to all eproc channels that are generated from an sproc channel.
To be discussed: Are the input/output flopping fifo configuration values required?