8#ifndef MLIR_AIE_DEVICEMODEL_H
9#define MLIR_AIE_DEVICEMODEL_H
14#include "llvm/ADT/ArrayRef.h"
15#include "llvm/ADT/DenseSet.h"
16#include "llvm/ADT/STLExtras.h"
17#include "llvm/ADT/SmallVector.h"
18#include "llvm/Support/MathExtras.h"
31 os <<
"TileID(" << s.col <<
", " << s.row <<
")";
35 friend std::string to_string(
const TileID &s) {
36 std::ostringstream ss;
41 friend llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
const TileID &s) {
47 inline bool operator<(
const TileID &rhs)
const {
48 return std::tie(col, row) < std::tie(rhs.col, rhs.row);
51 bool operator==(
const TileID &rhs)
const {
52 return std::tie(col, row) == std::tie(rhs.col, rhs.row);
55 bool operator!=(
const TileID &rhs)
const {
return !(*
this == rhs); }
67 return width >= 32 ? 0xFFFFFFFFu : (1u <<
width) - 1;
69 uint32_t
place(uint64_t value)
const {
89 llvm::SmallVector<std::pair<DmaBdField, DmaBdField>, 3>
padFields()
const {
90 llvm::SmallVector<std::pair<DmaBdField, DmaBdField>, 3> fields;
91 for (std::pair<DmaBdField, DmaBdField> field :
95 if (!field.first.exists())
97 fields.push_back(field);
153 uint32_t ModelProperties = 0;
157 mutable std::unique_ptr<RegisterDatabase> regDB;
158 mutable std::once_flag regDBInitFlag;
196 std::vector<int> starts;
228 return getTileType(col, row) == AIETileType::CoreTile;
233 return getTileType(col, row) == AIETileType::MemTile;
238 return getTileType(col, row) == AIETileType::ShimNOCTile;
243 return getTileType(col, row) == AIETileType::ShimPLTile;
249 return t == AIETileType::ShimNOCTile || t == AIETileType::ShimPLTile;
254 return src.col >= 0 && src.col <
columns() && src.row >= 0 &&
272 bool isInternal(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
273 return srcCol == dstCol && srcRow == dstRow;
277 bool isWest(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
278 return srcCol == dstCol + 1 && srcRow == dstRow;
282 bool isEast(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
283 return srcCol == dstCol - 1 && srcRow == dstRow;
287 bool isNorth(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
288 return srcCol == dstCol && srcRow == dstRow - 1;
292 bool isSouth(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
293 return srcCol == dstCol && srcRow == dstRow + 1;
305 std::pair{dstCol - srcCol, dstRow - srcRow});
309 virtual bool isMemWest(
int srcCol,
int srcRow,
int dstCol,
310 int dstRow)
const = 0;
312 virtual bool isMemEast(
int srcCol,
int srcRow,
int dstCol,
313 int dstRow)
const = 0;
316 int dstRow)
const = 0;
319 int dstRow)
const = 0;
323 int memRow)
const = 0;
347 if (aReachesB && bReachesA) {
374 int lockCol,
int lockRow)
const;
381 int memCol,
int memRow)
const;
406 return arch == AIEArch::AIE2p || arch == AIEArch::AIE2ps ? 64 : 32;
460 virtual uint32_t
getNumBDs(AIETileType tileType)
const = 0;
492 virtual std::optional<uint32_t>
494 uint32_t channel,
bool master)
const = 0;
529 for (uint32_t bd = 0; bd <
getNumBDs(col, row); ++bd)
543 uint32_t last = first;
546 return {first, last};
552 int channel)
const = 0;
569 int col,
int row, uint32_t bd_id,
int channel = -1,
570 AIE::DMAChannelDir direction = AIE::DMAChannelDir::MM2S)
const = 0;
579 AIE::DMAChannelDir direction)
const = 0;
586 virtual std::optional<uint32_t>
588 AIE::DMAChannelDir )
const {
605 AIE::DMAChannelDir direction)
const {
611 AIE::DMAChannelDir direction)
const {
628 WireBundle bundle)
const = 0;
633 WireBundle bundle)
const = 0;
637 WireBundle bundle)
const = 0;
641 WireBundle bundle)
const = 0;
681 AIE::DMAChannelDir )
const {
687 int srcChan, WireBundle dstBundle,
688 int dstChan)
const = 0;
712 virtual std::vector<std::pair<uint32_t, uint32_t>>
735 bool isMem =
false)
const;
740 bool isMem =
false)
const;
745 uint32_t value)
const;
754 llvm::DenseMap<TileID, int>
784 bool isMemWest(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const override;
785 bool isMemEast(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const override;
786 bool isMemNorth(
int srcCol,
int srcRow,
int dstCol,
787 int dstRow)
const override;
788 bool isMemSouth(
int srcCol,
int srcRow,
int dstCol,
789 int dstRow)
const override;
792 int memRow)
const override;
795 if (src.row % 2 == 0)
819 TileID tile)
const override;
820 uint32_t
getNumBDs(AIETileType tileType)
const override {
831 if (tileType == AIETileType::CoreTile)
833 return 0xFFFFFFFFull;
837 return tileType == AIETileType::CoreTile ? 8 : 10;
841 return tileType == AIETileType::CoreTile ? 13 : 20;
848 int channel)
const override {
852 uint64_t
getDmaBdAddress(
int col,
int row, uint32_t bd_id,
int channel,
853 AIE::DMAChannelDir direction)
const override;
858 AIE::DMAChannelDir direction)
const override;
862 uint32_t
getNumBanks(
int col,
int row)
const override {
return 4; }
869 WireBundle bundle)
const override;
871 WireBundle bundle)
const override;
873 WireBundle bundle)
const override;
875 WireBundle bundle)
const override;
877 int srcChan, WireBundle dstBundle,
878 int dstChan)
const override;
883 bool master)
const override;
893 std::vector<std::pair<uint32_t, uint32_t>>
915 static constexpr std::pair<int, int> steps[] = {{0, -1}, {1, 0}};
934 bool isMemWest(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const override;
935 bool isMemEast(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const override;
936 bool isMemNorth(
int srcCol,
int srcRow,
int dstCol,
937 int dstRow)
const override;
938 bool isMemSouth(
int srcCol,
int srcRow,
int dstCol,
939 int dstRow)
const override;
942 int memRow)
const override;
961 return tileType == AIETileType::MemTile ? 64 : 16;
967 TileID tile)
const override;
969 uint32_t
getNumBDs(AIETileType tileType)
const override {
970 return tileType == AIETileType::MemTile ? 48 : 16;
974 return tileType == AIETileType::MemTile ? 4 : 3;
980 return layout ? *layout : *
getDmaBdLayout(AIETileType::ShimNOCTile);
996 int channel)
const override {
997 if (
getTileType(col, row) != AIETileType::MemTile) {
1000 if ((channel & 1) == 0) {
1011 uint64_t
getDmaBdAddress(
int col,
int row, uint32_t bd_id,
int channel,
1012 AIE::DMAChannelDir direction)
const override;
1017 AIE::DMAChannelDir direction)
const override;
1018 std::optional<uint32_t>
1020 AIE::DMAChannelDir direction)
const override;
1034 return getTileType(col, row) == AIETileType::MemTile ? 8 : 4;
1042 WireBundle bundle)
const override;
1044 WireBundle bundle)
const override;
1046 WireBundle bundle)
const override;
1048 WireBundle bundle)
const override;
1050 int srcChan, WireBundle dstBundle,
1051 int dstChan)
const override;
1056 bool master)
const override;
1066 std::vector<std::pair<uint32_t, uint32_t>>
1087 std::vector<std::pair<uint32_t, uint32_t>>
1089 return {std::pair(0, 64), std::pair(1, 128), std::pair(2, 256),
1097 uint64_t
getDmaBdAddress(
int col,
int row, uint32_t bd_id,
int channel,
1098 AIE::DMAChannelDir direction)
const override;
1100 AIE::DMAChannelDir direction)
const override;
1101 std::optional<uint32_t>
1103 AIE::DMAChannelDir direction)
const override;
1106 WireBundle bundle)
const override;
1108 WireBundle bundle)
const override;
1112 bool master)
const override;
1127 int rows()
const override {
return 7; }
1134 return AIETileType::ShimNOCTile;
1136 return AIETileType::MemTile;
1137 return AIETileType::CoreTile;
1148 llvm::SmallDenseSet<unsigned, 16> nocColumns = {
1149 2, 3, 6, 7, 10, 11, 18, 19, 26, 27, 34, 35, 42, 43, 46, 47};
1158 int rows()
const override {
return 9; }
1162 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1163 : AIETileType::ShimPLTile;
1165 return AIETileType::CoreTile;
1174 llvm::SmallDenseSet<unsigned, 8> nocColumns = {2, 3, 6, 7, 10, 11};
1187 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1188 : AIETileType::ShimPLTile;
1191 return AIETileType::MemTile;
1192 return AIETileType::CoreTile;
1203 llvm::SmallDenseSet<unsigned, 16> nocColumns = {2, 3, 6, 7, 14, 15,
1204 22, 23, 30, 31, 34, 35};
1217 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1218 : AIETileType::ShimPLTile;
1220 if (row == 1 || row == 2)
1221 return AIETileType::MemTile;
1222 return AIETileType::CoreTile;
1273 return AIETileType::ShimNOCTile;
1275 return AIETileType::MemTile;
1276 return AIETileType::CoreTile;
1305 return AIETileType::ShimNOCTile;
1307 return AIETileType::MemTile;
1308 return AIETileType::CoreTile;
1313 std::vector<std::pair<uint32_t, uint32_t>>
1366 return llvm::isa<BaseNPU2TargetModel>(tm) ? 4 : 3;
1378 return detail::combineHashValue(FirstInfo::getHashValue(t.col),
1379 SecondInfo::getHashValue(t.row));
1392 std::size_t h1 = std::hash<int>{}(s.col);
1393 std::size_t h2 = std::hash<int>{}(s.row);
1394 return h1 ^ (h2 << 1);
uint32_t getLocalMemorySize() const override
Return the size (in bytes) of the local data memory of a core.
uint32_t getDmaBdIterBits(AIETileType tileType) const override
Return the bit width of the iteration (repeat) wrap/stride fields in a DMA buffer descriptor for the ...
uint32_t getNumMemTileRows() const override
uint32_t getMaxOutOfOrderId() const override
Return the largest out-of-order BD id (unsupported = 0).
bool isMemNorth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is North of dst.
uint32_t getMemWestBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getNumBanks(int col, int row) const override
Return the number of memory banks of a given tile.
uint64_t getDmaBdMaxLen(AIETileType tileType) const override
Return the maximum transfer length, measured in address-generation granules (see getAddressGenGranula...
uint32_t getDmaBdWrapBits(AIETileType tileType) const override
Return the bit width of the wrap (size) field in a DMA buffer descriptor for the given tile type.
uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma task queue register for the given col, row, channel and direction...
std::optional< TileID > getMemSouth(TileID src) const override
Return the tile ID of the memory to the south of the given tile, if it exists.
std::optional< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const override
uint32_t getCoreDataAddressSpaceSize() const override
Return the size (in bytes) of the address space a core can issue data accesses into.
uint32_t getProgramMemorySize() const override
Return the size (in bytes) of a core's program memory.
static bool classof(const AIETargetModel *model)
std::optional< TileID > getMemNorth(TileID src) const override
Return the tile ID of the memory to the north of the given tile, if it exists.
uint32_t getMemInternalBaseAddress(TileID src) const override
Return the base address in the local address map for a core.
std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t port_num, bool master) const override
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
uint32_t getDmaTaskQueueDepth() const override
Return how many DMA tasks a single channel's task queue holds (unsupported = 0).
uint32_t getDmaBdStepBits(AIETileType tileType) const override
Return the bit width of the step (stride) field in a DMA buffer descriptor for the given tile type.
bool isBdChannelAccessible(int col, int row, uint32_t bd_id, int channel) const override
Return true iff buffer descriptor bd_id on tile (col, row) can be submitted on channel channel.
bool isMemSouth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is South of dst.
uint32_t getMemEastBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMaxRepeatCount() const override
Return the largest DMA task repeat count (unsupported = 0).
std::optional< TileID > getMemWest(TileID src) const override
Return the tile ID of the memory to the west of the given tile, if it exists.
bool isLegalMemAffinity(int coreCol, int coreRow, int memCol, int memRow) const override
Return true if core can access the memory in mem.
uint32_t getNumMselsPerArbiter() const override
Return the number of master select values per stream-switch arbiter.
uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
uint32_t getRowShift() const override
uint32_t getBDMaxDims(AIETileType tileType) const override
Return the maximum number of addressing dimensions (wraps/strides) a single buffer descriptor support...
uint32_t getNumArbiters() const override
Return the number of arbiters per stream switch.
uint32_t getNumSlaveSlots() const override
Return the number of packet-rule slots per stream-switch slave port.
uint32_t getNumSourceShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a shimmux.
uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a switchbox.
uint32_t getColumnShift() const override
bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is East of dst.
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is West of dst.
uint32_t getNumLocks(AIETileType tileType) const override
Return the number of lock objects for a given tile type.
uint32_t getDmaBdAddressOffset(int col, int row) const override
Return the offset of the base address field within the shim dma buffer descriptor.
uint32_t getComputeTileLoadStoreBusWidth() const override
Return the data bus width (in bits) for load/store operations of a compute core.
uint32_t getAccumulatorCascadeSize() const override
Return the size (in bits) of the accumulator/cascade.
AIE1TargetModel(TargetModelKind k)
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
uint32_t getMemTileSize() const override
Return the size (in bytes) of a MemTile.
uint32_t getMemSouthBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override
AIEArch getTargetArch() const override
AIE1 TargetModel.
uint32_t getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a shimmux.
uint32_t getMemNorthBaseAddress() const override
Return the base address in the local address map for a core.
std::optional< TileID > getMemEast(TileID src) const override
Return the tile ID of the memory to the east of the given tile, if it exists.
uint32_t getNumBDs(AIETileType tileType) const override
Return the number of buffer descriptors for a given tile type.
bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const override
uint32_t getMaxLockValue() const override
Return the maximum value that can be stored in a lock register.
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
uint32_t getMaxPacketId() const override
Return the largest packet id the stream switch can route.
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma task queue register for the given col, row, channel and direction...
uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a switchbox.
AIEArch getTargetArch() const override
Return the target architecture.
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
std::optional< uint32_t > getDmaStatusAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the address of the DMA status register for a channel, or nullopt when this target's layout has...
uint32_t getNumControllersPerColumn() const override
Number of microcontrollers (uC) per column.
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t channel, bool master) const override
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
AIE2PSTargetModel(TargetModelKind k)
static bool classof(const AIETargetModel *model)
uint32_t getRowShift() const override
uint32_t getMemWestBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMemSouthBaseAddress() const override
Return the base address in the local address map for a core.
bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const override
llvm::ArrayRef< std::pair< int, int > > getCascadeSteps() const override
The steps (destination column - source column, destination row - source row) from one core's cascade ...
uint32_t getNumMselsPerArbiter() const override
Return the number of master select values per stream-switch arbiter.
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
uint32_t getCoreDataAddressSpaceSize() const override
Return the size (in bytes) of the address space a core can issue data accesses into.
uint32_t getNumLocks(AIETileType tileType) const override
Return the number of lock objects for a given tile type.
std::optional< uint32_t > getDmaStatusAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the address of the DMA status register for a channel, or nullopt when this target's layout has...
uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override
uint32_t getAddressGenGranularity() const override
Return the data bus width of the device.
std::optional< TileID > getMemWest(TileID src) const override
Return the tile ID of the memory to the west of the given tile, if it exists.
std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t port_num, bool master) const override
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
uint32_t getAccumulatorCascadeSize() const override
Return the size (in bits) of the accumulator/cascade.
uint32_t getMaxRepeatCount() const override
Return the largest DMA task repeat count (unsupported = 0).
std::unique_ptr< RegisterDatabase > loadRegisterDatabase() const override
AIE2 TargetModel.
bool isBdChannelAccessible(int col, int row, uint32_t bd_id, int channel) const override
Return true iff buffer descriptor bd_id on tile (col, row) can be submitted on channel channel.
uint32_t getDmaBdIterBits(AIETileType tileType) const override
Return the bit width of the iteration (repeat) wrap/stride fields in a DMA buffer descriptor for the ...
AIEArch getTargetArch() const override
Return the target architecture.
bool isLegalMemAffinity(int coreCol, int coreRow, int memCol, int memRow) const override
Return true if core can access the memory in mem.
std::optional< TileID > getMemEast(TileID src) const override
Return the tile ID of the memory to the east of the given tile, if it exists.
uint32_t getDmaChannelIdleMask() const override
Return the bits of the getDmaStatusAddress() register that are all clear exactly when the channel has...
uint32_t getMaxOutOfOrderId() const override
Return the largest out-of-order BD id (unsupported = 0).
uint32_t getMaxLockValue() const override
Return the maximum value that can be stored in a lock register.
uint64_t getDmaBdMaxLen(AIETileType tileType) const override
Return the maximum transfer length, measured in address-generation granules (see getAddressGenGranula...
uint32_t getDmaBdWrapBits(AIETileType tileType) const override
Return the bit width of the wrap (size) field in a DMA buffer descriptor for the given tile type.
uint32_t getBDMaxDims(AIETileType tileType) const override
Return the maximum number of addressing dimensions (wraps/strides) a single buffer descriptor support...
uint32_t getNumArbiters() const override
Return the number of arbiters per stream switch.
bool isMemNorth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is North of dst.
uint32_t getMaxPacketId() const override
Return the largest packet id the stream switch can route.
uint32_t getLocalMemorySize() const override
Return the size (in bytes) of the local data memory of a core.
uint32_t getMemNorthBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a shimmux.
const DmaBdLayout & getDmaBdLimits(AIETileType tileType) const
uint32_t getColumnShift() const override
uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
uint32_t getDmaBdStepBits(AIETileType tileType) const override
Return the bit width of the step (stride) field in a DMA buffer descriptor for the given tile type.
uint32_t getMemEastBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMemInternalBaseAddress(TileID src) const override
Return the base address in the local address map for a core.
uint32_t getNumBanks(int col, int row) const override
Return the number of memory banks of a given tile.
static bool classof(const AIETargetModel *model)
AIE2TargetModel(TargetModelKind k)
uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma task queue register for the given col, row, channel and direction...
uint32_t getNumBDs(AIETileType tileType) const override
Return the number of buffer descriptors for a given tile type.
std::optional< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const override
uint32_t getComputeTileLoadStoreBusWidth() const override
Return the data bus width (in bits) for load/store operations of a compute core.
std::optional< TileID > getMemSouth(TileID src) const override
Return the tile ID of the memory to the south of the given tile, if it exists.
const DmaBdLayout * getDmaBdLayout(AIETileType tileType) const override
Return the register layout of a buffer descriptor on the given tile type, or null if the target has n...
uint32_t getMemTileSize() const override
Return the size (in bytes) of a MemTile.
uint32_t getProgramMemorySize() const override
Return the size (in bytes) of a core's program memory.
uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a switchbox.
bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is West of dst.
uint32_t getDmaTaskQueueSizeMask() const override
Return the mask selecting the live task-queue occupancy field within the getDmaStatusAddress() regist...
bool isMemSouth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is South of dst.
uint32_t getDmaTaskQueueDepth() const override
Return how many DMA tasks a single channel's task queue holds (unsupported = 0).
uint32_t getNumSlaveSlots() const override
Return the number of packet-rule slots per stream-switch slave port.
std::optional< TileID > getMemNorth(TileID src) const override
Return the tile ID of the memory to the north of the given tile, if it exists.
bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is East of dst.
uint32_t getNumSourceShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a shimmux.
uint32_t getDmaBdAddressOffset(int col, int row) const override
Return the offset of the base address field within the shim dma buffer descriptor.
virtual uint32_t getCoreDataAddressSpaceSize() const =0
Return the size (in bytes) of the address space a core can issue data accesses into.
std::optional< uint32_t > encodeFieldValue(const BitFieldInfo &field, uint32_t value) const
Encode a field value with proper bit shifting.
std::optional< uint32_t > resolvePortValue(llvm::StringRef value, TileID tile, bool master) const
Resolve stream switch port specification to port index.
llvm::DenseMap< TileID, int > getTileToControllerIdMap(bool columnWiseUniqueIDs=true) const
Return a mapping from tile coordinates to controller IDs.
virtual uint32_t getNumMselsPerArbiter() const =0
Return the number of master select values per stream-switch arbiter.
std::optional< uint32_t > getMemLocalBaseAddress(int localCol, int localRow, int memCol, int memRow) const
Return the memory base address (or offset) in the local tile when accessing a neighbor's memory or an...
bool isNorth(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is North of dst.
bool isSouth(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is South of dst.
uint32_t getDmaBdWrapBits(int col, int row) const
bool isWest(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is West of dst.
virtual llvm::ArrayRef< std::pair< int, int > > getCascadeSteps() const
The steps (destination column - source column, destination row - source row) from one core's cascade ...
uint32_t getLocalDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const
Return the DMA task-queue register address relative to its tile.
TargetModelKind getKind() const
virtual bool isSupportedBlockFormat(std::string const &format) const
bool isCoreTile(int col, int row) const
Return true if the given tile is a Core tile.
virtual uint64_t getDmaBdMaxLen(AIETileType tileType) const =0
Return the maximum transfer length, measured in address-generation granules (see getAddressGenGranula...
uint32_t getModelProperties() const
virtual const DmaBdLayout * getDmaBdLayout(AIETileType tileType) const
Return the register layout of a buffer descriptor on the given tile type, or null if the target has n...
virtual AIEArch getTargetArch() const =0
Return the target architecture.
virtual bool isMemNorth(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is North of dst.
virtual uint32_t getNumSourceShimMuxConnections(int col, int row, WireBundle bundle) const =0
Return the number of sources of connections inside a shimmux.
bool isMemTile(int col, int row) const
Return true if the given tile is a Mem tile.
virtual uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const =0
Return the array address of the dma task queue register for the given col, row, channel and direction...
virtual uint32_t getDmaBdWrapBits(AIETileType tileType) const =0
Return the bit width of the wrap (size) field in a DMA buffer descriptor for the given tile type.
std::pair< uint32_t, uint32_t > getBdIdRangeForChannel(int col, int row, int channel) const
Return the half-open range [first, last) of buffer descriptor ids that channel channel of the tile at...
virtual uint32_t getMemSouthBaseAddress() const =0
Return the base address in the local address map for a core.
std::optional< uint32_t > getLockLocalBaseIndex(int localCol, int localRow, int lockCol, int lockRow) const
Return the lock base index (or offset) in the local tile when accessing a neighbor's lock or an empty...
virtual uint32_t getDmaChannelIdleMask() const
Return the bits of the getDmaStatusAddress() register that are all clear exactly when the channel has...
void addModelProperty(uint32_t prop)
AIETargetModel(TargetModelKind k)
virtual uint32_t getLocalMemorySize() const =0
Return the size (in bytes) of the local data memory of a core.
std::optional< uint32_t > getFieldMask(const BitFieldInfo &field) const
Compute a 32-bit mask for a register field.
virtual uint32_t getNumLocks(AIETileType tileType) const =0
Return the number of lock objects for a given tile type.
uint32_t getDmaBdIterBits(int col, int row) const
virtual uint32_t getComputeTileLoadStoreBusWidth() const =0
Return the data bus width (in bits) for load/store operations of a compute core.
std::vector< int > partitionStartColumns(int numCols) const
Every physical column offset at which a numCols-wide partition still fits.
std::optional< uint32_t > lookupEvent(llvm::StringRef name, TileID tile, bool isMem=false) const
Lookup event number by name and tile.
virtual std::optional< TileID > getMemNorth(TileID src) const =0
Return the tile ID of the memory to the north of the given tile, if it exists.
virtual int physicalColumns() const
Width of the physical array this (possibly virtualized) device is carved from.
virtual uint32_t getDmaBdIterBits(AIETileType tileType) const =0
Return the bit width of the iteration (repeat) wrap/stride fields in a DMA buffer descriptor for the ...
const RegisterInfo * lookupRegister(llvm::StringRef name, TileID tile, bool isMem=false) const
Register Database API - provides access to register and event information for trace configuration and...
virtual uint32_t getBDMaxDims(AIETileType tileType) const =0
Return the maximum number of addressing dimensions (wraps/strides) a single buffer descriptor support...
virtual std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const =0
const RegisterDatabase * getRegisterDatabase() const
Get the register database, loading it lazily on first access.
virtual bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const =0
virtual uint32_t getNumBanks(int col, int row) const =0
Return the number of memory banks of a given tile.
uint64_t getDmaBdMaxLen(int col, int row) const
virtual bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is East of dst.
virtual uint32_t getDmaTaskQueueDepth() const =0
Return how many DMA tasks a single channel's task queue holds (unsupported = 0).
virtual uint32_t getDmaBdStepBits(AIETileType tileType) const =0
Return the bit width of the step (stride) field in a DMA buffer descriptor for the given tile type.
bool isShimPLTile(int col, int row) const
Return true if the given tile is a ShimPL tile.
uint32_t getDmaTaskQueueDepth(int, int, int, AIE::DMAChannelDir) const
Return the task-queue depth for one channel.
virtual uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel=-1, AIE::DMAChannelDir direction=AIE::DMAChannelDir::MM2S) const =0
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
int getPacketIdMask() const
virtual ~AIETargetModel()
virtual bool isBdChannelAccessible(int col, int row, uint32_t bd_id, int channel) const =0
Return true iff buffer descriptor bd_id on tile (col, row) can be submitted on channel channel.
virtual uint32_t getDmaBdAddressOffset(int col, int row) const =0
Return the offset of the base address field within the shim dma buffer descriptor.
virtual uint32_t getAccumulatorCascadeSize() const =0
Return the size (in bits) of the accumulator/cascade.
virtual std::optional< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const =0
virtual uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const =0
virtual AIETileType getTileType(int col, int row) const =0
Return the tile type for the given tile coordinates.
uint32_t getCoreStackAlignment() const
Stack-pointer alignment in bytes, matching Peano's AIE frame lowering: AIE1/AIE2 require 32B; AIE2P/A...
virtual uint32_t getNumArbiters() const =0
Return the number of arbiters per stream switch.
virtual bool isValidTile(TileID src) const
Return true if the given tile ID is valid.
bool isEast(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is East of dst.
virtual uint32_t getDmaTaskQueueSizeMask() const
Return the mask selecting the live task-queue occupancy field within the getDmaStatusAddress() regist...
virtual bool isMemSouth(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is South of dst.
bool isShimNOCorPLTile(int col, int row) const
Return true if the given tile is either a ShimNOC or ShimPL tile.
virtual uint32_t getMaxRepeatCount() const =0
Return the largest DMA task repeat count (unsupported = 0).
virtual uint32_t getMemWestBaseAddress() const =0
Return the base address in the local address map for a core.
virtual uint32_t getNumControllersPerColumn() const
Number of microcontrollers (uC) per column.
virtual int rows() const =0
Return the number of rows in the device.
uint32_t getBDMaxDims(int col, int row) const
Return the maximum number of BD addressing dimensions for the tile at (col, row).
virtual std::optional< TileID > getMemSouth(TileID src) const =0
Return the tile ID of the memory to the south of the given tile, if it exists.
virtual std::optional< TileID > getMemEast(TileID src) const =0
Return the tile ID of the memory to the east of the given tile, if it exists.
bool isShimNOCTile(int col, int row) const
Return true if the given tile is a ShimNOC tile.
virtual uint32_t getNumBDs(AIETileType tileType) const =0
Return the number of buffer descriptors for a given tile type.
virtual uint32_t getMaxPacketId() const =0
Return the largest packet id the stream switch can route.
@ UsesMultiDimensionalBDs
virtual uint32_t getMaxLockValue() const =0
Return the maximum value that can be stored in a lock register.
virtual std::unique_ptr< RegisterDatabase > loadRegisterDatabase() const
Subclasses override to provide architecture-specific database loading.
virtual uint32_t getComputeTileMaxVectorAlignBits() const
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
virtual uint32_t getProgramMemorySize() const =0
Return the size (in bytes) of a core's program memory.
virtual uint32_t getMaxOutOfOrderId() const =0
Return the largest out-of-order BD id (unsupported = 0).
virtual std::optional< TileID > getMemWest(TileID src) const =0
Return the tile ID of the memory to the west of the given tile, if it exists.
virtual uint32_t getColumnShift() const =0
virtual uint32_t getMemNorthBaseAddress() const =0
Return the base address in the local address map for a core.
uint32_t getNumLocks(int col, int row) const
Return the number of lock objects for a tile at the given coordinates.
bool hasProperty(ModelProperty Prop) const
uint32_t getDmaQueueAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const
Return the array address of the task queue register a push writes, the word after the channel's contr...
uint32_t getNumDMAChannels(int col, int row, AIE::DMAChannelDir dir) const
Return the number of DMA channels a tile has in one direction.
virtual int columns() const =0
Return the number of columns in the device.
int getPacketIdBits() const
Bits a packet id spans, and the mask a switch's id match uses.
uint32_t getNumBDsForChannel(int col, int row, int channel) const
Return the number of buffer descriptors accessible on channel channel for the tile at (col,...
virtual bool isMemTilePadValueSupported() const
bool isLegalCascade(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if a cascade can run from src to dst.
virtual uint32_t getDefaultCoreStackSize() const
Return the default stack reservation (in bytes) for a core that does not state one.
virtual uint32_t getMemEastBaseAddress() const =0
Return the base address in the local address map for a core.
const DmaBdLayout * getDmaBdLayout(int col, int row) const
virtual uint32_t getNumControllers() const
Total number of microcontrollers (uC) in the device.
virtual uint32_t getMemTileLoadStoreBusWidth() const
Return the data bus width (in bits) for load/store operations of a memory tile.
uint32_t getDmaBdStepBits(int col, int row) const
virtual uint32_t getNumMemTileRows() const =0
virtual uint32_t getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const =0
Return the number of destinations of connections inside a shimmux.
virtual bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is West of dst.
virtual uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const =0
Return the number of destinations of connections inside a switchbox.
virtual uint32_t getMemInternalBaseAddress(TileID src) const =0
Return the base address in the local address map for a core.
virtual uint32_t getDefaultAxCache() const
SharedMemory
Which of two tiles' memory modules both of them can address.
@ None
Neither tile can address the other's memory module.
@ First
Only the first tile's module.
@ Second
Only the second tile's module.
virtual std::optional< uint32_t > getDmaStatusAddress(int, int, int, AIE::DMAChannelDir) const
Return the address of the DMA status register for a channel, or nullopt when this target's layout has...
bool isInternal(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is the internal memory of dst.
virtual uint32_t getRowShift() const =0
virtual uint32_t getNumSlaveSlots() const =0
Return the number of packet-rule slots per stream-switch slave port.
SharedMemory getSharedMemory(TileID a, TileID b) const
Return the memory module a and b can both reach, if any.
virtual int firstPlaceableColumn() const
First physical column at which a partition may be anchored.
virtual bool isLegalMemAffinity(int coreCol, int coreRow, int memCol, int memRow) const =0
Return true if core can access the memory in mem.
uint32_t getNumBDs(int col, int row) const
Return the number of buffer descriptors supported by the DMA in the given tile.
virtual uint32_t getAddressGenGranularity() const =0
Return the data bus width of the device.
virtual uint32_t getMemTileSize() const =0
Return the size (in bytes) of a MemTile.
virtual std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t channel, bool master) const =0
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
virtual uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const =0
Return the number of sources of connections inside a switchbox.
uint32_t getNumMemTileRows() const override
static bool classof(const AIETargetModel *model)
BaseNPU1TargetModel(TargetModelKind k)
int physicalColumns() const override
Width of the physical array this (possibly virtualized) device is carved from.
uint32_t getNumControllers() const override
Total number of microcontrollers (uC) in the device.
int rows() const override
Return the number of rows in the device.
uint32_t getNumControllers() const override
Total number of microcontrollers (uC) in the device.
static bool classof(const AIETargetModel *model)
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
BaseNPU2TargetModel(TargetModelKind k)
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getNumMemTileRows() const override
AIEArch getTargetArch() const override
Return the target architecture.
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
bool isSupportedBlockFormat(std::string const &format) const override
int rows() const override
Return the number of rows in the device.
int physicalColumns() const override
Width of the physical array this (possibly virtualized) device is carved from.
bool isMemTilePadValueSupported() const override
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
Register and event database for a specific architecture.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getAddressGenGranularity() const override
Return the data bus width of the device.
int rows() const override
Return the number of rows in the device.
int columns() const override
Return the number of columns in the device.
int rows() const override
Return the number of rows in the device.
uint32_t getNumMemTileRows() const override
static bool classof(const AIETargetModel *model)
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
static bool classof(const AIETargetModel *model)
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getNumMemTileRows() const override
int columns() const override
Return the number of columns in the device.
int rows() const override
Return the number of rows in the device.
static bool classof(const AIETargetModel *model)
int rows() const override
Return the number of rows in the device.
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getNumMemTileRows() const override
int columns() const override
Return the number of columns in the device.
VirtualizedNPU1TargetModel(int _cols)
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
static bool classof(const AIETargetModel *model)
VirtualizedNPU2TargetModel(int _cols)
int columns() const override
Return the number of columns in the device.
uint8_t txnDeviceGen(const AIETargetModel &tm)
Device generation ID written into the TXN header (aie_runtime::TxnDeviceInfo::devGen).
struct TileID { friend std::ostream &operator<<(std::ostream &os, const TileID &s) { os<< "TileID("<< s.col<< ", "<< s.row<< ")"; return os; } friend std::string to_string(const TileID &s) { std::ostringstream ss; ss<< s; return ss.str(); } friend llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const TileID &s) { os<< to_string(s); return os; } inline bool operator<(const TileID &rhs) const { return std::tie(col, row)< std::tie(rhs.col, rhs.row); } bool operator==(const TileID &rhs) const { return std::tie(col, row)==std::tie(rhs.col, rhs.row); } bool operator!=(const TileID &rhs) const { return !(*this==rhs);} int col, row;} TileID
llvm::raw_ostream & operator<<(llvm::raw_ostream &os, const SwitchSettings &ss)
DenseMapInfo< int > SecondInfo
static unsigned getHashValue(const xilinx::AIE::TileID &t)
static bool isEqual(const xilinx::AIE::TileID &lhs, const xilinx::AIE::TileID &rhs)
DenseMapInfo< int > FirstInfo
std::size_t operator()(const xilinx::AIE::TileID &s) const noexcept
Bit field information for a register.
Bits [shift, shift + width) of register word in a buffer descriptor's register block.
uint32_t place(uint64_t value) const
The register layout of one tile type's DMA buffer descriptor.
DmaBdField iterationCurrent
DmaBdField iterationStride
llvm::SmallVector< std::pair< DmaBdField, DmaBdField >, 3 > padFields() const
The (before, after) zero-padding fields, innermost dimension first.