From 15c572c97427d730638c321bcec63593ce536d2b Mon Sep 17 00:00:00 2001 From: erwei-xilinx Date: Thu, 29 Aug 2024 18:23:04 -0700 Subject: [PATCH] Packet flow new error message for `aie.packet_rule` op (#1738) --- .../AIE/Transforms/AIECreatePathFindFlows.cpp | 13 ++++++++ test/create-packet-flows/badpacket_flow.mlir | 31 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 test/create-packet-flows/badpacket_flow.mlir diff --git a/lib/Dialect/AIE/Transforms/AIECreatePathFindFlows.cpp b/lib/Dialect/AIE/Transforms/AIECreatePathFindFlows.cpp index 9c17853fa1..e369cb56b1 100644 --- a/lib/Dialect/AIE/Transforms/AIECreatePathFindFlows.cpp +++ b/lib/Dialect/AIE/Transforms/AIECreatePathFindFlows.cpp @@ -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()) { + 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(builder.getUnknownLoc(), mask, ID, amsel); } diff --git a/test/create-packet-flows/badpacket_flow.mlir b/test/create-packet-flows/badpacket_flow.mlir new file mode 100644 index 0000000000..9d43484fd5 --- /dev/null +++ b/test/create-packet-flows/badpacket_flow.mlir @@ -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> + } +}