MLIR-AIE 1.4.6.dev
AIETargetXAIEV2.cpp
Go to the documentation of this file.
1//===- AIETargetXAIEV2.cpp --------------------------------------*- C++ -*-===//
2//
3// Copyright (C) 2021-2022 Xilinx, Inc.
4// Copyright (C) 2021-2023 Advanced Micro Devices, Inc.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
9
13
14#include "mlir/Dialect/Utils/StaticValueUtils.h"
15#include "mlir/IR/Attributes.h"
16#include "mlir/IR/IRMapping.h"
17#include "mlir/Pass/Pass.h"
18#include "mlir/Tools/mlir-translate/MlirTranslateMain.h"
19
20#include "llvm/ADT/StringExtras.h"
21#include "llvm/IR/Module.h"
22
23#include <limits>
24
25using namespace mlir;
26using namespace xilinx;
27using namespace xilinx::AIE;
28using namespace xilinx::AIEX;
29
30// This string is output at the top of the lowered C++ code.
31static const char *xaie_cpp_file_header = R"code(
32// This file was auto-generated by aiecc --aie-generate-xaie.
33
34#ifndef MLIR_AIE_QUIET
35#define __mlir_aie_verbose(x) x
36#else
37#define __mlir_aie_verbose(x)
38#endif
39
40// The following is a wrapper for the common "if(call() != 0) return 1" pattern.
41// Use this only in functions that return int. If the call this wrapper is used
42// on does not succeed, the expanded code will exit out of the function
43// containing this macro with an error code.
44#define __mlir_aie_try(x) do { \
45 AieRC ret = (x); \
46 if(ret != XAIE_OK) { \
47 return x; \
48 } \
49} while(0)
50
51static XAie_DmaDimDesc *__mlir_aie_alloc_dim_desc(size_t ndims) {
52 XAie_DmaDimDesc *ret = NULL;
53 ret = (XAie_DmaDimDesc *)calloc(sizeof(XAie_DmaDimDesc), ndims);
54 if(NULL == ret) {
55 __mlir_aie_verbose(fprintf(stderr, "Allocating DmaDimDesc failed.\n"));
56 }
57 return ret;
58}
59
60)code";
61
62static std::string tileLockStr(StringRef id, StringRef val) {
63 std::string str;
64 llvm::raw_string_ostream rss(str);
65 // rss << "XAie_Lock(" << id << "," << val << ")";
66 rss << "XAie_LockInit(" << id << "," << val << ")";
67 return str;
68}
69
70// Translate mlir-aie WireBundle enum to string of aie-codegen StrmSwPortType
71// enum
72static std::string wireBundleToPortType(WireBundle bundle) {
73 switch (bundle) {
74 case WireBundle::PLIO:
75 return "PL";
76 case WireBundle::TileControl:
77 return "CTRL";
78 default:
79 return stringifyWireBundle(bundle).upper();
80 }
81}
82
83// FIXME: this is a template pending a common DMA-like interface across the op
84// types.
85// blockMap: A map that gives a unique bd ID assignment for every block.
86template <typename OpType>
87static mlir::LogicalResult generateDMAConfig(OpType memOp, raw_ostream &output,
88 const AIETargetModel &targetModel,
89 DenseMap<Block *, int> blockMap) {
90 StringRef enable = "XAIE_ENABLE";
91 StringRef disable = "XAIE_DISABLE";
92 StringRef deviceInstRef = "ctx->XAieDevInst";
93
94 int col = memOp.colIndex();
95 int row = memOp.rowIndex();
96
97 // Get the region's entry block, then start traversing through the chain of
98 // blocks.
99 llvm::SetVector<Block *> blockVector =
100 getOrderedChainOfBlocks(&memOp.getBody());
101
102 llvm::SmallPtrSet<Block *, 8> unchainedBlocks =
103 collectUnchainedBlocks(blockVector);
104
105 for (auto *block : blockVector) {
106 bool foundBdPacket = false;
107 int packetType = 0;
108 int packetID = 0;
109 bool foundBd = false;
110 uint64_t lenA = 0;
111 int64_t offsetA = 0;
112 int BaseAddrA = 0;
113 int elementWidthInBytes = 0;
114 int ndims = 0;
115 int iterSize = 0, iterStride = 0, iterCurr = 0;
116 uint32_t axcache = 0;
117 std::optional<int> oooId;
118 ArrayRef<BDDimLayoutAttr> dims;
119 // Owning storage for the folded dims; must outlive `dims` (used far below).
120 SmallVector<BDDimLayoutAttr> dimsStorage;
121 // StringRef FifoMode = disable; // FIXME: when to enable FIFO mode?
122 // A legacy dma_bd_packet op is read first so that a packet attribute on
123 // the dma_bd overrides it, matching AIERT.
124 for (auto op : block->getOps<DMABDPACKETOp>()) {
125 foundBdPacket = true;
126 packetType = op.getPacketType();
127 packetID = op.getPacketID();
128 }
129 for (auto op : block->getOps<DMABDOp>()) {
130 foundBd = true;
131 if (auto packetInfo = op.getPacket()) {
132 foundBdPacket = true;
133 packetType = packetInfo->getPktType();
134 packetID = packetInfo->assignedId();
135 }
136 if (!targetModel.isShimNOCTile(col, row)) {
137 std::optional<int32_t> bufferAddr = op.getBufferOp().getAddress();
138 assert(bufferAddr && "buffer must have address assigned");
139 BaseAddrA = *bufferAddr;
140 int bufferCol = op.getBufferOp().getTileOp().colIndex();
141 int bufferRow = op.getBufferOp().getTileOp().rowIndex();
142
143 // Memtile DMAs can access neighboring tiles.
144 if (targetModel.isMemTile(col, row)) {
145 auto addrOffset = targetModel.getMemLocalBaseAddress(
146 col, row, bufferCol, bufferRow);
147 if (addrOffset)
148 BaseAddrA += addrOffset.value();
149 }
150 }
151
152 lenA = op.getLenInBytes();
153 offsetA = op.getOffsetInBytes();
154 elementWidthInBytes = op.getBufferElementTypeWidthInBytes();
155 if (auto iter = op.getIteration()) {
156 iterSize = iter->getSize();
157 iterStride = iter->getStride();
158 iterCurr = iter->getCurrent();
159 }
160 axcache = op.getAxcacheOrDefault();
161 oooId = op.getOutOfOrderId();
162 if (!op.getMixedSizes().empty()) {
163 // Runtime-valued sizes/strides are not supported on this static path.
164 for (mlir::OpFoldResult s : op.getMixedSizes())
165 if (!mlir::getConstantIntValue(s))
166 return op->emitOpError(
167 "runtime-valued BD size/stride is not supported on the static "
168 "XAIE lowering path; use compile-time constant sizes");
169 for (mlir::OpFoldResult s : op.getMixedStrides())
170 if (!mlir::getConstantIntValue(s))
171 return op->emitOpError(
172 "runtime-valued BD size/stride is not supported on the static "
173 "XAIE lowering path; use compile-time constant sizes");
174 std::optional<SmallVector<BDDimLayoutAttr>> folded =
175 op.getConstantDimensions();
176 if (!folded)
177 return op->emitOpError("internal error folding BD dimensions");
178 dimsStorage = std::move(*folded);
179 dims = dimsStorage;
180 ndims = dims.size();
181 }
182 }
183
184 if (0 != ndims)
186 return memOp.emitOpError("DMA contains at least one multi-dimensional "
187 "buffer descriptor. This is currently only "
188 "supported for AIE-ML and later devices.");
189 // Ensure BD length in bytes fits in the u32 `Len` argument of the libxaie
190 // DMA APIs (XAie_DmaSetAddrLen / XAie_DmaSetMultiDimAddr).
191 if (foundBd && lenA > std::numeric_limits<uint32_t>::max()) {
192 return memOp.emitOpError("buffer descriptor length in bytes (")
193 << lenA << ") does not fit in 32 bits";
194 }
195
196 int acqValue = 0, relValue = 0;
197 bool hasAcq = false, hasRel = false;
198 int acqLockID = 0, relLockID = 0;
199 for (auto op : block->getOps<UseLockOp>()) {
200 LockOp lock = cast<LockOp>(op.getLock().getDefiningOp());
201 int lockCol = lock.colIndex();
202 int lockRow = lock.rowIndex();
203 int lockID = lock.getLockIDValue();
204 // Memtile DMAs can access neighboring tiles.
205 if (targetModel.isMemTile(col, row)) {
206 auto lockOffset =
207 targetModel.getLockLocalBaseIndex(col, row, lockCol, lockRow);
208 if (lockOffset)
209 lockID += lockOffset.value();
210 }
211
212 if (op.acquire() || op.acquireGE()) {
213 hasAcq = true;
214 acqLockID = lockID;
215 auto value = op.getConstantValue();
216 if (failed(value))
217 return failure();
218 acqValue = *value; // NOLINT(bugprone-unchecked-optional-access)
219 if (op.acquireGE())
220 acqValue = -acqValue;
221 } else if (op.release()) {
222 hasRel = true;
223 relLockID = lockID;
224 auto value = op.getConstantValue();
225 if (failed(value))
226 return failure();
227 relValue = *value; // NOLINT(bugprone-unchecked-optional-access)
228 } else {
229 // unreachable for current targets
230 return op.emitOpError("unsupported lock action");
231 }
232 }
233
234 int bdNum = blockMap[block];
235 if (foundBd) {
236 // TODO For now, we are going to name each dma desc with loc and bd
237 // which we assume is unique. This is strictly not enforced but in
238 // practice, this is true
239 output << "XAie_DmaDesc " << tileDMAInstStr(col, row, bdNum) << ";\n";
240 output << "__mlir_aie_try(XAie_DmaDescInit(" << deviceInstRef << ", "
241 << tileDMAInstRefStr(col, row, bdNum) << ", "
242 << tileLocStr(col, row) << "));\n";
243 if (hasAcq || hasRel) {
244 output << "__mlir_aie_try(XAie_DmaSetLock("
245 << tileDMAInstRefStr(col, row, bdNum) << ", "
246 << "XAie_LockInit(" << acqLockID << "," << acqValue << "),"
247 << "XAie_LockInit(" << relLockID << "," << relValue << ")));\n";
248 if (!hasAcq)
249 output << tileDMAInstStr(col, row, bdNum)
250 << ".LockDesc.LockAcqEn = " << disable << ";\n";
251 if (!hasRel)
252 output << tileDMAInstStr(col, row, bdNum)
253 << ".LockDesc.LockRelEn = " << disable << ";\n";
254 }
255
256 if (0 == ndims) {
257 if (targetModel.isShimNOCTile(col, row)) {
258 output << "__mlir_aie_try(XAie_DmaSetAddrLen("
259 << tileDMAInstRefStr(col, row, bdNum) << ", /* addrA */ "
260 << "mlir_aie_external_get_addr_myBuffer_" << col << row << "_"
261 << bdNum << "(), "
262 << " /* len */ " << lenA << "));\n";
263 output << "__mlir_aie_try(XAie_DmaSetAxi("
264 << tileDMAInstRefStr(col, row, bdNum) << ", "
265 << "/* smid */ 0, "
266 << "/* burstlen */ 4, "
267 << "/* QoS */ 0, "
268 << "/* Cache */ " << axcache << ", "
269 << "/* Secure */ " << enable << "));\n";
270 } else {
271 if ((BaseAddrA + offsetA) % 4)
272 return memOp.emitError("bd address must be 4B (32b) aligned");
273 output << "__mlir_aie_try(XAie_DmaSetAddrLen("
274 << tileDMAInstRefStr(col, row, bdNum) << ", /* addrA */ "
275 << "0x" << llvm::utohexstr(BaseAddrA + offsetA) << ", "
276 << " /* len */ " << lenA << "));\n";
277 }
278 } else
279 generateXAieDmaSetMultiDimAddr(output, ndims, dims, col, row, bdNum,
280 BaseAddrA, offsetA, lenA,
281 elementWidthInBytes, "1");
282
283 if (iterSize > 1 && iterStride > 0) {
284 int64_t strideInBytes =
285 static_cast<int64_t>(iterStride) * elementWidthInBytes;
286 if (strideInBytes % 4)
287 return memOp.emitError("iteration_stride must result in a stride "
288 "aligned to 32-bit words");
289 int stepInWords = static_cast<int>(strideInBytes / 4);
290 output << "__mlir_aie_try(XAie_DmaSetBdIteration("
291 << tileDMAInstRefStr(col, row, bdNum) << ", " << stepInWords
292 << ", " << iterSize << ", " << iterCurr << "));\n";
293 }
294
295 if (block->getNumSuccessors() > 0) {
296 Block *nextBlock = block->getSuccessors()[0]; // should have only one
297 // successor block
298
299 int enableNextBd = 1;
300 if (!nextBlock->getOps<EndOp>().empty())
301 enableNextBd = 0;
302 if (unchainedBlocks.contains(block))
303 enableNextBd = 0;
304
305 int nextBdNum = blockMap[nextBlock];
306 output << "__mlir_aie_try(XAie_DmaSetNextBd("
307 << tileDMAInstRefStr(col, row, bdNum) << ", "
308 << " /* nextbd */ " << nextBdNum << ", "
309 << " /* enableNextBd */ " << enableNextBd << "));\n";
310 }
311
312 if (foundBdPacket) {
313 output << "__mlir_aie_try(XAie_DmaSetPkt("
314 << tileDMAInstRefStr(col, row, bdNum) << ", "
315 << packetStr(packetID, packetType) << "));\n";
316 }
317 if (oooId.has_value()) {
318 output << "__mlir_aie_try(XAie_DmaSetOutofOrderBdId("
319 << tileDMAInstRefStr(col, row, bdNum) << ", " << *oooId
320 << "));\n";
321 }
322 output << "__mlir_aie_try(XAie_DmaEnableBd("
323 << tileDMAInstRefStr(col, row, bdNum) << "));\n";
324 output << "__mlir_aie_try(XAie_DmaWriteBd(" << deviceInstRef << ", "
325 << tileDMAInstRefStr(col, row, bdNum) << ", "
326 << tileLocStr(col, row) << ", "
327 << " /* bd */ " << bdNum << "));\n";
328 }
329 }
330
331 for (auto *block : blockVector) {
332 for (auto op : block->getOps<DMAStartOp>()) {
333 int bdNum = blockMap[op.getDest()];
334 StringRef dmaDir = stringifyDMAChannelDir(op.getChannelDir());
335 int chNum = op.getChannelIndex();
336 const auto &target_model = xilinx::AIE::getTargetModel(op);
337 if (target_model.getTargetArch() == AIEArch::AIE1) {
338 output << "__mlir_aie_try(XAie_DmaChannelPushBdToQueue("
339 << deviceInstRef << ", " << tileLocStr(col, row) << ", "
340 << "/* ChNum */" << chNum
341 << ", "
342 // TODO: interim handling until the physical dialect changes.
343 << "/* dmaDir */ DMA_" << dmaDir << ", "
344 << "/* BdNum */" << bdNum << "));\n";
345 } else if (op.getOutOfOrder()) {
346 // in english repeat_count==0 means "do it once" and don't repeat but
347 // libxaie treats repeat_count=1 as do it once.
348 int repeatCount = op.getRepeatCount() + 1;
349 // StartBd is ignored and the in-order validity check is skipped.
350 std::string oooSuffix = std::to_string(col) + "_" +
351 std::to_string(row) + "_" +
352 std::to_string(chNum);
353 output << "{\n";
354 output << "XAie_DmaChannelDesc ooo_desc_" << oooSuffix << ";\n";
355 output << "__mlir_aie_try(XAie_DmaChannelDescInit(" << deviceInstRef
356 << ", &ooo_desc_" << oooSuffix << ", " << tileLocStr(col, row)
357 << "));\n";
358 output << "__mlir_aie_try(XAie_DmaChannelEnOutofOrder(&ooo_desc_"
359 << oooSuffix << ", " << enable << "));\n";
360 output << "__mlir_aie_try(XAie_DmaWriteChannel(" << deviceInstRef
361 << ", &ooo_desc_" << oooSuffix << ", " << tileLocStr(col, row)
362 << ", /* ChNum */" << chNum << ", /* dmaDir */ DMA_" << dmaDir
363 << "));\n";
364 output << "XAie_DmaDeclareQueueConfig(ooo_queue_" << oooSuffix
365 << ", /* StartBd */ 0, /* Repeat */ " << repeatCount
366 << ", /* EnToken */ " << disable << ", /* EnOutOfOrder */ "
367 << enable << ");\n";
368 output << "__mlir_aie_try(XAie_DmaChannelSetStartQueueGeneric("
369 << deviceInstRef << ", " << tileLocStr(col, row)
370 << ", /* ChNum */" << chNum << ", /* dmaDir */ DMA_" << dmaDir
371 << ", &ooo_queue_" << oooSuffix << "));\n";
372 output << "}\n";
373 } else {
374 // in english repeat_count==0 means "do it once" and don't repeat but
375 // libxaie treats repeat_count=1 as do it once.
376 int repeatCount = op.getRepeatCount() + 1;
377 output << "__mlir_aie_try(XAie_DmaChannelSetStartQueue("
378 << deviceInstRef << ", " << tileLocStr(col, row) << ", "
379 << "/* ChNum */" << chNum
380 << ", "
381 // TODO: interim handling until the physical dialect changes.
382 << "/* dmaDir */ DMA_" << dmaDir << ", "
383 << "/* BdNum */" << bdNum << ", "
384 << "/* Repeat */ " << repeatCount << ", "
385 << "/* EnToken */ "
386 << "XAIE_DISABLE"
387 << "));\n";
388 }
389 output << "__mlir_aie_try(XAie_DmaChannelEnable(" << deviceInstRef << ", "
390 << tileLocStr(col, row) << ", "
391 << "/* ChNum */ " << chNum
392 << ", "
393 // TODO: interim handling until the physical dialect changes.
394 << "/* dmaDir */ DMA_" << dmaDir << "));\n";
395 }
396 }
397 return success();
398}
399
400mlir::LogicalResult
401xilinx::AIE::AIETranslateToXAIEV2(ModuleOp module, raw_ostream &output,
402 llvm::StringRef deviceName) {
403 StringRef ctx_p = "aie_libxaie_ctx_t* ctx";
404 StringRef deviceInstRef = "ctx->XAieDevInst";
405
406 DenseMap<TileID, Operation *> tiles;
407 DenseMap<Operation *, SmallVector<BufferOp, 4>> buffers;
408
409 DeviceOp targetOp = AIE::DeviceOp::getForSymbolInModule(module, deviceName);
410 if (!targetOp)
411 return module.emitOpError("expected AIE.device operation at toplevel");
412 if (failed(verifyDMAChannelsResolved(targetOp)))
413 return failure();
414 for (CoreOp core : targetOp.getOps<CoreOp>()) {
415 bool configuresDMA = core.getProcessorBus();
416 core.walk([&](Operation *op) {
417 configuresDMA |= isa<DmaPushQueueOp, DmaPollForQueueSpaceOp>(op);
418 });
419 if (configuresDMA)
420 return core.emitOpError("core-issued configuration is not supported by "
421 "the XAIEV2 backend");
422 }
423 WalkResult corePushes = targetOp.walk([&](DMAStartOp start) {
424 if (!start.getCorePushes())
425 return WalkResult::advance();
426 start.emitOpError("core-issued configuration is not supported by "
427 "the XAIEV2 backend");
428 return WalkResult::interrupt();
429 });
430 if (corePushes.wasInterrupted())
431 return failure();
432 const auto &targetModel = targetOp.getTargetModel();
433
434 collectTiles(targetOp, tiles);
435 collectBuffers(targetOp, buffers);
436
437 //---------------------------------------------------------------------------
438 // mlir_aie_init_libxaie
439 //---------------------------------------------------------------------------
440 output << xaie_cpp_file_header;
441 output << "aie_libxaie_ctx_t* mlir_aie_init_libxaie() {\n";
442 output << " aie_libxaie_ctx_t *ctx = new aie_libxaie_ctx_t;\n";
443 output << " if (!ctx)\n";
444 output << " return 0;\n";
445 output << " ctx->XAieConfig = new XAie_Config;\n";
446 output << " if (!ctx->XAieConfig)\n";
447 output << " return 0;\n";
448 output << " ctx->XAieDevInst = new XAie_DevInst;\n";
449 output << " if (!ctx->XAieDevInst)\n";
450 output << " return 0;\n";
451 auto arch = targetModel.getTargetArch();
452 std::string AIE1_device("XAIE_DEV_GEN_AIE");
453 std::string AIE2_device("XAIE_DEV_GEN_AIEML");
454 std::string AIE2p_device("XAIE_DEV_GEN_AIE2P");
455 std::string device;
456 switch (arch) {
457 case AIEArch::AIE1:
458 device = AIE1_device;
459 break;
460 case AIEArch::AIE2:
461 device = AIE2_device;
462 break;
463 case AIEArch::AIE2p:
464 device = AIE2p_device;
465 break;
466 case AIEArch::AIE2ps:
467 // AIE2PS configures the array through a CERT ELF instead of this libxaie
468 // source (see AIE2PSTargetModel). Listed here so that a new AIEArch still
469 // raises -Wswitch.
470 return targetOp.emitOpError(
471 "--aie-generate-xaie is not supported for the AIE2PS architecture");
472 case AIEArch::AIE4:
473 return targetOp.emitOpError(
474 "--aie-generate-xaie is not supported for the AIE4 architecture");
475 }
476 output << " ctx->XAieConfig->AieGen = " << device << ";\n";
477 output << " ctx->XAieConfig->BaseAddr = 0x20000000000;\n";
478 output << " ctx->XAieConfig->ColShift = " << targetModel.getColumnShift()
479 << ";\n";
480 output << " ctx->XAieConfig->RowShift = " << targetModel.getRowShift()
481 << ";\n";
482 output << " ctx->XAieConfig->NumRows = " << targetModel.rows() << ";\n";
483 output << " ctx->XAieConfig->NumCols = " << targetModel.columns() << ";\n";
484 output << " ctx->XAieConfig->ShimRowNum = 0;\n";
485 output << " ctx->XAieConfig->MemTileRowStart = 1;\n";
486 output << " ctx->XAieConfig->MemTileNumRows = "
487 << targetModel.getNumMemTileRows() << ";\n";
488 output << " // ctx->XAieConfig->ReservedRowStart = "
489 "XAIE_RES_TILE_ROW_START;\n";
490 output
491 << " // ctx->XAieConfig->ReservedNumRows = XAIE_RES_TILE_NUM_ROWS;\n";
492 output << " ctx->XAieConfig->AieTileRowStart = "
493 << (1 + targetModel.getNumMemTileRows()) << ";\n";
494 output << " ctx->XAieConfig->AieTileNumRows = "
495 << (targetModel.rows() - 1 - targetModel.getNumMemTileRows()) << ";\n";
496 output << " memset(ctx->XAieDevInst, 0, sizeof(XAie_DevInst));\n";
497 output << " return ctx;\n";
498 output << "}\n";
499 output << "\n";
500
501 //---------------------------------------------------------------------------
502 // mlir_aie_configure_cores
503 //---------------------------------------------------------------------------
504 // Defined below. configure_cores calls it at its end, once every ELF is
505 // loaded, so a PT_LOAD cannot land on top of an initialized buffer.
506 output << "int mlir_aie_initialize_buffers(" << ctx_p << ");\n";
507 output << "int mlir_aie_configure_cores(" << ctx_p << ") {\n";
508 // Reset each core. Load the corresponding ELF file, if necessary.
509 for (auto tileOp : targetOp.getOps<TileOp>()) {
510 int col = tileOp.colIndex();
511 int row = tileOp.rowIndex();
512 if (tileOp.isShimTile() || tileOp.isMemTile()) {
513 // Resets no needed with V2 kernel driver
514 } else {
515 // Resets no needed with V2 kernel driver
516 output << "__mlir_aie_try(XAie_CoreReset(" << deviceInstRef << ", "
517 << tileLocStr(col, row) << "));\n";
518 output << "__mlir_aie_try(XAie_CoreDisable(" << deviceInstRef << ", "
519 << tileLocStr(col, row) << "));\n";
520 // Release locks
521 int numLocks = targetModel.getNumLocks(col, row);
522 output << "for (int l = 0; l < " << numLocks << "; ++l)\n"
523 << " __mlir_aie_try(XAie_LockRelease(" << deviceInstRef << ", "
524 << tileLocStr(col, row) << ", XAie_LockInit(l, 0x0), 0));\n";
525 if (auto coreOp = tileOp.getCoreOp()) {
526 if (coreOp.isEmpty() && coreOp.getElfFile() == std::nullopt) {
527 // This core has no MLIR code and references no ELF file -- it is
528 // completely empty, so don't generate any code for it.
529 continue;
530 }
531 std::string fileName;
532 if (auto fileAttr = coreOp.getElfFile()) {
533 fileName = fileAttr.value().str();
534 } else {
535 return coreOp.emitOpError()
536 << "Expected lowered ELF file to be given as attribute "
537 "`elf_file` for this core. Compile cores first.";
538 }
539 output << "{\n"
540 << "AieRC RC = XAie_LoadElf(" << deviceInstRef << ", "
541 << tileLocStr(col, row) << ", "
542 << "(const char*)\"" << fileName << "\",0);\n";
543 output << "if (RC != XAIE_OK)\n"
544 << " __mlir_aie_verbose(fprintf(stderr, \"Failed to load elf "
545 "for Core[%d,%d], ret is %d\\n\", "
546 << std::to_string(col) << ", " << std::to_string(row)
547 << ", RC));\n"
548 << "assert(RC == XAIE_OK);\n"
549 << "}\n";
550 }
551 }
552 }
553 // __mlir_aie_try assigns to an AieRC, and the generated entry points return
554 // int, which C++ does not convert implicitly.
555 output << "{\n";
556 output << " int rc = mlir_aie_initialize_buffers(ctx);\n";
557 output << " if (rc != XAIE_OK)\n";
558 output << " return rc;\n";
559 output << "}\n";
560 output << "return XAIE_OK;\n";
561 output << "} // mlir_aie_configure_cores\n\n";
562
563 //---------------------------------------------------------------------------
564 // mlir_aie_start_cores
565 //---------------------------------------------------------------------------
566 output << "int mlir_aie_start_cores(" << ctx_p << ") {\n";
567 // Start execution of all the cores.
568 for (auto tileOp : targetOp.getOps<TileOp>()) {
569 int col = tileOp.colIndex();
570 int row = tileOp.rowIndex();
571 if (!tileOp.isShimTile() && !tileOp.isMemTile()) {
572 output << "__mlir_aie_try(XAie_CoreUnreset(" << deviceInstRef << ", "
573 << tileLocStr(col, row) << "));\n";
574 output << "__mlir_aie_try(XAie_CoreEnable(" << deviceInstRef << ", "
575 << tileLocStr(col, row) << "));\n";
576 }
577 }
578 output << "return XAIE_OK;\n";
579 output << "} // mlir_aie_start_cores\n\n";
580
581 //---------------------------------------------------------------------------
582 // mlir_aie_configure_dmas
583 //---------------------------------------------------------------------------
584 output << "int mlir_aie_configure_dmas(" << ctx_p << ") {\n";
585
586 for (auto memOp : targetOp.getOps<MemOp>()) {
587 DenseMap<Block *, int> blockMap;
588
589 // Use bd_ids, if specified.
590 int bdNum = 0;
591 for (auto &block : memOp.getBody()) {
592 auto bdOps = block.getOps<DMABDOp>();
593 if (bdOps.empty())
594 continue;
595 std::optional<int32_t> id = (*bdOps.begin()).getBdId();
596 blockMap[&block] = id.has_value() ? *id : bdNum;
597 bdNum++;
598 }
599 auto result = generateDMAConfig(memOp, output, targetModel, blockMap);
600 if (result.failed())
601 return result;
602 }
603 for (auto memOp : targetOp.getOps<MemTileDMAOp>()) {
604 DenseMap<Block *, int> blockMap;
605 // Memtiles have restrictions on which channels can access which BDs
606 DenseMap<Block *, int> channelMap;
607
608 for (auto &block : memOp.getBody()) {
609 for (auto op : block.getOps<DMAStartOp>()) {
610 int chNum = op.getChannelIndex();
611 channelMap[&block] = chNum;
612 auto *dest = op.getDest();
613 while (dest) {
614 channelMap[dest] = chNum;
615 if (dest->getSuccessors().empty())
616 break;
617 dest = dest->getSuccessors()[0];
618 if (channelMap.count(dest))
619 break;
620 }
621 }
622 }
623
624 // Assign each block a BD number, if unassigned
625 int evenBdNum = 0;
626 int oddBdNum = 24;
627 for (auto &block : memOp.getBody()) {
628 auto bdOps = block.getOps<DMABDOp>();
629 if (bdOps.empty())
630 continue;
631 assert(channelMap.count(&block));
632 if (std::optional<int32_t> id = (*bdOps.begin()).getBdId())
633 blockMap[&block] = *id;
634 else if (channelMap[&block] & 1)
635 blockMap[&block] = oddBdNum++;
636 else
637 blockMap[&block] = evenBdNum++;
638 }
639 auto result = generateDMAConfig(memOp, output, targetModel, blockMap);
640 if (result.failed())
641 return result;
642 }
643
644 output << "return XAIE_OK;\n";
645 output << "} // mlir_aie_configure_dmas\n\n";
646
647 for (auto op : targetOp.getOps<ExternalBufferOp>()) {
648 if (op.hasName()) {
649 output << "static u64 _mlir_aie_external_" << op.name().getValue()
650 << ";\n";
651 output << "static bool _mlir_aie_external_set_" << op.name().getValue()
652 << " = false;\n";
653
654 output << "void mlir_aie_external_set_addr_" << op.name().getValue()
655 << "(" << ctx_p << ", u64 VA) {\n"
656 << " u64 device_address = mlir_aie_get_device_address(ctx, (void "
657 "*)VA);\n"
658 << " _mlir_aie_external_set_" << op.name().getValue()
659 << " = true;\n"
660 << " _mlir_aie_external_" << op.name().getValue()
661 << " = device_address;\n"
662 << "}\n";
663 }
664 }
665
666 // ShimDMA Config
667 // int index = 0;
668 for (auto op : targetOp.getOps<ShimDMAOp>()) {
669 int col = op.colIndex();
670 int row = op.rowIndex();
671
672 DenseMap<Block *, int> blockMap;
673 {
674 // Assign each block a BD number, if unassigned
675 int bdNum = 0;
676 for (auto &block : op.getBody()) {
677 auto bdOps = block.getOps<DMABDOp>();
678 if (bdOps.empty())
679 continue;
680 std::optional<int32_t> id = (*bdOps.begin()).getBdId();
681 int slot = id.has_value() ? *id : bdNum;
682 blockMap[&block] = slot;
683 uint64_t offset = 0;
684 for (auto op : block.getOps<DMABDOp>()) {
685 offset = op.getOffsetInBytes();
686 auto buffer = cast<ExternalBufferOp>(op.getBuffer().getDefiningOp());
687
688 output << "u64 mlir_aie_external_get_addr_myBuffer_" << col << row
689 << "_" << slot << "(void) {\n"
690 << " assert(_mlir_aie_external_set_"
691 << buffer.name().getValue() << ");\n"
692 << " return _mlir_aie_external_" << buffer.name().getValue()
693 << " + " << llvm::utohexstr(offset) << ";\n"
694 << "}\n";
695 }
696
697 bdNum++;
698 }
699 }
700
701 output << "int mlir_aie_configure_shimdma_" << col << row << "(" << ctx_p
702 << ") {\n";
703 auto result = generateDMAConfig(op, output, targetModel, blockMap);
704 if (result.failed())
705 return result;
706 output << "return XAIE_OK;\n";
707 output << "} // mlir_aie_configure_shimdma\n\n";
708 }
709
710 //---------------------------------------------------------------------------
711 // mlir_aie_initialize_locks
712 //---------------------------------------------------------------------------
713 output << "int mlir_aie_initialize_locks(" << ctx_p << ") {\n";
714 // Lock configuration
715 targetOp.walk<WalkOrder::PreOrder>([&](LockOp lock) {
716 TileOp tile = lock.getTileOp();
717 int col = tile.colIndex();
718 int row = tile.rowIndex();
719 int lockID = lock.getLockIDValue();
720 auto init = lock.getInit();
721 if (init)
722 output << "__mlir_aie_try(XAie_LockSetValue(" << deviceInstRef << ", "
723 << tileLocStr(col, row) << ", "
724 << "XAie_LockInit(" << lockID << ", " << *init << ")));\n";
725 });
726 output << "return XAIE_OK;\n";
727 output << "} // mlir_aie_initialize_locks\n";
728
729 //---------------------------------------------------------------------------
730 // mlir_aie_initialize_buffers
731 //---------------------------------------------------------------------------
732 // A buffer's initial_value is device state, written by whoever configures
733 // the device: the CDO writer on the NPU path, this function on the simulator
734 // path. This walks every tile, because a memtile buffer has no core and so no
735 // other route. mlir_aie_configure_cores calls this, so a host that already
736 // configures its cores needs no change.
737 output << "int mlir_aie_initialize_buffers(" << ctx_p << ") {\n";
738 auto initBuffersResult = targetOp.walk<WalkOrder::PreOrder>([&](BufferOp
739 buffer) {
740 auto initialValue = buffer.getInitialValue();
741 if (!initialValue)
742 return WalkResult::advance();
743 auto denseInit = llvm::dyn_cast<DenseElementsAttr>(*initialValue);
744 if (!denseInit)
745 return WalkResult::advance();
746 std::optional<std::vector<char>> bytes = denseAttrToBytes(denseInit);
747 if (!bytes)
748 return WalkResult(buffer.emitOpError(
749 "buffer op type not supported for initialization"));
750 if (!buffer.getAddress())
751 return WalkResult(buffer.emitOpError(
752 "buffer has no address; run --aie-assign-buffer-addresses first"));
753 TileOp tile = buffer.getTileOp();
754 // Emitted as a byte array, so the value lands as data and matches the block
755 // write the CDO path performs.
756 std::string bufName(buffer.name().getValue());
757 output << "{\n";
758 output << "static const unsigned char " << bufName << "_init[] = {";
759 for (size_t i = 0; i < bytes->size(); ++i)
760 output << (i ? "," : "") << (unsigned)(unsigned char)(*bytes)[i];
761 output << "};\n";
762 output << "__mlir_aie_try(XAie_DataMemBlockWrite(" << deviceInstRef << ", "
763 << tileLocStr(tile.colIndex(), tile.rowIndex()) << ", "
764 << "0x" << llvm::utohexstr(*buffer.getAddress()) << ", "
765 << "(void *)" << bufName << "_init, " << bytes->size() << "));\n";
766 output << "}\n";
767 return WalkResult::advance();
768 });
769 if (initBuffersResult.wasInterrupted())
770 return failure();
771 output << "return XAIE_OK;\n";
772 output << "} // mlir_aie_initialize_buffers\n";
773
774 //---------------------------------------------------------------------------
775 // mlir_aie_configure_switchboxes
776 //---------------------------------------------------------------------------
777 output << "int mlir_aie_configure_switchboxes(" << ctx_p << ") {\n";
778 output << " int x, y;\n";
779
780 // StreamSwitch (switchbox) configuration
781 for (auto switchboxOp : targetOp.getOps<SwitchboxOp>()) {
782 Region &r = switchboxOp.getConnections();
783 Block &b = r.front();
784 bool isEmpty = b.getOps<ConnectOp>().empty() &&
785 b.getOps<MasterSetOp>().empty() &&
786 b.getOps<PacketRulesOp>().empty();
787 bool isParam = false;
788
789 if (isa<TileOp>(switchboxOp.getTile().getDefiningOp())) {
790 int col = switchboxOp.colIndex();
791 int row = switchboxOp.rowIndex();
792 if (!isEmpty) {
793 output << "// Core Stream Switch column " << col << " row " << row
794 << "\n";
795 output << "x = " << col << ";\n";
796 output << "y = " << row << ";\n";
797 }
798 }
799
800 for (auto connectOp : b.getOps<ConnectOp>())
801 output << "__mlir_aie_try(XAie_StrmConnCctEnable(" << deviceInstRef
802 << ", " << tileLocStr("x", "y") << ", "
803 << wireBundleToPortType(connectOp.getSourceBundle()) << ", "
804 << connectOp.sourceIndex() << ", "
805 << wireBundleToPortType(connectOp.getDestBundle()) << ", "
806 << connectOp.destIndex() << "));\n";
807
808 for (auto connectOp : b.getOps<MasterSetOp>()) {
809 int mask = 0;
810 int arbiter = -1;
811 // MasterSetOp::verify guarantees every amsel names the same arbiter, so
812 // folding them into one arbiter plus msel mask is safe here.
813 for (auto val : connectOp.getAmsels()) {
814 AMSelOp amsel = cast<AMSelOp>(val.getDefiningOp());
815 arbiter = amsel.arbiterIndex();
816 int msel = amsel.getMselValue();
817 mask |= (1 << msel);
818 }
819 bool isdma = (connectOp.getDestBundle() == WireBundle::DMA);
820
821 output << "__mlir_aie_try(XAie_StrmPktSwMstrPortEnable(" << deviceInstRef
822 << ", " << tileLocStr("x", "y") << ", "
823 << wireBundleToPortType(connectOp.getDestBundle()) << ", "
824 << connectOp.destIndex() << ", "
825 << "/* drop_header */ "
826 << (isdma ? "XAIE_SS_PKT_DROP_HEADER"
827 : "XAIE_SS_PKT_DONOT_DROP_HEADER")
828 << ", "
829 << "/* arbiter */ " << arbiter << ", "
830 << "/* MSelEn */ "
831 << "0x" << llvm::utohexstr(mask) << "));\n";
832 }
833
834 for (auto connectOp : b.getOps<PacketRulesOp>()) {
835 int slot = 0;
836 Block &block = connectOp.getRules().front();
837 for (auto slotOp : block.getOps<PacketRuleOp>()) {
838 AMSelOp amselOp = cast<AMSelOp>(slotOp.getAmsel().getDefiningOp());
839 int arbiter = amselOp.arbiterIndex();
840 int msel = amselOp.getMselValue();
841 output << "__mlir_aie_try(XAie_StrmPktSwSlavePortEnable("
842 << deviceInstRef << ", " << tileLocStr("x", "y") << ", "
843 << wireBundleToPortType(connectOp.getSourceBundle()) << ", "
844 << connectOp.sourceIndex() << "));\n";
845
846 // TODO Need to better define packet id,type used here
847 output << "__mlir_aie_try(XAie_StrmPktSwSlaveSlotEnable("
848 << deviceInstRef << ", " << tileLocStr("x", "y") << ", "
849 << wireBundleToPortType(connectOp.getSourceBundle()) << ", "
850 << connectOp.sourceIndex() << ", "
851 << "/* slot */ " << slot << ", "
852 << "/* packet */ " << packetStr(slotOp.valueInt(), /*type*/ 0)
853 << ", "
854 << "/* mask */ "
855 << "0x" << llvm::utohexstr(slotOp.maskInt()) << ", "
856 << "/* msel */ " << msel << ", "
857 << "/* arbiter */ " << arbiter << "));\n";
858 slot++;
859 }
860 }
861
862 if (isParam) {
863 output << "}\n";
864 output << "}\n";
865 }
866 }
867 for (auto op : targetOp.getOps<ShimMuxOp>()) {
868 Region &r = op.getConnections();
869 Block &b = r.front();
870 bool isEmpty = b.getOps<ConnectOp>().empty();
871
872 if (isa<TileOp>(op.getTile().getDefiningOp())) {
873 int col = op.colIndex();
874 int row = op.rowIndex();
875 if (!isEmpty) {
876 output << "// ShimMux column " << col << " row " << row << "\n";
877 output << "// NOTE ShimMux always connects from the south as "
878 << "directions are defined relative to the tile stream "
879 << "switch\n";
880 output << "x = " << col << ";\n";
881 output << "y = " << row << ";\n";
882 }
883 }
884
885 for (auto connectOp : b.getOps<ConnectOp>()) {
886
887 if (connectOp.getSourceBundle() == WireBundle::DMA ||
888 connectOp.getDestBundle() == WireBundle::DMA) {
889 if (connectOp.getSourceBundle() == WireBundle::North)
890 // demux!
891 output << "__mlir_aie_try(XAie_EnableAieToShimDmaStrmPort("
892 << deviceInstRef << ", " << tileLocStr("x", "y") << ", "
893 << connectOp.sourceIndex() << "));\n";
894 else if (connectOp.getDestBundle() == WireBundle::North)
895 // mux
896 output << "__mlir_aie_try(XAie_EnableShimDmaToAieStrmPort("
897 << deviceInstRef << ", " << tileLocStr("x", "y") << ", "
898 << connectOp.destIndex() << "));\n";
899 }
900
901 else if (connectOp.getSourceBundle() == WireBundle::PLIO ||
902 connectOp.getDestBundle() == WireBundle::PLIO) {
903 if (connectOp.getSourceBundle() == WireBundle::North) {
904 // mux
905 output << "__mlir_aie_try(XAie_AieToPlIntfEnable(" << deviceInstRef
906 << ", " << tileLocStr("x", "y") << ", "
907 << connectOp.destIndex() << ", PLIF_WIDTH_64));\n";
908 } else if (connectOp.getDestBundle() == WireBundle::North) {
909 // mux
910 output << "__mlir_aie_try(XAie_PlToAieIntfEnable(" << deviceInstRef
911 << ", " << tileLocStr("x", "y") << ", "
912 << connectOp.destIndex() << ", PLIF_WIDTH_64));\n";
913 }
914 }
915 }
916 }
917 output << "return XAIE_OK;\n";
918 output << "} // mlir_aie_configure_switchboxes\n\n";
919
920 //---------------------------------------------------------------------------
921 // mlir_aie_configure_cascade
922 //---------------------------------------------------------------------------
923 output << "int mlir_aie_configure_cascade(" << ctx_p << ") {\n";
924 for (auto configOp : targetOp.getOps<ConfigureCascadeOp>()) {
925 TileOp tile = cast<TileOp>(configOp.getTile().getDefiningOp());
926 int col = tile.colIndex();
927 int row = tile.rowIndex();
928 output << "XAie_CoreConfigAccumulatorControl(" << deviceInstRef << ", "
929 << "XAie_TileLoc(" << col << ", " << row << "), "
930 << stringifyCascadeDir(configOp.getInputDir()).upper() << ", "
931 << stringifyCascadeDir(configOp.getOutputDir()).upper() << ");\n";
932 }
933 output << "return XAIE_OK;\n";
934 output << "} // mlir_aie_configure_cascade\n\n";
935
936 //---------------------------------------------------------------------------
937 // Output Buffer Accessors
938 //---------------------------------------------------------------------------
939 for (auto tile : tiles) {
940 Operation *tileOp = tile.second;
941 TileID coord = cast<TileOp>(tileOp).getTileID();
942 int col = coord.col;
943 int row = coord.row;
944 auto loc = tileLocStr(col, row);
945
946 auto bufferAccessor = [&](BufferOp buf) {
947 // int32_t mlir_aie_read_buffer_a13(int index) {
948 // void mlir_aie_write_buffer_a13(int index, int32_t value) {
949 std::string bufName(buf.name().getValue());
950 Type t = buf.getType();
951 Type et;
952 std::string typestr;
953 if (auto memrefType = llvm::dyn_cast<MemRefType>(t)) {
954 et = memrefType.getElementType();
955 if (et.isInteger(32))
956 typestr = "int32_t";
957 else if (et.isF32())
958 typestr = "float";
959 else {
960 output << "// buffer " << bufName << " with unsupported type " << t
961 << ";\n";
962 return; // Unsupported type
963 }
964
965 } else {
966 output << "// buffer " << bufName << " with unsupported type " << t
967 << ";\n";
968 return; // Unsupported type
969 }
970 assert(buf.getAddress().has_value() && "buffer must have address");
971 output << "const int " << bufName
972 << "_offset = " << buf.getAddress().value() << ";\n";
973 output << typestr << " mlir_aie_read_buffer_" << bufName << "(" << ctx_p
974 << ", int index) {\n";
975 output << "u32 value; auto rc = XAie_DataMemRdWord(" << deviceInstRef
976 << ", " << loc << ", " << bufName
977 << "_offset + (index*4), &value);\n";
978 if (et.isInteger(32))
979 output << " return value;\n";
980 else if (et.isF32()) {
981 output << " union caster { int32_t i; float f; };\n";
982 output << " caster c; c.i = value;\n";
983 output << " return c.f;\n";
984 }
985 output << "}\n";
986 output << "int mlir_aie_write_buffer_" << bufName << "(" << ctx_p
987 << ", int index, " << typestr << " value) {\n";
988 if (et.isInteger(32))
989 output << " int32_t int_value = value;\n";
990 else if (et.isF32()) {
991 output << " union caster { int32_t i; float f; };\n";
992 output << " caster c; c.f = value;\n";
993 output << " int32_t int_value = c.i;\n";
994 }
995 output << "AieRC rc = XAie_DataMemWrWord(" << deviceInstRef << ", "
996 << loc << ", " << bufName << "_offset + (index*4), int_value);\n";
997 output << "return rc;\n";
998 output << "}\n";
999 };
1000
1001 // if(tiles.count(tile.getValue()))
1002 for (auto buf : buffers[tileOp])
1003 bufferAccessor(buf);
1004 }
1005
1006 auto lockAccessor = [&](LockOp lock) {
1007 int col = lock.colIndex();
1008 int row = lock.rowIndex();
1009 if (!lock.hasName())
1010 return;
1011 std::string lockName(lock.name().getValue());
1012 output << "int mlir_aie_acquire_" << lockName << "(" << ctx_p
1013 << ", int value, int timeout) {\n";
1014 output << " const int id = " << lock.getLockIDValue() << ";\n";
1015 output << " return XAie_LockAcquire(" << deviceInstRef << ", "
1016 << tileLocStr(col, row) << ", " << tileLockStr("id", "value")
1017 << ", timeout);\n";
1018 output << "}\n";
1019 output << "int mlir_aie_release_" << lockName << "(" << ctx_p
1020 << ", int value, int timeout) {\n";
1021 output << " const int id = " << lock.getLockIDValue() << ";\n";
1022 output << " return XAie_LockRelease(" << deviceInstRef << ", "
1023 << tileLocStr(col, row) << ", " << tileLockStr("id", "value")
1024 << ", timeout);\n";
1025 output << "}\n";
1026 };
1027
1028 targetOp.walk<WalkOrder::PreOrder>([&](LockOp lock) { lockAccessor(lock); });
1029
1030 return success();
1031}
virtual 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.
bool isMemTile(int col, int row) const
Return true if the given tile is a Mem tile.
virtual 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 getNumLocks(AIETileType tileType) const =0
Return the number of lock objects for a given tile type.
virtual int rows() const =0
Return the number of rows in the device.
bool isShimNOCTile(int col, int row) const
Return true if the given tile is a ShimNOC 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
void collectTiles(DeviceOp &device, llvm::DenseMap< TileID, mlir::Operation * > &tiles)
void collectBuffers(DeviceOp &device, llvm::DenseMap< mlir::Operation *, llvm::SmallVector< BufferOp, 4 > > &buffers)
std::string tileDMAInstStr(llvm::StringRef col, llvm::StringRef row, llvm::StringRef bdNum)
void generateXAieDmaSetMultiDimAddr(llvm::raw_ostream &output, int ndims, llvm::ArrayRef< BDDimLayoutAttr > dims, int col, int row, int bdNum, int baseAddrA, int64_t offsetA, uint32_t lenA, int elementWidthInBytes, const char *errorRet)
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
const AIETargetModel & getTargetModel(mlir::Operation *op)
mlir::LogicalResult verifyDMAChannelsResolved(DeviceOp device)
std::optional< std::vector< char > > denseAttrToBytes(mlir::DenseElementsAttr denseInit)
A buffer's initial_value as the bytes to write to its tile memory, in element order.
std::string tileDMAInstRefStr(llvm::StringRef col, llvm::StringRef row, llvm::StringRef bdNum)
llvm::SmallPtrSet< mlir::Block *, 8 > collectUnchainedBlocks(const llvm::SetVector< mlir::Block * > &blockVector)
Collect BD blocks that require use_next_bd=0 during configuration.
llvm::SetVector< mlir::Block * > getOrderedChainOfBlocks(mlir::Region *region)
mlir::LogicalResult AIETranslateToXAIEV2(mlir::ModuleOp module, llvm::raw_ostream &output, llvm::StringRef deviceName="")
std::string tileLocStr(llvm::StringRef col, llvm::StringRef row)
std::string packetStr(llvm::StringRef id, llvm::StringRef type)