MLIR-AIE 1.4.6.dev
AIEPoolLocks.h
Go to the documentation of this file.
1//===- AIEPoolLocks.h -------------------------------------------*- C++ -*-===//
2//
3// Copyright (C) 2026 Advanced Micro Devices, Inc.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5//
6//===----------------------------------------------------------------------===//
7
8#ifndef AIE_DIALECT_AIE_TRANSFORMS_AIEPOOLLOCKS_H
9#define AIE_DIALECT_AIE_TRANSFORMS_AIEPOOLLOCKS_H
10
13
14#include "llvm/ADT/DenseSet.h"
15#include "llvm/ADT/SmallVector.h"
16#include "llvm/ADT/StringMap.h"
17
18namespace xilinx::AIE {
19
20/// Which of a device's objectFIFO pools get locks, read once from its
21/// endpoints and its `aiex.dma_channel_reset_for` ops.
22class PoolLocks {
23public:
24 explicit PoolLocks(DeviceOp device);
25
26 /// Whether `pool` gets locks. One with synchronization disabled does not,
27 /// nor one that starts full, is never refilled and is not re-armed each
28 /// launch: it holds constants its readers have nothing to wait for.
29 bool needsLocks(ObjectFifoPoolOp pool) const;
30 /// The same rule on plain facts, for the pools the split has not made yet.
31 static bool needsLocks(bool unsynchronized, int64_t full, int64_t depth,
32 bool filled, bool rearmed) {
33 // Locks would let a pool of constants be read only as many times as they
34 // count, so a second launch would hang, unless a reset re-arms them.
35 return !unsynchronized && (full != depth || full <= 0 || filled || rearmed);
36 }
37
38 /// The `aiex.dma_channel_reset_for` ops re-arming each fifo, by fifo name.
39 const llvm::StringMap<llvm::SmallVector<AIEX::DmaChannelResetForOp>> &
40 rearms() const {
41 return rearmsByFifo;
42 }
43
44private:
45 llvm::DenseSet<mlir::Operation *> filled;
46 llvm::StringMap<llvm::SmallVector<AIEX::DmaChannelResetForOp>> rearmsByFifo;
47};
48
49} // namespace xilinx::AIE
50
51#endif // AIE_DIALECT_AIE_TRANSFORMS_AIEPOOLLOCKS_H
bool needsLocks(ObjectFifoPoolOp pool) const
Whether pool gets locks.
static bool needsLocks(bool unsynchronized, int64_t full, int64_t depth, bool filled, bool rearmed)
The same rule on plain facts, for the pools the split has not made yet.
PoolLocks(DeviceOp device)
const llvm::StringMap< llvm::SmallVector< AIEX::DmaChannelResetForOp > > & rearms() const
The aiex.dma_channel_reset_for ops re-arming each fifo, by fifo name.