MLIR-AIE 1.4.5.dev
AIEChannelTurns.h
Go to the documentation of this file.
1//===- AIEChannelTurns.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_AIECHANNELTURNS_H
9#define AIE_DIALECT_AIE_TRANSFORMS_AIECHANNELTURNS_H
10
12
13#include "llvm/ADT/ArrayRef.h"
14#include "llvm/ADT/SmallVector.h"
15
16#include <string>
17
18namespace xilinx::AIE {
19
20/// The order one core moves objects through several pools, read off its
21/// program, so that one DMA channel can serve those pools in turn. The core's
22/// period is the innermost loop holding every acquire and release on the
23/// pools, with the loops of static trip count inside it unrolled and the
24/// branches on their counters folded; where a branch depends on that loop's
25/// own counter, the next loop out. Its order through them must not depend on
26/// data.
27class CoreTurns {
28public:
29 /// Reads the order off the program of the core working through `ends`, all
30 /// draining (the channel fills their pools) or all filling (the channel
31 /// drains them). Fails, saying why in `reason`, when the order is not
32 /// static.
33 mlir::LogicalResult read(llvm::ArrayRef<ObjectFifoCoreEndpointOp> ends,
34 std::string &reason);
35 /// The same, before split: `names` are objectFIFOs `core` acquires from
36 /// (`coreDrains`) or into.
37 mlir::LogicalResult read(CoreOp core, llvm::ArrayRef<mlir::StringAttr> names,
38 bool coreDrains, std::string &reason);
39
40 /// Indices into `ends`, one per object the channel moves in a period of the
41 /// core's steady state.
42 llvm::ArrayRef<unsigned> turns() const { return order; }
43
44 /// Whether a channel moving objects in `turns()` order forever, through
45 /// pools of `depths`, never has itself and the core both waiting. Settles
46 /// `turns()` on the shortest such order cut from the period's.
47 bool keepsUp(llvm::ArrayRef<int64_t> depths);
48
49private:
50 bool keepsUp(llvm::ArrayRef<unsigned> order,
51 llvm::ArrayRef<int64_t> depths) const;
52
53 struct Event {
54 unsigned end;
55 int64_t count;
56 bool acquire;
57 };
58
59 llvm::SmallVector<Event> period;
60 llvm::SmallVector<unsigned> order;
61 size_t ends = 0;
62 bool coreDrains = true;
63};
64
65} // namespace xilinx::AIE
66
67#endif // AIE_DIALECT_AIE_TRANSFORMS_AIECHANNELTURNS_H
The order one core moves objects through several pools, read off its program, so that one DMA channel...
mlir::LogicalResult read(llvm::ArrayRef< ObjectFifoCoreEndpointOp > ends, std::string &reason)
Reads the order off the program of the core working through ends, all draining (the channel fills the...
bool keepsUp(llvm::ArrayRef< int64_t > depths)
Whether a channel moving objects in turns() order forever, through pools of depths,...
mlir::LogicalResult read(CoreOp core, llvm::ArrayRef< mlir::StringAttr > names, bool coreDrains, std::string &reason)
The same, before split: names are objectFIFOs core acquires from (coreDrains) or into.
llvm::ArrayRef< unsigned > turns() const
Indices into ends, one per object the channel moves in a period of the core's steady state.