14#include "mlir/Support/LogicalResult.h"
17#include "xaiengine/xaie_core.h"
18#include "xaiengine/xaie_dma.h"
19#include "xaiengine/xaie_elfloader.h"
20#include "xaiengine/xaie_interrupt.h"
21#include "xaiengine/xaie_locks.h"
22#include "xaiengine/xaie_mem.h"
23#include "xaiengine/xaie_plif.h"
24#include "xaiengine/xaie_ss.h"
25#include "xaiengine/xaie_txn.h"
26#include "xaiengine/xaiegbl.h"
27#include "xaiengine/xaiegbl_defs.h"
32#define AIERC_STR(x) x, #x
33static const std::map<AieRC, std::string> AIERCTOSTR = {
59 {
AIERC_STR(XAIE_INSUFFICIENT_BUFFER_SIZE)},
63static const std::map<xilinx::AIE::WireBundle, StrmSwPortType>
64 WIRE_BUNDLE_TO_STRM_SW_PORT_TYPE = {
65 {xilinx::AIE::WireBundle::Core, StrmSwPortType::CORE},
66 {xilinx::AIE::WireBundle::DMA, StrmSwPortType::DMA},
67 {xilinx::AIE::WireBundle::TileControl, StrmSwPortType::CTRL},
68 {xilinx::AIE::WireBundle::FIFO, StrmSwPortType::FIFO},
69 {xilinx::AIE::WireBundle::South, StrmSwPortType::SOUTH},
70 {xilinx::AIE::WireBundle::West, StrmSwPortType::WEST},
71 {xilinx::AIE::WireBundle::North, StrmSwPortType::NORTH},
72 {xilinx::AIE::WireBundle::East, StrmSwPortType::EAST},
75 {xilinx::AIE::WireBundle::Trace, StrmSwPortType::TRACE},
84 return out << label <<
"=" << std::forward<H1>(value);
87template <
typename H1,
typename... T>
89 H1 &&value, T &&...rest) {
90 const char *pcomma = strchr(label,
',');
92 <<
"=" << std::forward<H1>(value) <<
',',
93 pcomma + 1, std::forward<T>(rest)...);
96llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
const XAie_LocType &loc);
98llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
const XAie_Lock &lock);
100llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
const XAie_Packet &packet);
102#define SHOW_AIERT_ARGS(os, ...) showAIEXRTArgs(os, #__VA_ARGS__, __VA_ARGS__)
106static_assert(XAIE_OK == 0);
108#define TRY_XAIE_API_FATAL_ERROR(API, ...) \
110 LLVM_DEBUG(llvm::dbgs() << "trying XAIE API: " << #API << " with args: "); \
111 LLVM_DEBUG(SHOW_AIERT_ARGS(llvm::dbgs(), __VA_ARGS__)); \
112 LLVM_DEBUG(llvm::dbgs() << "\n"); \
113 if (auto r = API(__VA_ARGS__)) \
114 llvm::report_fatal_error(llvm::Twine(#API " failed with ") + \
118#define TRY_XAIE_API_EMIT_ERROR(OP, API, ...) \
120 LLVM_DEBUG(llvm::dbgs() << "trying XAIE API: " << #API << " with args: "); \
121 LLVM_DEBUG(SHOW_AIERT_ARGS(llvm::dbgs(), __VA_ARGS__)); \
122 LLVM_DEBUG(llvm::dbgs() << "\n"); \
123 if (auto r = API(__VA_ARGS__)) \
124 return OP.emitOpError() << #API " failed with " << AIERCTOSTR.at(r); \
127#define TRY_XAIE_API_LOGICAL_RESULT(API, ...) \
129 LLVM_DEBUG(llvm::dbgs() << "trying XAIE API: " << #API << " with args: "); \
130 LLVM_DEBUG(SHOW_AIERT_ARGS(llvm::dbgs(), __VA_ARGS__)); \
131 LLVM_DEBUG(llvm::dbgs() << "\n"); \
132 if (auto r = API(__VA_ARGS__)) { \
133 llvm::errs() << #API " failed with " << AIERCTOSTR.at(r); \
140#define TRY_XAIE_API_FATAL_ERROR(API, ...) \
142 if (auto r = API(__VA_ARGS__)) \
143 llvm::report_fatal_error(llvm::Twine(#API " failed with ") + \
147#define TRY_XAIE_API_EMIT_ERROR(OP, API, ...) \
149 if (auto r = API(__VA_ARGS__)) \
150 return OP.emitOpError() << #API " failed with " << AIERCTOSTR.at(r); \
153#define TRY_XAIE_API_LOGICAL_RESULT(API, ...) \
155 if (auto r = API(__VA_ARGS__)) { \
156 llvm::errs() << #API " failed with " << AIERCTOSTR.at(r); \
166#define DEBUG_TYPE "aie-aiert"
168llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
const XAie_LocType &loc) {
169 os <<
"XAie_LocType(col: " << std::to_string(loc.Col)
170 <<
", row: " << std::to_string(loc.Row) <<
")";
174llvm::raw_ostream &
operator<<(llvm::raw_ostream &os,
const XAie_Lock &lock) {
175 os <<
"XAie_Lock(id: " << std::to_string(lock.LockId)
176 <<
", val: " << std::to_string(lock.LockVal) <<
")";
181 const XAie_Packet &packet) {
182 os <<
"XAie_Packet(id: " << std::to_string(packet.PktId)
183 <<
", type: " << std::to_string(packet.PktType) <<
")";
187#define XAIE_BASE_ADDR 0x40000000
188#define XAIE_SHIM_ROW 0
189#define XAIE_MEM_TILE_ROW_START 1
190#define XAIE_PARTITION_BASE_ADDR 0x0
194#define EVEN_BD_NUM_START 0
195#define ODD_BD_NUM_START 24
205 : targetModel(tm), aiert(std::make_unique<
AIERtImpl>()) {
208 size_t partitionStartCol =
210 size_t partitionNumCols = tm.
columns();
211 size_t deviceRows = tm.
rows();
212 size_t deviceCols = tm.
columns() + partitionStartCol;
215 unsigned char devGen;
218 devGen = XAIE_DEV_GEN_AIE;
223 devGen = XAIE_DEV_GEN_AIE2IPU;
226 devGen = XAIE_DEV_GEN_AIE2P_STRIX_B0;
229 aiert->configPtr = XAie_Config{
234 static_cast<uint8_t
>(deviceRows),
235 static_cast<uint8_t
>(deviceCols),
244 XAIE_IO_BACKEND_CDO};
245 XAie_InstDeclare(_devInst, &aiert->configPtr);
246 aiert->devInst = _devInst;
263 XAIE_IO_BACKEND_SIM);
264 }
else if (xaieDebug)
266 XAIE_IO_BACKEND_DEBUG);
269 XAIE_IO_BACKEND_CDO);
274 XAie_DmaDesc &dmaTileBd, Block &block,
276 LLVM_DEBUG(llvm::dbgs() <<
"\nstart configuring bds\n");
277 std::optional<int> acqValue, relValue, acqLockId, relLockId;
282 for (
auto op : block.getOps<AIE::UseLockOp>()) {
287 lock = cast<AIE::LockOp>(op.getLock().getDefiningOp());
288 switch (op.getAction()) {
289 case AIE::LockAction::Acquire:
290 case AIE::LockAction::AcquireGreaterEqual:
291 acqEn = op.getAcqEn();
292 acqLockId = lock.getLockIDValue();
293 acqValue = op.getLockValue();
295 acqValue.value() = -acqValue.value();
297 case AIE::LockAction::Release:
298 relLockId = lock.getLockIDValue();
299 relValue = op.getLockValue();
304 assert(acqValue && relValue && acqLockId && relLockId &&
305 "expected both use_lock(acquire) and use_lock(release) with bd");
309 col,
row, lock.colIndex(), lock.rowIndex());
310 if (lockOffset && acqLockId)
311 acqLockId.value() += lockOffset.value();
312 if (lockOffset && relLockId)
313 relLockId.value() += lockOffset.value();
318 XAie_Lock acqLock = XAie_LockInit(acqLockId.value(), acqValue.value());
319 XAie_Lock relLock = XAie_LockInit(relLockId.value(), relValue.value());
321 dmaTileBd.DmaMod->SetLock, &dmaTileBd, acqLock,
322 relLock, acqEn, relEn);
327 XAie_DevInst *devInst, XAie_DmaDesc &dmaTileBd,
328 Block &block,
int col,
int row,
int bdId,
329 std::optional<int> nextBdId) {
330 std::optional<int> packetType;
331 std::optional<int> packetID;
334 auto maybePacketOps = block.getOps<AIE::DMABDPACKETOp>();
335 if (!maybePacketOps.empty()) {
336 assert(llvm::range_size(maybePacketOps) == 1 &&
337 "expected only one dma_bd_packet");
338 auto packetOp = *maybePacketOps.begin();
339 packetType = packetOp.getPacketType();
340 packetID = packetOp.getPacketID();
343 auto bdOp = *block.getOps<AIE::DMABDOp>().begin();
354 burstLen / 16, qOs, cache, secure);
358 uint64_t baseAddr = 0;
361 cast<AIE::ExternalBufferOp>(bdOp.getBuffer().getDefiningOp());
365 if (bufferOp.getAddress())
366 baseAddr = bufferOp.getAddress().value();
368 auto bufferOp = cast<AIE::BufferOp>(bdOp.getBuffer().getDefiningOp());
369 if (!bufferOp.getAddress())
370 return bufferOp.emitError(
"buffer must have address assigned");
371 baseAddr = bufferOp.getAddress().value();
377 auto bufferOp = cast<AIE::BufferOp>(bdOp.getBuffer().getDefiningOp());
378 auto bufferRow = bufferOp.getTileOp().getRow();
379 auto bufferCol = bufferOp.getTileOp().getCol();
383 baseAddr += addrOffset.value();
386 std::optional<llvm::ArrayRef<AIE::BDDimLayoutAttr>> dims =
387 bdOp.getDimensions();
388 uint64_t lenInBytes = bdOp.getLenInBytes();
389 uint64_t basePlusOffsetInBytes = baseAddr + bdOp.getOffsetInBytes();
392 basePlusOffsetInBytes, lenInBytes);
394 XAie_DmaTensor dmaTileBdTensor = {};
395 dmaTileBdTensor.NumDim = dims->size();
396 dmaTileBdTensor.Dim =
static_cast<XAie_DmaDimDesc *
>(
397 calloc(dmaTileBdTensor.NumDim,
sizeof(XAie_DmaDimDesc)));
398 if (!dmaTileBdTensor.Dim)
399 return bdOp.emitError(
"couldn't allocate array of XAie_DmaDimDesc");
401 double elementWidthIn32bWords =
402 static_cast<double>(bdOp.getBufferElementTypeWidthInBytes()) / 4.0;
403 for (
size_t i = 0; i < dims->size(); i++) {
407 int j = dims->size() - i - 1;
411 stride =
static_cast<uint32_t
>(dims.value()[i].getStride() *
412 elementWidthIn32bWords);
413 size = dims.value()[i].getSize();
415 stride = dims.value()[i].getStride();
416 size =
static_cast<uint16_t
>(dims.value()[i].getSize() *
417 elementWidthIn32bWords);
419 stride = stride > 0 ? stride : 1;
422 dmaTileBdTensor.Dim[j].AieMlDimDesc = {stride, size};
425 &dmaTileBdTensor, basePlusOffsetInBytes,
430 std::optional<llvm::ArrayRef<AIE::BDPadLayoutAttr>> padDims =
431 bdOp.getPadDimensions();
434 XAie_DmaPadTensor dmaPadTensor = {};
435 dmaPadTensor.NumDim = padDims->size();
436 dmaPadTensor.PadDesc =
static_cast<XAie_PadDesc *
>(
437 calloc(dmaPadTensor.NumDim,
sizeof(XAie_PadDesc)));
438 if (!dmaPadTensor.PadDesc)
439 return bdOp.emitError(
"couldn't allocate array of XAie_PadDesc");
441 double elementWidthIn32bWords =
442 static_cast<double>(bdOp.getBufferElementTypeWidthInBytes()) / 4.0;
443 for (
size_t i = 0; i < padDims->size(); i++) {
445 int j = padDims->size() - i - 1;
449 before =
static_cast<uint8_t
>(padDims.value()[i].getConstPadBefore());
450 after =
static_cast<uint8_t
>(padDims.value()[i].getConstPadAfter());
452 before =
static_cast<uint8_t
>(padDims.value()[i].getConstPadBefore() *
453 elementWidthIn32bWords);
454 after =
static_cast<uint8_t
>(padDims.value()[i].getConstPadAfter() *
455 elementWidthIn32bWords);
457 dmaPadTensor.PadDesc[j] = {before, after};
463 auto enableNextBd = 1;
465 nextBdId.value(), enableNextBd);
468 if (
auto packetInfo = bdOp.getPacket()) {
469 packetType = packetInfo->getPktType();
470 packetID = packetInfo->getPktId();
475 bdOp.emitError(
"must have packetType with packetID");
476 if (bdOp.getLen() == 0)
477 return bdOp.emitOpError(
478 "For MM2S channels, if Buffer_Length=0 then Enable_Packet must be "
479 "set to 0, otherwise behavior is undefined (3.7.8 arch spec)");
481 bdOp, XAie_DmaSetPkt, &dmaTileBd,
482 XAie_PacketInit(packetID.value(), packetType.value()));
485 auto tileLoc = XAie_TileLoc(
col,
row);
488 LLVM_DEBUG(llvm::dbgs() <<
"\nend configuring bds\n");
493 Operation &op,
int col,
int row,
int chNum,
const DMAChannelDir &channelDir,
494 int bdId,
int repeatCount) {
495 XAie_DmaDirection direction =
496 channelDir == DMAChannelDir::S2MM ? DMA_S2MM : DMA_MM2S;
497 auto tileLoc = XAie_TileLoc(
col,
row);
498 auto enTokenIssue = tileLoc.Row == 0 && direction == DMA_S2MM;
503 tileLoc, chNum, direction, bdId, repeatCount,
512 DMABDOp bd = *block.getOps<DMABDOp>().begin();
513 assert(bd.getBdId().has_value() &&
514 "DMABDOp must have assigned bd_id; did you forget to run "
515 "aie-assign-bd-ids?");
516 XAie_DmaDesc dmaTileBd;
517 auto tileLoc = XAie_TileLoc(
col,
row);
520 if (!block.getOps<UseLockOp>().empty() &&
523 if (!block.getOps<DMABDOp>().empty() &&
525 col,
row, bd.getBdId().value(),
532 for (
auto tileOp : targetOp.getOps<TileOp>()) {
533 auto tileLoc = XAie_TileLoc(tileOp.colIndex(), tileOp.rowIndex());
534 if (!tileOp.isShimTile() && tileOp.getCoreOp()) {
539 for (uint8_t l = 0; l <
NUM_LOCKS; l++) {
540 auto locInit = XAie_LockInit(l, 0);
548 targetOp.walk<WalkOrder::PreOrder>([&](LockOp lockOp) {
549 if (lockOp.getLockID() && lockOp.getInit()) {
550 auto tileLoc = XAie_TileLoc(lockOp.getTileOp().colIndex(),
551 lockOp.getTileOp().rowIndex());
552 auto locInit = XAie_LockInit(*lockOp.getLockID(), *lockOp.getInit());
556 LLVM_DEBUG(llvm::dbgs()
557 <<
"lock op missing either id or init" << lockOp <<
"\n");
564 targetOp.walk<WalkOrder::PreOrder>([&](BufferOp bufferOp) {
565 auto initialValue = bufferOp.getInitialValue();
568 mlir::DenseElementsAttr denseInit =
569 dyn_cast<mlir::DenseElementsAttr>(initialValue.value());
572 auto tileLoc = XAie_TileLoc(bufferOp.getTileOp().colIndex(),
573 bufferOp.getTileOp().rowIndex());
574 std::vector<char> byteVec;
575 if (denseInit.getElementType().isIntOrIndex()) {
576 for (
auto intVal : denseInit.getValues<APInt>()) {
578 size_t byteSize = (intVal.getBitWidth() + 7) / 8;
580 std::vector<char> bytes(byteSize);
582 static_cast<const char *
>(
static_cast<const void *
>(&intVal)),
583 static_cast<const char *
>(
static_cast<const void *
>(&intVal)) +
586 byteVec.insert(byteVec.end(), bytes.begin(), bytes.end());
588 }
else if (isa<FloatType>(denseInit.getElementType())) {
589 for (
auto floatVal : denseInit.getValues<APFloat>()) {
590 APInt floatInt = floatVal.bitcastToAPInt();
592 size_t byteSize = (floatInt.getBitWidth() + 7) / 8;
594 std::vector<char> bytes(byteSize);
596 static_cast<const char *
>(
static_cast<const void *
>(&floatInt)),
597 static_cast<const char *
>(
static_cast<const void *
>(&floatInt)) +
600 byteVec.insert(byteVec.end(), bytes.begin(), bytes.end());
603 llvm::outs() <<
"buffer op type not supported for initialization "
608 bufferOp.getAddress().value(), byteVec.data(),
617 for (
auto switchboxOp : targetOp.getOps<SwitchboxOp>()) {
618 int32_t
col = switchboxOp.colIndex();
619 int32_t
row = switchboxOp.rowIndex();
620 XAie_LocType tileLoc = XAie_TileLoc(
col,
row);
622 "Only NPU currently supported");
624 Block &b = switchboxOp.getConnections().front();
625 for (
auto connectOp : b.getOps<ConnectOp>())
627 switchboxOp, XAie_StrmConnCctEnable, &aiert->devInst, tileLoc,
628 WIRE_BUNDLE_TO_STRM_SW_PORT_TYPE.at(connectOp.getSourceBundle()),
629 connectOp.sourceIndex(),
630 WIRE_BUNDLE_TO_STRM_SW_PORT_TYPE.at(connectOp.getDestBundle()),
631 connectOp.destIndex());
633 for (
auto masterSetOp : b.getOps<MasterSetOp>()) {
637 for (
auto val : masterSetOp.getAmsels()) {
638 AMSelOp amsel = cast<AMSelOp>(val.getDefiningOp());
639 arbiter = amsel.arbiterIndex();
640 int msel = amsel.getMselValue();
645 bool keepHeader =
true;
647 if (masterSetOp.getDestBundle() == WireBundle::DMA)
651 if (switchboxOp.rowIndex() == 0 &&
652 masterSetOp.getDestBundle() == WireBundle::South)
656 if (
auto keep = masterSetOp.getKeepPktHeader())
660 keepHeader ? XAIE_SS_PKT_DONOT_DROP_HEADER : XAIE_SS_PKT_DROP_HEADER;
662 masterSetOp, XAie_StrmPktSwMstrPortEnable, &aiert->devInst, tileLoc,
663 WIRE_BUNDLE_TO_STRM_SW_PORT_TYPE.at(masterSetOp.getDestBundle()),
664 masterSetOp.destIndex(), dropHeader, arbiter, mask);
667 for (
auto packetRulesOp : b.getOps<PacketRulesOp>()) {
669 Block &block = packetRulesOp.getRules().front();
670 for (
auto slotOp : block.getOps<PacketRuleOp>()) {
671 AMSelOp amselOp = cast<AMSelOp>(slotOp.getAmsel().getDefiningOp());
672 int arbiter = amselOp.arbiterIndex();
673 int msel = amselOp.getMselValue();
675 &aiert->devInst, tileLoc,
676 WIRE_BUNDLE_TO_STRM_SW_PORT_TYPE.at(
677 packetRulesOp.getSourceBundle()),
678 packetRulesOp.sourceIndex());
679 auto packetInit = XAie_PacketInit(slotOp.valueInt(), 0);
682 &aiert->devInst, tileLoc,
683 WIRE_BUNDLE_TO_STRM_SW_PORT_TYPE.at(
684 packetRulesOp.getSourceBundle()),
685 packetRulesOp.sourceIndex(), slot, packetInit,
686 slotOp.maskInt(), msel, arbiter);
692 for (
auto muxOp : targetOp.getOps<ShimMuxOp>()) {
696 XAie_TileLoc(muxOp.getTileOp().getCol(), muxOp.getTileOp().getRow());
697 Block &b = muxOp.getConnections().front();
698 for (
auto connectOp : b.getOps<ConnectOp>()) {
700 if (connectOp.getSourceBundle() == WireBundle::North)
702 &aiert->devInst, tileLoc,
703 connectOp.sourceIndex());
705 if (connectOp.getDestBundle() == WireBundle::North)
707 &aiert->devInst, tileLoc,
708 connectOp.destIndex());
712 for (
auto switchboxOp : targetOp.getOps<ShimSwitchboxOp>()) {
713 Block &b = switchboxOp.getConnections().front();
714 auto tileLoc = XAie_TileLoc(switchboxOp.getCol(), 0);
715 for (
auto connectOp : b.getOps<ConnectOp>())
717 switchboxOp, XAie_StrmConnCctEnable, &aiert->devInst, tileLoc,
718 WIRE_BUNDLE_TO_STRM_SW_PORT_TYPE.at(connectOp.getSourceBundle()),
719 connectOp.sourceIndex(),
720 WIRE_BUNDLE_TO_STRM_SW_PORT_TYPE.at(connectOp.getDestBundle()),
721 connectOp.destIndex());
725 if (isa<AIE2TargetModel>(targetModel)) {
726 for (
auto configOp : targetOp.getOps<ConfigureCascadeOp>()) {
727 TileOp tile = cast<TileOp>(configOp.getTile().getDefiningOp());
728 auto tileLoc = XAie_TileLoc(tile.getCol(), tile.getRow());
730 targetOp, XAie_CoreConfigAccumulatorControl, &aiert->devInst, tileLoc,
731 WIRE_BUNDLE_TO_STRM_SW_PORT_TYPE.at(
732 static_cast<WireBundle
>(configOp.getInputDir())),
733 WIRE_BUNDLE_TO_STRM_SW_PORT_TYPE.at(
734 static_cast<WireBundle
>(configOp.getOutputDir())));
743 if (failed(initLocks(targetOp))) {
747 if (failed(initBuffers(targetOp))) {
751 auto memOps = llvm::to_vector_of<TileElement>(targetOp.getOps<MemOp>());
752 llvm::append_range(memOps, targetOp.getOps<MemTileDMAOp>());
753 llvm::append_range(memOps, targetOp.getOps<ShimDMAOp>());
754 for (TileElement memOp : memOps) {
755 int col = memOp.getTileID().col;
756 int row = memOp.getTileID().row;
760 llvm::SetVector<Block *> blockVector =
764 auto dmaOps = llvm::to_vector_of<DMAOp>(
765 memOp.getOperation()->getRegion(0).getOps<DMAOp>());
766 if (!dmaOps.empty()) {
767 for (
auto dmaOp : dmaOps)
768 for (
auto &bdRegion : dmaOp.getBds()) {
769 Block &block = bdRegion.getBlocks().front();
770 if (failed(configureLocksAndBd(block,
col,
row)))
774 for (Block *block : blockVector) {
775 if (block->getOps<DMABDOp>().empty())
777 if (failed(configureLocksAndBd(*block,
col,
row)))
783 for (
auto dmaOp : dmaOps) {
784 auto &block = dmaOp.getBds().front().getBlocks().front();
785 DMABDOp bd = *block.getOps<DMABDOp>().begin();
786 if (failed(pushToBdQueueAndEnable(
787 *dmaOp.getOperation(),
col,
row, dmaOp.getChannelIndex(),
788 dmaOp.getChannelDir(), bd.getBdId().value(),
789 dmaOp.getRepeatCount())))
793 for (Block *block : blockVector) {
794 for (
auto op : block->getOps<DMAStartOp>()) {
795 DMABDOp bd = *op.getDest()->getOps<DMABDOp>().begin();
796 int chNum = op.getChannelIndex();
797 auto channelDir = op.getChannelDir();
798 if (failed(pushToBdQueueAndEnable(*bd.getOperation(),
col,
row, chNum,
799 channelDir, bd.getBdId().value(),
800 op.getRepeatCount())))
806 if (failed(configureSwitches(targetOp))) {
815 for (
auto tileOp : targetOp.getOps<TileOp>()) {
816 auto tileLoc = XAie_TileLoc(tileOp.colIndex(), tileOp.rowIndex());
817 if (!tileOp.isShimTile() && tileOp.getCoreOp())
825 const StringRef elfPath,
831 XAie_DmaChReset::DMA_CHANNEL_RESET);
836 XAie_TileLoc(
col,
row), elfPath.str().c_str(),
841 XAie_DmaChReset::DMA_CHANNEL_UNRESET);
847 const StringRef elfPath,
849 for (
auto tileOp : targetOp.getOps<TileOp>())
850 if (tileOp.isShimNOCorPLTile()) {
853 int col = tileOp.colIndex();
854 int row = tileOp.rowIndex();
855 if (
auto coreOp = tileOp.getCoreOp()) {
856 std::string fileName;
857 if (
auto fileAttr = coreOp.getElfFile())
858 fileName = fileAttr->str();
860 fileName = (llvm::Twine(
"core_") + std::to_string(
col) +
"_" +
861 std::to_string(
row) +
".elf")
863 auto ps = std::filesystem::path::preferred_separator;
864 if (failed(addAieElf(
866 (llvm::Twine(elfPath) + std::string(1, ps) + fileName).str(),
876 auto tileLoc = XAie_TileLoc(
col,
row);
883 XAIE_TRANSACTION_DISABLE_AUTO_FLUSH);
888 uint8_t *txn_ptr = XAie_ExportSerializedTransaction(&aiert->devInst, 0, 0);
889 XAie_TxnHeader *hdr = (XAie_TxnHeader *)txn_ptr;
890 std::vector<uint8_t> txn_data(txn_ptr, txn_ptr + hdr->TxnSize);
llvm::raw_ostream & showAIEXRTArgs(llvm::raw_ostream &out, const char *label, H1 &&value)
LogicalResult configureLocksInBdBlock(const AIE::AIETargetModel &targetModel, XAie_DmaDesc &dmaTileBd, Block &block, int col, int row)
#define XAIE_PARTITION_BASE_ADDR
#define TRY_XAIE_API_LOGICAL_RESULT(API,...)
#define TRY_XAIE_API_FATAL_ERROR(API,...)
llvm::raw_ostream & operator<<(llvm::raw_ostream &os, const XAie_LocType &loc)
#define TRY_XAIE_API_EMIT_ERROR(OP, API,...)
#define XAIE_MEM_TILE_ROW_START
LogicalResult configureBdInBlock(const AIE::AIETargetModel &targetModel, XAie_DevInst *devInst, XAie_DmaDesc &dmaTileBd, Block &block, int col, int row, int bdId, std::optional< int > nextBdId)
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...
virtual AIEArch getTargetArch() const =0
Return the target architecture.
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 bool isMemTile(int col, int row) const =0
Return true if the given tile is an AIE2 'Memory' tile.
virtual int rows() const =0
Return the number of rows in the device.
virtual bool isShimNOCTile(int col, int row) const =0
Return true if the given tile is a Shim NOC tile.
virtual uint32_t getColumnShift() const =0
bool hasProperty(ModelProperty Prop) const
virtual int columns() const =0
Return the number of columns in the device.
virtual uint32_t getNumMemTileRows() const =0
virtual uint32_t getRowShift() const =0
uint32_t getShimBurstLengthBytes(const AIE::AIETargetModel &tm, uint32_t burstLength)
llvm::SetVector< mlir::Block * > getOrderedChainOfBlocks(mlir::Region *region)
mlir::LogicalResult pushToBdQueueAndEnable(mlir::Operation &op, int col, int row, int chNum, const DMAChannelDir &channelDir, int bdId, int repeatCount)
void dmaUpdateBdAddr(int col, int row, size_t addr, size_t bdId)
mlir::LogicalResult addAieElfs(DeviceOp &targetOp, const mlir::StringRef workDirPath, bool aieSim)
mlir::LogicalResult setIOBackend(bool aieSim, bool xaieDebug)
std::vector< uint8_t > exportSerializedTransaction()
AIERTControl(const xilinx::AIE::AIETargetModel &tm)
mlir::LogicalResult initLocks(DeviceOp &targetOp)
mlir::LogicalResult configureSwitches(DeviceOp &targetOp)
mlir::LogicalResult initBuffers(DeviceOp &targetOp)
mlir::LogicalResult addCoreEnable(DeviceOp &targetOp)
mlir::LogicalResult addAieElf(uint8_t col, uint8_t row, const mlir::StringRef elfPath, bool aieSim)
mlir::LogicalResult configureLocksAndBd(mlir::Block &block, int col, int row)
mlir::LogicalResult addInitConfig(DeviceOp &targetOp)