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 virtual uint32_t getNumMemTileRows() const = 0;
253 /// Return the size (in bytes) of a MemTile.
254 virtual uint32_t getMemTileSize() const = 0;
255 /// Return the number of memory banks of a given tile.
256 virtual uint32_t getNumBanks(int col, int row) const = 0;
257 /// Return the number of destinations of connections inside a switchbox. These
258 /// are the targets of connect operations in the switchbox.
259 virtual uint32_t getNumDestSwitchboxConnections(int col, int row,
260 WireBundle bundle) const = 0;
261 /// Return the number of sources of connections inside a switchbox. These are
262 /// the origins of connect operations in the switchbox.
263 virtual uint32_t
265 WireBundle bundle) const = 0;
266 /// Return the number of destinations of connections inside a shimmux. These
267 /// are the targets of connect operations in the switchbox.
268 virtual uint32_t getNumDestShimMuxConnections(int col, int row,
269 WireBundle bundle) const = 0;
270 /// Return the number of sources of connections inside a shimmux. These are
271 /// the origins of connect operations in the switchbox.
272 virtual uint32_t getNumSourceShimMuxConnections(int col, int row,
273 WireBundle bundle) const = 0;
274
275 // Return true if the stream switch connection is legal, false otherwise.
276 virtual bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
277 int srcChan, WireBundle dstBundle,
278 int dstChan) const = 0;
279
280 // Run consistency checks on the target model.
281 void validate() const;
282
283 uint32_t getModelProperties() const { return ModelProperties; }
284 void addModelProperty(uint32_t prop) { ModelProperties |= prop; }
285 // Return true if this device has a given property.
286 bool hasProperty(ModelProperty Prop) const {
287 return (getModelProperties() & Prop) == Prop;
288 }
289
290 // Return the bit offset of the column within a tile address.
291 // This is used to compute the control address of a tile from it's column
292 // location.
293 virtual uint32_t getColumnShift() const = 0;
294
295 // Return the bit offset of the row within a tile address.
296 // This is used to compute the control address of a tile from it's row
297 // location.
298 virtual uint32_t getRowShift() const = 0;
299
300 // Returns the list of possible burst encodings (first) and
301 // their corresponding lengths in bytes (second).
302 virtual std::vector<std::pair<uint32_t, uint32_t>>
304};
305
307public:
309
310 bool isCoreTile(int col, int row) const override { return row > 0; }
311 bool isMemTile(int col, int row) const override { return false; }
312
313 AIEArch getTargetArch() const override;
314
315 std::optional<TileID> getMemWest(TileID src) const override;
316 std::optional<TileID> getMemEast(TileID src) const override;
317 std::optional<TileID> getMemNorth(TileID src) const override;
318 std::optional<TileID> getMemSouth(TileID src) const override;
319
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;
326
327 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
328 int memRow) const override;
329
330 uint32_t getMemInternalBaseAddress(TileID src) const override {
331 if (src.row % 2 == 0)
332 // Internal is West
333 return getMemWestBaseAddress();
334 // Internal is East
335 return getMemEastBaseAddress();
336 }
337
338 uint32_t getMemSouthBaseAddress() const override { return 0x00020000; }
339 uint32_t getMemWestBaseAddress() const override { return 0x00028000; }
340 uint32_t getMemNorthBaseAddress() const override { return 0x00030000; }
341 uint32_t getMemEastBaseAddress() const override { return 0x00038000; }
342 uint32_t getLocalMemorySize() const override { return 0x00008000; }
343 uint32_t getAccumulatorCascadeSize() const override { return 384; }
344 uint32_t getNumLocks(int col, int row) const override { return 16; }
345 uint32_t getMaxLockValue() const override { return 1; }
346 std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
347 TileID tile) const override;
348 uint32_t getNumBDs(int col, int row) const override { return 16; }
349 bool isBdChannelAccessible(int col, int row, uint32_t bd_id,
350 int channel) const override {
351 return true;
352 }
353 uint32_t getNumMemTileRows() const override { return 0; }
354 uint32_t getMemTileSize() const override { return 0; }
355 uint32_t getNumBanks(int col, int row) const override { return 4; }
356
357 uint32_t getNumDestSwitchboxConnections(int col, int row,
358 WireBundle bundle) const override;
359 uint32_t getNumSourceSwitchboxConnections(int col, int row,
360 WireBundle bundle) const override;
361 uint32_t getNumDestShimMuxConnections(int col, int row,
362 WireBundle bundle) const override;
363 uint32_t getNumSourceShimMuxConnections(int col, int row,
364 WireBundle bundle) const override;
365 bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
366 int srcChan, WireBundle dstBundle,
367 int dstChan) const override;
368
369 uint32_t getColumnShift() const override { return 23; }
370 uint32_t getRowShift() const override { return 18; }
371
372 static bool classof(const AIETargetModel *model) {
373 return model->getKind() >= TK_AIE1_VC1902 &&
374 model->getKind() < TK_AIE1_Last;
375 }
376
377 std::vector<std::pair<uint32_t, uint32_t>>
378 getShimBurstEncodingsAndLengths() const override;
379};
380
382public:
388
389 AIEArch getTargetArch() const override;
390
391 uint32_t getAddressGenGranularity() const override { return 32; }
392
393 std::optional<TileID> getMemWest(TileID src) const override;
394 std::optional<TileID> getMemEast(TileID src) const override;
395 std::optional<TileID> getMemNorth(TileID src) const override;
396 std::optional<TileID> getMemSouth(TileID src) const override;
397
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;
404
405 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
406 int memRow) const override;
407
408 uint32_t getMemInternalBaseAddress(TileID src) const override {
409 return getMemEastBaseAddress();
410 }
411
412 uint32_t getMemSouthBaseAddress() const override { return 0x00040000; }
413 uint32_t getMemWestBaseAddress() const override { return 0x00050000; }
414 uint32_t getMemNorthBaseAddress() const override { return 0x00060000; }
415 uint32_t getMemEastBaseAddress() const override { return 0x00070000; }
416 uint32_t getLocalMemorySize() const override { return 0x00010000; }
417 uint32_t getAccumulatorCascadeSize() const override { return 512; }
418
419 uint32_t getNumLocks(int col, int row) const override {
420 return isMemTile(col, row) ? 64 : 16;
421 }
422
423 uint32_t getMaxLockValue() const override { return 0x3F; }
424
425 std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
426 TileID tile) const override;
427
428 uint32_t getNumBDs(int col, int row) const override {
429 return isMemTile(col, row) ? 48 : 16;
430 }
431
432 bool isBdChannelAccessible(int col, int row, uint32_t bd_id,
433 int channel) const override {
434 if (!isMemTile(col, row)) {
435 return true;
436 } else {
437 if ((channel & 1) == 0) { // even channel number
438 return bd_id < 24;
439 } else {
440 return bd_id >= 24;
441 }
442 }
443 }
444
445 uint32_t getMemTileSize() const override { return 0x00080000; }
446
447 uint32_t getNumBanks(int col, int row) const override {
448 return isMemTile(col, row) ? 8 : 4;
449 }
450
451 uint32_t getNumDestSwitchboxConnections(int col, int row,
452 WireBundle bundle) const override;
453 uint32_t getNumSourceSwitchboxConnections(int col, int row,
454 WireBundle bundle) const override;
455 uint32_t getNumDestShimMuxConnections(int col, int row,
456 WireBundle bundle) const override;
457 uint32_t getNumSourceShimMuxConnections(int col, int row,
458 WireBundle bundle) const override;
459 bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
460 int srcChan, WireBundle dstBundle,
461 int dstChan) const override;
462
463 uint32_t getColumnShift() const override { return 25; }
464 uint32_t getRowShift() const override { return 20; }
465
466 static bool classof(const AIETargetModel *model) {
467 return model->getKind() >= TK_AIE2_VE2302 &&
468 model->getKind() < TK_AIE2_Last;
469 }
470
471 std::vector<std::pair<uint32_t, uint32_t>>
472 getShimBurstEncodingsAndLengths() const override;
473};
474
476 llvm::SmallDenseSet<unsigned, 16> nocColumns = {
477 2, 3, 6, 7, 10, 11, 18, 19, 26, 27, 34, 35, 42, 43, 46, 47};
478
479public:
481
482 uint32_t getAddressGenGranularity() const override { return 32; }
483
484 int columns() const override { return 50; }
485
486 int rows() const override { return 9; /* One Shim row and 8 Core rows. */ }
487
488 bool isShimNOCTile(int col, int row) const override {
489 return row == 0 && nocColumns.contains(col);
490 }
491
492 bool isShimPLTile(int col, int row) const override {
493 return row == 0 && !nocColumns.contains(col);
494 }
495
496 bool isShimNOCorPLTile(int col, int row) const override {
497 return isShimNOCTile(col, row) || isShimPLTile(col, row);
498 }
499
500 static bool classof(const AIETargetModel *model) {
501 return model->getKind() == TK_AIE1_VC1902;
502 }
503};
504
506 llvm::SmallDenseSet<unsigned, 8> nocColumns = {2, 3, 6, 7, 10, 11};
507
508public:
510
511 int columns() const override { return 17; }
512
513 int rows() const override {
514 return 4; /* One Shim row, 1 memtile rows, and 2 Core rows. */
515 }
516
517 bool isCoreTile(int col, int row) const override { return row > 1; }
518 bool isMemTile(int col, int row) const override { return row == 1; }
519
520 bool isShimNOCTile(int col, int row) const override {
521 return row == 0 && nocColumns.contains(col);
522 }
523
524 bool isShimPLTile(int col, int row) const override {
525 return row == 0 && !nocColumns.contains(col);
526 }
527
528 bool isShimNOCorPLTile(int col, int row) const override {
529 return isShimNOCTile(col, row) || isShimPLTile(col, row);
530 }
531
532 uint32_t getNumMemTileRows() const override { return 1; }
533
534 static bool classof(const AIETargetModel *model) {
535 return model->getKind() == TK_AIE2_VE2302;
536 }
537};
538
540 llvm::SmallDenseSet<unsigned, 16> nocColumns = {2, 3, 6, 7, 14, 15,
541 22, 23, 30, 31, 34, 35};
542
543public:
545
546 int columns() const override { return 38; }
547
548 int rows() const override {
549 return 11; /* One Shim row, 2 memtile rows, and 8 Core rows. */
550 }
551
552 bool isCoreTile(int col, int row) const override { return row > 2; }
553
554 bool isMemTile(int col, int row) const override {
555 return row == 1 || row == 2;
556 }
557
558 bool isShimNOCTile(int col, int row) const override {
559 return row == 0 && nocColumns.contains(col);
560 }
561
562 bool isShimPLTile(int col, int row) const override {
563 return row == 0 && !nocColumns.contains(col);
564 }
565
566 bool isShimNOCorPLTile(int col, int row) const override {
567 return isShimNOCTile(col, row) || isShimPLTile(col, row);
568 }
569
570 uint32_t getNumMemTileRows() const override { return 2; }
571
572 static bool classof(const AIETargetModel *model) {
573 return model->getKind() == TK_AIE2_VE2802;
574 }
575};
576
578public:
580 // Device properties initialization
582 }
583
584 int rows() const override {
585 return 6; /* 1 Shim row, 1 memtile row, and 4 Core rows. */
586 }
587
588 bool isCoreTile(int col, int row) const override { return row > 1; }
589 bool isMemTile(int col, int row) const override { return row == 1; }
590
591 bool isShimPLTile(int col, int row) const override {
592 return false; // No PL
593 }
594
595 bool isShimNOCorPLTile(int col, int row) const override {
596 return isShimNOCTile(col, row) || isShimPLTile(col, row);
597 }
598
599 uint32_t getNumMemTileRows() const override { return 1; }
600
601 static bool classof(const AIETargetModel *model) {
602 return model->getKind() >= TK_AIE2_NPU1 &&
603 model->getKind() < TK_AIE2_NPU2_Last;
604 }
605};
606
607// The full Phoenix NPU
609public:
611
612 int columns() const override { return 5; }
613
614 bool isShimNOCTile(int col, int row) const override {
615 return row == 0 && col > 0;
616 }
617
618 bool isShimPLTile(int col, int row) const override {
619 // This isn't useful because it's not connected to anything.
620 return row == 0 && col == 0;
621 }
622
623 static bool classof(const AIETargetModel *model) {
624 return model->getKind() == TK_AIE2_NPU1;
625 }
626};
627
628// A sub-portion of the Phoenix NPU
630 int cols;
631
632public:
634 : BaseNPUTargetModel(static_cast<TargetModelKind>(
635 static_cast<std::underlying_type_t<TargetModelKind>>(TK_AIE2_NPU1) +
636 _cols)),
637 cols(_cols) {
638 // Device properties initialization
640 }
641
642 uint32_t getAddressGenGranularity() const override { return 32; }
643
644 int columns() const override { return cols; }
645
646 bool isShimNOCTile(int col, int row) const override { return row == 0; }
647
648 static bool classof(const AIETargetModel *model) {
649 return model->getKind() >= TK_AIE2_NPU1_1Col &&
650 model->getKind() < TK_AIE2_NPU1_Last;
651 }
652};
653
654// The full Strix NPU
656public:
658
659 AIEArch getTargetArch() const override;
660
661 int columns() const override { return 8; }
662
663 bool isShimNOCTile(int col, int row) const override { return row == 0; }
664
665 bool isShimPLTile(int col, int row) const override { return false; }
666
667 static bool classof(const AIETargetModel *model) {
668 return model->getKind() == TK_AIE2_NPU2;
669 }
670
671 std::vector<std::pair<uint32_t, uint32_t>>
672 getShimBurstEncodingsAndLengths() const override;
673};
674
675// A sub-portion of the Strix NPU
677 int cols;
678
679public:
681 : BaseNPUTargetModel(static_cast<TargetModelKind>(
682 static_cast<std::underlying_type_t<TargetModelKind>>(TK_AIE2_NPU2) +
683 _cols)),
684 cols(_cols) {
685 // Device properties initialization
687 }
688
689 uint32_t getAddressGenGranularity() const override { return 32; }
690
691 int columns() const override { return cols; }
692
693 bool isShimNOCTile(int col, int row) const override { return row == 0; }
694
695 static bool classof(const AIETargetModel *model) {
696 return model->getKind() >= TK_AIE2_NPU2_1Col &&
697 model->getKind() < TK_AIE2_NPU2_Last;
698 }
699};
700
701} // namespace xilinx::AIE
702
703namespace llvm {
704template <>
705struct DenseMapInfo<xilinx::AIE::TileID> {
706 using FirstInfo = DenseMapInfo<int>;
707 using SecondInfo = DenseMapInfo<int>;
708
710 return {FirstInfo::getEmptyKey(), SecondInfo::getEmptyKey()};
711 }
712
714 return {FirstInfo::getTombstoneKey(), SecondInfo::getTombstoneKey()};
715 }
716
717 static unsigned getHashValue(const xilinx::AIE::TileID &t) {
718 return detail::combineHashValue(FirstInfo::getHashValue(t.col),
719 SecondInfo::getHashValue(t.row));
720 }
721
722 static bool isEqual(const xilinx::AIE::TileID &lhs,
723 const xilinx::AIE::TileID &rhs) {
724 return lhs == rhs;
725 }
726};
727} // namespace llvm
728
729template <>
730struct std::hash<xilinx::AIE::TileID> {
731 std::size_t operator()(const xilinx::AIE::TileID &s) const noexcept {
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);
735 }
736};
737
738#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.
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 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.
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.
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.
static bool classof(const AIETargetModel *model)
Include the generated interface declarations.
friend std::ostream & operator<<(std::ostream &os, const Port &port)
Definition AIEDialect.h:131
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:125
PathEndPoint src
bool operator==(const Port &rhs) const
Definition AIEDialect.h:121
bool operator<(const Port &rhs) const
Definition AIEDialect.h:127
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