EPFL-LAP / dynamatic

DHLS (Dynamic High-Level Synthesis) compiler based on MLIR
Other
49 stars 14 forks source link

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

Closed Jiahui17 closed 6 months ago

Jiahui17 commented 7 months ago

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?

Jiahui17 commented 6 months ago

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