diff --git a/include/aie/Dialect/AIE/Transforms/AIEPathFinder.h b/include/aie/Dialect/AIE/Transforms/AIEPathFinder.h index 6546584b63..e60845ce5d 100644 --- a/include/aie/Dialect/AIE/Transforms/AIEPathFinder.h +++ b/include/aie/Dialect/AIE/Transforms/AIEPathFinder.h @@ -252,6 +252,9 @@ class DynamicTileAnalysis { ShimMuxOp getShimMux(mlir::OpBuilder &builder, int col); }; +// Get enum int value from WireBundle. +int getWireBundleAsInt(WireBundle bundle); + } // namespace xilinx::AIE namespace llvm { diff --git a/lib/Dialect/AIE/Transforms/AIECreatePathFindFlows.cpp b/lib/Dialect/AIE/Transforms/AIECreatePathFindFlows.cpp index 183c255631..06746cb9b6 100644 --- a/lib/Dialect/AIE/Transforms/AIECreatePathFindFlows.cpp +++ b/lib/Dialect/AIE/Transforms/AIECreatePathFindFlows.cpp @@ -445,50 +445,23 @@ void AIEPathfinderPass::runOnPacketFlow(DeviceOp device, OpBuilder &builder) { return -1; }; - // To get determinsitic behaviour; allocate amsels for control packet flows - // before others - auto getWireBundleAsInt = [](WireBundle bundle) { - switch (bundle) { - case WireBundle::Core: - return 0; - case WireBundle::DMA: - return 1; - case WireBundle::FIFO: - return 2; - case WireBundle::South: - return 3; - case WireBundle::West: - return 4; - case WireBundle::North: - return 5; - case WireBundle::East: - return 6; - case WireBundle::PLIO: - return 7; - case WireBundle::NOC: - return 8; - case WireBundle::Trace: - return 9; - case WireBundle::Ctrl: - return 10; + // Sorting the packet flows in order to get determinsitic amsel allocation; + // allocate amsels for control packet flows before others to ensure + // consistency in control packet flow overlay. + auto getUniqueIdPerFlowPerSB = [](int flowID, WireBundle srcBundle, + SmallVector dests) { + int totalNumOfWireBundles = AIE::getMaxEnumValForWireBundle(); + int currMultiplier = totalNumOfWireBundles; + int uniqueId = flowID; + uniqueId += currMultiplier + getWireBundleAsInt(srcBundle); + currMultiplier += totalNumOfWireBundles; + for (auto dst : dests) { + uniqueId += currMultiplier; + uniqueId += getWireBundleAsInt(dst.second.bundle); + currMultiplier += totalNumOfWireBundles; } - return -1; + return uniqueId; }; - auto getUniqueIdPerFlowPerSB = - [getWireBundleAsInt](int flowID, WireBundle srcBundle, - SmallVector dests) { - int totalNumOfWireBundles = AIE::getMaxEnumValForWireBundle(); - int currMultiplier = totalNumOfWireBundles; - int uniqueId = flowID; - uniqueId += currMultiplier + getWireBundleAsInt(srcBundle); - currMultiplier += totalNumOfWireBundles; - for (auto dst : dests) { - uniqueId += currMultiplier; - uniqueId += getWireBundleAsInt(dst.second.bundle); - currMultiplier += totalNumOfWireBundles; - } - return uniqueId; - }; auto getSortedPacketFlows = [&](DenseMap, SmallVector> pktFlows, DenseMap, SmallVector> diff --git a/lib/Dialect/AIE/Transforms/AIEPathFinder.cpp b/lib/Dialect/AIE/Transforms/AIEPathFinder.cpp index 80390a60e2..cc49dc4be2 100644 --- a/lib/Dialect/AIE/Transforms/AIEPathFinder.cpp +++ b/lib/Dialect/AIE/Transforms/AIEPathFinder.cpp @@ -357,22 +357,15 @@ void Pathfinder::sortFlows(const int maxCol, const int maxRow) { [maxCol, maxRow](const auto &lhs, const auto &rhs) { int lhsUniqueID = lhs.src.coords.col; lhsUniqueID += lhs.src.coords.row * maxCol; - int currMultiplier = maxCol * maxRow; - for (auto dest : lhs.dsts) { - lhsUniqueID += currMultiplier; - lhsUniqueID += dest.coords.col; - lhsUniqueID += dest.coords.row * maxCol; - currMultiplier += maxCol * maxRow; - } + lhsUniqueID += maxRow * maxCol; + lhsUniqueID += getWireBundleAsInt(lhs.src.port.bundle); + lhsUniqueID += AIE::getMaxEnumValForWireBundle(); + lhsUniqueID += lhs.src.port.channel; int rhsUniqueID = rhs.src.coords.col; rhsUniqueID += rhs.src.coords.row * maxCol; - currMultiplier = maxCol * maxRow; - for (auto dest : rhs.dsts) { - rhsUniqueID += currMultiplier; - rhsUniqueID += dest.coords.col; - rhsUniqueID += dest.coords.row * maxCol; - currMultiplier += maxCol * maxRow; - } + rhsUniqueID += maxRow * maxCol; + rhsUniqueID += getWireBundleAsInt(rhs.src.port.bundle); + rhsUniqueID += rhs.src.port.channel; return lhsUniqueID < rhsUniqueID; }); flows = priorityFlows; @@ -693,3 +686,8 @@ Pathfinder::findPaths(const int maxIterations) { LLVM_DEBUG(llvm::dbgs() << "\t---End Pathfinder::findPaths---\n"); return routingSolution; } + +// Get enum int value from WireBundle. +int AIE::getWireBundleAsInt(WireBundle bundle) { + return static_cast::type>(bundle); +}