MLIR-AIE
AIETargetModel.h
Go to the documentation of this file.
1//===- AIETargetModel.h -----------------------------------------*- C++ -*-===//
2//
3// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7// (c) Copyright 2023 Advanced Micro Devices, Inc.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef MLIR_AIE_DEVICEMODEL_H
12#define MLIR_AIE_DEVICEMODEL_H
13
15
16#include "llvm/ADT/DenseSet.h"
17
18#include <iostream>
19
20namespace xilinx::AIE {
21
22using TileID = struct TileID {
23 // friend definition (will define the function as a non-member function in the
24 // namespace surrounding the class).
25 friend std::ostream &operator<<(std::ostream &os, const TileID &s) {
26 os << "TileID(" << s.col << ", " << s.row << ")";
27 return os;
28 }
29
30 friend std::string to_string(const TileID &s) {
31 std::ostringstream ss;
32 ss << s;
33 return ss.str();
34 }
35
36 friend llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const TileID &s) {
37 os << to_string(s);
38 return os;
39 }
40
41 // Imposes a lexical order on TileIDs.
42 inline bool operator<(const TileID &rhs) const {
43 return std::tie(col, row) < std::tie(rhs.col, rhs.row);
44 }
45
46 bool operator==(const TileID &rhs) const {
47 return std::tie(col, row) == std::tie(rhs.col, rhs.row);
48 }
49
50 bool operator!=(const TileID &rhs) const { return !(*this == rhs); }
51
52 int col, row;
53};
54
56
57public:
80
81 // One-hot encoded list of target model properties.
83 // Device uses semaphore locks.
85 // Device is an NPU-based device.
86 // There are several special cases for handling the NPU at the moment.
87 IsNPU = 1U << 1,
88 // Device model is virtualized.
89 // This is used during CDO code generation to configure aie-rt properly.
90 IsVirtualized = 1U << 2,
91 // Device uses multi-dimensional buffer descriptors.
93 };
94
95private:
96 const TargetModelKind kind;
97
98 uint32_t ModelProperties = 0;
99
100public:
101 TargetModelKind getKind() const { return kind; }
102
104
106
107 /// Return the target architecture.
108 virtual AIEArch getTargetArch() const = 0;
109
110 /// Return the data bus width of the device.
111 virtual uint32_t getAddressGenGranularity() const = 0;
112
113 /// Return the number of columns in the device.
114 virtual int columns() const = 0;
115
116 /// Return the number of rows in the device.
117 virtual int rows() const = 0;
118
119 /// Return true if the given tile is a 'Core' tile. These tiles
120 /// include a Core, TileDMA, tile memory, and stream connections.
121 virtual bool isCoreTile(int col, int row) const = 0;
122
123 /// Return true if the given tile is an AIE2 'Memory' tile. These tiles
124 /// include a TileDMA, tile memory, and stream connections, but no core.
125 virtual bool isMemTile(int col, int row) const = 0;
126
127 /// Return true if the given tile is a Shim NOC tile. These tiles include a
128 /// ShimDMA and a connection to the memory-mapped NOC. They do not contain
129 /// any memory.
130 virtual bool isShimNOCTile(int col, int row) const = 0;
131
132 /// Return true if the given tile is a Shim PL interface tile. These
133 /// tiles do not include a ShimDMA and instead include connections to the PL.
134 /// They do not contain any memory.
135 virtual bool isShimPLTile(int col, int row) const = 0;
136
137 /// Return true if the given tile is either a Shim NOC or a Shim PL interface
138 /// tile.
139 virtual bool isShimNOCorPLTile(int col, int row) const = 0;
140
141 /// Return true if the given tile ID is valid.
142 virtual bool isValidTile(TileID src) const {
143 return src.col >= 0 && src.col < columns() && src.row >= 0 &&
144 src.row < rows();
145 }
146
147 /// Return the tile ID of the memory to the west of the given tile, if it
148 /// exists.
149 virtual std::optional<TileID> getMemWest(TileID src) const = 0;
150 /// Return the tile ID of the memory to the east of the given tile, if it
151 /// exists.
152 virtual std::optional<TileID> getMemEast(TileID src) const = 0;
153 /// Return the tile ID of the memory to the north of the given tile, if it
154 /// exists.
155 virtual std::optional<TileID> getMemNorth(TileID src) const = 0;
156 /// Return the tile ID of the memory to the south of the given tile, if it
157 /// exists.
158 virtual std::optional<TileID> getMemSouth(TileID src) const = 0;
159
160 /// Return true if src is the internal memory of dst
161 bool isInternal(int srcCol, int srcRow, int dstCol, int dstRow) const {
162 return srcCol == dstCol && srcRow == dstRow;
163 }
164
165 /// Return true if src is West of dst
166 bool isWest(int srcCol, int srcRow, int dstCol, int dstRow) const {
167 return srcCol == dstCol + 1 && srcRow == dstRow;
168 }
169
170 /// Return true if src is East of dst
171 bool isEast(int srcCol, int srcRow, int dstCol, int dstRow) const {
172 return srcCol == dstCol - 1 && srcRow == dstRow;
173 }
174
175 /// Return true if src is North of dst
176 bool isNorth(int srcCol, int srcRow, int dstCol, int dstRow) const {
177 return srcCol == dstCol && srcRow == dstRow - 1;
178 }
179
180 /// Return true if src is South of dst
181 bool isSouth(int srcCol, int srcRow, int dstCol, int dstRow) const {
182 return srcCol == dstCol && srcRow == dstRow + 1;
183 }
184
185 /// Return true if src has a memory tile which is West of dst
186 virtual bool isMemWest(int srcCol, int srcRow, int dstCol,
187 int dstRow) const = 0;
188 /// Return true if src has a memory tile which is East of dst
189 virtual bool isMemEast(int srcCol, int srcRow, int dstCol,
190 int dstRow) const = 0;
191 /// Return true if src has a memory tile which is North of dst
192 virtual bool isMemNorth(int srcCol, int srcRow, int dstCol,
193 int dstRow) const = 0;
194 /// Return true if src has a memory tile which is South of dst
195 virtual bool isMemSouth(int srcCol, int srcRow, int dstCol,
196 int dstRow) const = 0;
197
198 /// Return true if core can access the memory in mem
199 virtual bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
200 int memRow) const = 0;
201
202 /// Return the base address in the local address map for a core.
203 virtual uint32_t getMemInternalBaseAddress(TileID src) const = 0;
204 /// Return the base address in the local address map for a core.
205 virtual uint32_t getMemSouthBaseAddress() const = 0;
206 /// Return the base address in the local address map for a core.
207 virtual uint32_t getMemWestBaseAddress() const = 0;
208 /// Return the base address in the local address map for a core.
209 virtual uint32_t getMemNorthBaseAddress() const = 0;
210 /// Return the base address in the local address map for a core.
211 virtual uint32_t getMemEastBaseAddress() const = 0;
212
213 /// Return the lock base index (or offset) in the local tile when accessing a
214 /// neighbor's lock or an empty optional if an invalid neighbor is given
215 /// Takes into account differences between Memory and Core tiles
216 std::optional<uint32_t> getLockLocalBaseIndex(int localCol, int localRow,
217 int lockCol, int lockRow) const;
218
219 /// Return the memory base address (or offset) in the local tile when
220 /// accessing a neighbor's memory or an empty optional if an invalid neighbor
221 /// is given
222 /// Takes into account differences between Memory and Core tiles
223 std::optional<uint32_t> getMemLocalBaseAddress(int localCol, int localRow,
224 int memCol, int memRow) const;
225
226 /// Return the size (in bytes) of the local data memory of a core.
227 virtual uint32_t getLocalMemorySize() const = 0;
228
229 /// Return the size (in bits) of the accumulator/cascade.
230 virtual uint32_t getAccumulatorCascadeSize() const = 0;
231
232 /// Return the number of lock objects
233 virtual uint32_t getNumLocks(int col, int row) const = 0;
234
235 /// Return the maximum value that can be stored in a lock register
236 virtual uint32_t getMaxLockValue() const = 0;
237
238 // Return the lock address for the lock ID in the local memory for a given
239 // tile or a nullopt if invalid arguments are given.
240 virtual std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
241 TileID tile) const = 0;
242
243 /// Return the number of buffer descriptors supported by the DMA in the given
244 /// tile.
245 virtual uint32_t getNumBDs(int col, int row) const = 0;
246
247 /// Return true iff buffer descriptor `bd_id` on tile (`col`, `row`) can be
248 /// submitted on channel `channel`.
249 virtual bool isBdChannelAccessible(int col, int row, uint32_t bd_id,
250 int channel) const = 0;
251
252 /// Return the array address of the dma buffer descriptor for the given
253 /// col, row, buffer descriptor id, channel and direction. Not all
254 /// architecture variants will use channel and direction so these have default
255 /// values.
256 virtual uint64_t getDmaBdAddress(
257 int col, int row, uint32_t bd_id, int channel = -1,
258 AIE::DMAChannelDir direction = AIE::DMAChannelDir::MM2S) const = 0;
259
260 /// Return the offset of the base address field within the shim dma buffer
261 /// descriptor.
262 virtual uint32_t getDmaBdAddressOffset(int col, int row) const = 0;
263
264 /// Return the array address of the dma task queue register for the given
265 /// col, row, channel and direction
266 virtual uint32_t getDmaControlAddress(int col, int row, int channel,
267 AIE::DMAChannelDir direction) const = 0;
268
269 virtual uint32_t getNumMemTileRows() const = 0;
270 /// Return the size (in bytes) of a MemTile.
271 virtual uint32_t getMemTileSize() const = 0;
272 /// Return the number of memory banks of a given tile.
273 virtual uint32_t getNumBanks(int col, int row) const = 0;
274
276 int row) const = 0;
277
278 /// Return the number of destinations of connections inside a switchbox. These
279 /// are the targets of connect operations in the switchbox.
280 virtual uint32_t getNumDestSwitchboxConnections(int col, int row,
281 WireBundle bundle) const = 0;
282 /// Return the number of sources of connections inside a switchbox. These are
283 /// the origins of connect operations in the switchbox.
284 virtual uint32_t
286 WireBundle bundle) const = 0;
287 /// Return the number of destinations of connections inside a shimmux. These
288 /// are the targets of connect operations in the switchbox.
289 virtual uint32_t getNumDestShimMuxConnections(int col, int row,
290 WireBundle bundle) const = 0;
291 /// Return the number of sources of connections inside a shimmux. These are
292 /// the origins of connect operations in the switchbox.
293 virtual uint32_t getNumSourceShimMuxConnections(int col, int row,
294 WireBundle bundle) const = 0;
295
296 // Return true if the stream switch connection is legal, false otherwise.
297 virtual bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
298 int srcChan, WireBundle dstBundle,
299 int dstChan) const = 0;
300
301 // Run consistency checks on the target model.
302 void validate() const;
303
304 uint32_t getModelProperties() const { return ModelProperties; }
305 void addModelProperty(uint32_t prop) { ModelProperties |= prop; }
306 // Return true if this device has a given property.
307 bool hasProperty(ModelProperty Prop) const {
308 return (getModelProperties() & Prop) == Prop;
309 }
310
311 // Return the bit offset of the column within a tile address.
312 // This is used to compute the control address of a tile from it's column
313 // location.
314 virtual uint32_t getColumnShift() const = 0;
315
316 // Return the bit offset of the row within a tile address.
317 // This is used to compute the control address of a tile from it's row
318 // location.
319 virtual uint32_t getRowShift() const = 0;
320
321 // Returns the list of possible burst encodings (first) and
322 // their corresponding lengths in bytes (second).
323 virtual std::vector<std::pair<uint32_t, uint32_t>>
325
326 // Returns true if the target model supports the given block format.
327 virtual bool isSupportedBlockFormat(std::string const &format) const;
328};
329
331public:
333
334 bool isCoreTile(int col, int row) const override { return row > 0; }
335 bool isMemTile(int col, int row) const override { return false; }
336
337 AIEArch getTargetArch() const override;
338
339 std::optional<TileID> getMemWest(TileID src) const override;
340 std::optional<TileID> getMemEast(TileID src) const override;
341 std::optional<TileID> getMemNorth(TileID src) const override;
342 std::optional<TileID> getMemSouth(TileID src) const override;
343
344 bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override;
345 bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override;
346 bool isMemNorth(int srcCol, int srcRow, int dstCol,
347 int dstRow) const override;
348 bool isMemSouth(int srcCol, int srcRow, int dstCol,
349 int dstRow) const override;
350
351 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
352 int memRow) const override;
353
354 uint32_t getMemInternalBaseAddress(TileID src) const override {
355 if (src.row % 2 == 0)
356 // Internal is West
357 return getMemWestBaseAddress();
358 // Internal is East
359 return getMemEastBaseAddress();
360 }
361
362 uint32_t getMemSouthBaseAddress() const override { return 0x00020000; }
363 uint32_t getMemWestBaseAddress() const override { return 0x00028000; }
364 uint32_t getMemNorthBaseAddress() const override { return 0x00030000; }
365 uint32_t getMemEastBaseAddress() const override { return 0x00038000; }
366 uint32_t getLocalMemorySize() const override { return 0x00008000; }
367 uint32_t getAccumulatorCascadeSize() const override { return 384; }
368 uint32_t getNumLocks(int col, int row) const override { return 16; }
369 uint32_t getMaxLockValue() const override { return 1; }
370 std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
371 TileID tile) const override;
372 uint32_t getNumBDs(int col, int row) const override { return 16; }
373 bool isBdChannelAccessible(int col, int row, uint32_t bd_id,
374 int channel) const override {
375 return true;
376 }
377
378 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
379 AIE::DMAChannelDir direction) const override;
380
381 uint32_t getDmaBdAddressOffset(int col, int row) const override;
382
383 uint32_t getDmaControlAddress(int col, int row, int channel,
384 AIE::DMAChannelDir direction) const override;
385
386 uint32_t getNumMemTileRows() const override { return 0; }
387 uint32_t getMemTileSize() const override { return 0; }
388 uint32_t getNumBanks(int col, int row) const override { return 4; }
389
390 uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override {
391 return 0;
392 }
393
394 uint32_t getNumDestSwitchboxConnections(int col, int row,
395 WireBundle bundle) const override;
396 uint32_t getNumSourceSwitchboxConnections(int col, int row,
397 WireBundle bundle) const override;
398 uint32_t getNumDestShimMuxConnections(int col, int row,
399 WireBundle bundle) const override;
400 uint32_t getNumSourceShimMuxConnections(int col, int row,
401 WireBundle bundle) const override;
402 bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
403 int srcChan, WireBundle dstBundle,
404 int dstChan) const override;
405
406 uint32_t getColumnShift() const override { return 23; }
407 uint32_t getRowShift() const override { return 18; }
408
409 static bool classof(const AIETargetModel *model) {
410 return model->getKind() >= TK_AIE1_VC1902 &&
411 model->getKind() < TK_AIE1_Last;
412 }
413
414 std::vector<std::pair<uint32_t, uint32_t>>
415 getShimBurstEncodingsAndLengths() const override;
416};
417
419public:
425
426 AIEArch getTargetArch() const override;
427
428 uint32_t getAddressGenGranularity() const override { return 32; }
429
430 std::optional<TileID> getMemWest(TileID src) const override;
431 std::optional<TileID> getMemEast(TileID src) const override;
432 std::optional<TileID> getMemNorth(TileID src) const override;
433 std::optional<TileID> getMemSouth(TileID src) const override;
434
435 bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override;
436 bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override;
437 bool isMemNorth(int srcCol, int srcRow, int dstCol,
438 int dstRow) const override;
439 bool isMemSouth(int srcCol, int srcRow, int dstCol,
440 int dstRow) const override;
441
442 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
443 int memRow) const override;
444
445 uint32_t getMemInternalBaseAddress(TileID src) const override {
446 return getMemEastBaseAddress();
447 }
448
449 uint32_t getMemSouthBaseAddress() const override { return 0x00040000; }
450 uint32_t getMemWestBaseAddress() const override { return 0x00050000; }
451 uint32_t getMemNorthBaseAddress() const override { return 0x00060000; }
452 uint32_t getMemEastBaseAddress() const override { return 0x00070000; }
453 uint32_t getLocalMemorySize() const override { return 0x00010000; }
454 uint32_t getAccumulatorCascadeSize() const override { return 512; }
455
456 uint32_t getNumLocks(int col, int row) const override {
457 return isMemTile(col, row) ? 64 : 16;
458 }
459
460 uint32_t getMaxLockValue() const override { return 0x3F; }
461
462 std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
463 TileID tile) const override;
464
465 uint32_t getNumBDs(int col, int row) const override {
466 return isMemTile(col, row) ? 48 : 16;
467 }
468
469 bool isBdChannelAccessible(int col, int row, uint32_t bd_id,
470 int channel) const override {
471 if (!isMemTile(col, row)) {
472 return true;
473 } else {
474 if ((channel & 1) == 0) { // even channel number
475 return bd_id < 24;
476 } else {
477 return bd_id >= 24;
478 }
479 }
480 }
481
482 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
483 AIE::DMAChannelDir direction) const override;
484
485 uint32_t getDmaBdAddressOffset(int col, int row) const override;
486
487 uint32_t getDmaControlAddress(int col, int row, int channel,
488 AIE::DMAChannelDir direction) const override;
489
490 uint32_t getMemTileSize() const override { return 0x00080000; }
491
492 uint32_t getNumBanks(int col, int row) const override {
493 return isMemTile(col, row) ? 8 : 4;
494 }
495
496 uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override {
497 return 4;
498 }
499
500 uint32_t getNumDestSwitchboxConnections(int col, int row,
501 WireBundle bundle) const override;
502 uint32_t getNumSourceSwitchboxConnections(int col, int row,
503 WireBundle bundle) const override;
504 uint32_t getNumDestShimMuxConnections(int col, int row,
505 WireBundle bundle) const override;
506 uint32_t getNumSourceShimMuxConnections(int col, int row,
507 WireBundle bundle) const override;
508 bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
509 int srcChan, WireBundle dstBundle,
510 int dstChan) const override;
511
512 uint32_t getColumnShift() const override { return 25; }
513 uint32_t getRowShift() const override { return 20; }
514
515 static bool classof(const AIETargetModel *model) {
516 return model->getKind() >= TK_AIE2_VE2302 &&
517 model->getKind() < TK_AIE2_Last;
518 }
519
520 std::vector<std::pair<uint32_t, uint32_t>>
521 getShimBurstEncodingsAndLengths() const override;
522};
523
525 llvm::SmallDenseSet<unsigned, 16> nocColumns = {
526 2, 3, 6, 7, 10, 11, 18, 19, 26, 27, 34, 35, 42, 43, 46, 47};
527
528public:
530
531 uint32_t getAddressGenGranularity() const override { return 32; }
532
533 int columns() const override { return 50; }
534
535 int rows() const override { return 9; /* One Shim row and 8 Core rows. */ }
536
537 bool isShimNOCTile(int col, int row) const override {
538 return row == 0 && nocColumns.contains(col);
539 }
540
541 bool isShimPLTile(int col, int row) const override {
542 return row == 0 && !nocColumns.contains(col);
543 }
544
545 bool isShimNOCorPLTile(int col, int row) const override {
546 return isShimNOCTile(col, row) || isShimPLTile(col, row);
547 }
548
549 static bool classof(const AIETargetModel *model) {
550 return model->getKind() == TK_AIE1_VC1902;
551 }
552};
553
555 llvm::SmallDenseSet<unsigned, 8> nocColumns = {2, 3, 6, 7, 10, 11};
556
557public:
559
560 int columns() const override { return 17; }
561
562 int rows() const override {
563 return 4; /* One Shim row, 1 memtile rows, and 2 Core rows. */
564 }
565
566 bool isCoreTile(int col, int row) const override { return row > 1; }
567 bool isMemTile(int col, int row) const override { return row == 1; }
568
569 bool isShimNOCTile(int col, int row) const override {
570 return row == 0 && nocColumns.contains(col);
571 }
572
573 bool isShimPLTile(int col, int row) const override {
574 return row == 0 && !nocColumns.contains(col);
575 }
576
577 bool isShimNOCorPLTile(int col, int row) const override {
578 return isShimNOCTile(col, row) || isShimPLTile(col, row);
579 }
580
581 uint32_t getNumMemTileRows() const override { return 1; }
582
583 static bool classof(const AIETargetModel *model) {
584 return model->getKind() == TK_AIE2_VE2302;
585 }
586};
587
589 llvm::SmallDenseSet<unsigned, 16> nocColumns = {2, 3, 6, 7, 14, 15,
590 22, 23, 30, 31, 34, 35};
591
592public:
594
595 int columns() const override { return 38; }
596
597 int rows() const override {
598 return 11; /* One Shim row, 2 memtile rows, and 8 Core rows. */
599 }
600
601 bool isCoreTile(int col, int row) const override { return row > 2; }
602
603 bool isMemTile(int col, int row) const override {
604 return row == 1 || row == 2;
605 }
606
607 bool isShimNOCTile(int col, int row) const override {
608 return row == 0 && nocColumns.contains(col);
609 }
610
611 bool isShimPLTile(int col, int row) const override {
612 return row == 0 && !nocColumns.contains(col);
613 }
614
615 bool isShimNOCorPLTile(int col, int row) const override {
616 return isShimNOCTile(col, row) || isShimPLTile(col, row);
617 }
618
619 uint32_t getNumMemTileRows() const override { return 2; }
620
621 static bool classof(const AIETargetModel *model) {
622 return model->getKind() == TK_AIE2_VE2802;
623 }
624};
625
627public:
629 // Device properties initialization
631 }
632
633 int rows() const override {
634 return 6; /* 1 Shim row, 1 memtile row, and 4 Core rows. */
635 }
636
637 bool isCoreTile(int col, int row) const override { return row > 1; }
638 bool isMemTile(int col, int row) const override { return row == 1; }
639
640 bool isShimPLTile(int col, int row) const override {
641 return false; // No PL
642 }
643
644 bool isShimNOCorPLTile(int col, int row) const override {
645 return isShimNOCTile(col, row) || isShimPLTile(col, row);
646 }
647
648 uint32_t getNumMemTileRows() const override { return 1; }
649
650 static bool classof(const AIETargetModel *model) {
651 return model->getKind() >= TK_AIE2_NPU1_1Col &&
652 model->getKind() < TK_AIE2_NPU1_Last;
653 }
654};
655
656// A sub-portion of the Phoenix NPU
658 int cols;
659
660public:
663 static_cast<std::underlying_type_t<TargetModelKind>>(
665 _cols - 1)),
666 cols(_cols) {
667 // Device properties initialization
669 }
670
671 int columns() const override { return cols; }
672
673 bool isShimNOCTile(int col, int row) const override { return row == 0; }
674
675 static bool classof(const AIETargetModel *model) {
676 return model->getKind() >= TK_AIE2_NPU1_1Col &&
677 model->getKind() < TK_AIE2_NPU1_Last;
678 }
679};
680
682public:
684 // Device properties initialization
686 }
687
688 AIEArch getTargetArch() const override;
689
690 int rows() const override {
691 return 6; /* 1 Shim row, 1 memtile row, and 4 Core rows. */
692 }
693
694 bool isCoreTile(int col, int row) const override { return row > 1; }
695 bool isMemTile(int col, int row) const override { return row == 1; }
696
697 bool isShimPLTile(int col, int row) const override {
698 return false; // No PL tiles
699 }
700
701 bool isShimNOCTile(int col, int row) const override { return row == 0; }
702
703 bool isShimNOCorPLTile(int col, int row) const override {
704 return isShimNOCTile(col, row);
705 }
706
707 uint32_t getNumMemTileRows() const override { return 1; }
708
709 std::vector<std::pair<uint32_t, uint32_t>>
710 getShimBurstEncodingsAndLengths() const override;
711
712 bool isSupportedBlockFormat(std::string const &format) const override;
713
714 static bool classof(const AIETargetModel *model) {
715 return model->getKind() >= TK_AIE2_NPU2 &&
716 model->getKind() < TK_AIE2_NPU2_Last;
717 }
718};
719
720// The full Strix NPU
722public:
724
725 int columns() const override { return 8; }
726
727 static bool classof(const AIETargetModel *model) {
728 return model->getKind() == TK_AIE2_NPU2;
729 }
730};
731
732// A sub-portion of the Strix NPU
734 int cols;
735
736public:
739 static_cast<std::underlying_type_t<TargetModelKind>>(TK_AIE2_NPU2) +
740 _cols)),
741 cols(_cols) {
742 // Device properties initialization
744 }
745
746 int columns() const override { return cols; }
747
748 static bool classof(const AIETargetModel *model) {
749 return model->getKind() >= TK_AIE2_NPU2_1Col &&
750 model->getKind() < TK_AIE2_NPU2_Last;
751 }
752};
753
754} // namespace xilinx::AIE
755
756namespace llvm {
757template <>
758struct DenseMapInfo<xilinx::AIE::TileID> {
759 using FirstInfo = DenseMapInfo<int>;
760 using SecondInfo = DenseMapInfo<int>;
761
763 return {FirstInfo::getEmptyKey(), SecondInfo::getEmptyKey()};
764 }
765
767 return {FirstInfo::getTombstoneKey(), SecondInfo::getTombstoneKey()};
768 }
769
770 static unsigned getHashValue(const xilinx::AIE::TileID &t) {
771 return detail::combineHashValue(FirstInfo::getHashValue(t.col),
772 SecondInfo::getHashValue(t.row));
773 }
774
775 static bool isEqual(const xilinx::AIE::TileID &lhs,
776 const xilinx::AIE::TileID &rhs) {
777 return lhs == rhs;
778 }
779};
780} // namespace llvm
781
782template <>
783struct std::hash<xilinx::AIE::TileID> {
784 std::size_t operator()(const xilinx::AIE::TileID &s) const noexcept {
785 std::size_t h1 = std::hash<int>{}(s.col);
786 std::size_t h2 = std::hash<int>{}(s.row);
787 return h1 ^ (h2 << 1);
788 }
789};
790
791#endif
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.
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
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.
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 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 getDmaBdAddressOffset(int col, int row) const override
Return the offset of the base address field within the shim dma buffer descriptor.
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.
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.
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 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.
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
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 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...
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.
uint32_t getDmaBdAddressOffset(int col, int row) const override
Return the offset of the base address field within the shim dma buffer descriptor.
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
virtual bool isSupportedBlockFormat(std::string const &format) 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 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 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 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,...
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 bool isMemTile(int col, int row) const =0
Return true if the given tile is an AIE2 'Memory' tile.
virtual uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const =0
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.
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.
uint32_t getNumMemTileRows() const override
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)
BaseNPU1TargetModel(TargetModelKind k)
bool isCoreTile(int col, int row) const override
Return true if the given tile is a 'Core' tile.
int rows() const override
Return the number of rows 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.
bool isShimPLTile(int col, int row) const override
Return true if the given tile is a Shim PL interface 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.
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
BaseNPU2TargetModel(TargetModelKind k)
bool isCoreTile(int col, int row) const override
Return true if the given tile is a 'Core' tile.
uint32_t getNumMemTileRows() const override
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.
AIEArch getTargetArch() const override
AIE2 TargetModel.
bool isShimPLTile(int col, int row) const override
Return true if the given tile is a Shim PL interface tile.
bool isSupportedBlockFormat(std::string const &format) const override
int rows() const override
Return the number of rows in the device.
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.
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.
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.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
Include the generated interface declarations.
friend std::ostream & operator<<(std::ostream &os, const Port &port)
Definition AIEDialect.h:132
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
Definition AIEDialect.h:126
PathEndPoint src
bool operator==(const Port &rhs) const
Definition AIEDialect.h:122
bool operator<(const Port &rhs) const
Definition AIEDialect.h:128
AIEArch
Definition Passes.h:21
static xilinx::AIE::TileID getTombstoneKey()
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)
std::size_t operator()(const xilinx::AIE::TileID &s) const noexcept