11#ifndef MLIR_AIE_DEVICEMODEL_H
12#define MLIR_AIE_DEVICEMODEL_H
16#include "llvm/ADT/DenseSet.h"
26 os <<
"TileID(" << s.col <<
", " << s.row <<
")";
31 std::ostringstream ss;
43 return std::tie(
col,
row) < std::tie(rhs.col, rhs.row);
47 return std::tie(
col,
row) == std::tie(rhs.col, rhs.row);
98 uint32_t ModelProperties = 0;
161 bool isInternal(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
162 return srcCol == dstCol && srcRow == dstRow;
161 bool isInternal(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
…}
166 bool isWest(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
167 return srcCol == dstCol + 1 && srcRow == dstRow;
166 bool isWest(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
…}
171 bool isEast(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
172 return srcCol == dstCol - 1 && srcRow == dstRow;
171 bool isEast(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
…}
176 bool isNorth(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
177 return srcCol == dstCol && srcRow == dstRow - 1;
176 bool isNorth(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
…}
181 bool isSouth(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
182 return srcCol == dstCol && srcRow == dstRow + 1;
181 bool isSouth(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const {
…}
186 virtual bool isMemWest(
int srcCol,
int srcRow,
int dstCol,
187 int dstRow)
const = 0;
189 virtual bool isMemEast(
int srcCol,
int srcRow,
int dstCol,
190 int dstRow)
const = 0;
193 int dstRow)
const = 0;
196 int dstRow)
const = 0;
200 int memRow)
const = 0;
217 int lockCol,
int lockRow)
const;
224 int memCol,
int memRow)
const;
260 WireBundle bundle)
const = 0;
265 WireBundle bundle)
const = 0;
269 WireBundle bundle)
const = 0;
273 WireBundle bundle)
const = 0;
277 int srcChan, WireBundle dstBundle,
278 int dstChan)
const = 0;
302 virtual std::vector<std::pair<uint32_t, uint32_t>>
320 bool isMemWest(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const override;
321 bool isMemEast(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const override;
322 bool isMemNorth(
int srcCol,
int srcRow,
int dstCol,
323 int dstRow)
const override;
324 bool isMemSouth(
int srcCol,
int srcRow,
int dstCol,
325 int dstRow)
const override;
328 int memRow)
const override;
331 if (
src.row % 2 == 0)
347 TileID tile)
const override;
358 WireBundle bundle)
const override;
360 WireBundle bundle)
const override;
362 WireBundle bundle)
const override;
364 WireBundle bundle)
const override;
366 int srcChan, WireBundle dstBundle,
367 int dstChan)
const override;
377 std::vector<std::pair<uint32_t, uint32_t>>
398 bool isMemWest(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const override;
399 bool isMemEast(
int srcCol,
int srcRow,
int dstCol,
int dstRow)
const override;
400 bool isMemNorth(
int srcCol,
int srcRow,
int dstCol,
401 int dstRow)
const override;
402 bool isMemSouth(
int srcCol,
int srcRow,
int dstCol,
403 int dstRow)
const override;
406 int memRow)
const override;
426 TileID tile)
const override;
452 WireBundle bundle)
const override;
454 WireBundle bundle)
const override;
456 WireBundle bundle)
const override;
458 WireBundle bundle)
const override;
460 int srcChan, WireBundle dstBundle,
461 int dstChan)
const override;
471 std::vector<std::pair<uint32_t, uint32_t>>
476 llvm::SmallDenseSet<unsigned, 16> nocColumns = {
477 2, 3, 6, 7, 10, 11, 18, 19, 26, 27, 34, 35, 42, 43, 46, 47};
486 int rows()
const override {
return 9; }
489 return row == 0 && nocColumns.contains(
col);
493 return row == 0 && !nocColumns.contains(
col);
506 llvm::SmallDenseSet<unsigned, 8> nocColumns = {2, 3, 6, 7, 10, 11};
521 return row == 0 && nocColumns.contains(
col);
525 return row == 0 && !nocColumns.contains(
col);
540 llvm::SmallDenseSet<unsigned, 16> nocColumns = {2, 3, 6, 7, 14, 15,
541 22, 23, 30, 31, 34, 35};
555 return row == 1 ||
row == 2;
559 return row == 0 && nocColumns.contains(
col);
563 return row == 0 && !nocColumns.contains(
col);
615 return row == 0 &&
col > 0;
620 return row == 0 &&
col == 0;
671 std::vector<std::pair<uint32_t, uint32_t>>
705struct DenseMapInfo<
xilinx::AIE::TileID> {
710 return {FirstInfo::getEmptyKey(), SecondInfo::getEmptyKey()};
714 return {FirstInfo::getTombstoneKey(), SecondInfo::getTombstoneKey()};
718 return detail::combineHashValue(FirstInfo::getHashValue(t.col),
719 SecondInfo::getHashValue(t.row));
732 std::size_t h1 = std::hash<int>{}(s.col);
733 std::size_t h2 = std::hash<int>{}(s.row);
734 return h1 ^ (h2 << 1);
uint32_t getLocalMemorySize() const override
Return the size (in bytes) of the local data memory of a core.
uint32_t getNumMemTileRows() const override
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.
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
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.
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.
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 getRowShift() const override
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.
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(int col, int row) const override
Return the number of lock objects.
uint32_t getAccumulatorCascadeSize() const override
Return the size (in bits) of the accumulator/cascade.
AIE1TargetModel(TargetModelKind k)
bool isCoreTile(int col, int row) const override
Return true if the given tile is a 'Core' tile.
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.
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.
bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const override
bool isMemTile(int col, int row) const override
Return true if the given tile is an AIE2 'Memory' tile.
uint32_t getNumBDs(int col, int row) const override
Return the number of buffer descriptors supported by the DMA in the given tile.
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 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
uint32_t getNumLocks(int col, int row) const override
Return the number of lock objects.
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 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.
uint32_t getAccumulatorCascadeSize() const override
Return the size (in bits) of the accumulator/cascade.
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.
AIEArch getTargetArch() const override
AIE2 TargetModel.
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 getMaxLockValue() const override
Return the maximum value that can be stored in a lock register.
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 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.
uint32_t getColumnShift() const override
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)
std::optional< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const override
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.
uint32_t getMemTileSize() const override
Return the size (in bytes) of a MemTile.
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.
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 getNumBDs(int col, int row) const override
Return the number of buffer descriptors supported by the DMA in the given tile.
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.
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.
bool isWest(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is West of dst.
TargetModelKind getKind() const
uint32_t getModelProperties() const
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.
virtual uint32_t getNumBDs(int col, int row) const =0
Return the number of buffer descriptors supported by the DMA in the given tile.
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...
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.
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 bool isCoreTile(int col, int row) const =0
Return true if the given tile is a 'Core' tile.
virtual std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const =0
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.
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 ~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 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 bool isMemTile(int col, int row) const =0
Return true if the given tile is an AIE2 'Memory' tile.
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 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.
virtual uint32_t getMemWestBaseAddress() const =0
Return the base address in the local address map for a core.
virtual uint32_t getNumLocks(int col, int row) const =0
Return the number of lock objects.
virtual int rows() const =0
Return the number of rows in the device.
virtual bool isShimNOCTile(int col, int row) const =0
Return true if the given tile is a Shim NOC tile.
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 bool isShimNOCorPLTile(int col, int row) const =0
Return true if the given tile is either a Shim NOC or a Shim PL interface tile.
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.
@ UsesMultiDimensionalBDs
virtual uint32_t getMaxLockValue() const =0
Return the maximum value that can be stored in a lock register.
virtual bool isShimPLTile(int col, int row) const =0
Return true if the given tile is a Shim PL interface tile.
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.
bool hasProperty(ModelProperty Prop) const
virtual int columns() const =0
Return the number of columns in the device.
virtual uint32_t getMemEastBaseAddress() const =0
Return the base address in the local address map for a core.
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.
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 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol, int memRow) const =0
Return true if core can access the memory in mem.
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 uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const =0
Return the number of sources of connections inside a switchbox.
int rows() const override
Return the number of rows in the device.
static bool classof(const AIETargetModel *model)
bool isShimNOCorPLTile(int col, int row) const override
Return true if the given tile is either a Shim NOC or a Shim PL interface tile.
bool isMemTile(int col, int row) const override
Return true if the given tile is an AIE2 'Memory' tile.
bool isShimPLTile(int col, int row) const override
Return true if the given tile is a Shim PL interface tile.
BaseNPUTargetModel(TargetModelKind k)
uint32_t getNumMemTileRows() const override
bool isCoreTile(int col, int row) const override
Return true if the given tile is a 'Core' tile.
bool isShimPLTile(int col, int row) const override
Return true if the given tile is a Shim PL interface tile.
AIEArch getTargetArch() const override
AIE2 TargetModel.
static bool classof(const AIETargetModel *model)
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
bool isShimNOCTile(int col, int row) const override
Return true if the given tile is a Shim NOC tile.
int columns() const override
Return the number of columns in the device.
static bool classof(const AIETargetModel *model)
bool isShimNOCTile(int col, int row) const override
Return true if the given tile is a Shim NOC tile.
int columns() const override
Return the number of columns in the device.
bool isShimPLTile(int col, int row) const override
Return true if the given tile is a Shim PL interface tile.
bool isShimNOCorPLTile(int col, int row) const override
Return true if the given tile is either a Shim NOC or a Shim PL interface tile.
bool isShimNOCTile(int col, int row) const override
Return true if the given tile is a Shim NOC tile.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
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.
bool isShimPLTile(int col, int row) const override
Return true if the given tile is a Shim PL interface tile.
bool isCoreTile(int col, int row) const override
Return true if the given tile is a 'Core' tile.
int columns() const override
Return the number of columns in the device.
int rows() const override
Return the number of rows in the device.
bool isShimPLTile(int col, int row) const override
Return true if the given tile is a Shim PL interface tile.
uint32_t getNumMemTileRows() const override
bool isShimNOCTile(int col, int row) const override
Return true if the given tile is a Shim NOC tile.
static bool classof(const AIETargetModel *model)
bool isMemTile(int col, int row) const override
Return true if the given tile is an AIE2 'Memory' tile.
bool isShimNOCorPLTile(int col, int row) const override
Return true if the given tile is either a Shim NOC or a Shim PL interface tile.
bool isMemTile(int col, int row) const override
Return true if the given tile is an AIE2 'Memory' tile.
static bool classof(const AIETargetModel *model)
bool isShimPLTile(int col, int row) const override
Return true if the given tile is a Shim PL interface tile.
uint32_t getNumMemTileRows() const override
bool isCoreTile(int col, int row) const override
Return true if the given tile is a 'Core' tile.
bool isShimNOCTile(int col, int row) const override
Return true if the given tile is a Shim NOC tile.
int columns() const override
Return the number of columns in the device.
bool isShimNOCorPLTile(int col, int row) const override
Return true if the given tile is either a Shim NOC or a Shim PL interface tile.
int rows() const override
Return the number of rows in the device.
static bool classof(const AIETargetModel *model)
uint32_t getAddressGenGranularity() const override
Return the data bus width of the device.
VirtualizedNPU2TargetModel(int _cols)
bool isShimNOCTile(int col, int row) const override
Return true if the given tile is a Shim NOC tile.
int columns() const override
Return the number of columns in the device.
uint32_t getAddressGenGranularity() const override
Return the data bus width of the device.
int columns() const override
Return the number of columns in the device.
bool isShimNOCTile(int col, int row) const override
Return true if the given tile is a Shim NOC tile.
VirtualizedNPUTargetModel(int _cols)
static bool classof(const AIETargetModel *model)
Include the generated interface declarations.
friend std::ostream & operator<<(std::ostream &os, const Port &port)
TileID { friend std::ostream &operator<<(std::ostream &os, const TileID &s) { os<< "TileID("<< s.col<< ", "<< s.row<< ")" TileID
friend std::string to_string(const TileID &s)
bool operator!=(const Port &rhs) const
bool operator==(const Port &rhs) const
bool operator<(const Port &rhs) const
static xilinx::AIE::TileID getTombstoneKey()
DenseMapInfo< int > SecondInfo
static xilinx::AIE::TileID getEmptyKey()
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