MLIR-AIE 1.4.6.dev
AIETargetModel.h
Go to the documentation of this file.
1//===- AIETargetModel.h -----------------------------------------*- C++ -*-===//
2//
3// Copyright (C) 2023 Advanced Micro Devices, Inc.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5//
6//===----------------------------------------------------------------------===//
7
8#ifndef MLIR_AIE_DEVICEMODEL_H
9#define MLIR_AIE_DEVICEMODEL_H
10
13
14#include "llvm/ADT/ArrayRef.h"
15#include "llvm/ADT/DenseSet.h"
16#include "llvm/ADT/STLExtras.h"
17#include "llvm/ADT/SmallVector.h"
18#include "llvm/Support/MathExtras.h"
19
20#include <iostream>
21#include <memory>
22#include <mutex>
23#include <vector>
24
25namespace xilinx::AIE {
26
27using TileID = struct TileID {
28 // friend definition (will define the function as a non-member function in the
29 // namespace surrounding the class).
30 friend std::ostream &operator<<(std::ostream &os, const TileID &s) {
31 os << "TileID(" << s.col << ", " << s.row << ")";
32 return os;
33 }
34
35 friend std::string to_string(const TileID &s) {
36 std::ostringstream ss;
37 ss << s;
38 return ss.str();
39 }
40
41 friend llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const TileID &s) {
42 os << to_string(s);
43 return os;
44 }
45
46 // Imposes a lexical order on TileIDs.
47 inline bool operator<(const TileID &rhs) const {
48 return std::tie(col, row) < std::tie(rhs.col, rhs.row);
49 }
50
51 bool operator==(const TileID &rhs) const {
52 return std::tie(col, row) == std::tie(rhs.col, rhs.row);
53 }
54
55 bool operator!=(const TileID &rhs) const { return !(*this == rhs); }
56
57 int col, row;
58};
59
60/// Bits [shift, shift + width) of register `word` in a buffer descriptor's
61/// register block. A field a tile type does not have has width 0.
62struct DmaBdField {
63 uint8_t word = 0, shift = 0, width = 0;
64
65 bool exists() const { return width != 0; }
66 uint32_t mask() const {
67 return width >= 32 ? 0xFFFFFFFFu : (1u << width) - 1;
68 }
69 uint32_t place(uint64_t value) const {
70 return exists() ? (static_cast<uint32_t>(value) & mask()) << shift : 0;
71 }
72};
73
74/// The register layout of one tile type's DMA buffer descriptor. The static
75/// and runtime BD lowerings both pack through it, so the two cannot disagree.
77 uint8_t numWords = 0;
87
88 /// The (before, after) zero-padding fields, innermost dimension first.
89 llvm::SmallVector<std::pair<DmaBdField, DmaBdField>, 3> padFields() const {
90 llvm::SmallVector<std::pair<DmaBdField, DmaBdField>, 3> fields;
91 for (std::pair<DmaBdField, DmaBdField> field :
92 {std::pair(d0ZeroBefore, d0ZeroAfter),
93 std::pair(d1ZeroBefore, d1ZeroAfter),
94 std::pair(d2ZeroBefore, d2ZeroAfter)}) {
95 if (!field.first.exists())
96 break;
97 fields.push_back(field);
98 }
99 return fields;
100 }
101};
102
104
105public:
129
130 // One-hot encoded list of target model properties.
132 // Device uses semaphore locks.
134 // Device is an NPU-based device.
135 IsNPU = 1U << 1,
136 // Device model is virtualized.
137 // This is used during CDO code generation to configure aie-codegen
138 // properly.
139 IsVirtualized = 1U << 2,
140 // Device uses multi-dimensional buffer descriptors.
142 // Device supports BD per-execution base address advance.
144 // Device supports out-of-order S2MM DMA.
146 // Device tiles can be configured by control packets.
148 };
149
150private:
151 const TargetModelKind kind;
152
153 uint32_t ModelProperties = 0;
154
155 // Register database (loaded lazily on first access)
156 // Thread-safe lazy initialization using std::call_once
157 mutable std::unique_ptr<RegisterDatabase> regDB;
158 mutable std::once_flag regDBInitFlag;
159
160protected:
161 /// Subclasses override to provide architecture-specific database loading.
162 /// Returns nullptr if register database is not available for this
163 /// architecture.
164 virtual std::unique_ptr<RegisterDatabase> loadRegisterDatabase() const;
165
166 /// Get the register database, loading it lazily on first access.
167 /// Throws fatal error if database is required but unavailable.
169
170public:
171 TargetModelKind getKind() const { return kind; }
172
174
176
177 /// Return the target architecture.
178 virtual AIEArch getTargetArch() const = 0;
179
180 /// Return the data bus width of the device.
181 virtual uint32_t getAddressGenGranularity() const = 0;
182
183 /// Return the number of columns in the device.
184 virtual int columns() const = 0;
185
186 /// Width of the physical array this (possibly virtualized) device is carved
187 /// from. This defaults to columns(), which is correct for devices that are
188 /// the whole array.
189 virtual int physicalColumns() const { return columns(); }
190
191 /// First physical column at which a partition may be anchored.
192 virtual int firstPlaceableColumn() const { return 0; }
193
194 /// Every physical column offset at which a numCols-wide partition still fits.
195 std::vector<int> partitionStartColumns(int numCols) const {
196 std::vector<int> starts;
197 for (int c = firstPlaceableColumn(); c + numCols <= physicalColumns(); ++c)
198 starts.push_back(c);
199 return starts;
200 }
201
202 /// Return the number of rows in the device.
203 virtual int rows() const = 0;
204
205 /// Number of microcontrollers (uC) per column
206 virtual uint32_t getNumControllersPerColumn() const { return 0; }
207
208 /// Total number of microcontrollers (uC) in the device.
209 /// Defaults to columns() * getNumControllersPerColumn();
210 /// architectures with a single device-level uC (e.g. AIE2/AIE2P NPUs)
211 /// override this directly instead, since their controller count doesn't
212 /// scale with column count.
213 virtual uint32_t getNumControllers() const {
214 return static_cast<uint32_t>(columns()) * getNumControllersPerColumn();
215 }
216
217 /// Return the tile type for the given tile coordinates.
218 /// - CoreTile: tiles with a Core, TileDMA, tile memory, and stream
219 /// connections.
220 /// - MemTile: tiles with TileDMA, tile memory, and stream connections,
221 /// but no core.
222 /// - ShimNOCTile: tiles with ShimDMA and connection to the memory-mapped NOC.
223 /// - ShimPLTile: tiles with connections to the PL, no ShimDMA.
224 virtual AIETileType getTileType(int col, int row) const = 0;
225
226 /// Return true if the given tile is a Core tile.
227 bool isCoreTile(int col, int row) const {
228 return getTileType(col, row) == AIETileType::CoreTile;
229 }
230
231 /// Return true if the given tile is a Mem tile.
232 bool isMemTile(int col, int row) const {
233 return getTileType(col, row) == AIETileType::MemTile;
234 }
235
236 /// Return true if the given tile is a ShimNOC tile.
237 bool isShimNOCTile(int col, int row) const {
238 return getTileType(col, row) == AIETileType::ShimNOCTile;
239 }
240
241 /// Return true if the given tile is a ShimPL tile.
242 bool isShimPLTile(int col, int row) const {
243 return getTileType(col, row) == AIETileType::ShimPLTile;
244 }
245
246 /// Return true if the given tile is either a ShimNOC or ShimPL tile.
247 bool isShimNOCorPLTile(int col, int row) const {
248 AIETileType t = getTileType(col, row);
249 return t == AIETileType::ShimNOCTile || t == AIETileType::ShimPLTile;
250 }
251
252 /// Return true if the given tile ID is valid.
253 virtual bool isValidTile(TileID src) const {
254 return src.col >= 0 && src.col < columns() && src.row >= 0 &&
255 src.row < rows();
256 }
257
258 /// Return the tile ID of the memory to the west of the given tile, if it
259 /// exists.
260 virtual std::optional<TileID> getMemWest(TileID src) const = 0;
261 /// Return the tile ID of the memory to the east of the given tile, if it
262 /// exists.
263 virtual std::optional<TileID> getMemEast(TileID src) const = 0;
264 /// Return the tile ID of the memory to the north of the given tile, if it
265 /// exists.
266 virtual std::optional<TileID> getMemNorth(TileID src) const = 0;
267 /// Return the tile ID of the memory to the south of the given tile, if it
268 /// exists.
269 virtual std::optional<TileID> getMemSouth(TileID src) const = 0;
270
271 /// Return true if src is the internal memory of dst
272 bool isInternal(int srcCol, int srcRow, int dstCol, int dstRow) const {
273 return srcCol == dstCol && srcRow == dstRow;
274 }
275
276 /// Return true if src is West of dst
277 bool isWest(int srcCol, int srcRow, int dstCol, int dstRow) const {
278 return srcCol == dstCol + 1 && srcRow == dstRow;
279 }
280
281 /// Return true if src is East of dst
282 bool isEast(int srcCol, int srcRow, int dstCol, int dstRow) const {
283 return srcCol == dstCol - 1 && srcRow == dstRow;
284 }
285
286 /// Return true if src is North of dst
287 bool isNorth(int srcCol, int srcRow, int dstCol, int dstRow) const {
288 return srcCol == dstCol && srcRow == dstRow - 1;
289 }
290
291 /// Return true if src is South of dst
292 bool isSouth(int srcCol, int srcRow, int dstCol, int dstRow) const {
293 return srcCol == dstCol && srcRow == dstRow + 1;
294 }
295
296 /// The steps (destination column - source column, destination row - source
297 /// row) from one core's cascade output to the next core's input.
298 virtual llvm::ArrayRef<std::pair<int, int>> getCascadeSteps() const {
299 return {};
300 }
301
302 /// Return true if a cascade can run from src to dst.
303 bool isLegalCascade(int srcCol, int srcRow, int dstCol, int dstRow) const {
304 return llvm::is_contained(getCascadeSteps(),
305 std::pair{dstCol - srcCol, dstRow - srcRow});
306 }
307
308 /// Return true if src has a memory tile which is West of dst
309 virtual bool isMemWest(int srcCol, int srcRow, int dstCol,
310 int dstRow) const = 0;
311 /// Return true if src has a memory tile which is East of dst
312 virtual bool isMemEast(int srcCol, int srcRow, int dstCol,
313 int dstRow) const = 0;
314 /// Return true if src has a memory tile which is North of dst
315 virtual bool isMemNorth(int srcCol, int srcRow, int dstCol,
316 int dstRow) const = 0;
317 /// Return true if src has a memory tile which is South of dst
318 virtual bool isMemSouth(int srcCol, int srcRow, int dstCol,
319 int dstRow) const = 0;
320
321 /// Return true if core can access the memory in mem
322 virtual bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
323 int memRow) const = 0;
324
325 /// Which of two tiles' memory modules both of them can address.
326 enum class SharedMemory {
327 /// Neither tile can address the other's memory module.
329 /// Only the first tile's module.
331 /// Only the second tile's module.
333 /// Either will do.
335 };
336
337 /// Return the memory module `a` and `b` can both reach, if any.
339 // A shim or mem tile's memory module is only ever reachable from its own
340 // kind, so tiles of different kinds share nothing.
341 if (isShimNOCorPLTile(a.col, a.row) != isShimNOCorPLTile(b.col, b.row) ||
342 isMemTile(a.col, a.row) != isMemTile(b.col, b.row)) {
343 return SharedMemory::None;
344 }
345 bool aReachesB = isLegalMemAffinity(a.col, a.row, b.col, b.row);
346 bool bReachesA = isLegalMemAffinity(b.col, b.row, a.col, a.row);
347 if (aReachesB && bReachesA) {
349 }
350 if (bReachesA) {
351 return SharedMemory::First;
352 }
353 if (aReachesB) {
355 }
356 return SharedMemory::None;
357 }
358
359 /// Return the base address in the local address map for a core.
360 virtual uint32_t getMemInternalBaseAddress(TileID src) const = 0;
361 /// Return the base address in the local address map for a core.
362 virtual uint32_t getMemSouthBaseAddress() const = 0;
363 /// Return the base address in the local address map for a core.
364 virtual uint32_t getMemWestBaseAddress() const = 0;
365 /// Return the base address in the local address map for a core.
366 virtual uint32_t getMemNorthBaseAddress() const = 0;
367 /// Return the base address in the local address map for a core.
368 virtual uint32_t getMemEastBaseAddress() const = 0;
369
370 /// Return the lock base index (or offset) in the local tile when accessing a
371 /// neighbor's lock or an empty optional if an invalid neighbor is given
372 /// Takes into account differences between Memory and Core tiles
373 std::optional<uint32_t> getLockLocalBaseIndex(int localCol, int localRow,
374 int lockCol, int lockRow) const;
375
376 /// Return the memory base address (or offset) in the local tile when
377 /// accessing a neighbor's memory or an empty optional if an invalid neighbor
378 /// is given
379 /// Takes into account differences between Memory and Core tiles
380 std::optional<uint32_t> getMemLocalBaseAddress(int localCol, int localRow,
381 int memCol, int memRow) const;
382
383 /// Return the size (in bytes) of the local data memory of a core.
384 virtual uint32_t getLocalMemorySize() const = 0;
385
386 /// Return the size (in bytes) of a core's program memory.
387 virtual uint32_t getProgramMemorySize() const = 0;
388
389 /// Return the size (in bytes) of the address space a core can issue data
390 /// accesses into. The neighbour memory windows sit at the bottom of it; the
391 /// span above them reaches no memory and is reserved so nothing is placed
392 /// there.
393 virtual uint32_t getCoreDataAddressSpaceSize() const = 0;
394
395 /// Return the default stack reservation (in bytes) for a core that does not
396 /// state one. It is also the floor when aiecc sizes the stack from its
397 /// measurement. The linker script places the stack directly below the
398 /// objectFIFO buffers with no clearance, so a design whose frames exceed its
399 /// reservation corrupts them instead of faulting.
400 virtual uint32_t getDefaultCoreStackSize() const { return 0x400; }
401
402 /// Stack-pointer alignment in bytes, matching Peano's AIE frame lowering:
403 /// AIE1/AIE2 require 32B; AIE2P/AIE2PS require 64B, not their 32B data bus.
404 uint32_t getCoreStackAlignment() const {
405 AIEArch arch = getTargetArch();
406 return arch == AIEArch::AIE2p || arch == AIEArch::AIE2ps ? 64 : 32;
407 }
408
409 /// Return the data bus width (in bits) for load/store operations of a compute
410 /// core.
411 virtual uint32_t getComputeTileLoadStoreBusWidth() const = 0;
412
413 /// Return the alignment (in bits) required by the widest vector load/store a
414 /// compute core can issue.
415 ///
416 /// This is NOT the load/store bus width. From AIE2P on, a full-width
417 /// (512-bit) vector access requires 512-bit alignment even though the bus is
418 /// 256 bits wide. Mirrors `vector_ldst_align` in aie_api
419 /// (aie_api/detail/ld_st.hpp), which is the contract kernels compile against:
420 /// AIE1 (__AIE_ARCH__ 10): 16B
421 /// AIE2 (__AIE_ARCH__ 20): 32B
422 /// AIE2P/AIE2PS (__AIE_ARCH__ 21/22): 64B
423 /// A buffer a core may access with a full-width vector must be aligned to
424 /// this, or the access silently touches the wrong memory.
425 virtual uint32_t getComputeTileMaxVectorAlignBits() const {
427 }
428
429 // NOTE: Maybe this should be set to 4-byte alignment, since DMA on Memtile
430 // seems to handle unaligned access.
431 /// Return the data bus width (in bits) for load/store operations of a memory
432 /// tile.
433 virtual uint32_t getMemTileLoadStoreBusWidth() const {
434 return 4 * 8; // Simply have buffer to be 4 byte aligned.
435 // Since 4 byte is the minimum access size for DMA.
436 // See discussion in
437 // https://github.com/Xilinx/mlir-aie/pull/3037#discussion_r3176686935
438 }
439
440 /// Return the size (in bits) of the accumulator/cascade.
441 virtual uint32_t getAccumulatorCascadeSize() const = 0;
442
443 /// Return the number of lock objects for a given tile type.
444 virtual uint32_t getNumLocks(AIETileType tileType) const = 0;
445
446 /// Return the number of lock objects for a tile at the given coordinates.
447 uint32_t getNumLocks(int col, int row) const {
448 return getNumLocks(getTileType(col, row));
449 }
450
451 /// Return the maximum value that can be stored in a lock register
452 virtual uint32_t getMaxLockValue() const = 0;
453
454 // Return the lock address for the lock ID in the local memory for a given
455 // tile or a nullopt if invalid arguments are given.
456 virtual std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
457 TileID tile) const = 0;
458
459 /// Return the number of buffer descriptors for a given tile type.
460 virtual uint32_t getNumBDs(AIETileType tileType) const = 0;
461
462 /// Return the maximum number of addressing dimensions (wraps/strides) a
463 /// single buffer descriptor supports for a given tile type. This is the
464 /// hardware ND access-pattern limit; it does not count the separate shim
465 /// iteration/repeat dimension that runtime-sequence BD tasks hoist the
466 /// leading tap dimension into.
467 virtual uint32_t getBDMaxDims(AIETileType tileType) const = 0;
468
469 /// Return the maximum transfer length, measured in address-generation
470 /// granules (see getAddressGenGranularity(), 32-bit words on AIE2), that fits
471 /// in the buffer_length field of a DMA buffer descriptor for the given tile
472 /// type. The field width is tile-type specific (e.g. on AIE2 the shim field
473 /// is 32 bits, the mem-tile field 17 bits and the core-tile field 14 bits).
474 virtual uint64_t getDmaBdMaxLen(AIETileType tileType) const = 0;
475
476 /// Return the bit width of the wrap (size) field in a DMA buffer descriptor
477 /// for the given tile type. Used to compute the maximum legal wrap value
478 /// per dimension.
479 virtual uint32_t getDmaBdWrapBits(AIETileType tileType) const = 0;
480
481 /// Return the bit width of the step (stride) field in a DMA buffer
482 /// descriptor for the given tile type.
483 virtual uint32_t getDmaBdStepBits(AIETileType tileType) const = 0;
484
485 /// Return the bit width of the iteration (repeat) wrap/stride fields in a
486 /// DMA buffer descriptor for the given tile type.
487 virtual uint32_t getDmaBdIterBits(AIETileType tileType) const = 0;
488
489 /// Get stream switch port index for a given port specification
490 /// Return port index for Stream_Switch_Event_Port_Selection register, or
491 /// nullopt if invalid
492 virtual std::optional<uint32_t>
493 getStreamSwitchPortIndex(int col, int row, WireBundle bundle,
494 uint32_t channel, bool master) const = 0;
495
496 /// Return the number of buffer descriptors supported by the DMA in the given
497 /// tile.
498 uint32_t getNumBDs(int col, int row) const {
499 return getNumBDs(getTileType(col, row));
500 }
501
502 /// Return the maximum number of BD addressing dimensions for the tile at
503 /// (`col`, `row`).
504 uint32_t getBDMaxDims(int col, int row) const {
505 return getBDMaxDims(getTileType(col, row));
506 }
507
508 uint64_t getDmaBdMaxLen(int col, int row) const {
509 return getDmaBdMaxLen(getTileType(col, row));
510 }
511
512 uint32_t getDmaBdWrapBits(int col, int row) const {
513 return getDmaBdWrapBits(getTileType(col, row));
514 }
515
516 uint32_t getDmaBdStepBits(int col, int row) const {
517 return getDmaBdStepBits(getTileType(col, row));
518 }
519
520 uint32_t getDmaBdIterBits(int col, int row) const {
521 return getDmaBdIterBits(getTileType(col, row));
522 }
523
524 /// Return the number of buffer descriptors accessible on channel `channel`
525 /// for the tile at (`col`, `row`). For tiles with no per-channel BD
526 /// partitioning this equals getNumBDs(col, row).
527 uint32_t getNumBDsForChannel(int col, int row, int channel) const {
528 uint32_t count = 0;
529 for (uint32_t bd = 0; bd < getNumBDs(col, row); ++bd)
530 if (isBdChannelAccessible(col, row, bd, channel))
531 ++count;
532 return count;
533 }
534
535 /// Return the half-open range [first, last) of buffer descriptor ids that
536 /// channel `channel` of the tile at (`col`, `row`) can submit.
537 std::pair<uint32_t, uint32_t> getBdIdRangeForChannel(int col, int row,
538 int channel) const {
539 uint32_t numBds = getNumBDs(col, row);
540 uint32_t first = 0;
541 while (first < numBds && !isBdChannelAccessible(col, row, first, channel))
542 ++first;
543 uint32_t last = first;
544 while (last < numBds && isBdChannelAccessible(col, row, last, channel))
545 ++last;
546 return {first, last};
547 }
548
549 /// Return true iff buffer descriptor `bd_id` on tile (`col`, `row`) can be
550 /// submitted on channel `channel`.
551 virtual bool isBdChannelAccessible(int col, int row, uint32_t bd_id,
552 int channel) const = 0;
553
554 /// Return the register layout of a buffer descriptor on the given tile
555 /// type, or null if the target has none modeled for it.
556 virtual const DmaBdLayout *getDmaBdLayout(AIETileType tileType) const {
557 return nullptr;
558 }
559
560 const DmaBdLayout *getDmaBdLayout(int col, int row) const {
561 return getDmaBdLayout(getTileType(col, row));
562 }
563
564 /// Return the array address of the dma buffer descriptor for the given
565 /// col, row, buffer descriptor id, channel and direction. Not all
566 /// architecture variants will use channel and direction so these have default
567 /// values.
568 virtual uint64_t getDmaBdAddress(
569 int col, int row, uint32_t bd_id, int channel = -1,
570 AIE::DMAChannelDir direction = AIE::DMAChannelDir::MM2S) const = 0;
571
572 /// Return the offset of the base address field within the shim dma buffer
573 /// descriptor.
574 virtual uint32_t getDmaBdAddressOffset(int col, int row) const = 0;
575
576 /// Return the array address of the dma task queue register for the given
577 /// col, row, channel and direction
578 virtual uint32_t getDmaControlAddress(int col, int row, int channel,
579 AIE::DMAChannelDir direction) const = 0;
580
581 /// Return the address of the DMA status register for a channel, or nullopt
582 /// when this target's layout has not been verified. The register carries the
583 /// live task-queue occupancy in getDmaTaskQueueSizeMask(), which is the only
584 /// way to observe queue space: the queue does not backpressure, so a push
585 /// onto a full queue is dropped rather than stalled.
586 virtual std::optional<uint32_t>
587 getDmaStatusAddress(int /*col*/, int /*row*/, int /*channel*/,
588 AIE::DMAChannelDir /*direction*/) const {
589 return std::nullopt;
590 }
591
592 /// Return the mask selecting the live task-queue occupancy field within the
593 /// getDmaStatusAddress() register (0 when unsupported). The field does not
594 /// count the task the channel is running.
595 virtual uint32_t getDmaTaskQueueSizeMask() const { return 0; }
596
597 /// Return the bits of the getDmaStatusAddress() register that are all clear
598 /// exactly when the channel has finished every task pushed to it: nothing
599 /// queued, nothing running, nothing stalled (0 when unsupported).
600 virtual uint32_t getDmaChannelIdleMask() const { return 0; }
601
602 /// Return the array address of the task queue register a push writes, the
603 /// word after the channel's control register.
604 uint32_t getDmaQueueAddress(int col, int row, int channel,
605 AIE::DMAChannelDir direction) const {
606 return getDmaControlAddress(col, row, channel, direction) + 0x4;
607 }
608
609 /// Return the DMA task-queue register address relative to its tile.
610 uint32_t getLocalDmaControlAddress(int col, int row, int channel,
611 AIE::DMAChannelDir direction) const {
612 return getDmaControlAddress(col, row, channel, direction) &
613 ((1u << getRowShift()) - 1);
614 }
615
616 virtual uint32_t getNumMemTileRows() const = 0;
617 /// Return the size (in bytes) of a MemTile.
618 virtual uint32_t getMemTileSize() const = 0;
619 /// Return the number of memory banks of a given tile.
620 virtual uint32_t getNumBanks(int col, int row) const = 0;
621
622 virtual uint32_t getMaxChannelNumForAdjacentMemTile(int col,
623 int row) const = 0;
624
625 /// Return the number of destinations of connections inside a switchbox. These
626 /// are the targets of connect operations in the switchbox.
627 virtual uint32_t getNumDestSwitchboxConnections(int col, int row,
628 WireBundle bundle) const = 0;
629 /// Return the number of sources of connections inside a switchbox. These are
630 /// the origins of connect operations in the switchbox.
631 virtual uint32_t
633 WireBundle bundle) const = 0;
634 /// Return the number of destinations of connections inside a shimmux. These
635 /// are the targets of connect operations in the switchbox.
636 virtual uint32_t getNumDestShimMuxConnections(int col, int row,
637 WireBundle bundle) const = 0;
638 /// Return the number of sources of connections inside a shimmux. These are
639 /// the origins of connect operations in the switchbox.
640 virtual uint32_t getNumSourceShimMuxConnections(int col, int row,
641 WireBundle bundle) const = 0;
642 /// Return the number of DMA channels a tile has in one direction. An MM2S
643 /// channel feeds the stream switch, or the shim mux on a shim tile, so it is
644 /// counted by that switch's DMA sources; an S2MM channel by its DMA
645 /// destinations. Prefer this to the TileOp connection accessors, which are
646 /// named from the switch's side and so read the other way round.
647 uint32_t getNumDMAChannels(int col, int row, AIE::DMAChannelDir dir) const;
648
649 /// Return the number of packet-rule slots per stream-switch slave port.
650 virtual uint32_t getNumSlaveSlots() const = 0;
651 /// Return the number of arbiters per stream switch.
652 virtual uint32_t getNumArbiters() const = 0;
653 /// Return the number of master select values per stream-switch arbiter.
654 virtual uint32_t getNumMselsPerArbiter() const = 0;
655 /// Return the largest packet id the stream switch can route.
656 virtual uint32_t getMaxPacketId() const = 0;
657
658 /// Bits a packet id spans, and the mask a switch's id match uses.
659 int getPacketIdBits() const {
660 return llvm::Log2_32_Ceil(getMaxPacketId() + 1);
661 }
662 int getPacketIdMask() const { return (1 << getPacketIdBits()) - 1; }
663 /// Return the largest out-of-order BD id (unsupported = 0).
664 virtual uint32_t getMaxOutOfOrderId() const = 0;
665 /// Return the largest DMA task repeat count (unsupported = 0).
666 virtual uint32_t getMaxRepeatCount() const = 0;
667
668 /// Return how many DMA tasks a single channel's task queue holds
669 /// (unsupported = 0). Pushing to a full queue drops the push and sets the
670 /// channel's sticky Task_Queue_Overflow bit, stranding whoever waits on that
671 /// transfer. Flat rather than per-tile-type because aie-codegen's
672 /// XAie_DmaGetMaxQueueSize (XAIE_DMA_MAX_QUEUE_SIZE) returns the same depth
673 /// for every tile type and architecture.
674 virtual uint32_t getDmaTaskQueueDepth() const = 0;
675
676 /// Return the task-queue depth for one channel. The queue is a per-channel
677 /// resource in hardware, but no shipping target gives channels different
678 /// depths, so this forwards to the flat accessor; carrying the parameters
679 /// spares call sites churn if one ever does.
680 uint32_t getDmaTaskQueueDepth(int /*col*/, int /*row*/, int /*channel*/,
681 AIE::DMAChannelDir /*direction*/) const {
682 return getDmaTaskQueueDepth();
683 }
684
685 // Return true if the stream switch connection is legal, false otherwise.
686 virtual bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
687 int srcChan, WireBundle dstBundle,
688 int dstChan) const = 0;
689
690 // Run consistency checks on the target model.
691 void validate() const;
692
693 uint32_t getModelProperties() const { return ModelProperties; }
694 void addModelProperty(uint32_t prop) { ModelProperties |= prop; }
695 // Return true if this device has a given property.
696 bool hasProperty(ModelProperty Prop) const {
697 return (getModelProperties() & Prop) == Prop;
698 }
699
700 // Return the bit offset of the column within a tile address.
701 // This is used to compute the control address of a tile from it's column
702 // location.
703 virtual uint32_t getColumnShift() const = 0;
704
705 // Return the bit offset of the row within a tile address.
706 // This is used to compute the control address of a tile from it's row
707 // location.
708 virtual uint32_t getRowShift() const = 0;
709
710 // Returns the list of possible burst encodings (first) and
711 // their corresponding lengths in bytes (second).
712 virtual std::vector<std::pair<uint32_t, uint32_t>>
714
715 // Returns the default 4-bit AxCACHE value used for shim NOC DMA AXI-MM
716 // transfers when a `dma_bd`/`npu.writebd`'s `axcache` attribute is unset.
717 // Tuned to 2 to enable upsizing in the NoC. No target currently needs
718 // a different value, so this is a single non-pure-virtual default rather
719 // than a per-architecture override.
720 virtual uint32_t getDefaultAxCache() const { return 2; }
721
722 // Returns true if the target model supports the given block format.
723 virtual bool isSupportedBlockFormat(std::string const &format) const;
724
725 // Returns true if the target supports a constant pad value on MemTile MM2S
726 // DMA channels (register=CONSTANT_PAD_VALUE).
727 virtual bool isMemTilePadValueSupported() const { return false; }
728
729 /// Register Database API - provides access to register and event information
730 /// for trace configuration and low-level register access.
731
732 /// Lookup register information by name and tile.
733 /// Return pointer to register info, or nullptr if not found
734 const RegisterInfo *lookupRegister(llvm::StringRef name, TileID tile,
735 bool isMem = false) const;
736
737 /// Lookup event number by name and tile.
738 /// Return Event number if found, nullopt otherwise
739 std::optional<uint32_t> lookupEvent(llvm::StringRef name, TileID tile,
740 bool isMem = false) const;
741
742 /// Encode a field value with proper bit shifting.
743 /// Return nullopt if value does not fit in the field's bit width.
744 std::optional<uint32_t> encodeFieldValue(const BitFieldInfo &field,
745 uint32_t value) const;
746
747 /// Compute a 32-bit mask for a register field.
748 /// Return nullopt if the field does not fit in a 32-bit register.
749 std::optional<uint32_t> getFieldMask(const BitFieldInfo &field) const;
750
751 /// Return a mapping from tile coordinates to controller IDs.
752 /// When columnWiseUniqueIDs is true (default), IDs are unique within each
753 /// column. Otherwise they are globally unique across the device.
754 llvm::DenseMap<TileID, int>
755 getTileToControllerIdMap(bool columnWiseUniqueIDs = true) const;
756
757 /// Resolve stream switch port specification to port index.
758 /// Return Port index for stream switch register, or nullopt if invalid
759 std::optional<uint32_t> resolvePortValue(llvm::StringRef value, TileID tile,
760 bool master) const;
761};
762
764public:
766
767 AIEArch getTargetArch() const override;
768
769 uint32_t getNumSlaveSlots() const override { return 4; }
770 uint32_t getNumArbiters() const override { return 6; }
771 uint32_t getNumMselsPerArbiter() const override { return 4; }
772 uint32_t getMaxPacketId() const override { return 31; }
773 uint32_t getMaxOutOfOrderId() const override { return 0; }
774 uint32_t getMaxRepeatCount() const override { return 0; }
775 // AIE1 has no queued DMA-task model (BDs are started directly), so there is
776 // no queue to overflow.
777 uint32_t getDmaTaskQueueDepth() const override { return 0; }
778
779 std::optional<TileID> getMemWest(TileID src) const override;
780 std::optional<TileID> getMemEast(TileID src) const override;
781 std::optional<TileID> getMemNorth(TileID src) const override;
782 std::optional<TileID> getMemSouth(TileID src) const override;
783
784 bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override;
785 bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override;
786 bool isMemNorth(int srcCol, int srcRow, int dstCol,
787 int dstRow) const override;
788 bool isMemSouth(int srcCol, int srcRow, int dstCol,
789 int dstRow) const override;
790
791 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
792 int memRow) const override;
793
794 uint32_t getMemInternalBaseAddress(TileID src) const override {
795 if (src.row % 2 == 0)
796 // Internal is West
797 return getMemWestBaseAddress();
798 // Internal is East
799 return getMemEastBaseAddress();
800 }
801
802 uint32_t getMemSouthBaseAddress() const override { return 0x00020000; }
803 uint32_t getMemWestBaseAddress() const override { return 0x00028000; }
804 uint32_t getMemNorthBaseAddress() const override { return 0x00030000; }
805 uint32_t getMemEastBaseAddress() const override { return 0x00038000; }
806 uint32_t getLocalMemorySize() const override { return 0x00008000; }
807 uint32_t getProgramMemorySize() const override { return 0x00004000; }
808 uint32_t getCoreDataAddressSpaceSize() const override { return 0x00100000; }
809 uint32_t getAccumulatorCascadeSize() const override { return 384; }
810 uint32_t getComputeTileLoadStoreBusWidth() const override { return 128; }
811 uint32_t getComputeTileMaxVectorAlignBits() const override { return 128; }
812
814 uint32_t getNumLocks(AIETileType tileType) const override {
815 return 16; // AIE1 has no MemTiles, always 16
816 }
817 uint32_t getMaxLockValue() const override { return 1; }
818 std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
819 TileID tile) const override;
820 uint32_t getNumBDs(AIETileType tileType) const override {
821 return 16; // AIE1 has no MemTiles, always 16
822 }
823 uint32_t getBDMaxDims(AIETileType tileType) const override {
824 // AIE1 has no MemTiles; preserve the historical BD dimension limit.
825 return 3;
826 }
827 uint64_t getDmaBdMaxLen(AIETileType tileType) const override {
828 // AIE1 has no mem tiles. Core tiles use a 13-bit length field with a +1
829 // hardware encoding (max 2^13 = 8192 32-bit words); shim tiles use a full
830 // 32-bit length register.
831 if (tileType == AIETileType::CoreTile)
832 return 1ull << 13;
833 return 0xFFFFFFFFull;
834 }
835 uint32_t getDmaBdWrapBits(AIETileType tileType) const override {
836 // AIE1 core tiles have 8-bit wrap fields; shim tiles have 10-bit.
837 return tileType == AIETileType::CoreTile ? 8 : 10;
838 }
839 uint32_t getDmaBdStepBits(AIETileType tileType) const override {
840 // AIE1 core tiles have 13-bit step fields; shim tiles have 20-bit.
841 return tileType == AIETileType::CoreTile ? 13 : 20;
842 }
843 uint32_t getDmaBdIterBits(AIETileType tileType) const override {
844 // AIE1 core and shim tiles both have a 6-bit Iteration_Wrap field.
845 return 6;
846 }
847 bool isBdChannelAccessible(int col, int row, uint32_t bd_id,
848 int channel) const override {
849 return true;
850 }
851
852 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
853 AIE::DMAChannelDir direction) const override;
854
855 uint32_t getDmaBdAddressOffset(int col, int row) const override;
856
857 uint32_t getDmaControlAddress(int col, int row, int channel,
858 AIE::DMAChannelDir direction) const override;
859
860 uint32_t getNumMemTileRows() const override { return 0; }
861 uint32_t getMemTileSize() const override { return 0; }
862 uint32_t getNumBanks(int col, int row) const override { return 4; }
863
864 uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override {
865 return 0;
866 }
867
868 uint32_t getNumDestSwitchboxConnections(int col, int row,
869 WireBundle bundle) const override;
870 uint32_t getNumSourceSwitchboxConnections(int col, int row,
871 WireBundle bundle) const override;
872 uint32_t getNumDestShimMuxConnections(int col, int row,
873 WireBundle bundle) const override;
874 uint32_t getNumSourceShimMuxConnections(int col, int row,
875 WireBundle bundle) const override;
876 bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
877 int srcChan, WireBundle dstBundle,
878 int dstChan) const override;
879
880 std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
881 WireBundle bundle,
882 uint32_t port_num,
883 bool master) const override;
884
885 uint32_t getColumnShift() const override { return 23; }
886 uint32_t getRowShift() const override { return 18; }
887
888 static bool classof(const AIETargetModel *model) {
889 return model->getKind() >= TK_AIE1_VC1902 &&
890 model->getKind() < TK_AIE1_Last;
891 }
892
893 std::vector<std::pair<uint32_t, uint32_t>>
894 getShimBurstEncodingsAndLengths() const override;
895};
896
898protected:
899 std::unique_ptr<RegisterDatabase> loadRegisterDatabase() const override;
900
901public:
910
911 AIEArch getTargetArch() const override;
912
913 // Cascade input comes from the North or West, output goes South or East.
914 llvm::ArrayRef<std::pair<int, int>> getCascadeSteps() const override {
915 static constexpr std::pair<int, int> steps[] = {{0, -1}, {1, 0}};
916 return steps;
917 }
918
919 uint32_t getAddressGenGranularity() const override { return 32; }
920
921 uint32_t getNumSlaveSlots() const override { return 4; }
922 uint32_t getNumArbiters() const override { return 6; }
923 uint32_t getNumMselsPerArbiter() const override { return 4; }
924 uint32_t getMaxPacketId() const override { return 31; }
925 uint32_t getMaxOutOfOrderId() const override { return 63; }
926 uint32_t getMaxRepeatCount() const override { return 255; }
927 uint32_t getDmaTaskQueueDepth() const override { return 4; }
928
929 std::optional<TileID> getMemWest(TileID src) const override;
930 std::optional<TileID> getMemEast(TileID src) const override;
931 std::optional<TileID> getMemNorth(TileID src) const override;
932 std::optional<TileID> getMemSouth(TileID src) const override;
933
934 bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override;
935 bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override;
936 bool isMemNorth(int srcCol, int srcRow, int dstCol,
937 int dstRow) const override;
938 bool isMemSouth(int srcCol, int srcRow, int dstCol,
939 int dstRow) const override;
940
941 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
942 int memRow) const override;
943
944 uint32_t getMemInternalBaseAddress(TileID src) const override {
945 return getMemEastBaseAddress();
946 }
947
948 uint32_t getMemSouthBaseAddress() const override { return 0x00040000; }
949 uint32_t getMemWestBaseAddress() const override { return 0x00050000; }
950 uint32_t getMemNorthBaseAddress() const override { return 0x00060000; }
951 uint32_t getMemEastBaseAddress() const override { return 0x00070000; }
952 uint32_t getLocalMemorySize() const override { return 0x00010000; }
953 uint32_t getProgramMemorySize() const override { return 0x00004000; }
954 uint32_t getCoreDataAddressSpaceSize() const override { return 0x00100000; }
955 uint32_t getAccumulatorCascadeSize() const override { return 512; }
956 uint32_t getComputeTileLoadStoreBusWidth() const override { return 256; }
957 uint32_t getComputeTileMaxVectorAlignBits() const override { return 256; }
958
960 uint32_t getNumLocks(AIETileType tileType) const override {
961 return tileType == AIETileType::MemTile ? 64 : 16;
962 }
963
964 uint32_t getMaxLockValue() const override { return 0x3F; }
965
966 std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
967 TileID tile) const override;
968
969 uint32_t getNumBDs(AIETileType tileType) const override {
970 return tileType == AIETileType::MemTile ? 48 : 16;
971 }
972 uint32_t getBDMaxDims(AIETileType tileType) const override {
973 // MemTile BDs support 4 ND dimensions; core and shim BDs support 3.
974 return tileType == AIETileType::MemTile ? 4 : 3;
975 }
976 // The field limits read off the BD layout the lowerings pack through, the
977 // shim's for tiles without one.
978 const DmaBdLayout &getDmaBdLimits(AIETileType tileType) const {
979 const DmaBdLayout *layout = getDmaBdLayout(tileType);
980 return layout ? *layout : *getDmaBdLayout(AIETileType::ShimNOCTile);
981 }
982 uint64_t getDmaBdMaxLen(AIETileType tileType) const override {
983 return getDmaBdLimits(tileType).bufferLength.mask();
984 }
985 uint32_t getDmaBdWrapBits(AIETileType tileType) const override {
986 return getDmaBdLimits(tileType).d0Size.width;
987 }
988 uint32_t getDmaBdStepBits(AIETileType tileType) const override {
989 return getDmaBdLimits(tileType).d0Stride.width;
990 }
991 uint32_t getDmaBdIterBits(AIETileType tileType) const override {
992 return getDmaBdLimits(tileType).iterationSize.width;
993 }
994
995 bool isBdChannelAccessible(int col, int row, uint32_t bd_id,
996 int channel) const override {
997 if (getTileType(col, row) != AIETileType::MemTile) {
998 return true;
999 } else {
1000 if ((channel & 1) == 0) { // even channel number
1001 return bd_id < 24;
1002 } else {
1003 return bd_id >= 24;
1004 }
1005 }
1006 }
1007
1009 const DmaBdLayout *getDmaBdLayout(AIETileType tileType) const override;
1010
1011 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
1012 AIE::DMAChannelDir direction) const override;
1013
1014 uint32_t getDmaBdAddressOffset(int col, int row) const override;
1015
1016 uint32_t getDmaControlAddress(int col, int row, int channel,
1017 AIE::DMAChannelDir direction) const override;
1018 std::optional<uint32_t>
1019 getDmaStatusAddress(int col, int row, int channel,
1020 AIE::DMAChannelDir direction) const override;
1021 // Task_Queue_Size, bits 22:20 of the DMA_{MM2S,S2MM}_Status_N register.
1022 uint32_t getDmaTaskQueueSizeMask() const override { return 0x7u << 20; }
1023 // Task_Queue_Size, Channel_Running (bit 19) and the four Stalled_* bits
1024 // (5:2): what aie-codegen's _XAieMl_DmaWaitForDone polls clear. aie-codegen's
1025 // pending count adds one to Task_Queue_Size for Channel_Running or a stall,
1026 // which is why the field alone does not cover the running task.
1027 uint32_t getDmaChannelIdleMask() const override {
1028 return getDmaTaskQueueSizeMask() | (1u << 19) | 0x3Cu;
1029 }
1030
1031 uint32_t getMemTileSize() const override { return 0x00080000; }
1032
1033 uint32_t getNumBanks(int col, int row) const override {
1034 return getTileType(col, row) == AIETileType::MemTile ? 8 : 4;
1035 }
1036
1037 uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override {
1038 return 4;
1039 }
1040
1041 uint32_t getNumDestSwitchboxConnections(int col, int row,
1042 WireBundle bundle) const override;
1043 uint32_t getNumSourceSwitchboxConnections(int col, int row,
1044 WireBundle bundle) const override;
1045 uint32_t getNumDestShimMuxConnections(int col, int row,
1046 WireBundle bundle) const override;
1047 uint32_t getNumSourceShimMuxConnections(int col, int row,
1048 WireBundle bundle) const override;
1049 bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
1050 int srcChan, WireBundle dstBundle,
1051 int dstChan) const override;
1052
1053 std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
1054 WireBundle bundle,
1055 uint32_t port_num,
1056 bool master) const override;
1057
1058 uint32_t getColumnShift() const override { return 25; }
1059 uint32_t getRowShift() const override { return 20; }
1060
1061 static bool classof(const AIETargetModel *model) {
1062 return model->getKind() >= TK_AIE2_VE2302 &&
1063 model->getKind() < TK_AIE2_Last;
1064 }
1065
1066 std::vector<std::pair<uint32_t, uint32_t>>
1067 getShimBurstEncodingsAndLengths() const override;
1068};
1069
1070// AIE2PS base model
1072public:
1074 // AIE2PS is an NPU but uses CERT ELF, not CDO/xclbin.
1076 }
1077
1078 AIEArch getTargetArch() const override { return AIEArch::AIE2ps; }
1079 // AIE2P/AIE2PS: a full-width (512-bit) vector access requires 512-bit
1080 // alignment, stricter than the 256-bit load/store bus. See aie_api's
1081 // vector_ldst_align for __AIE_ARCH__ 21/22.
1082 uint32_t getComputeTileMaxVectorAlignBits() const override { return 512; }
1083
1084 uint32_t getNumControllersPerColumn() const override { return 1; }
1085
1086 // AIE2PS supports 512B burst (same as AIE2P)
1087 std::vector<std::pair<uint32_t, uint32_t>>
1089 return {std::pair(0, 64), std::pair(1, 128), std::pair(2, 256),
1090 std::pair(3, 512)};
1091 }
1092
1093 // TODO(aie2ps): AIE2PS changed block floating point from bfp16 to
1094 // MX9/MX6/MX4. isSupportedBlockFormat() currently returns false (inherited).
1095 // Override with correct MX format strings when ML kernels need it.
1096
1097 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
1098 AIE::DMAChannelDir direction) const override;
1099 uint32_t getDmaControlAddress(int col, int row, int channel,
1100 AIE::DMAChannelDir direction) const override;
1101 std::optional<uint32_t>
1102 getDmaStatusAddress(int col, int row, int channel,
1103 AIE::DMAChannelDir direction) const override;
1104
1105 uint32_t getNumDestSwitchboxConnections(int col, int row,
1106 WireBundle bundle) const override;
1107 uint32_t getNumSourceSwitchboxConnections(int col, int row,
1108 WireBundle bundle) const override;
1109 std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
1110 WireBundle bundle,
1111 uint32_t channel,
1112 bool master) const override;
1113
1114 static bool classof(const AIETargetModel *model) {
1115 return model->getKind() >= TK_AIE2PS_VE3858 &&
1116 model->getKind() < TK_AIE2PS_Last;
1117 }
1118};
1119
1120// VE3858 target model (AIE2PS, xc2ve3858 on VEK385)
1121// 36 columns, 7 rows: 1 shim + 2 memtile + 4 core
1123public:
1125
1126 int columns() const override { return 36; }
1127 int rows() const override { return 7; }
1128
1129 // AIE2PS Shim-South tiles (cols 1-23) have both NoC and PL.
1130 // Shim-Global (col 0) has NoC only. Modeling all as ShimNOC is a working
1131 // approximation for the CERT compilation path.
1132 AIETileType getTileType(int col, int row) const override {
1133 if (row == 0)
1134 return AIETileType::ShimNOCTile;
1135 if (row <= 2)
1136 return AIETileType::MemTile;
1137 return AIETileType::CoreTile;
1138 }
1139
1140 uint32_t getNumMemTileRows() const override { return 2; }
1141
1142 static bool classof(const AIETargetModel *model) {
1143 return model->getKind() == TK_AIE2PS_VE3858;
1144 }
1145};
1146
1148 llvm::SmallDenseSet<unsigned, 16> nocColumns = {
1149 2, 3, 6, 7, 10, 11, 18, 19, 26, 27, 34, 35, 42, 43, 46, 47};
1150
1151public:
1153
1154 uint32_t getAddressGenGranularity() const override { return 32; }
1155
1156 int columns() const override { return 50; }
1157
1158 int rows() const override { return 9; /* One Shim row and 8 Core rows. */ }
1159
1160 AIETileType getTileType(int col, int row) const override {
1161 if (row == 0) {
1162 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1163 : AIETileType::ShimPLTile;
1164 }
1165 return AIETileType::CoreTile; // AIE1 has no MemTiles
1166 }
1167
1168 static bool classof(const AIETargetModel *model) {
1169 return model->getKind() == TK_AIE1_VC1902;
1170 }
1171};
1172
1174 llvm::SmallDenseSet<unsigned, 8> nocColumns = {2, 3, 6, 7, 10, 11};
1175
1176public:
1178
1179 int columns() const override { return 17; }
1180
1181 int rows() const override {
1182 return 4; /* One Shim row, 1 memtile rows, and 2 Core rows. */
1183 }
1184
1185 AIETileType getTileType(int col, int row) const override {
1186 if (row == 0) {
1187 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1188 : AIETileType::ShimPLTile;
1189 }
1190 if (row == 1)
1191 return AIETileType::MemTile;
1192 return AIETileType::CoreTile;
1193 }
1194
1195 uint32_t getNumMemTileRows() const override { return 1; }
1196
1197 static bool classof(const AIETargetModel *model) {
1198 return model->getKind() == TK_AIE2_VE2302;
1199 }
1200};
1201
1203 llvm::SmallDenseSet<unsigned, 16> nocColumns = {2, 3, 6, 7, 14, 15,
1204 22, 23, 30, 31, 34, 35};
1205
1206public:
1208
1209 int columns() const override { return 38; }
1210
1211 int rows() const override {
1212 return 11; /* One Shim row, 2 memtile rows, and 8 Core rows. */
1213 }
1214
1215 AIETileType getTileType(int col, int row) const override {
1216 if (row == 0) {
1217 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1218 : AIETileType::ShimPLTile;
1219 }
1220 if (row == 1 || row == 2)
1221 return AIETileType::MemTile;
1222 return AIETileType::CoreTile;
1223 }
1224
1225 uint32_t getNumMemTileRows() const override { return 2; }
1226
1227 static bool classof(const AIETargetModel *model) {
1228 return model->getKind() == TK_AIE2_VE2802;
1229 }
1230};
1231
1233public:
1237
1238 int rows() const override {
1239 return 6; /* 1 Shim row, 1 memtile row, and 4 Core rows. */
1240 }
1241
1242 int physicalColumns() const override { return 4; }
1243
1244 uint32_t getNumMemTileRows() const override { return 1; }
1245
1246 uint32_t getNumControllers() const override { return 1; }
1247
1248 static bool classof(const AIETargetModel *model) {
1249 return model->getKind() >= TK_AIE2_NPU1_1Col &&
1250 model->getKind() < TK_AIE2_NPU1_Last;
1251 }
1252};
1253
1254// A sub-portion of the Phoenix NPU
1256 int cols;
1257
1258public:
1260 : BaseNPU1TargetModel(static_cast<TargetModelKind>(
1261 static_cast<std::underlying_type_t<TargetModelKind>>(
1263 _cols - 1)),
1264 cols(_cols) {
1265 // Device properties initialization
1267 }
1268
1269 int columns() const override { return cols; }
1270
1271 AIETileType getTileType(int col, int row) const override {
1272 if (row == 0)
1273 return AIETileType::ShimNOCTile; // NPU1 has no ShimPL tiles
1274 if (row == 1)
1275 return AIETileType::MemTile;
1276 return AIETileType::CoreTile;
1277 }
1278
1279 static bool classof(const AIETargetModel *model) {
1280 return model->getKind() >= TK_AIE2_NPU1_1Col &&
1281 model->getKind() < TK_AIE2_NPU1_Last;
1282 }
1283};
1284
1286public:
1290
1291 AIEArch getTargetArch() const override;
1292 // AIE2P/AIE2PS: a full-width (512-bit) vector access requires 512-bit
1293 // alignment, stricter than the 256-bit load/store bus. See aie_api's
1294 // vector_ldst_align for __AIE_ARCH__ 21/22.
1295 uint32_t getComputeTileMaxVectorAlignBits() const override { return 512; }
1296
1297 int rows() const override {
1298 return 6; /* 1 Shim row, 1 memtile row, and 4 Core rows. */
1299 }
1300
1301 int physicalColumns() const override { return 8; }
1302
1303 AIETileType getTileType(int col, int row) const override {
1304 if (row == 0)
1305 return AIETileType::ShimNOCTile;
1306 if (row == 1)
1307 return AIETileType::MemTile;
1308 return AIETileType::CoreTile;
1309 }
1310
1311 uint32_t getNumMemTileRows() const override { return 1; }
1312
1313 std::vector<std::pair<uint32_t, uint32_t>>
1314 getShimBurstEncodingsAndLengths() const override;
1315
1316 bool isSupportedBlockFormat(std::string const &format) const override;
1317
1318 bool isMemTilePadValueSupported() const override { return true; }
1319
1320 uint32_t getNumControllers() const override { return 1; }
1321
1322 static bool classof(const AIETargetModel *model) {
1323 return model->getKind() >= TK_AIE2_NPU2 &&
1324 model->getKind() < TK_AIE2_NPU2_Last;
1325 }
1326};
1327
1328// The full Strix NPU
1330public:
1332
1333 int columns() const override { return 8; }
1334
1335 static bool classof(const AIETargetModel *model) {
1336 return model->getKind() == TK_AIE2_NPU2;
1337 }
1338};
1339
1340// A sub-portion of the Strix NPU
1342 int cols;
1343
1344public:
1346 : BaseNPU2TargetModel(static_cast<TargetModelKind>(
1347 static_cast<std::underlying_type_t<TargetModelKind>>(TK_AIE2_NPU2) +
1348 _cols)),
1349 cols(_cols) {
1350 // Device properties initialization
1352 }
1353
1354 int columns() const override { return cols; }
1355
1356 static bool classof(const AIETargetModel *model) {
1357 return model->getKind() >= TK_AIE2_NPU2_1Col &&
1358 model->getKind() < TK_AIE2_NPU2_Last;
1359 }
1360};
1361
1362/// \brief Device generation ID written into the TXN header
1363/// (aie_runtime::TxnDeviceInfo::devGen). Both the static binary emitter and the
1364/// generated-C++ builder read it from here, so a new device family is one edit.
1365inline uint8_t txnDeviceGen(const AIETargetModel &tm) {
1366 return llvm::isa<BaseNPU2TargetModel>(tm) ? 4 : 3;
1367}
1368
1369} // namespace xilinx::AIE
1370
1371namespace llvm {
1372template <>
1373struct DenseMapInfo<xilinx::AIE::TileID> {
1374 using FirstInfo = DenseMapInfo<int>;
1375 using SecondInfo = DenseMapInfo<int>;
1376
1377 static unsigned getHashValue(const xilinx::AIE::TileID &t) {
1378 return detail::combineHashValue(FirstInfo::getHashValue(t.col),
1379 SecondInfo::getHashValue(t.row));
1380 }
1381
1382 static bool isEqual(const xilinx::AIE::TileID &lhs,
1383 const xilinx::AIE::TileID &rhs) {
1384 return lhs == rhs;
1385 }
1386};
1387} // namespace llvm
1388
1389template <>
1390struct std::hash<xilinx::AIE::TileID> {
1391 std::size_t operator()(const xilinx::AIE::TileID &s) const noexcept {
1392 std::size_t h1 = std::hash<int>{}(s.col);
1393 std::size_t h2 = std::hash<int>{}(s.row);
1394 return h1 ^ (h2 << 1);
1395 }
1396};
1397
1398#endif
uint32_t getLocalMemorySize() const override
Return the size (in bytes) of the local data memory of a core.
uint32_t getDmaBdIterBits(AIETileType tileType) const override
Return the bit width of the iteration (repeat) wrap/stride fields in a DMA buffer descriptor for the ...
uint32_t getNumMemTileRows() const override
uint32_t getMaxOutOfOrderId() const override
Return the largest out-of-order BD id (unsupported = 0).
bool isMemNorth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is North of dst.
uint32_t getMemWestBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getNumBanks(int col, int row) const override
Return the number of memory banks of a given tile.
uint64_t getDmaBdMaxLen(AIETileType tileType) const override
Return the maximum transfer length, measured in address-generation granules (see getAddressGenGranula...
uint32_t getDmaBdWrapBits(AIETileType tileType) const override
Return the bit width of the wrap (size) field in a DMA buffer descriptor for the given tile type.
uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma task queue register for the given col, row, channel and direction...
std::optional< TileID > getMemSouth(TileID src) const override
Return the tile ID of the memory to the south of the given tile, if it exists.
std::optional< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const override
uint32_t getCoreDataAddressSpaceSize() const override
Return the size (in bytes) of the address space a core can issue data accesses into.
uint32_t getProgramMemorySize() const override
Return the size (in bytes) of a core's program memory.
static bool classof(const AIETargetModel *model)
std::optional< TileID > getMemNorth(TileID src) const override
Return the tile ID of the memory to the north of the given tile, if it exists.
uint32_t getMemInternalBaseAddress(TileID src) const override
Return the base address in the local address map for a core.
std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t port_num, bool master) const override
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
uint32_t getDmaTaskQueueDepth() const override
Return how many DMA tasks a single channel's task queue holds (unsupported = 0).
uint32_t getDmaBdStepBits(AIETileType tileType) const override
Return the bit width of the step (stride) field in a DMA buffer descriptor for the given tile type.
bool isBdChannelAccessible(int col, int row, uint32_t bd_id, int channel) const override
Return true iff buffer descriptor bd_id on tile (col, row) can be submitted on channel channel.
bool isMemSouth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is South of dst.
uint32_t getMemEastBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMaxRepeatCount() const override
Return the largest DMA task repeat count (unsupported = 0).
std::optional< TileID > getMemWest(TileID src) const override
Return the tile ID of the memory to the west of the given tile, if it exists.
bool isLegalMemAffinity(int coreCol, int coreRow, int memCol, int memRow) const override
Return true if core can access the memory in mem.
uint32_t getNumMselsPerArbiter() const override
Return the number of master select values per stream-switch arbiter.
uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
uint32_t getRowShift() const override
uint32_t getBDMaxDims(AIETileType tileType) const override
Return the maximum number of addressing dimensions (wraps/strides) a single buffer descriptor support...
uint32_t getNumArbiters() const override
Return the number of arbiters per stream switch.
uint32_t getNumSlaveSlots() const override
Return the number of packet-rule slots per stream-switch slave port.
uint32_t getNumSourceShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a shimmux.
uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a switchbox.
uint32_t getColumnShift() const override
bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is East of dst.
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is West of dst.
uint32_t getNumLocks(AIETileType tileType) const override
Return the number of lock objects for a given tile type.
uint32_t getDmaBdAddressOffset(int col, int row) const override
Return the offset of the base address field within the shim dma buffer descriptor.
uint32_t getComputeTileLoadStoreBusWidth() const override
Return the data bus width (in bits) for load/store operations of a compute core.
uint32_t getAccumulatorCascadeSize() const override
Return the size (in bits) of the accumulator/cascade.
AIE1TargetModel(TargetModelKind k)
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
uint32_t getMemTileSize() const override
Return the size (in bytes) of a MemTile.
uint32_t getMemSouthBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override
AIEArch getTargetArch() const override
AIE1 TargetModel.
uint32_t getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a shimmux.
uint32_t getMemNorthBaseAddress() const override
Return the base address in the local address map for a core.
std::optional< TileID > getMemEast(TileID src) const override
Return the tile ID of the memory to the east of the given tile, if it exists.
uint32_t getNumBDs(AIETileType tileType) const override
Return the number of buffer descriptors for a given tile type.
bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const override
uint32_t getMaxLockValue() const override
Return the maximum value that can be stored in a lock register.
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
uint32_t getMaxPacketId() const override
Return the largest packet id the stream switch can route.
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma task queue register for the given col, row, channel and direction...
uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a switchbox.
AIEArch getTargetArch() const override
Return the target architecture.
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
std::optional< uint32_t > getDmaStatusAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the address of the DMA status register for a channel, or nullopt when this target's layout has...
uint32_t getNumControllersPerColumn() const override
Number of microcontrollers (uC) per column.
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t channel, bool master) const override
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
AIE2PSTargetModel(TargetModelKind k)
static bool classof(const AIETargetModel *model)
uint32_t getRowShift() const override
uint32_t getMemWestBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMemSouthBaseAddress() const override
Return the base address in the local address map for a core.
bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const override
llvm::ArrayRef< std::pair< int, int > > getCascadeSteps() const override
The steps (destination column - source column, destination row - source row) from one core's cascade ...
uint32_t getNumMselsPerArbiter() const override
Return the number of master select values per stream-switch arbiter.
uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a switchbox.
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
uint32_t getCoreDataAddressSpaceSize() const override
Return the size (in bytes) of the address space a core can issue data accesses into.
uint32_t getNumLocks(AIETileType tileType) const override
Return the number of lock objects for a given tile type.
std::optional< uint32_t > getDmaStatusAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the address of the DMA status register for a channel, or nullopt when this target's layout has...
uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override
uint32_t getAddressGenGranularity() const override
Return the data bus width of the device.
std::optional< TileID > getMemWest(TileID src) const override
Return the tile ID of the memory to the west of the given tile, if it exists.
std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t port_num, bool master) const override
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
uint32_t getAccumulatorCascadeSize() const override
Return the size (in bits) of the accumulator/cascade.
uint32_t getMaxRepeatCount() const override
Return the largest DMA task repeat count (unsupported = 0).
std::unique_ptr< RegisterDatabase > loadRegisterDatabase() const override
AIE2 TargetModel.
bool isBdChannelAccessible(int col, int row, uint32_t bd_id, int channel) const override
Return true iff buffer descriptor bd_id on tile (col, row) can be submitted on channel channel.
uint32_t getDmaBdIterBits(AIETileType tileType) const override
Return the bit width of the iteration (repeat) wrap/stride fields in a DMA buffer descriptor for the ...
AIEArch getTargetArch() const override
Return the target architecture.
bool isLegalMemAffinity(int coreCol, int coreRow, int memCol, int memRow) const override
Return true if core can access the memory in mem.
std::optional< TileID > getMemEast(TileID src) const override
Return the tile ID of the memory to the east of the given tile, if it exists.
uint32_t getDmaChannelIdleMask() const override
Return the bits of the getDmaStatusAddress() register that are all clear exactly when the channel has...
uint32_t getMaxOutOfOrderId() const override
Return the largest out-of-order BD id (unsupported = 0).
uint32_t getMaxLockValue() const override
Return the maximum value that can be stored in a lock register.
uint64_t getDmaBdMaxLen(AIETileType tileType) const override
Return the maximum transfer length, measured in address-generation granules (see getAddressGenGranula...
uint32_t getDmaBdWrapBits(AIETileType tileType) const override
Return the bit width of the wrap (size) field in a DMA buffer descriptor for the given tile type.
uint32_t getBDMaxDims(AIETileType tileType) const override
Return the maximum number of addressing dimensions (wraps/strides) a single buffer descriptor support...
uint32_t getNumArbiters() const override
Return the number of arbiters per stream switch.
bool isMemNorth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is North of dst.
uint32_t getMaxPacketId() const override
Return the largest packet id the stream switch can route.
uint32_t getLocalMemorySize() const override
Return the size (in bytes) of the local data memory of a core.
uint32_t getMemNorthBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a shimmux.
const DmaBdLayout & getDmaBdLimits(AIETileType tileType) const
uint32_t getColumnShift() const override
uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
uint32_t getDmaBdStepBits(AIETileType tileType) const override
Return the bit width of the step (stride) field in a DMA buffer descriptor for the given tile type.
uint32_t getMemEastBaseAddress() const override
Return the base address in the local address map for a core.
uint32_t getMemInternalBaseAddress(TileID src) const override
Return the base address in the local address map for a core.
uint32_t getNumBanks(int col, int row) const override
Return the number of memory banks of a given tile.
static bool classof(const AIETargetModel *model)
AIE2TargetModel(TargetModelKind k)
uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const override
Return the array address of the dma task queue register for the given col, row, channel and direction...
uint32_t getNumBDs(AIETileType tileType) const override
Return the number of buffer descriptors for a given tile type.
std::optional< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const override
uint32_t getComputeTileLoadStoreBusWidth() const override
Return the data bus width (in bits) for load/store operations of a compute core.
std::optional< TileID > getMemSouth(TileID src) const override
Return the tile ID of the memory to the south of the given tile, if it exists.
const DmaBdLayout * getDmaBdLayout(AIETileType tileType) const override
Return the register layout of a buffer descriptor on the given tile type, or null if the target has n...
uint32_t getMemTileSize() const override
Return the size (in bytes) of a MemTile.
uint32_t getProgramMemorySize() const override
Return the size (in bytes) of a core's program memory.
uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const override
Return the number of destinations of connections inside a switchbox.
bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is West of dst.
uint32_t getDmaTaskQueueSizeMask() const override
Return the mask selecting the live task-queue occupancy field within the getDmaStatusAddress() regist...
bool isMemSouth(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is South of dst.
uint32_t getDmaTaskQueueDepth() const override
Return how many DMA tasks a single channel's task queue holds (unsupported = 0).
uint32_t getNumSlaveSlots() const override
Return the number of packet-rule slots per stream-switch slave port.
std::optional< TileID > getMemNorth(TileID src) const override
Return the tile ID of the memory to the north of the given tile, if it exists.
bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override
Return true if src has a memory tile which is East of dst.
uint32_t getNumSourceShimMuxConnections(int col, int row, WireBundle bundle) const override
Return the number of sources of connections inside a shimmux.
uint32_t getDmaBdAddressOffset(int col, int row) const override
Return the offset of the base address field within the shim dma buffer descriptor.
virtual uint32_t getCoreDataAddressSpaceSize() const =0
Return the size (in bytes) of the address space a core can issue data accesses into.
std::optional< uint32_t > encodeFieldValue(const BitFieldInfo &field, uint32_t value) const
Encode a field value with proper bit shifting.
std::optional< uint32_t > resolvePortValue(llvm::StringRef value, TileID tile, bool master) const
Resolve stream switch port specification to port index.
llvm::DenseMap< TileID, int > getTileToControllerIdMap(bool columnWiseUniqueIDs=true) const
Return a mapping from tile coordinates to controller IDs.
virtual uint32_t getNumMselsPerArbiter() const =0
Return the number of master select values per stream-switch arbiter.
std::optional< uint32_t > getMemLocalBaseAddress(int localCol, int localRow, int memCol, int memRow) const
Return the memory base address (or offset) in the local tile when accessing a neighbor's memory or an...
bool isNorth(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is North of dst.
bool isSouth(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is South of dst.
uint32_t getDmaBdWrapBits(int col, int row) const
bool isWest(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is West of dst.
virtual llvm::ArrayRef< std::pair< int, int > > getCascadeSteps() const
The steps (destination column - source column, destination row - source row) from one core's cascade ...
uint32_t getLocalDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const
Return the DMA task-queue register address relative to its tile.
TargetModelKind getKind() const
virtual bool isSupportedBlockFormat(std::string const &format) const
bool isCoreTile(int col, int row) const
Return true if the given tile is a Core tile.
virtual uint64_t getDmaBdMaxLen(AIETileType tileType) const =0
Return the maximum transfer length, measured in address-generation granules (see getAddressGenGranula...
uint32_t getModelProperties() const
virtual const DmaBdLayout * getDmaBdLayout(AIETileType tileType) const
Return the register layout of a buffer descriptor on the given tile type, or null if the target has n...
virtual AIEArch getTargetArch() const =0
Return the target architecture.
virtual bool isMemNorth(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is North of dst.
virtual uint32_t getNumSourceShimMuxConnections(int col, int row, WireBundle bundle) const =0
Return the number of sources of connections inside a shimmux.
bool isMemTile(int col, int row) const
Return true if the given tile is a Mem tile.
virtual uint32_t getDmaControlAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const =0
Return the array address of the dma task queue register for the given col, row, channel and direction...
virtual uint32_t getDmaBdWrapBits(AIETileType tileType) const =0
Return the bit width of the wrap (size) field in a DMA buffer descriptor for the given tile type.
std::pair< uint32_t, uint32_t > getBdIdRangeForChannel(int col, int row, int channel) const
Return the half-open range [first, last) of buffer descriptor ids that channel channel of the tile at...
virtual uint32_t getMemSouthBaseAddress() const =0
Return the base address in the local address map for a core.
std::optional< uint32_t > getLockLocalBaseIndex(int localCol, int localRow, int lockCol, int lockRow) const
Return the lock base index (or offset) in the local tile when accessing a neighbor's lock or an empty...
virtual uint32_t getDmaChannelIdleMask() const
Return the bits of the getDmaStatusAddress() register that are all clear exactly when the channel has...
void addModelProperty(uint32_t prop)
AIETargetModel(TargetModelKind k)
virtual uint32_t getLocalMemorySize() const =0
Return the size (in bytes) of the local data memory of a core.
std::optional< uint32_t > getFieldMask(const BitFieldInfo &field) const
Compute a 32-bit mask for a register field.
virtual uint32_t getNumLocks(AIETileType tileType) const =0
Return the number of lock objects for a given tile type.
uint32_t getDmaBdIterBits(int col, int row) const
virtual uint32_t getComputeTileLoadStoreBusWidth() const =0
Return the data bus width (in bits) for load/store operations of a compute core.
std::vector< int > partitionStartColumns(int numCols) const
Every physical column offset at which a numCols-wide partition still fits.
std::optional< uint32_t > lookupEvent(llvm::StringRef name, TileID tile, bool isMem=false) const
Lookup event number by name and tile.
virtual std::optional< TileID > getMemNorth(TileID src) const =0
Return the tile ID of the memory to the north of the given tile, if it exists.
virtual int physicalColumns() const
Width of the physical array this (possibly virtualized) device is carved from.
virtual uint32_t getDmaBdIterBits(AIETileType tileType) const =0
Return the bit width of the iteration (repeat) wrap/stride fields in a DMA buffer descriptor for the ...
const RegisterInfo * lookupRegister(llvm::StringRef name, TileID tile, bool isMem=false) const
Register Database API - provides access to register and event information for trace configuration and...
virtual uint32_t getBDMaxDims(AIETileType tileType) const =0
Return the maximum number of addressing dimensions (wraps/strides) a single buffer descriptor support...
virtual std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const =0
const RegisterDatabase * getRegisterDatabase() const
Get the register database, loading it lazily on first access.
virtual bool isLegalTileConnection(int col, int row, WireBundle srcBundle, int srcChan, WireBundle dstBundle, int dstChan) const =0
virtual uint32_t getNumBanks(int col, int row) const =0
Return the number of memory banks of a given tile.
uint64_t getDmaBdMaxLen(int col, int row) const
virtual bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is East of dst.
virtual uint32_t getDmaTaskQueueDepth() const =0
Return how many DMA tasks a single channel's task queue holds (unsupported = 0).
virtual uint32_t getDmaBdStepBits(AIETileType tileType) const =0
Return the bit width of the step (stride) field in a DMA buffer descriptor for the given tile type.
bool isShimPLTile(int col, int row) const
Return true if the given tile is a ShimPL tile.
uint32_t getDmaTaskQueueDepth(int, int, int, AIE::DMAChannelDir) const
Return the task-queue depth for one channel.
virtual uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel=-1, AIE::DMAChannelDir direction=AIE::DMAChannelDir::MM2S) const =0
Return the array address of the dma buffer descriptor for the given col, row, buffer descriptor id,...
virtual bool isBdChannelAccessible(int col, int row, uint32_t bd_id, int channel) const =0
Return true iff buffer descriptor bd_id on tile (col, row) can be submitted on channel channel.
virtual uint32_t getDmaBdAddressOffset(int col, int row) const =0
Return the offset of the base address field within the shim dma buffer descriptor.
virtual uint32_t getAccumulatorCascadeSize() const =0
Return the size (in bits) of the accumulator/cascade.
virtual std::optional< uint32_t > getLocalLockAddress(uint32_t lockId, TileID tile) const =0
virtual uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const =0
virtual AIETileType getTileType(int col, int row) const =0
Return the tile type for the given tile coordinates.
uint32_t getCoreStackAlignment() const
Stack-pointer alignment in bytes, matching Peano's AIE frame lowering: AIE1/AIE2 require 32B; AIE2P/A...
virtual uint32_t getNumArbiters() const =0
Return the number of arbiters per stream switch.
virtual bool isValidTile(TileID src) const
Return true if the given tile ID is valid.
bool isEast(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is East of dst.
virtual uint32_t getDmaTaskQueueSizeMask() const
Return the mask selecting the live task-queue occupancy field within the getDmaStatusAddress() regist...
virtual bool isMemSouth(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is South of dst.
bool isShimNOCorPLTile(int col, int row) const
Return true if the given tile is either a ShimNOC or ShimPL tile.
virtual uint32_t getMaxRepeatCount() const =0
Return the largest DMA task repeat count (unsupported = 0).
virtual uint32_t getMemWestBaseAddress() const =0
Return the base address in the local address map for a core.
virtual uint32_t getNumControllersPerColumn() const
Number of microcontrollers (uC) per column.
virtual int rows() const =0
Return the number of rows in the device.
uint32_t getBDMaxDims(int col, int row) const
Return the maximum number of BD addressing dimensions for the tile at (col, row).
virtual std::optional< TileID > getMemSouth(TileID src) const =0
Return the tile ID of the memory to the south of the given tile, if it exists.
virtual std::optional< TileID > getMemEast(TileID src) const =0
Return the tile ID of the memory to the east of the given tile, if it exists.
bool isShimNOCTile(int col, int row) const
Return true if the given tile is a ShimNOC tile.
virtual uint32_t getNumBDs(AIETileType tileType) const =0
Return the number of buffer descriptors for a given tile type.
virtual uint32_t getMaxPacketId() const =0
Return the largest packet id the stream switch can route.
virtual uint32_t getMaxLockValue() const =0
Return the maximum value that can be stored in a lock register.
virtual std::unique_ptr< RegisterDatabase > loadRegisterDatabase() const
Subclasses override to provide architecture-specific database loading.
virtual uint32_t getComputeTileMaxVectorAlignBits() const
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
virtual uint32_t getProgramMemorySize() const =0
Return the size (in bytes) of a core's program memory.
virtual uint32_t getMaxOutOfOrderId() const =0
Return the largest out-of-order BD id (unsupported = 0).
virtual std::optional< TileID > getMemWest(TileID src) const =0
Return the tile ID of the memory to the west of the given tile, if it exists.
virtual uint32_t getColumnShift() const =0
virtual uint32_t getMemNorthBaseAddress() const =0
Return the base address in the local address map for a core.
uint32_t getNumLocks(int col, int row) const
Return the number of lock objects for a tile at the given coordinates.
bool hasProperty(ModelProperty Prop) const
uint32_t getDmaQueueAddress(int col, int row, int channel, AIE::DMAChannelDir direction) const
Return the array address of the task queue register a push writes, the word after the channel's contr...
uint32_t getNumDMAChannels(int col, int row, AIE::DMAChannelDir dir) const
Return the number of DMA channels a tile has in one direction.
virtual int columns() const =0
Return the number of columns in the device.
int getPacketIdBits() const
Bits a packet id spans, and the mask a switch's id match uses.
uint32_t getNumBDsForChannel(int col, int row, int channel) const
Return the number of buffer descriptors accessible on channel channel for the tile at (col,...
virtual bool isMemTilePadValueSupported() const
bool isLegalCascade(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if a cascade can run from src to dst.
virtual uint32_t getDefaultCoreStackSize() const
Return the default stack reservation (in bytes) for a core that does not state one.
virtual uint32_t getMemEastBaseAddress() const =0
Return the base address in the local address map for a core.
const DmaBdLayout * getDmaBdLayout(int col, int row) const
virtual uint32_t getNumControllers() const
Total number of microcontrollers (uC) in the device.
virtual uint32_t getMemTileLoadStoreBusWidth() const
Return the data bus width (in bits) for load/store operations of a memory tile.
uint32_t getDmaBdStepBits(int col, int row) const
virtual uint32_t getNumMemTileRows() const =0
virtual uint32_t getNumDestShimMuxConnections(int col, int row, WireBundle bundle) const =0
Return the number of destinations of connections inside a shimmux.
virtual bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const =0
Return true if src has a memory tile which is West of dst.
virtual uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const =0
Return the number of destinations of connections inside a switchbox.
virtual uint32_t getMemInternalBaseAddress(TileID src) const =0
Return the base address in the local address map for a core.
virtual uint32_t getDefaultAxCache() const
SharedMemory
Which of two tiles' memory modules both of them can address.
@ None
Neither tile can address the other's memory module.
@ First
Only the first tile's module.
@ Second
Only the second tile's module.
virtual std::optional< uint32_t > getDmaStatusAddress(int, int, int, AIE::DMAChannelDir) const
Return the address of the DMA status register for a channel, or nullopt when this target's layout has...
bool isInternal(int srcCol, int srcRow, int dstCol, int dstRow) const
Return true if src is the internal memory of dst.
virtual uint32_t getRowShift() const =0
virtual uint32_t getNumSlaveSlots() const =0
Return the number of packet-rule slots per stream-switch slave port.
SharedMemory getSharedMemory(TileID a, TileID b) const
Return the memory module a and b can both reach, if any.
virtual int firstPlaceableColumn() const
First physical column at which a partition may be anchored.
virtual bool isLegalMemAffinity(int coreCol, int coreRow, int memCol, int memRow) const =0
Return true if core can access the memory in mem.
uint32_t getNumBDs(int col, int row) const
Return the number of buffer descriptors supported by the DMA in the given tile.
virtual uint32_t getAddressGenGranularity() const =0
Return the data bus width of the device.
virtual uint32_t getMemTileSize() const =0
Return the size (in bytes) of a MemTile.
virtual std::optional< uint32_t > getStreamSwitchPortIndex(int col, int row, WireBundle bundle, uint32_t channel, bool master) const =0
Get stream switch port index for a given port specification Return port index for Stream_Switch_Event...
virtual uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const =0
Return the number of sources of connections inside a switchbox.
uint32_t getNumMemTileRows() const override
static bool classof(const AIETargetModel *model)
int physicalColumns() const override
Width of the physical array this (possibly virtualized) device is carved from.
uint32_t getNumControllers() const override
Total number of microcontrollers (uC) in the device.
int rows() const override
Return the number of rows in the device.
uint32_t getNumControllers() const override
Total number of microcontrollers (uC) in the device.
static bool classof(const AIETargetModel *model)
std::vector< std::pair< uint32_t, uint32_t > > getShimBurstEncodingsAndLengths() const override
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getNumMemTileRows() const override
AIEArch getTargetArch() const override
Return the target architecture.
uint32_t getComputeTileMaxVectorAlignBits() const override
Return the alignment (in bits) required by the widest vector load/store a compute core can issue.
bool isSupportedBlockFormat(std::string const &format) const override
int rows() const override
Return the number of rows in the device.
int physicalColumns() const override
Width of the physical array this (possibly virtualized) device is carved from.
bool isMemTilePadValueSupported() const override
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
Register and event database for a specific architecture.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getAddressGenGranularity() const override
Return the data bus width of the device.
int rows() const override
Return the number of rows in the device.
int columns() const override
Return the number of columns in the device.
int rows() const override
Return the number of rows in the device.
uint32_t getNumMemTileRows() const override
static bool classof(const AIETargetModel *model)
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
static bool classof(const AIETargetModel *model)
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getNumMemTileRows() const override
int columns() const override
Return the number of columns in the device.
int rows() const override
Return the number of rows in the device.
static bool classof(const AIETargetModel *model)
int rows() const override
Return the number of rows in the device.
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
uint32_t getNumMemTileRows() const override
int columns() const override
Return the number of columns in the device.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
AIETileType getTileType(int col, int row) const override
Return the tile type for the given tile coordinates.
static bool classof(const AIETargetModel *model)
int columns() const override
Return the number of columns in the device.
uint8_t txnDeviceGen(const AIETargetModel &tm)
Device generation ID written into the TXN header (aie_runtime::TxnDeviceInfo::devGen).
struct TileID { friend std::ostream &operator<<(std::ostream &os, const TileID &s) { os<< "TileID("<< s.col<< ", "<< s.row<< ")"; return os; } friend std::string to_string(const TileID &s) { std::ostringstream ss; ss<< s; return ss.str(); } friend llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const TileID &s) { os<< to_string(s); return os; } inline bool operator<(const TileID &rhs) const { return std::tie(col, row)< std::tie(rhs.col, rhs.row); } bool operator==(const TileID &rhs) const { return std::tie(col, row)==std::tie(rhs.col, rhs.row); } bool operator!=(const TileID &rhs) const { return !(*this==rhs);} int col, row;} TileID
llvm::raw_ostream & operator<<(llvm::raw_ostream &os, const SwitchSettings &ss)
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
Bit field information for a register.
Bits [shift, shift + width) of register word in a buffer descriptor's register block.
uint32_t place(uint64_t value) const
uint32_t mask() const
The register layout of one tile type's DMA buffer descriptor.
llvm::SmallVector< std::pair< DmaBdField, DmaBdField >, 3 > padFields() const
The (before, after) zero-padding fields, innermost dimension first.