EPFL-LAP / dynamatic

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

[tools][dynamatic] support for more delimiters and reading commands from stdin #68

Closed Jiahui17 closed 7 months ago

Jiahui17 commented 7 months ago

This PR adds support for having multiple delimiters '\n' and ';' in a Dynamatic frontend script .dyn, which enables us to write multiple commands in a single line (both in the batch mode and in the interactive mode).

For instance, in a bash script, we could do the following to run multiple benchmarks in batch:

#!/bin/bash
set -e

DYNAMATIC_PATH=./dynamatic

ls $DYNAMATIC_PATH/integration-test/*/*.c | while read benchmark
do
  $DYNAMATIC_PATH/bin/dynamatic --run \
    <(echo "set-dynamatic-path $DYNAMATIC_PATH; \
    set-src $benchmark; \
    compile; write-hdl; simulate; exit")
done
#!/bin/bash
set -e

DYNAMATIC_PATH=./dynamatic

ls $DYNAMATIC_PATH/integration-test/*/*.c | while read benchmark
do
    echo "set-dynamatic-path $DYNAMATIC_PATH; \
    set-src $benchmark; \
    compile; write-hdl; simulate; exit" | dynamatic/bin/dynamatic
done

i.e., pipe a sequence of commands into dynamatic frontend.

What do you think?

Jiahui17 commented 7 months ago

Hi Lucas, thanks for the comments! All cosmetic stuffs are addressed

Looking at this I think I handle comments very badly (what if there is a # character in the middle of a line?). In any case, this is something I can fix after this PR.

Actually, this thing is handled in the tokenize function, so we don't even need to check it here in the for loop