MLIR-AIE 1.4.6.dev
AIEPoolLocks.cpp
Go to the documentation of this file.
1//===- AIEPoolLocks.cpp -----------------------------------------*- C++ -*-===//
2//
3// Copyright (C) 2026 Advanced Micro Devices, Inc.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5//
6//===----------------------------------------------------------------------===//
7
9
10using namespace mlir;
11using namespace xilinx;
12using namespace xilinx::AIE;
13
14PoolLocks::PoolLocks(DeviceOp device) {
15 for (auto endpoint : device.getOps<ObjectFifoCoreEndpointOp>())
16 if (!endpoint.drains())
17 filled.insert(endpoint.getPoolOp());
18 for (auto endpoint : device.getOps<ObjectFifoDmaEndpointOp>())
19 if (!endpoint.drains())
20 filled.insert(endpoint.getPoolOp());
21 device.walk([&](AIEX::DmaChannelResetForOp reset) {
22 // Split may already have pointed it at the fifo's shim endpoint.
23 StringRef name = reset.getObjfifo();
24 if (auto endpoint = dyn_cast_or_null<RouteEndpoint>(
25 SymbolTable::lookupNearestSymbolFrom(device,
26 reset.getObjfifoAttr())))
27 if (std::optional<StringRef> fifoName = endpoint.getFifoName())
28 name = *fifoName;
29 rearmsByFifo[name].push_back(reset);
30 });
31}
32
33bool PoolLocks::needsLocks(ObjectFifoPoolOp pool) const {
34 if (pool.getDisableSynchronization())
35 return false;
36 std::optional<ArrayAttr> initValues = pool.getInitValues();
37 int64_t full = initValues ? initValues->size() : 0;
38 // Locks would let a pool of constants be read only as many times as they
39 // count, so a second launch would hang, unless a reset re-arms them.
40 std::optional<StringRef> fifo = pool.getFifoName();
41 return full != pool.getDepth() || full <= 0 || filled.contains(pool) ||
42 (fifo && rearmsByFifo.contains(*fifo));
43}
bool needsLocks(ObjectFifoPoolOp pool) const
Whether pool gets locks.
PoolLocks(DeviceOp device)