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

Separate the routing for control flows and data flows #1082

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Yu-Zhewen
Copy link
Contributor

@Yu-Zhewen Yu-Zhewen commented Feb 6, 2025

The routing results for control flows should remain unchanged, no matter whether (or how many data flows) are present. Therefore, the routing pass is now run twice, with the first time to route control flows only, and the second to route data flows. To achieve this,

  • router can now load existing, partially routed packet flows from IR (previously, only circuit flows could be loaded).
  • the above information is passed to the Dijkstra pathfinding algorithm and the arbiter/MSel allocation algorithm, for deterministic behavior.

Note: mlir-aie handled the problem by still running the routing pass only once, and sorting flows before invoking Dijkstra's algorithm (https://github.com/Xilinx/mlir-aie/blob/a60888210c76266cc932d5a0cc922fceef0322f0/lib/Dialect/AIE/Transforms/AIEPathFinder.cpp#L349). However, since Dijkstra is an iterative, congestion-aware algorithm, sorting alone does not fully prevent congestion from data flows affecting control flow routing.

@Yu-Zhewen Yu-Zhewen changed the title [WIP][Do Not Review] Separate the routing for CTRL and non-CTRL [WIP][Do Not Review] Separate the routing for control flows and data flows Feb 11, 2025
@Yu-Zhewen Yu-Zhewen changed the title [WIP][Do Not Review] Separate the routing for control flows and data flows Separate the routing for control flows and data flows Feb 11, 2025
@@ -236,7 +236,8 @@ def AIE_PacketRuleOp: AIE_Op<"rule"> {
let arguments = (
ins I8Attr:$mask,
I8Attr:$value,
Index:$amsel
Index:$amsel,
OptionalAttr<DenseI32ArrayAttr>:$packet_ids
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When lowering packet_flow to packet_rule, the IDs can be used to calculate the mask and value. However, the reverse operation (calculating the IDs from the mask and value) is not feasible, as we will probably get a superset of actual IDs. This can cause issues during the second run of the router.

@@ -108,22 +139,17 @@ PacketRulesOp getOrCreatePacketRules(OpBuilder &builder, SwitchboxOp &swboxOp,
return packetRules;
}

struct ConvertFlowsToInterconnect : OpConversionPattern<FlowOp> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't use OpConversionPattern, as it is also conditional based on whether it is control flow or not.

// CHECK: aie.rule(31, 10, %3)
// CHECK: aie.rule(27, 11, %3)
// CHECK: aie.rule(24, 8, %2)
// CHECK: aie.rule(31, 13, %[[VAL_70]])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -132,6 +117,23 @@ struct PhysPortAndID {
TUPLE_LIKE_STRUCT_RELATIONAL_OPS(PhysPortAndID)
};

struct RouterImpl;
struct Router {
Copy link
Contributor Author

@Yu-Zhewen Yu-Zhewen Feb 11, 2025

Choose a reason for hiding this comment

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

The struct Router has been moved after the definition of PhysPort to accommodate the newly introduced addFixedPacketConnection function.

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.

1 participant