Skip to content
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions data/rtl-config-vhdl.json
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,26 @@
"name": "handshake.shrsi",
"generator": "python $DYNAMATIC/tools/unit-generators/vhdl/vhdl-unit-generator.py -n $MODULE_NAME -o $OUTPUT_DIR/$MODULE_NAME.vhd -t shrsi -p bitwidth=$BITWIDTH extra_signals=$EXTRA_SIGNALS"
},
{
"name": "handshake.init",
"parameters": [
{
"name": "INITIAL_VALUE",
"type": "unsigned"
}
],
"generator": "python $DYNAMATIC/tools/unit-generators/vhdl/vhdl-unit-generator.py -n $MODULE_NAME -o $OUTPUT_DIR/$MODULE_NAME.vhd -t init -p bitwidth=$BITWIDTH extra_signals=$EXTRA_SIGNALS initial_value=$INITIAL_VALUE"
},
{
"name": "handshake.repeating_init",
"parameters": [
{
"name": "INIT_TOKEN",
Comment thread
emorbach marked this conversation as resolved.
Outdated
"type": "unsigned"
}
],
"generator": "python3 $DYNAMATIC/tools/unit-generators/vhdl/vhdl-unit-generator.py -n $MODULE_NAME -o $OUTPUT_DIR/$MODULE_NAME.vhd -t repeating_init -p init_token=$INIT_TOKEN"
},
{
"name": "handshake.shrui",
"generator": "python $DYNAMATIC/tools/unit-generators/vhdl/vhdl-unit-generator.py -n $MODULE_NAME -o $OUTPUT_DIR/$MODULE_NAME.vhd -t shrui -p bitwidth=$BITWIDTH extra_signals=$EXTRA_SIGNALS"
Expand Down
Comment thread
emorbach marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Eagerly Elastic

The eagerly elastic pass implements eager execution through two main Rewrites, specifically Rewrite A and Rewrite D from the [EagerlyElastic Paper](https://dl.acm.org/doi/pdf/10.1145/3748173.3779196). To execute this pass during compilation, it must be paired with fast token delivery by specifying both the `--fast-token-delivery` and `--eagerlyelastic` flags.

When no buffer algorithm is specified, no speedup can be achieved. However, with the buffer algorithm `fpga20` the necessary buffers are placed and the desired speedup can be achieved.

## Code Structure

The pass begins by converting all conditional branches into suppressors. This means each branch discards tokens on its true path by routing them to a sink, while allowing tokens on the false path to proceed normally through the circuit. If a branch does not initially have a sink, it is split into two separate branches where one uses an inverted condition. Next, the pass enters its main phase by executing Rewrite A as many times as possible and then enters a loop driven by the user-defined `numRewriteD` parameter. This loop alternates between applying Rewrite D once and then running Rewrite A as often as possible to move all suppressors as far down the circuit as possible. The execution sequence follows the pattern: A, (D, A)^n.

### Rewrite A
Rewrite A pushes suppressors past eligible downstream operations. An operation is eligible if it is pure and matched, such as arithmetic operations or a fork, and all of its other inputs either match the suppressor's condition or originate from a constant source. If an eligible operation has multiple independent consumers, the pass inserts a fork to make it possible for a suppressor to only move past some of the consumers. The functions that implement this are `advanceSuppressorMotion`, `isEligibleForSuppressorMotion`, and `performSuppressorMotion`.

![Def](Figures/EagerlyElastic/RewriteA.png)

### Rewrite D
Rewrite D identifies loop multiplexers and moves the suppressor past them. When a suppressor is connected to the true data path of the multiplexer, this rewrite builds an additional control structure. This structure is simplified in the code into a `RepeatingInitOp`, which implements the pink circuit seen in the picture below. This allows the suppressor to safely move past the mux. Rewrite D is implemented with the functions `checkForLoopMuxSuppressorMotion` and `applyLoopMuxSuppressorMotion`. After Rewrite D, Rewrite A is applied to move this suppressor further down the loop.

![Def](Figures/EagerlyElastic/RewriteD.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion experimental/include/experimental/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ def PredictedConstantDuplication : Pass<"predicted-constant-duplication", "mlir:
}];
}


def EagerlyElasticAD : Pass<"eagerly-elastic-a-d", "mlir::ModuleOp"> {
let summary = "Applies the Rewrites A and D of the EagerlyElastic Paper";
let description = [{
This pass prepares the conditional branches into suppressors and then applies Rewrite A
as often as possible. In the next step it applies Rewrite D and then again Rewrite A and
repeats this `numRewriteD` times.
}];
let options =
[Option<"numRewriteD", "num-rewrite-d", "unsigned", "1",
"The number of times that Rewrite D should be applied.">];
}

#endif // EXPERIMENTAL_TRANSFORMS_PASSES_TD
1 change: 1 addition & 0 deletions experimental/lib/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ add_subdirectory(Speculation)
add_subdirectory(LSQSizing)
add_subdirectory(Rigidification)
add_subdirectory(Duplication)
add_subdirectory(EagerlyElastic)
17 changes: 17 additions & 0 deletions experimental/lib/Transforms/EagerlyElastic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
add_dynamatic_library(DynamaticEagerlyElastic
EagerlyElasticAD.cpp

DEPENDS
DynamaticTransformsPassIncGen

LINK_LIBS PUBLIC
MLIRIR
MLIRMemRefDialect
MLIRFuncDialect
MLIRSupport
MLIRTransformUtils
DynamaticHandshake
DynamaticSupport
DynamaticExperimentalSupport
DynamaticBufferPlacement
)
Loading
Loading