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 }
473 output << " ctx->XAieConfig->AieGen = " << device << ";\n";
474 output << " ctx->XAieConfig->BaseAddr = 0x20000000000;\n";
475 output << " ctx->XAieConfig->ColShift = " << targetModel.getColumnShift()
476 << ";\n";
477 output << " ctx->XAieConfig->RowShift = " << targetModel.getRowShift()
478 << ";\n";
479 output << " ctx->XAieConfig->NumRows = " << targetModel.rows() << ";\n";
480 output << " ctx->XAieConfig->NumCols = " << targetModel.columns() << ";\n";
481 output << " ctx->XAieConfig->ShimRowNum = 0;\n";
482 output << " ctx->XAieConfig->MemTileRowStart = 1;\n";
483 output << " ctx->XAieConfig->MemTileNumRows = "
484 << targetModel.getNumMemTileRows() << ";\n";
485 output << " // ctx->XAieConfig->ReservedRowStart = "
486 "XAIE_RES_TILE_ROW_START;\n";
487 output
488 << " // ctx->XAieConfig->ReservedNumRows = XAIE_RES_TILE_NUM_ROWS;\n";
489 output << " ctx->XAieConfig->AieTileRowStart = "
490 << (1 + targetModel.getNumMemTileRows()) << ";\n";
491 output << " ctx->XAieConfig->AieTileNumRows = "
492 << (targetModel.rows() - 1 - targetModel.getNumMemTileRows()) << ";\n";
493 output << " memset(ctx->XAieDevInst, 0, sizeof(XAie_DevInst));\n";
494 output << " return ctx;\n";
495 output << "}\n";
496 output << "\n";
497
498 //---------------------------------------------------------------------------
499 // mlir_aie_configure_cores
500 //---------------------------------------------------------------------------
501 // Defined below. configure_cores calls it at its end, once every ELF is
502 // loaded, so a PT_LOAD cannot land on top of an initialized buffer.
503 output << "int mlir_aie_initialize_buffers(" << ctx_p << ");\n";
504 output << "int mlir_aie_configure_cores(" << ctx_p << ") {\n";
505 // Reset each core. Load the corresponding ELF file, if necessary.
506 for (auto tileOp : targetOp.getOps<TileOp>()) {
507 int col = tileOp.colIndex();
508 int row = tileOp.rowIndex();
509 if (tileOp.isShimTile() || tileOp.isMemTile()) {
510 // Resets no needed with V2 kernel driver
511 } else {
512 // Resets no needed with V2 kernel driver
513 output << "__mlir_aie_try(XAie_CoreReset(" << deviceInstRef << ", "
514 << tileLocStr(col, row) << "));\n";
515 output << "__mlir_aie_try(XAie_CoreDisable(" << deviceInstRef << ", "
516 << tileLocStr(col, row) << "));\n";
517 // Release locks
518 int numLocks = targetModel.getNumLocks(col, row);
519 output << "for (int l = 0; l < " << numLocks << "; ++l)\n"
520 << " __mlir_aie_try(XAie_LockRelease(" << deviceInstRef << ", "
521 << tileLocStr(col, row) << ", XAie_LockInit(l, 0x0), 0));\n";
522 if (auto coreOp = tileOp.getCoreOp()) {
523 if (coreOp.isEmpty() && coreOp.getElfFile() == std::nullopt) {
524 // This core has no MLIR code and references no ELF file -- it is
525 // completely empty, so don't generate any code for it.
526 continue;
527 }
528 std::string fileName;
529 if (auto fileAttr = coreOp.getElfFile()) {
530 fileName = fileAttr.value().str();
531 } else {
532 return coreOp.emitOpError()
533 << "Expected lowered ELF file to be given as attribute "
534 "`elf_file` for this core. Compile cores first.";
535 }
536 output << "{\n"
537 << "AieRC RC = XAie_LoadElf(" << deviceInstRef << ", "
538 << tileLocStr(col, row) << ", "
539 << "(const char*)\"" << fileName << "\",0);\n";
540 output << "if (RC != XAIE_OK)\n"
541 << " __mlir_aie_verbose(fprintf(stderr, \"Failed to load elf "
542 "for Core[%d,%d], ret is %d\\n\", "
543 << std::to_string(col) << ", " << std::to_string(row)
544 << ", RC));\n"
545 << "assert(RC == XAIE_OK);\n"
546 << "}\n";
547 }
548 }
549 }
550 // __mlir_aie_try assigns to an AieRC, and the generated entry points return
551 // int, which C++ does not convert implicitly.
552 output << "{\n";
553 output << " int rc = mlir_aie_initialize_buffers(ctx);\n";
554 output << " if (rc != XAIE_OK)\n";
555 output << " return rc;\n";
556 output << "}\n";
557 output << "return XAIE_OK;\n";
558 output << "} // mlir_aie_configure_cores\n\n";
559
560 //---------------------------------------------------------------------------
561 // mlir_aie_start_cores
562 //---------------------------------------------------------------------------
563 output << "int mlir_aie_start_cores(" << ctx_p << ") {\n";
564 // Start execution of all the cores.
565 for (auto tileOp : targetOp.getOps<TileOp>()) {
566 int col = tileOp.colIndex();
567 int row = tileOp.rowIndex();
568 if (!tileOp.isShimTile() && !tileOp.isMemTile()) {
569 output << "__mlir_aie_try(XAie_CoreUnreset(" << deviceInstRef << ", "
570 << tileLocStr(col, row) << "));\n";
571 output << "__mlir_aie_try(XAie_CoreEnable(" << deviceInstRef << ", "
572 << tileLocStr(col, row) << "));\n";
573 }
574 }
575 output << "return XAIE_OK;\n";
576 output << "} // mlir_aie_start_cores\n\n";
577
578 //---------------------------------------------------------------------------
579 // mlir_aie_configure_dmas
580 //---------------------------------------------------------------------------
581 output << "int mlir_aie_configure_dmas(" << ctx_p << ") {\n";
582
583 for (auto memOp : targetOp.getOps<MemOp>()) {
584 DenseMap<Block *, int> blockMap;
585
586 // Use bd_ids, if specified.
587 int bdNum = 0;
588 for (auto &block : memOp.getBody()) {
589 auto bdOps = block.getOps<DMABDOp>();
590 if (bdOps.empty())
591 continue;
592 std::optional<int32_t> id = (*bdOps.begin()).getBdId();
593 blockMap[&block] = id.has_value() ? *id : bdNum;
594 bdNum++;
595 }
596 auto result = generateDMAConfig(memOp, output, targetModel, blockMap);
597 if (result.failed())
598 return result;
599 }
600 for (auto memOp : targetOp.getOps<MemTileDMAOp>()) {
601 DenseMap<Block *, int> blockMap;
602 // Memtiles have restrictions on which channels can access which BDs
603 DenseMap<Block *, int> channelMap;
604
605 for (auto &block : memOp.getBody()) {
606 for (auto op : block.getOps<DMAStartOp>()) {
607 int chNum = op.getChannelIndex();
608 channelMap[&block] = chNum;
609 auto *dest = op.getDest();
610 while (dest) {
611 channelMap[dest] = chNum;
612 if (dest->getSuccessors().empty())
613 break;
614 dest = dest->getSuccessors()[0];
615 if (channelMap.count(dest))
616 break;
617 }
618 }
619 }
620
621 // Assign each block a BD number, if unassigned
622 int evenBdNum = 0;
623 int oddBdNum = 24;
624 for (auto &block : memOp.getBody()) {
625 auto bdOps = block.getOps<DMABDOp>();
626 if (bdOps.empty())
627 continue;
628 assert(channelMap.count(&block));
629 if (std::optional<int32_t> id = (*bdOps.begin()).getBdId())
630 blockMap[&block] = *id;
631 else if (channelMap[&block] & 1)
632 blockMap[&block] = oddBdNum++;
633 else
634 blockMap[&block] = evenBdNum++;
635 }
636 auto result = generateDMAConfig(memOp, output, targetModel, blockMap);
637 if (result.failed())
638 return result;
639 }
640
641 output << "return XAIE_OK;\n";
642 output << "} // mlir_aie_configure_dmas\n\n";
643
644 for (auto op : targetOp.getOps<ExternalBufferOp>()) {
645 if (op.hasName()) {
646 output << "static u64 _mlir_aie_external_" << op.name().getValue()
647 << ";\n";
648 output << "static bool _mlir_aie_external_set_" << op.name().getValue()
649 << " = false;\n";
650
651 output << "void mlir_aie_external_set_addr_" << op.name().getValue()
652 << "(" << ctx_p << ", u64 VA) {\n"
653 << " u64 device_address = mlir_aie_get_device_address(ctx, (void "
654 "*)VA);\n"
655 << " _mlir_aie_external_set_" << op.name().getValue()
656 << " = true;\n"
657 << " _mlir_aie_external_" << op.name().getValue()
658 << " = device_address;\n"
659 << "}\n";
660 }
661 }
662
663 // ShimDMA Config
664 // int index = 0;
665 for (auto op : targetOp.getOps<ShimDMAOp>()) {
666 int col = op.colIndex();
667 int row = op.rowIndex();
668
669 DenseMap<Block *, int> blockMap;
670 {
671 // Assign each block a BD number, if unassigned
672 int bdNum = 0;
673 for (auto &block : op.getBody()) {
674 auto bdOps = block.getOps<DMABDOp>();
675 if (bdOps.empty())
676 continue;
677 std::optional<int32_t> id = (*bdOps.begin()).getBdId();
678 int slot = id.has_value() ? *id : bdNum;
679 blockMap[&block] = slot;
680 uint64_t offset = 0;
681 for (auto op : block.getOps<DMABDOp>()) {
682 offset = op.getOffsetInBytes();
683 auto buffer = cast<ExternalBufferOp>(op.getBuffer().getDefiningOp());
684
685 output << "u64 mlir_aie_external_get_addr_myBuffer_" << col << row
686 << "_" << slot << "(void) {\n"
687 << " assert(_mlir_aie_external_set_"
688 << buffer.name().getValue() << ");\n"
689 << " return _mlir_aie_external_" << buffer.name().getValue()
690 << " + " << llvm::utohexstr(offset) << ";\n"
691 << "}\n";
692 }
693
694 bdNum++;
695 }
696 }
697
698 output << "int mlir_aie_configure_shimdma_" << col << row << "(" << ctx_p
699 << ") {\n";
700 auto result = generateDMAConfig(op, output, targetModel, blockMap);
701 if (result.failed())
702 return result;
703 output << "return XAIE_OK;\n";
704 output << "} // mlir_aie_configure_shimdma\n\n";
705 }
706
707 //---------------------------------------------------------------------------
708 // mlir_aie_initialize_locks
709 //---------------------------------------------------------------------------
710 output << "int mlir_aie_initialize_locks(" << ctx_p << ") {\n";
711 // Lock configuration
712 targetOp.walk<WalkOrder::PreOrder>([&](LockOp lock) {
713 TileOp tile = lock.getTileOp();
714 int col = tile.colIndex();
715 int row = tile.rowIndex();
716 int lockID = lock.getLockIDValue();
717 auto init = lock.getInit();
718 if (init)
719 output << "__mlir_aie_try(XAie_LockSetValue(" << deviceInstRef << ", "
720 << tileLocStr(col, row) << ", "
721 << "XAie_LockInit(" << lockID << ", " << *init << ")));\n";
722 });
723 output << "return XAIE_OK;\n";
724 output << "} // mlir_aie_initialize_locks\n";
725
726 //---------------------------------------------------------------------------
727 // mlir_aie_initialize_buffers
728 //---------------------------------------------------------------------------
729 // A buffer's initial_value is device state, written by whoever configures
730 // the device: the CDO writer on the NPU path, this function on the simulator
731 // path. This walks every tile, because a memtile buffer has no core and so no
732 // other route. mlir_aie_configure_cores calls this, so a host that already
733 // configures its cores needs no change.
734 output << "int mlir_aie_initialize_buffers(" << ctx_p << ") {\n";
735 auto initBuffersResult = targetOp.walk<WalkOrder::PreOrder>([&](BufferOp
736 buffer) {
737 auto initialValue = buffer.getInitialValue();
738 if (!initialValue)
739 return WalkResult::advance();
740 auto denseInit = llvm::dyn_cast<DenseElementsAttr>(*initialValue);
741 if (!denseInit)
742 return WalkResult::advance();
743 std::optional<std::vector<char>> bytes = denseAttrToBytes(denseInit);
744 if (!bytes)
745 return WalkResult(buffer.emitOpError(
746 "buffer op type not supported for initialization"));
747 if (!buffer.getAddress())
748 return WalkResult(buffer.emitOpError(
749 "buffer has no address; run --aie-assign-buffer-addresses first"));
750 TileOp tile = buffer.getTileOp();
751 // Emitted as a byte array, so the value lands as data and matches the block
752 // write the CDO path performs.
753 std::string bufName(buffer.name().getValue());
754 output << "{\n";
755 output << "static const unsigned char " << bufName << "_init[] = {";
756 for (size_t i = 0; i < bytes->size(); ++i)
757 output << (i ? "," : "") << (unsigned)(unsigned char)(*bytes)[i];
758 output << "};\n";
759 output << "__mlir_aie_try(XAie_DataMemBlockWrite(" << deviceInstRef << ", "
760 << tileLocStr(tile.colIndex(), tile.rowIndex()) << ", "
761 << "0x" << llvm::utohexstr(*buffer.getAddress()) << ", "
762 << "(void *)" << bufName << "_init, " << bytes->size() << "));\n";
763 output << "}\n";
764 return WalkResult::advance();
765 });
766 if (initBuffersResult.wasInterrupted())
767 return failure();
768 output << "return XAIE_OK;\n";
769 output << "} // mlir_aie_initialize_buffers\n";
770
771 //---------------------------------------------------------------------------
772 // mlir_aie_configure_switchboxes
773 //---------------------------------------------------------------------------
774 output << "int mlir_aie_configure_switchboxes(" << ctx_p << ") {\n";
775 output << " int x, y;\n";
776
777 // StreamSwitch (switchbox) configuration
778 for (auto switchboxOp : targetOp.getOps<SwitchboxOp>()) {
779 Region &r = switchboxOp.getConnections();
780 Block &b = r.front();
781 bool isEmpty = b.getOps<ConnectOp>().empty() &&
782 b.getOps<MasterSetOp>().empty() &&
783 b.getOps<PacketRulesOp>().empty();
784 bool isParam = false;
785
786 if (isa<TileOp>(switchboxOp.getTile().getDefiningOp())) {
787 int col = switchboxOp.colIndex();
788 int row = switchboxOp.rowIndex();
789 if (!isEmpty) {
790 output << "// Core Stream Switch column " << col << " row " << row
791 << "\n";
792 output << "x = " << col << ";\n";
793 output << "y = " << row << ";\n";
794 }
795 }
796
797 for (auto connectOp : b.getOps<ConnectOp>())
798 output << "__mlir_aie_try(XAie_StrmConnCctEnable(" << deviceInstRef
799 << ", " << tileLocStr("x", "y") << ", "
800 << wireBundleToPortType(connectOp.getSourceBundle()) << ", "
801 << connectOp.sourceIndex() << ", "
802 << wireBundleToPortType(connectOp.getDestBundle()) << ", "
803 << connectOp.destIndex() << "));\n";
804
805 for (auto connectOp : b.getOps<MasterSetOp>()) {
806 int mask = 0;
807 int arbiter = -1;
808 // MasterSetOp::verify guarantees every amsel names the same arbiter, so
809 // folding them into one arbiter plus msel mask is safe here.
810 for (auto val : connectOp.getAmsels()) {
811 AMSelOp amsel = cast<AMSelOp>(val.getDefiningOp());
812 arbiter = amsel.arbiterIndex();
813 int msel = amsel.getMselValue();
814 mask |= (1 << msel);
815 }
816 bool isdma = (connectOp.getDestBundle() == WireBundle::DMA);
817
818 output << "__mlir_aie_try(XAie_StrmPktSwMstrPortEnable(" << deviceInstRef
819 << ", " << tileLocStr("x", "y") << ", "
820 << wireBundleToPortType(connectOp.getDestBundle()) << ", "
821 << connectOp.destIndex() << ", "
822 << "/* drop_header */ "
823 << (isdma ? "XAIE_SS_PKT_DROP_HEADER"
824 : "XAIE_SS_PKT_DONOT_DROP_HEADER")
825 << ", "
826 << "/* arbiter */ " << arbiter << ", "
827 << "/* MSelEn */ "
828 << "0x" << llvm::utohexstr(mask) << "));\n";
829 }
830
831 for (auto connectOp : b.getOps<PacketRulesOp>()) {
832 int slot = 0;
833 Block &block = connectOp.getRules().front();
834 for (auto slotOp : block.getOps<PacketRuleOp>()) {
835 AMSelOp amselOp = cast<AMSelOp>(slotOp.getAmsel().getDefiningOp());
836 int arbiter = amselOp.arbiterIndex();
837 int msel = amselOp.getMselValue();
838 output << "__mlir_aie_try(XAie_StrmPktSwSlavePortEnable("
839 << deviceInstRef << ", " << tileLocStr("x", "y") << ", "
840 << wireBundleToPortType(connectOp.getSourceBundle()) << ", "
841 << connectOp.sourceIndex() << "));\n";
842
843 // TODO Need to better define packet id,type used here
844 output << "__mlir_aie_try(XAie_StrmPktSwSlaveSlotEnable("
845 << deviceInstRef << ", " << tileLocStr("x", "y") << ", "
846 << wireBundleToPortType(connectOp.getSourceBundle()) << ", "
847 << connectOp.sourceIndex() << ", "
848 << "/* slot */ " << slot << ", "
849 << "/* packet */ " << packetStr(slotOp.valueInt(), /*type*/ 0)
850 << ", "
851 << "/* mask */ "
852 << "0x" << llvm::utohexstr(slotOp.maskInt()) << ", "
853 << "/* msel */ " << msel << ", "
854 << "/* arbiter */ " << arbiter << "));\n";
855 slot++;
856 }
857 }
858
859 if (isParam) {
860 output << "}\n";
861 output << "}\n";
862 }
863 }
864 for (auto op : targetOp.getOps<ShimMuxOp>()) {
865 Region &r = op.getConnections();
866 Block &b = r.front();
867 bool isEmpty = b.getOps<ConnectOp>().empty();
868
869 if (isa<TileOp>(op.getTile().getDefiningOp())) {
870 int col = op.colIndex();
871 int row = op.rowIndex();
872 if (!isEmpty) {
873 output << "// ShimMux column " << col << " row " << row << "\n";
874 output << "// NOTE ShimMux always connects from the south as "
875 << "directions are defined relative to the tile stream "
876 << "switch\n";
877 output << "x = " << col << ";\n";
878 output << "y = " << row << ";\n";
879 }
880 }
881
882 for (auto connectOp : b.getOps<ConnectOp>()) {
883
884 if (connectOp.getSourceBundle() == WireBundle::DMA ||
885 connectOp.getDestBundle() == WireBundle::DMA) {
886 if (connectOp.getSourceBundle() == WireBundle::North)
887 // demux!
888 output << "__mlir_aie_try(XAie_EnableAieToShimDmaStrmPort("
889 << deviceInstRef << ", " << tileLocStr("x", "y") << ", "
890 << connectOp.sourceIndex() << "));\n";
891 else if (connectOp.getDestBundle() == WireBundle::North)
892 // mux
893 output << "__mlir_aie_try(XAie_EnableShimDmaToAieStrmPort("
894 << deviceInstRef << ", " << tileLocStr("x", "y") << ", "
895 << connectOp.destIndex() << "));\n";
896 }
897
898 else if (connectOp.getSourceBundle() == WireBundle::PLIO ||
899 connectOp.getDestBundle() == WireBundle::PLIO) {
900 if (connectOp.getSourceBundle() == WireBundle::North) {
901 // mux
902 output << "__mlir_aie_try(XAie_AieToPlIntfEnable(" << deviceInstRef
903 << ", " << tileLocStr("x", "y") << ", "
904 << connectOp.destIndex() << ", PLIF_WIDTH_64));\n";
905 } else if (connectOp.getDestBundle() == WireBundle::North) {
906 // mux
907 output << "__mlir_aie_try(XAie_PlToAieIntfEnable(" << deviceInstRef
908 << ", " << tileLocStr("x", "y") << ", "
909 << connectOp.destIndex() << ", PLIF_WIDTH_64));\n";
910 }
911 }
912 }
913 }
914 output << "return XAIE_OK;\n";
915 output << "} // mlir_aie_configure_switchboxes\n\n";
916
917 //---------------------------------------------------------------------------
918 // mlir_aie_configure_cascade
919 //---------------------------------------------------------------------------
920 output << "int mlir_aie_configure_cascade(" << ctx_p << ") {\n";
921 for (auto configOp : targetOp.getOps<ConfigureCascadeOp>()) {
922 TileOp tile = cast<TileOp>(configOp.getTile().getDefiningOp());
923 int col = tile.colIndex();
924 int row = tile.rowIndex();
925 output << "XAie_CoreConfigAccumulatorControl(" << deviceInstRef << ", "
926 << "XAie_TileLoc(" << col << ", " << row << "), "
927 << stringifyCascadeDir(configOp.getInputDir()).upper() << ", "
928 << stringifyCascadeDir(configOp.getOutputDir()).upper() << ");\n";
929 }
930 output << "return XAIE_OK;\n";
931 output << "} // mlir_aie_configure_cascade\n\n";
932
933 //---------------------------------------------------------------------------
934 // Output Buffer Accessors
935 //---------------------------------------------------------------------------
936 for (auto tile : tiles) {
937 Operation *tileOp = tile.second;
938 TileID coord = cast<TileOp>(tileOp).getTileID();
939 int col = coord.col;
940 int row = coord.row;
941 auto loc = tileLocStr(col, row);
942
943 auto bufferAccessor = [&](BufferOp buf) {
944 // int32_t mlir_aie_read_buffer_a13(int index) {
945 // void mlir_aie_write_buffer_a13(int index, int32_t value) {
946 std::string bufName(buf.name().getValue());
947 Type t = buf.getType();
948 Type et;
949 std::string typestr;
950 if (auto memrefType = llvm::dyn_cast<MemRefType>(t)) {
951 et = memrefType.getElementType();
952 if (et.isInteger(32))
953 typestr = "int32_t";
954 else if (et.isF32())
955 typestr = "float";
956 else {
957 output << "// buffer " << bufName << " with unsupported type " << t
958 << ";\n";
959 return; // Unsupported type
960 }
961
962 } else {
963 output << "// buffer " << bufName << " with unsupported type " << t
964 << ";\n";
965 return; // Unsupported type
966 }
967 assert(buf.getAddress().has_value() && "buffer must have address");
968 output << "const int " << bufName
969 << "_offset = " << buf.getAddress().value() << ";\n";
970 output << typestr << " mlir_aie_read_buffer_" << bufName << "(" << ctx_p
971 << ", int index) {\n";
972 output << "u32 value; auto rc = XAie_DataMemRdWord(" << deviceInstRef
973 << ", " << loc << ", " << bufName
974 << "_offset + (index*4), &value);\n";
975 if (et.isInteger(32))
976 output << " return value;\n";
977 else if (et.isF32()) {
978 output << " union caster { int32_t i; float f; };\n";
979 output << " caster c; c.i = value;\n";
980 output << " return c.f;\n";
981 }
982 output << "}\n";
983 output << "int mlir_aie_write_buffer_" << bufName << "(" << ctx_p
984 << ", int index, " << typestr << " value) {\n";
985 if (et.isInteger(32))
986 output << " int32_t int_value = value;\n";
987 else if (et.isF32()) {
988 output << " union caster { int32_t i; float f; };\n";
989 output << " caster c; c.f = value;\n";
990 output << " int32_t int_value = c.i;\n";
991 }
992 output << "AieRC rc = XAie_DataMemWrWord(" << deviceInstRef << ", "
993 << loc << ", " << bufName << "_offset + (index*4), int_value);\n";
994 output << "return rc;\n";
995 output << "}\n";
996 };
997
998 // if(tiles.count(tile.getValue()))
999 for (auto buf : buffers[tileOp])
1000 bufferAccessor(buf);
1001 }
1002
1003 auto lockAccessor = [&](LockOp lock) {
1004 int col = lock.colIndex();
1005 int row = lock.rowIndex();
1006 if (!lock.hasName())
1007 return;
1008 std::string lockName(lock.name().getValue());
1009 output << "int mlir_aie_acquire_" << lockName << "(" << ctx_p
1010 << ", int value, int timeout) {\n";
1011 output << " const int id = " << lock.getLockIDValue() << ";\n";
1012 output << " return XAie_LockAcquire(" << deviceInstRef << ", "
1013 << tileLocStr(col, row) << ", " << tileLockStr("id", "value")
1014 << ", timeout);\n";
1015 output << "}\n";
1016 output << "int mlir_aie_release_" << lockName << "(" << ctx_p
1017 << ", int value, int timeout) {\n";
1018 output << " const int id = " << lock.getLockIDValue() << ";\n";
1019 output << " return XAie_LockRelease(" << deviceInstRef << ", "
1020 << tileLocStr(col, row) << ", " << tileLockStr("id", "value")
1021 << ", timeout);\n";
1022 output << "}\n";
1023 };
1024
1025 targetOp.walk<WalkOrder::PreOrder>([&](LockOp lock) { lockAccessor(lock); });
1026
1027 return success();
1028}
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.
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)