Skip to content

Commit

Permalink
Packet flow new error message for aie.packet_rule op (#1738)
Browse files Browse the repository at this point in the history
  • Loading branch information
erwei-xilinx authored Aug 30, 2024
1 parent a863d44 commit 15c572c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/Dialect/AIE/Transforms/AIECreatePathFindFlows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,19 @@ void AIEPathfinderPass::runOnPacketFlow(DeviceOp device, OpBuilder &builder) {
packetrules = slaveRules[slave];

Block &rules = packetrules.getRules().front();

// Verify ID mapping against all other rules of the same slave.
for (auto rule : rules.getOps<PacketRuleOp>()) {
auto verifyMask = rule.maskInt();
auto verifyValue = rule.valueInt();
if ((group.front().second & verifyMask) == verifyValue) {
rule->emitOpError("can lead to false packet id match for id ")
<< ID << ", which is not supposed to pass through this port.";
rule->emitRemark("Please consider changing all uses of packet id ")
<< ID << " to avoid deadlock.";
}
}

builder.setInsertionPoint(rules.getTerminator());
builder.create<PacketRuleOp>(builder.getUnknownLoc(), mask, ID, amsel);
}
Expand Down
31 changes: 31 additions & 0 deletions test/create-packet-flows/badpacket_flow.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//===- badpacket_flow.mlir -------------------------------------*- MLIR -*-===//
//
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// (c) Copyright 2024 Advanced Micro Devices, Inc.
//
//===----------------------------------------------------------------------===//

// RUN: aie-opt --aie-create-pathfinder-flows %s 2>&1 | FileCheck %s
// CHECK: error{{.*}} 'aie.rule' op can lead to false packet id match for id 28, which is not supposed to pass through this port
// CHECK: remark: Please consider changing all uses of packet id 28 to avoid deadlock.

aie.device(npu1_1col) {
%03 = aie.tile(0, 3)
%02 = aie.tile(0, 2)
%00 = aie.tile(0, 0)
aie.packet_flow(28) {
aie.packet_source<%00, DMA : 0>
aie.packet_dest<%02, Ctrl : 0>
}
aie.packet_flow(29) {
aie.packet_source<%00, DMA : 0>
aie.packet_dest<%03, Ctrl : 0>
}
aie.packet_flow(26) {
aie.packet_source<%00, DMA : 0>
aie.packet_dest<%03, DMA : 0>
}
}

0 comments on commit 15c572c

Please sign in to comment.