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

Merged
merged 14 commits into from
Feb 12, 2025
Merged
3 changes: 2 additions & 1 deletion compiler/plugins/target/AMD-AIE/aie/AIEOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -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.

);
let summary = "Packet switched routing rule";
let assemblyFormat = [{
Expand Down
450 changes: 306 additions & 144 deletions compiler/plugins/target/AMD-AIE/aie/AMDAIECreatePathFindFlows.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions compiler/plugins/target/AMD-AIE/aie/PassDetail.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace mlir::iree_compiler::AMDAIE {

#define GEN_PASS_DECL
#define GEN_PASS_DEF_AMDAIEROUTEFLOWSWITHPATHFINDER
#define GEN_PASS_DEF_AMDAIECORETOSTANDARD

#include "aie/Passes.h.inc"
Expand Down
9 changes: 2 additions & 7 deletions compiler/plugins/target/AMD-AIE/aie/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@

namespace mlir::iree_compiler::AMDAIE {

struct AIERoutePathfinderFlowsOptions {
bool clRouteCircuit = true;
bool clRoutePacket = true;
};

std::unique_ptr<OperationPass<xilinx::AIE::DeviceOp>>
createAMDAIEAssignBufferAddressesBasicPass();
std::unique_ptr<OperationPass<xilinx::AIE::DeviceOp>>
Expand All @@ -29,7 +24,8 @@ createAMDAIELocalizeLocksPass();
std::unique_ptr<OperationPass<xilinx::AIE::DeviceOp>>
createAMDAIENormalizeAddressSpacesPass();
std::unique_ptr<OperationPass<xilinx::AIE::DeviceOp>>
createAMDAIEPathfinderPass();
createAMDAIERouteFlowsWithPathfinderPass(
AMDAIERouteFlowsWithPathfinderOptions options = {});
std::unique_ptr<OperationPass<ModuleOp>> createAMDAIECoreToStandardPass(
AMDAIECoreToStandardOptions options = {});
std::unique_ptr<OperationPass<xilinx::AIE::DeviceOp>>
Expand All @@ -39,7 +35,6 @@ void registerAMDAIEAssignBufferAddressesBasic();
void registerAMDAIEAssignBufferDescriptorIDs();
void registerAMDAIELocalizeLocks();
void registerAMDAIENormalizeAddressSpaces();
void registerAMDAIERoutePathfinderFlows();
void registerAMDAIEDmaToNpu();

} // namespace mlir::iree_compiler::AMDAIE
Expand Down
19 changes: 19 additions & 0 deletions compiler/plugins/target/AMD-AIE/aie/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@
#define AMDAIE_AIE_PASSES

include "mlir/Pass/PassBase.td"
include "AIEOps.td"

def AMDAIERouteFlowsWithPathfinder :
Pass<"amdaie-create-pathfinder-flows", "xilinx::AIE::DeviceOp"> {
let summary = "Using Dijkstra's pathfinding algorithm to route"
"`aie.flow` and `aie.packet_flow` operations through switchboxes";
let constructor = "mlir::iree_compiler::AMDAIE::createAMDAIERouteFlowsWithPathfinderPass()";
let options = [
Option<"routeCircuit", "route-circuit", "bool", /*default=*/"true",
"Enable `aie.flow` routing.">,
Option<"routePacket", "route-packet", "bool", /*default=*/"true",
"Enable `aie.packet_flow` routing.">,
Option<"routeCtrl", "route-ctrl", "bool", /*default=*/"true",
"Enable routing for control flows, i.e., flows where a `CTRL` port is either the source or the destination.">,
Option<"routeData", "route-data", "bool", /*default=*/"true",
"Enable routing for data flows, i.e., flows where both the source and destination are non-`CTRL` ports.">,
];
}


def AMDAIECoreToStandard :
Pass<"amdaie-standard-lowering", "ModuleOp"> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@
// CHECK: aie.rule(24, 0, %[[VAL_69]])
// CHECK: }
// CHECK: aie.packet_rules(EAST : 0) {
// CHECK: aie.rule(31, 9, %3)
// 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.

// CHECK: aie.rule(31, 14, %[[VAL_70]])
// CHECK: aie.rule(27, 8, %[[VAL_70]])
// CHECK: aie.rule(24, 8, %[[VAL_71]])
// CHECK: }
// CHECK: }
// CHECK: %[[TILE_7_5:.*]] = aie.tile(7, 5)
Expand Down
Loading
Loading