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

[Experimental][Buffers] A simple pass for inserting a single buffer at a specific channel #62

Merged
merged 10 commits into from
Feb 16, 2024

Conversation

Jiahui17
Copy link
Collaborator

@Jiahui17 Jiahui17 commented Feb 11, 2024

This pass facilitates externally prototyping a custom buffer placement analysis, e.g., in Python. This also makes the results of some research artifacts (e.g., Mapbuf) developed in Python easily reproducible in the current Dynamatic framework.

A typical workflow would be:

  1. Export the handshake_transformed.mlir to DOT, apply some external analysis using Python to determine where to place buffers.
  2. Using this pass: add all the buffers, and generate handshake_buffered.mlir.
  3. Continue with the rest of the HLS flow.

For example, we can add a buffer by specifying the following (this is for the benchmark fir):

dynamatic-opt handshake_transformed.mlir \
	--handshake-placebuffers-custom="pred=mux1 outid=0 slots=1 type=oehb" \
	--handshake-placebuffers-custom="pred=mux1 outid=0 slots=1 type=tehb" \
	--handshake-placebuffers-custom="pred=mux2 outid=0 slots=1 type=oehb" \
	--handshake-placebuffers-custom="pred=mux2 outid=0 slots=1 type=tehb" \
	--handshake-placebuffers-custom="pred=control_merge2 outid=0 slots=1 type=oehb" \
	--handshake-placebuffers-custom="pred=control_merge2 outid=0 slots=1 type=tehb" \
	> "handshake_buffered.mlir"

dynamatic-opt handshake_buffered.mlir --handshake-canonicalize \
  > handshake_export.mlir

Any suggestions?

output of a unit

This pass facilitates prototyping a custom buffer placement analysis
externally, e.g., in python, for example, we can add a buffer by
specifying the follows:

dynamatic-opt handshake_transformed.mlir \
	--handshake-placebuffers-custom="pred=mux2 outid=0 slots=5 type=oehb" \
	--handshake-placebuffers-custom="pred=mux2 outid=0 slots=5 type=tehb" \
Copy link
Member

@lucas-rami lucas-rami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the contibution :) I think that could be very useful to other Dynamatic developers! I left a couple of minor comments.

For example, we can add a buffer by specifying the following

The convention I have followed so far when having to refer to a specific value use (i.e., channel) externally is by a combination of the consumer's name and operand index (instead of by a combination of producer's name and result index). Different uses of the same SSA value will always have a different consumer or operand index hence the former has the advantage of working even when the IR is not materialized. Since you check that the IR is materialized as a pass pre-condition and that I don't think it makes sense to deal with buffers on unmaterialized IR anyway I am fine leaving this as is, just mentioning it for future work.

At some point I think it would make sense to provide a generic way to insert semi-arbitrary operations in the IR at semi-arbitrary points (by expressing their connections with surrounding operations) to support the kind of workflow you describe in more situations.

@Jiahui17 Jiahui17 force-pushed the placebuffers-custom branch 2 times, most recently from 2ab3322 to 0745f09 Compare February 15, 2024 09:59
@Jiahui17
Copy link
Collaborator Author

Thanks for the comments! I have updated PR accordingly:)

Copy link
Member

@lucas-rami lucas-rami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the contribution :)

@lucas-rami lucas-rami merged commit 7d44854 into EPFL-LAP:main Feb 16, 2024
@Jiahui17 Jiahui17 deleted the placebuffers-custom branch February 17, 2024 13:50
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.

2 participants