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