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/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 /// Return the number of DMA channels a tile has in one direction. An MM2S
603 /// channel feeds the stream switch, or the shim mux on a shim tile, so it is
604 /// counted by that switch's DMA sources; an S2MM channel by its DMA
605 /// destinations. Prefer this to the TileOp connection accessors, which are
606 /// named from the switch's side and so read the other way round.
607 uint32_t getNumDMAChannels(int col, int row, AIE::DMAChannelDir dir) const;
608
609 /// Return the number of packet-rule slots per stream-switch slave port.
610 virtual uint32_t getNumSlaveSlots() const = 0;
611 /// Return the number of arbiters per stream switch.
612 virtual uint32_t getNumArbiters() const = 0;
613 /// Return the number of master select values per stream-switch arbiter.
614 virtual uint32_t getNumMselsPerArbiter() const = 0;
615 /// Return the largest packet id the stream switch can route.
616 virtual uint32_t getMaxPacketId() const = 0;
617 /// Return the largest out-of-order BD id (unsupported = 0).
618 virtual uint32_t getMaxOutOfOrderId() const = 0;
619 /// Return the largest DMA task repeat count (unsupported = 0).
620 virtual uint32_t getMaxRepeatCount() const = 0;
621
622 /// Return how many DMA tasks a single channel's task queue holds
623 /// (unsupported = 0). Pushing to a full queue drops the push and sets the
624 /// channel's sticky Task_Queue_Overflow bit, stranding whoever waits on that
625 /// transfer. Flat rather than per-tile-type because aie-rt's
626 /// XAie_DmaGetMaxQueueSize (XAIE_DMA_MAX_QUEUE_SIZE) returns the same depth
627 /// for every tile type and architecture.
628 virtual uint32_t getDmaTaskQueueDepth() const = 0;
629
630 /// Return the task-queue depth for one channel. The queue is a per-channel
631 /// resource in hardware, but no shipping target gives channels different
632 /// depths, so this forwards to the flat accessor; carrying the parameters
633 /// spares call sites churn if one ever does.
634 uint32_t getDmaTaskQueueDepth(int /*col*/, int /*row*/, int /*channel*/,
635 AIE::DMAChannelDir /*direction*/) const {
636 return getDmaTaskQueueDepth();
637 }
638
639 // Return true if the stream switch connection is legal, false otherwise.
640 virtual bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
641 int srcChan, WireBundle dstBundle,
642 int dstChan) const = 0;
643
644 // Run consistency checks on the target model.
645 void validate() const;
646
647 uint32_t getModelProperties() const { return ModelProperties; }
648 void addModelProperty(uint32_t prop) { ModelProperties |= prop; }
649 // Return true if this device has a given property.
650 bool hasProperty(ModelProperty Prop) const {
651 return (getModelProperties() & Prop) == Prop;
652 }
653
654 // Return the bit offset of the column within a tile address.
655 // This is used to compute the control address of a tile from it's column
656 // location.
657 virtual uint32_t getColumnShift() const = 0;
658
659 // Return the bit offset of the row within a tile address.
660 // This is used to compute the control address of a tile from it's row
661 // location.
662 virtual uint32_t getRowShift() const = 0;
663
664 // Returns the list of possible burst encodings (first) and
665 // their corresponding lengths in bytes (second).
666 virtual std::vector<std::pair<uint32_t, uint32_t>>
668
669 // Returns the default 4-bit AxCACHE value used for shim NOC DMA AXI-MM
670 // transfers when a `dma_bd`/`npu.writebd`'s `axcache` attribute is unset.
671 // Tuned to 2 to enable upsizing in the NoC. No target currently needs
672 // a different value, so this is a single non-pure-virtual default rather
673 // than a per-architecture override.
674 virtual uint32_t getDefaultAxCache() const { return 2; }
675
676 // Returns true if the target model supports the given block format.
677 virtual bool isSupportedBlockFormat(std::string const &format) const;
678
679 // Returns true if the target supports a constant pad value on MemTile MM2S
680 // DMA channels (register=CONSTANT_PAD_VALUE).
681 virtual bool isMemTilePadValueSupported() const { return false; }
682
683 /// Register Database API - provides access to register and event information
684 /// for trace configuration and low-level register access.
685
686 /// Lookup register information by name and tile.
687 /// Return pointer to register info, or nullptr if not found
688 const RegisterInfo *lookupRegister(llvm::StringRef name, TileID tile,
689 bool isMem = false) const;
690
691 /// Lookup event number by name and tile.
692 /// Return Event number if found, nullopt otherwise
693 std::optional<uint32_t> lookupEvent(llvm::StringRef name, TileID tile,
694 bool isMem = false) const;
695
696 /// Encode a field value with proper bit shifting.
697 /// Return nullopt if value does not fit in the field's bit width.
698 std::optional<uint32_t> encodeFieldValue(const BitFieldInfo &field,
699 uint32_t value) const;
700
701 /// Compute a 32-bit mask for a register field.
702 /// Return nullopt if the field does not fit in a 32-bit register.
703 std::optional<uint32_t> getFieldMask(const BitFieldInfo &field) const;
704
705 /// Return a mapping from tile coordinates to controller IDs.
706 /// When columnWiseUniqueIDs is true (default), IDs are unique within each
707 /// column. Otherwise they are globally unique across the device.
708 llvm::DenseMap<TileID, int>
709 getTileToControllerIdMap(bool columnWiseUniqueIDs = true) const;
710
711 /// Resolve stream switch port specification to port index.
712 /// Return Port index for stream switch register, or nullopt if invalid
713 std::optional<uint32_t> resolvePortValue(llvm::StringRef value, TileID tile,
714 bool master) const;
715};
716
718public:
720
721 AIEArch getTargetArch() const override;
722
723 uint32_t getNumSlaveSlots() const override { return 4; }
724 uint32_t getNumArbiters() const override { return 6; }
725 uint32_t getNumMselsPerArbiter() const override { return 4; }
726 uint32_t getMaxPacketId() const override { return 31; }
727 uint32_t getMaxOutOfOrderId() const override { return 0; }
728 uint32_t getMaxRepeatCount() const override { return 0; }
729 // AIE1 has no queued DMA-task model (BDs are started directly), so there is
730 // no queue to overflow.
731 uint32_t getDmaTaskQueueDepth() const override { return 0; }
732
733 std::optional<TileID> getMemWest(TileID src) const override;
734 std::optional<TileID> getMemEast(TileID src) const override;
735 std::optional<TileID> getMemNorth(TileID src) const override;
736 std::optional<TileID> getMemSouth(TileID src) const override;
737
738 bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override;
739 bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override;
740 bool isMemNorth(int srcCol, int srcRow, int dstCol,
741 int dstRow) const override;
742 bool isMemSouth(int srcCol, int srcRow, int dstCol,
743 int dstRow) const override;
744
745 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
746 int memRow) const override;
747
748 uint32_t getMemInternalBaseAddress(TileID src) const override {
749 if (src.row % 2 == 0)
750 // Internal is West
751 return getMemWestBaseAddress();
752 // Internal is East
753 return getMemEastBaseAddress();
754 }
755
756 uint32_t getMemSouthBaseAddress() const override { return 0x00020000; }
757 uint32_t getMemWestBaseAddress() const override { return 0x00028000; }
758 uint32_t getMemNorthBaseAddress() const override { return 0x00030000; }
759 uint32_t getMemEastBaseAddress() const override { return 0x00038000; }
760 uint32_t getLocalMemorySize() const override { return 0x00008000; }
761 uint32_t getProgramMemorySize() const override { return 0x00004000; }
762 uint32_t getCoreDataAddressSpaceSize() const override { return 0x00100000; }
763 uint32_t getAccumulatorCascadeSize() const override { return 384; }
764 uint32_t getComputeTileLoadStoreBusWidth() const override { return 128; }
765 uint32_t getComputeTileMaxVectorAlignBits() const override { return 128; }
766
768 uint32_t getNumLocks(AIETileType tileType) const override {
769 return 16; // AIE1 has no MemTiles, always 16
770 }
771 uint32_t getMaxLockValue() const override { return 1; }
772 std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
773 TileID tile) const override;
774 uint32_t getNumBDs(AIETileType tileType) const override {
775 return 16; // AIE1 has no MemTiles, always 16
776 }
777 uint32_t getBDMaxDims(AIETileType tileType) const override {
778 // AIE1 has no MemTiles; preserve the historical BD dimension limit.
779 return 3;
780 }
781 uint64_t getDmaBdMaxLen(AIETileType tileType) const override {
782 // AIE1 has no mem tiles. Core tiles use a 13-bit length field with a +1
783 // hardware encoding (max 2^13 = 8192 32-bit words); shim tiles use a full
784 // 32-bit length register.
785 if (tileType == AIETileType::CoreTile)
786 return 1ull << 13;
787 return 0xFFFFFFFFull;
788 }
789 uint32_t getDmaBdWrapBits(AIETileType tileType) const override {
790 // AIE1 core tiles have 8-bit wrap fields; shim tiles have 10-bit.
791 return tileType == AIETileType::CoreTile ? 8 : 10;
792 }
793 uint32_t getDmaBdStepBits(AIETileType tileType) const override {
794 // AIE1 core tiles have 13-bit step fields; shim tiles have 20-bit.
795 return tileType == AIETileType::CoreTile ? 13 : 20;
796 }
797 uint32_t getDmaBdIterBits(AIETileType tileType) const override {
798 // AIE1 core and shim tiles both have a 6-bit Iteration_Wrap field.
799 return 6;
800 }
801 bool isBdChannelAccessible(int col, int row, uint32_t bd_id,
802 int channel) const override {
803 return true;
804 }
805
806 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
807 AIE::DMAChannelDir direction) const override;
808
809 uint32_t getDmaBdAddressOffset(int col, int row) const override;
810
811 uint32_t getDmaControlAddress(int col, int row, int channel,
812 AIE::DMAChannelDir direction) const override;
813
814 uint32_t getNumMemTileRows() const override { return 0; }
815 uint32_t getMemTileSize() const override { return 0; }
816 uint32_t getNumBanks(int col, int row) const override { return 4; }
817
818 uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override {
819 return 0;
820 }
821
822 uint32_t getNumDestSwitchboxConnections(int col, int row,
823 WireBundle bundle) const override;
824 uint32_t getNumSourceSwitchboxConnections(int col, int row,
825 WireBundle bundle) const override;
826 uint32_t getNumDestShimMuxConnections(int col, int row,
827 WireBundle bundle) const override;
828 uint32_t getNumSourceShimMuxConnections(int col, int row,
829 WireBundle bundle) const override;
830 bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
831 int srcChan, WireBundle dstBundle,
832 int dstChan) const override;
833
834 std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
835 WireBundle bundle,
836 uint32_t port_num,
837 bool master) const override;
838
839 uint32_t getColumnShift() const override { return 23; }
840 uint32_t getRowShift() const override { return 18; }
841
842 static bool classof(const AIETargetModel *model) {
843 return model->getKind() >= TK_AIE1_VC1902 &&
844 model->getKind() < TK_AIE1_Last;
845 }
846
847 std::vector<std::pair<uint32_t, uint32_t>>
848 getShimBurstEncodingsAndLengths() const override;
849};
850
852protected:
853 std::unique_ptr<RegisterDatabase> loadRegisterDatabase() const override;
854
855public:
863
864 AIEArch getTargetArch() const override;
865
866 uint32_t getAddressGenGranularity() const override { return 32; }
867
868 uint32_t getNumSlaveSlots() const override { return 4; }
869 uint32_t getNumArbiters() const override { return 6; }
870 uint32_t getNumMselsPerArbiter() const override { return 4; }
871 uint32_t getMaxPacketId() const override { return 31; }
872 uint32_t getMaxOutOfOrderId() const override { return 63; }
873 uint32_t getMaxRepeatCount() const override { return 255; }
874 uint32_t getDmaTaskQueueDepth() const override { return 4; }
875
876 std::optional<TileID> getMemWest(TileID src) const override;
877 std::optional<TileID> getMemEast(TileID src) const override;
878 std::optional<TileID> getMemNorth(TileID src) const override;
879 std::optional<TileID> getMemSouth(TileID src) const override;
880
881 bool isMemWest(int srcCol, int srcRow, int dstCol, int dstRow) const override;
882 bool isMemEast(int srcCol, int srcRow, int dstCol, int dstRow) const override;
883 bool isMemNorth(int srcCol, int srcRow, int dstCol,
884 int dstRow) const override;
885 bool isMemSouth(int srcCol, int srcRow, int dstCol,
886 int dstRow) const override;
887
888 bool isLegalMemAffinity(int coreCol, int coreRow, int memCol,
889 int memRow) const override;
890
891 uint32_t getMemInternalBaseAddress(TileID src) const override {
892 return getMemEastBaseAddress();
893 }
894
895 uint32_t getMemSouthBaseAddress() const override { return 0x00040000; }
896 uint32_t getMemWestBaseAddress() const override { return 0x00050000; }
897 uint32_t getMemNorthBaseAddress() const override { return 0x00060000; }
898 uint32_t getMemEastBaseAddress() const override { return 0x00070000; }
899 uint32_t getLocalMemorySize() const override { return 0x00010000; }
900 uint32_t getProgramMemorySize() const override { return 0x00004000; }
901 uint32_t getCoreDataAddressSpaceSize() const override { return 0x00100000; }
902 uint32_t getAccumulatorCascadeSize() const override { return 512; }
903 uint32_t getComputeTileLoadStoreBusWidth() const override { return 256; }
904 uint32_t getComputeTileMaxVectorAlignBits() const override { return 256; }
905
907 uint32_t getNumLocks(AIETileType tileType) const override {
908 return tileType == AIETileType::MemTile ? 64 : 16;
909 }
910
911 uint32_t getMaxLockValue() const override { return 0x3F; }
912
913 std::optional<uint32_t> getLocalLockAddress(uint32_t lockId,
914 TileID tile) const override;
915
916 uint32_t getNumBDs(AIETileType tileType) const override {
917 return tileType == AIETileType::MemTile ? 48 : 16;
918 }
919 uint32_t getBDMaxDims(AIETileType tileType) const override {
920 // MemTile BDs support 4 ND dimensions; core and shim BDs support 3.
921 return tileType == AIETileType::MemTile ? 4 : 3;
922 }
923 // The field limits read off the BD layout the lowerings pack through, the
924 // shim's for tiles without one.
925 const DmaBdLayout &getDmaBdLimits(AIETileType tileType) const {
926 const DmaBdLayout *layout = getDmaBdLayout(tileType);
927 return layout ? *layout : *getDmaBdLayout(AIETileType::ShimNOCTile);
928 }
929 uint64_t getDmaBdMaxLen(AIETileType tileType) const override {
930 return getDmaBdLimits(tileType).bufferLength.mask();
931 }
932 uint32_t getDmaBdWrapBits(AIETileType tileType) const override {
933 return getDmaBdLimits(tileType).d0Size.width;
934 }
935 uint32_t getDmaBdStepBits(AIETileType tileType) const override {
936 return getDmaBdLimits(tileType).d0Stride.width;
937 }
938 uint32_t getDmaBdIterBits(AIETileType tileType) const override {
939 return getDmaBdLimits(tileType).iterationSize.width;
940 }
941
942 bool isBdChannelAccessible(int col, int row, uint32_t bd_id,
943 int channel) const override {
944 if (getTileType(col, row) != AIETileType::MemTile) {
945 return true;
946 } else {
947 if ((channel & 1) == 0) { // even channel number
948 return bd_id < 24;
949 } else {
950 return bd_id >= 24;
951 }
952 }
953 }
954
956 const DmaBdLayout *getDmaBdLayout(AIETileType tileType) const override;
957
958 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
959 AIE::DMAChannelDir direction) const override;
960
961 uint32_t getDmaBdAddressOffset(int col, int row) const override;
962
963 uint32_t getDmaControlAddress(int col, int row, int channel,
964 AIE::DMAChannelDir direction) const override;
965 std::optional<uint32_t>
966 getDmaStatusAddress(int col, int row, int channel,
967 AIE::DMAChannelDir direction) const override;
968 // Task_Queue_Size, bits 22:20 of the DMA_{MM2S,S2MM}_Status_N register.
969 uint32_t getDmaTaskQueueSizeMask() const override { return 0x7u << 20; }
970 // Task_Queue_Size, Channel_Running (bit 19) and the four Stalled_* bits
971 // (5:2): what aie-rt's _XAieMl_DmaWaitForDone polls clear. aie-rt's pending
972 // count adds one to Task_Queue_Size for Channel_Running or a stall, which is
973 // why the field alone does not cover the running task.
974 uint32_t getDmaChannelIdleMask() const override {
975 return getDmaTaskQueueSizeMask() | (1u << 19) | 0x3Cu;
976 }
977
978 uint32_t getMemTileSize() const override { return 0x00080000; }
979
980 uint32_t getNumBanks(int col, int row) const override {
981 return getTileType(col, row) == AIETileType::MemTile ? 8 : 4;
982 }
983
984 uint32_t getMaxChannelNumForAdjacentMemTile(int col, int row) const override {
985 return 4;
986 }
987
988 uint32_t getNumDestSwitchboxConnections(int col, int row,
989 WireBundle bundle) const override;
990 uint32_t getNumSourceSwitchboxConnections(int col, int row,
991 WireBundle bundle) const override;
992 uint32_t getNumDestShimMuxConnections(int col, int row,
993 WireBundle bundle) const override;
994 uint32_t getNumSourceShimMuxConnections(int col, int row,
995 WireBundle bundle) const override;
996 bool isLegalTileConnection(int col, int row, WireBundle srcBundle,
997 int srcChan, WireBundle dstBundle,
998 int dstChan) const override;
999
1000 std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
1001 WireBundle bundle,
1002 uint32_t port_num,
1003 bool master) const override;
1004
1005 uint32_t getColumnShift() const override { return 25; }
1006 uint32_t getRowShift() const override { return 20; }
1007
1008 static bool classof(const AIETargetModel *model) {
1009 return model->getKind() >= TK_AIE2_VE2302 &&
1010 model->getKind() < TK_AIE2_Last;
1011 }
1012
1013 std::vector<std::pair<uint32_t, uint32_t>>
1014 getShimBurstEncodingsAndLengths() const override;
1015};
1016
1017// AIE2PS base model
1019public:
1021 // AIE2PS is an NPU but uses CERT ELF, not CDO/xclbin.
1023 }
1024
1025 AIEArch getTargetArch() const override { return AIEArch::AIE2ps; }
1026 // AIE2P/AIE2PS: a full-width (512-bit) vector access requires 512-bit
1027 // alignment, stricter than the 256-bit load/store bus. See aie_api's
1028 // vector_ldst_align for __AIE_ARCH__ 21/22.
1029 uint32_t getComputeTileMaxVectorAlignBits() const override { return 512; }
1030
1031 uint32_t getNumControllersPerColumn() const override { return 1; }
1032
1033 // AIE2PS supports 512B burst (same as AIE2P)
1034 std::vector<std::pair<uint32_t, uint32_t>>
1036 return {std::pair(0, 64), std::pair(1, 128), std::pair(2, 256),
1037 std::pair(3, 512)};
1038 }
1039
1040 // TODO(aie2ps): AIE2PS changed block floating point from bfp16 to
1041 // MX9/MX6/MX4. isSupportedBlockFormat() currently returns false (inherited).
1042 // Override with correct MX format strings when ML kernels need it.
1043
1044 uint64_t getDmaBdAddress(int col, int row, uint32_t bd_id, int channel,
1045 AIE::DMAChannelDir direction) const override;
1046 uint32_t getDmaControlAddress(int col, int row, int channel,
1047 AIE::DMAChannelDir direction) const override;
1048 std::optional<uint32_t>
1049 getDmaStatusAddress(int col, int row, int channel,
1050 AIE::DMAChannelDir direction) const override;
1051
1052 uint32_t getNumDestSwitchboxConnections(int col, int row,
1053 WireBundle bundle) const override;
1054 uint32_t getNumSourceSwitchboxConnections(int col, int row,
1055 WireBundle bundle) const override;
1056 std::optional<uint32_t> getStreamSwitchPortIndex(int col, int row,
1057 WireBundle bundle,
1058 uint32_t channel,
1059 bool master) const override;
1060
1061 static bool classof(const AIETargetModel *model) {
1062 return model->getKind() >= TK_AIE2PS_VE3858 &&
1063 model->getKind() < TK_AIE2PS_Last;
1064 }
1065};
1066
1067// VE3858 target model (AIE2PS, xc2ve3858 on VEK385)
1068// 36 columns, 7 rows: 1 shim + 2 memtile + 4 core
1070public:
1072
1073 int columns() const override { return 36; }
1074 int rows() const override { return 7; }
1075
1076 // AIE2PS Shim-South tiles (cols 1-23) have both NoC and PL.
1077 // Shim-Global (col 0) has NoC only. Modeling all as ShimNOC is a working
1078 // approximation for the CERT compilation path.
1079 AIETileType getTileType(int col, int row) const override {
1080 if (row == 0)
1081 return AIETileType::ShimNOCTile;
1082 if (row <= 2)
1083 return AIETileType::MemTile;
1084 return AIETileType::CoreTile;
1085 }
1086
1087 uint32_t getNumMemTileRows() const override { return 2; }
1088
1089 static bool classof(const AIETargetModel *model) {
1090 return model->getKind() == TK_AIE2PS_VE3858;
1091 }
1092};
1093
1095 llvm::SmallDenseSet<unsigned, 16> nocColumns = {
1096 2, 3, 6, 7, 10, 11, 18, 19, 26, 27, 34, 35, 42, 43, 46, 47};
1097
1098public:
1100
1101 uint32_t getAddressGenGranularity() const override { return 32; }
1102
1103 int columns() const override { return 50; }
1104
1105 int rows() const override { return 9; /* One Shim row and 8 Core rows. */ }
1106
1107 AIETileType getTileType(int col, int row) const override {
1108 if (row == 0) {
1109 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1110 : AIETileType::ShimPLTile;
1111 }
1112 return AIETileType::CoreTile; // AIE1 has no MemTiles
1113 }
1114
1115 static bool classof(const AIETargetModel *model) {
1116 return model->getKind() == TK_AIE1_VC1902;
1117 }
1118};
1119
1121 llvm::SmallDenseSet<unsigned, 8> nocColumns = {2, 3, 6, 7, 10, 11};
1122
1123public:
1125
1126 int columns() const override { return 17; }
1127
1128 int rows() const override {
1129 return 4; /* One Shim row, 1 memtile rows, and 2 Core rows. */
1130 }
1131
1132 AIETileType getTileType(int col, int row) const override {
1133 if (row == 0) {
1134 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1135 : AIETileType::ShimPLTile;
1136 }
1137 if (row == 1)
1138 return AIETileType::MemTile;
1139 return AIETileType::CoreTile;
1140 }
1141
1142 uint32_t getNumMemTileRows() const override { return 1; }
1143
1144 static bool classof(const AIETargetModel *model) {
1145 return model->getKind() == TK_AIE2_VE2302;
1146 }
1147};
1148
1150 llvm::SmallDenseSet<unsigned, 16> nocColumns = {2, 3, 6, 7, 14, 15,
1151 22, 23, 30, 31, 34, 35};
1152
1153public:
1155
1156 int columns() const override { return 38; }
1157
1158 int rows() const override {
1159 return 11; /* One Shim row, 2 memtile rows, and 8 Core rows. */
1160 }
1161
1162 AIETileType getTileType(int col, int row) const override {
1163 if (row == 0) {
1164 return nocColumns.contains(col) ? AIETileType::ShimNOCTile
1165 : AIETileType::ShimPLTile;
1166 }
1167 if (row == 1 || row == 2)
1168 return AIETileType::MemTile;
1169 return AIETileType::CoreTile;
1170 }
1171
1172 uint32_t getNumMemTileRows() const override { return 2; }
1173
1174 static bool classof(const AIETargetModel *model) {
1175 return model->getKind() == TK_AIE2_VE2802;
1176 }
1177};
1178
1180public:
1184
1185 int rows() const override {
1186 return 6; /* 1 Shim row, 1 memtile row, and 4 Core rows. */
1187 }
1188
1189 int physicalColumns() const override { return 4; }
1190
1191 uint32_t getNumMemTileRows() const override { return 1; }
1192
1193 uint32_t getNumControllers() const override { return 1; }
1194
1195 static bool classof(const AIETargetModel *model) {
1196 return model->getKind() >= TK_AIE2_NPU1_1Col &&
1197 model->getKind() < TK_AIE2_NPU1_Last;
1198 }
1199};
1200
1201// A sub-portion of the Phoenix NPU
1203 int cols;
1204
1205public:
1207 : BaseNPU1TargetModel(static_cast<TargetModelKind>(
1208 static_cast<std::underlying_type_t<TargetModelKind>>(
1210 _cols - 1)),
1211 cols(_cols) {
1212 // Device properties initialization
1214 }
1215
1216 int columns() const override { return cols; }
1217
1218 AIETileType getTileType(int col, int row) const override {
1219 if (row == 0)
1220 return AIETileType::ShimNOCTile; // NPU1 has no ShimPL tiles
1221 if (row == 1)
1222 return AIETileType::MemTile;
1223 return AIETileType::CoreTile;
1224 }
1225
1226 static bool classof(const AIETargetModel *model) {
1227 return model->getKind() >= TK_AIE2_NPU1_1Col &&
1228 model->getKind() < TK_AIE2_NPU1_Last;
1229 }
1230};
1231
1233public:
1237
1238 AIEArch getTargetArch() const override;
1239 // AIE2P/AIE2PS: a full-width (512-bit) vector access requires 512-bit
1240 // alignment, stricter than the 256-bit load/store bus. See aie_api's
1241 // vector_ldst_align for __AIE_ARCH__ 21/22.
1242 uint32_t getComputeTileMaxVectorAlignBits() const override { return 512; }
1243
1244 int rows() const override {
1245 return 6; /* 1 Shim row, 1 memtile row, and 4 Core rows. */
1246 }
1247
1248 int physicalColumns() const override { return 8; }
1249
1250 AIETileType getTileType(int col, int row) const override {
1251 if (row == 0)
1252 return AIETileType::ShimNOCTile;
1253 if (row == 1)
1254 return AIETileType::MemTile;
1255 return AIETileType::CoreTile;
1256 }
1257
1258 uint32_t getNumMemTileRows() const override { return 1; }
1259
1260 std::vector<std::pair<uint32_t, uint32_t>>
1261 getShimBurstEncodingsAndLengths() const override;
1262
1263 bool isSupportedBlockFormat(std::string const &format) const override;
1264
1265 bool isMemTilePadValueSupported() const override { return true; }
1266
1267 uint32_t getNumControllers() const override { return 1; }
1268
1269 static bool classof(const AIETargetModel *model) {
1270 return model->getKind() >= TK_AIE2_NPU2 &&
1271 model->getKind() < TK_AIE2_NPU2_Last;
1272 }
1273};
1274
1275// The full Strix NPU
1277public:
1279
1280 int columns() const override { return 8; }
1281
1282 static bool classof(const AIETargetModel *model) {
1283 return model->getKind() == TK_AIE2_NPU2;
1284 }
1285};
1286
1287// A sub-portion of the Strix NPU
1289 int cols;
1290
1291public:
1293 : BaseNPU2TargetModel(static_cast<TargetModelKind>(
1294 static_cast<std::underlying_type_t<TargetModelKind>>(TK_AIE2_NPU2) +
1295 _cols)),
1296 cols(_cols) {
1297 // Device properties initialization
1299 }
1300
1301 int columns() const override { return cols; }
1302
1303 static bool classof(const AIETargetModel *model) {
1304 return model->getKind() >= TK_AIE2_NPU2_1Col &&
1305 model->getKind() < TK_AIE2_NPU2_Last;
1306 }
1307};
1308
1309/// \brief Device generation ID written into the TXN header
1310/// (aie_runtime::TxnDeviceInfo::devGen). Both the static binary emitter and the
1311/// generated-C++ builder read it from here, so a new device family is one edit.
1312inline uint8_t txnDeviceGen(const AIETargetModel &tm) {
1313 return llvm::isa<BaseNPU2TargetModel>(tm) ? 4 : 3;
1314}
1315
1316} // namespace xilinx::AIE
1317
1318namespace llvm {
1319template <>
1320struct DenseMapInfo<xilinx::AIE::TileID> {
1321 using FirstInfo = DenseMapInfo<int>;
1322 using SecondInfo = DenseMapInfo<int>;
1323
1324 static unsigned getHashValue(const xilinx::AIE::TileID &t) {
1325 return detail::combineHashValue(FirstInfo::getHashValue(t.col),
1326 SecondInfo::getHashValue(t.row));
1327 }
1328
1329 static bool isEqual(const xilinx::AIE::TileID &lhs,
1330 const xilinx::AIE::TileID &rhs) {
1331 return lhs == rhs;
1332 }
1333};
1334} // namespace llvm
1335
1336template <>
1337struct std::hash<xilinx::AIE::TileID> {
1338 std::size_t operator()(const xilinx::AIE::TileID &s) const noexcept {
1339 std::size_t h1 = std::hash<int>{}(s.col);
1340 std::size_t h2 = std::hash<int>{}(s.row);
1341 return h1 ^ (h2 << 1);
1342 }
1343};
1344
1345#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
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.
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.