13#include "llvm/ADT/BitVector.h"
14#include "llvm/ADT/DenseSet.h"
26Value DMAChannelAnalysis::getTileKey(Value tile) {
27 auto tileOp = cast<TileLike>(tile.getDefiningOp());
28 auto col = tileOp.tryGetCol();
29 auto row = tileOp.tryGetRow();
32 return tilesByCoordinate.try_emplace({*col, *row}, tile).first->second;
35void DMAChannelAnalysis::claim(Value tile, DMAChannelDir dir,
int channel,
37 if (usedChannels.try_emplace({getTileKey(tile), dir, channel}, owner).second)
38 claims.emplace_back(tile, dir, channel, owner);
42 for (
auto program : device.getOps<DmaBody>()) {
43 for (Block &block : program.getDmaBody()) {
44 for (
auto start : block.getOps<DMAStartOp>()) {
46 if (start.getEndpoint())
48 claim(program.getTile(), start.getChannelDir(), start.getChannelIndex(),
59 auto streamDMA = [&](Value tile, DMAChannelDir dir,
int channel,
61 streamedChannels.try_emplace(
62 std::make_tuple(getTileKey(tile), dir, channel), owner);
64 for (
auto flowOp : device.getOps<FlowOp>()) {
65 if (flowOp.getSourceBundle() == WireBundle::Core) {
66 usedStreams.try_emplace({getTileKey(flowOp.getSource()),
67 DMAChannelDir::MM2S, flowOp.getSourceChannel()},
68 StreamClaim{flowOp,
false});
70 if (flowOp.getDestBundle() == WireBundle::Core) {
71 usedStreams.try_emplace({getTileKey(flowOp.getDest()),
72 DMAChannelDir::S2MM, flowOp.getDestChannel()},
73 StreamClaim{flowOp,
false});
75 if (flowOp.getSourceBundle() == WireBundle::DMA)
76 streamDMA(flowOp.getSource(), DMAChannelDir::MM2S,
77 flowOp.getSourceChannel(), flowOp);
78 if (flowOp.getDestBundle() == WireBundle::DMA)
79 streamDMA(flowOp.getDest(), DMAChannelDir::S2MM, flowOp.getDestChannel(),
82 for (
auto packetFlow : device.getOps<PacketFlowOp>()) {
83 for (
auto source : packetFlow.getOps<PacketSourceOp>())
84 if (source.getBundle() == WireBundle::DMA)
85 streamDMA(source.getTile(), DMAChannelDir::MM2S, source.getChannel(),
87 for (
auto dest : packetFlow.getOps<PacketDestOp>())
88 if (dest.getBundle() == WireBundle::DMA)
89 streamDMA(dest.getTile(), DMAChannelDir::S2MM, dest.getChannel(),
95 device.walk([&](AIEX::DMAConfigureTaskOp task) {
96 claim(task.getTile(), task.getDirection(), (
int)task.getChannel(), task);
99 for (
auto flow : device.getOps<PacketFlowOp>()) {
100 Block &ports = flow.getPorts().front();
101 for (
auto source : ports.getOps<PacketSourceOp>())
102 if (source.getBundle() == WireBundle::Core)
103 usedStreams.try_emplace({getTileKey(source.getTile()),
104 DMAChannelDir::MM2S, source.channelIndex()},
105 StreamClaim{source,
true});
106 for (
auto dest : ports.getOps<PacketDestOp>())
107 if (dest.getBundle() == WireBundle::Core)
108 usedStreams.try_emplace({getTileKey(dest.getTile()),
109 DMAChannelDir::S2MM, dest.channelIndex()},
110 StreamClaim{dest,
true});
117 for (
auto allocOp : device.getOps<ShimDMAAllocationOp>()) {
118 MLIRContext *context = allocOp->getContext();
119 if (!AIEDialect::ShareableWithAttrHelper(context).isAttrPresent(allocOp)) {
120 claim(allocOp.getTile(), allocOp.getChannelDir(),
121 (
int)allocOp.getChannelIndex(), allocOp);
124 shareableChannels.try_emplace(
125 std::make_tuple(getTileKey(allocOp.getTile()), allocOp.getChannelDir(),
126 (
int)allocOp.getChannelIndex()),
127 allocOp.getOperation());
128 if (!AIEDialect::IsCtrlPktOverlayAttrHelper(context).isAttrPresent(allocOp))
129 claims.emplace_back(allocOp.getTile(), allocOp.getChannelDir(),
130 (
int)allocOp.getChannelIndex(), allocOp);
135 TileLike tile, DMAChannelDir dir,
bool requiresAdjacentTileAccessChannels) {
136 std::optional<int> col = tile.tryGetCol();
137 std::optional<int> row = tile.tryGetRow();
143 : cast<LogicalTileOp>(tile.getOperation()).getCanonicalTileID();
144 int maxChannelNum = targetModel.getNumDMAChannels(
id.col,
id.row, dir);
146 if (!requiresAdjacentTileAccessChannels)
147 return maxChannelNum;
150 return std::min<int>(
152 targetModel.getMaxChannelNumForAdjacentMemTile(*col, *row));
156 bool foundPosition =
false;
157 for (
int c = 0; c < targetModel.columns(); ++c) {
158 if (col && c != *col)
160 for (
int r = 0; r < targetModel.rows(); ++r) {
161 if ((row && r != *row) ||
162 targetModel.getTileType(c, r) != tile.getTileType())
164 foundPosition =
true;
165 maxChannelNum = std::min<int>(
166 maxChannelNum, targetModel.getMaxChannelNumForAdjacentMemTile(c, r));
170 return foundPosition ? maxChannelNum : 0;
174 TileLike tile, DMAChannelDir dir,
bool requiresAdjacentTileAccessChannels,
177 for (
int i = 0; i < limit; i++) {
188 auto key = std::make_tuple(getTileKey(tile->getResult(0)), dir, channel);
189 return !usedChannels.contains(key) && !streamedChannels.contains(key) &&
190 !shareableChannels.contains(key);
194 int channel, Operation *owner,
197 if (channel < 0 || channel >= maxChannelNum) {
200 auto key = std::make_tuple(getTileKey(tile->getResult(0)), dir, channel);
201 if (
auto *reservation = shareableChannels.lookup(key)) {
205 AIEDialect::ShareableWithAttrHelper(reservation->getContext())
206 .getAttr(reservation);
208 owner ? owner->getAttrOfType<StringAttr>(
"sym_name") : StringAttr();
209 if (!allowed || !name || llvm::none_of(allowed, [&](Attribute attr) {
210 auto symbol = dyn_cast<FlatSymbolRefAttr>(attr);
211 return symbol && symbol.getAttr() == name;
215 if (usedChannels.try_emplace(key, owner).second) {
217 sharedChannels.insert(key);
222 if (shareable && sharedChannels.contains(key))
230 auto key = std::make_tuple(getTileKey(tile->getResult(0)), dir, channel);
231 if (Operation *owner = usedChannels.lookup(key))
233 if (Operation *owner = streamedChannels.lookup(key))
235 return shareableChannels.lookup(key);
242 auto [it, inserted] = usedStreams.try_emplace(
243 {getTileKey(tile->getResult(0)), chan.direction, chan.channel},
244 StreamClaim{user, packet});
245 if (inserted || (packet && it->second.packet)) {
248 auto diag = user->emitOpError(
"Core ")
249 << (chan.direction == DMAChannelDir::MM2S ?
"output " :
"input ")
251 <<
" is already in use on this tile; a core stream port carries "
252 "one circuit or only packet flows";
253 diag.attachNote(it->second.owner->getLoc()) <<
"the other stream is here";
258 SmallVector<Block *> chain;
259 SmallPtrSet<Block *, 8> seen;
260 SmallVector<Block *> work{start.getDest()};
261 while (!work.empty()) {
262 Block *block = work.pop_back_val();
263 if (!seen.insert(block).second || block->getOps<DMABDOp>().empty())
265 chain.push_back(block);
266 if (
auto next = dyn_cast<NextBDOp>(block->getTerminator()))
267 work.push_back(next.getDest());
274 for (Block *block :
chainOf(start))
275 bds += llvm::range_size(block->getOps<DMABDOp>());
280 for (
auto program : device.getOps<DmaBody>())
281 for (Block &block : program.getDmaBody())
282 for (
auto start : block.getOps<DMAStartOp>())
283 if (!start.getEndpointOp())
284 if (Operation *tile = program.getTile().getDefiningOp())
285 fixed[tile][start.getChannelIndex()] +=
countBDs(start);
289 [&](Operation *, Operation *tile, std::optional<int> channel,
290 int32_t
id) { pinned[tile].try_emplace(
id, Pin{order++, channel}); });
293DenseMap<int, int64_t>
295 ArrayRef<Operation *> tiles)
const {
296 auto here = [&](Operation *tile) {
297 auto like = dyn_cast<TileLike>(tile);
298 return llvm::is_contained(tiles, tile) ||
299 (like && like.tryGetCol() == col && like.tryGetRow() == row);
301 DenseMap<int, int64_t> taken;
302 for (
auto &[tile, channels] : fixed)
304 for (
auto [channel, bds] : channels)
305 taken[channel] += bds;
306 std::map<int32_t, Pin> ids;
307 for (
auto &[tile, pins] : pinned)
309 for (
auto [
id, pin] : pins)
310 if (
auto [it, added] = ids.try_emplace(
id, pin);
311 !added && pin.order < it->second.order)
313 int numChannels = std::max(
316 for (
auto [
id, pin] : ids)
317 for (
int channel = 0, last = pin.channel.value_or(numChannels - 1);
318 channel <= last; ++channel)
326SmallVector<std::pair<int, int>>
328 std::set<std::pair<int, int>>
at;
329 auto add = [&](Operation *tile) {
330 auto like = dyn_cast<TileLike>(tile);
333 if (
auto col = like.tryGetCol(), row = like.tryGetRow(); col && row)
334 at.insert({*col, *row});
336 for (
auto &entry : fixed)
338 for (
auto &entry : pinned)
340 return {
at.begin(),
at.end()};
343llvm::SmallVector<DMAChannelAnalysis::BDGroup>
346 uint32_t numBDs = target.
getNumBDs(col, row);
347 SmallVector<BDGroup> groups;
348 for (
int channel = 0; channel < numChannels; ++channel) {
349 llvm::BitVector ids(numBDs);
350 for (uint32_t bd = 0; bd < numBDs; ++bd)
353 BDGroup merged{ids, {channel}};
354 for (
auto *it = groups.begin(); it != groups.end();) {
355 if (!it->ids.anyCommon(merged.
ids)) {
359 merged.
ids |= it->ids;
360 llvm::append_range(merged.
channels, it->channels);
361 it = groups.erase(it);
363 groups.push_back(std::move(merged));
366 llvm::sort(group.channels);
370static SmallVector<DMAChannelAnalysis::BDGroup>
372 int numChannels = std::max(
378std::optional<SmallVector<int>>
380 int row, ArrayRef<BDPlanEnd> allEnds,
381 function_ref<
bool(DMAChannelDir,
int)> free,
382 function_ref<int64_t(
int)> spent) {
383 return planBDChannels(tileBDGroups(target, col, row), allEnds, free, spent);
386std::optional<SmallVector<int>>
388 ArrayRef<BDPlanEnd> allEnds,
389 function_ref<
bool(DMAChannelDir,
int)> free,
390 function_ref<int64_t(
int)> spent) {
395 SmallVector<int> channels;
398 SmallVector<Group> groups;
399 for (
const BDGroup &group : tileGroups)
400 groups.push_back({group.ids, group.channels, 0});
401 for (Group &group : groups) {
402 group.room = group.ids.count();
403 for (
int channel : group.channels)
404 group.room -= spent(channel);
409 SmallVector<BDPlanEnd> ends;
410 SmallVector<unsigned> looseOf;
411 llvm::DenseSet<std::pair<int, int>> pinned;
412 for (
auto [index, end] : llvm::enumerate(allEnds)) {
415 looseOf.push_back(index);
418 int channel = *end.pinned;
419 auto *group = llvm::find_if(groups, [&](
const Group &group) {
420 return llvm::is_contained(group.channels, channel);
422 if (group == groups.end())
424 group->room -= end.bds;
425 pinned.insert({
static_cast<int>(end.dir), *end.pinned});
427 if (llvm::any_of(groups, [](
const Group &group) {
return group.room < 0; }))
429 auto open = [&](DMAChannelDir dir,
int channel) {
430 return free(dir, channel) &&
431 !pinned.contains({
static_cast<int>(dir), channel});
439 SmallVector<unsigned> order(ends.size());
440 std::iota(order.begin(), order.end(), 0);
441 auto shape = [&](
unsigned end) {
442 return std::make_tuple(-ends[end].bds,
static_cast<int>(ends[end].dir),
446 order, [&](
unsigned a,
unsigned b) {
return shape(a) < shape(b); });
447 SmallVector<unsigned> groupOf(ends.size());
448 SmallVector<int> channelOf(ends.size(), -1);
450 SmallVector<unsigned> byBound(ends.size());
451 std::iota(byBound.begin(), byBound.end(), 0);
452 llvm::stable_sort(byBound, [&](
unsigned a,
unsigned b) {
453 return ends[a].limit < ends[b].limit;
455 llvm::DenseSet<std::pair<int, int>> taken;
456 for (
unsigned end : byBound) {
458 for (
int channel : groups[groupOf[end]].channels) {
459 int dir =
static_cast<int>(ends[end].dir);
460 if (channel < ends[end].limit && open(ends[end].dir, channel) &&
461 taken.insert({dir, channel}).second) {
462 channelOf[end] = channel;
466 if (channelOf[end] < 0)
476 SmallVector<int> bounds;
478 bounds.push_back(end.limit);
480 bounds.erase(llvm::unique(bounds), bounds.end());
481 size_t slots = 2 * bounds.size();
482 SmallVector<int64_t> below(groups.size() * slots, 0);
483 for (
auto [g, group] : llvm::enumerate(groups))
484 for (DMAChannelDir dir : {DMAChannelDir::S2MM, DMAChannelDir::MM2S})
485 for (
auto [i, bound] : llvm::enumerate(bounds))
486 for (
int channel : group.channels)
487 below[g * slots +
static_cast<int>(dir) * bounds.size() + i] +=
488 channel < bound && open(dir, channel);
489 SmallVector<int64_t> held(groups.size() * slots, 0);
490 auto fits = [&](
unsigned g, DMAChannelDir dir) {
491 size_t base = g * slots +
static_cast<int>(dir) * bounds.size();
493 for (
size_t i = 0; i < bounds.size(); ++i) {
494 tighter += held[base + i];
495 if (tighter > below[base + i])
502 for (DMAChannelDir dir : {DMAChannelDir::S2MM, DMAChannelDir::MM2S}) {
504 for (
size_t i = 0; i < bounds.size(); ++i) {
506 for (
size_t g = 0; g < groups.size(); ++g)
507 room += below[g * slots +
static_cast<int>(dir) * bounds.size() + i];
508 tighter += llvm::count_if(ends, [&](
const BDPlanEnd &end) {
509 return end.dir == dir && end.limit == bounds[i];
517 std::function<bool(
size_t)> place = [&](
size_t next) {
518 if (next == order.size())
520 unsigned end = order[next];
521 size_t slot =
static_cast<int>(ends[end].dir) * bounds.size() +
522 (llvm::lower_bound(bounds, ends[end].limit) - bounds.begin());
523 unsigned first = next > 0 && shape(order[next - 1]) == shape(end)
524 ? groupOf[order[next - 1]]
526 for (
unsigned g = first; g < groups.size(); ++g) {
527 if (groups[g].room < ends[end].bds)
529 ++held[g * slots + slot];
530 if (fits(g, ends[end].dir)) {
532 groups[g].room -= ends[end].bds;
533 bool placed = place(next + 1);
534 groups[g].room += ends[end].bds;
536 --held[g * slots + slot];
540 --held[g * slots + slot];
546 SmallVector<int> result;
548 result.push_back(end.pinned ? *end.pinned : -1);
549 for (
auto [loose, index] : llvm::enumerate(looseOf))
550 result[index] = channelOf[loose];
555 ArrayRef<BDPlanEnd> ends, ArrayRef<unsigned> poolOf,
556 ArrayRef<BDWalkPool> pools, ArrayRef<bool> whole) {
557 SmallVector<int64_t> bds(pools.size(), 0);
558 for (
auto [end, pool] : llvm::zip_equal(ends, poolOf))
559 bds[pool] += end.bds;
560 auto key = [&](
unsigned pool) {
561 return std::make_tuple(pools[pool].depth, -pools[pool].objectBytes,
564 std::optional<unsigned> next;
565 for (
unsigned pool = 0, e = pools.size(); pool < e; ++pool)
566 if (pools[pool].walkable && !whole[pool] &&
567 (!next || key(pool) > key(*next)))
573 const AIETargetModel &target,
int col,
int row, ArrayRef<BDPlanEnd> ends,
574 ArrayRef<unsigned> poolOf, ArrayRef<BDWalkPool> pools,
575 function_ref<
bool(DMAChannelDir,
int)> free,
576 function_ref<int64_t(
int)> spent,
unsigned maxSets) {
578 SmallVector<BDGroup> tileGroups = tileBDGroups(target, col, row);
579 auto none = [](int) -> int64_t {
return 0; };
580 auto fitsWalking = [&](ArrayRef<bool> whole,
bool weighted) {
581 SmallVector<BDPlanEnd> planned;
582 for (
auto [end, pool] : llvm::zip_equal(ends, poolOf))
583 planned.push_back({end.dir,
587 end.limit, end.pinned});
589 weighted ? spent : function_ref<int64_t(
int)>(none))
592 SmallVector<bool> whole(pools.size(),
false);
593 if (!fitsWalking(whole,
false)) {
597 if (fitsWalking(whole,
true))
600 SmallVector<unsigned> ranked;
601 while (std::optional<unsigned> next =
603 ranked.push_back(*next);
606 if (!fitsWalking(whole,
true)) {
612 unsigned n = ranked.size();
613 assert(n < 32 &&
"each walkable pool draws a channel the plan above fit");
614 SmallVector<int64_t> maskBytes(uint32_t(1) << n, 0);
615 for (uint32_t mask = 1; mask < (uint32_t(1) << n); ++mask) {
616 const BDWalkPool &pool = pools[ranked[llvm::countr_zero(mask)]];
620 auto bytes = [&](uint32_t mask) {
return maskBytes[mask]; };
626 SmallVector<uint32_t> order;
627 for (uint32_t mask = 1; mask < (uint32_t(1) << n); ++mask)
628 order.push_back(mask);
629 llvm::stable_sort(order, [&](uint32_t a, uint32_t b) {
630 int64_t aBytes = bytes(a), bBytes = bytes(b);
631 if (aBytes != bBytes)
632 return aBytes < bBytes;
633 if (llvm::popcount(a) != llvm::popcount(b))
634 return llvm::popcount(a) < llvm::popcount(b);
637 uint32_t differ = a ^ b;
638 return differ && (a & differ & -differ);
640 llvm::BitVector fitsMask(uint32_t(1) << n);
641 for (uint32_t mask : order) {
642 if (result.
sets.size() >= maxSets)
644 bool fits = llvm::any_of(llvm::seq<unsigned>(0, n), [&](
unsigned bit) {
645 return (mask >> bit & 1) && fitsMask.test(mask & ~(uint32_t(1) << bit));
648 llvm::fill(whole,
false);
649 for (
unsigned bit = 0; bit < n; ++bit)
651 whole[ranked[bit]] =
true;
652 fits = fitsWalking(whole,
true);
656 SmallVector<unsigned> set;
657 for (
unsigned bit = 0; bit < n; ++bit)
659 set.push_back(ranked[bit]);
660 result.
sets.push_back(std::move(set));
661 result.
bytes.push_back(bytes(mask));
668 ArrayRef<SmallVector<int64_t>> bytes,
669 function_ref<
bool(ArrayRef<unsigned>)> places,
unsigned maxTries) {
670 using Choice = std::vector<unsigned>;
671 auto total = [&](
const Choice &choice) {
673 for (
auto [tile, set] : llvm::enumerate(choice))
674 sum += bytes[tile][set];
680 std::set<std::pair<int64_t, Choice>> frontier;
681 std::set<Choice> seen;
682 Choice first(bytes.size(), 0);
683 frontier.insert({total(first), first});
686 result.
sets.assign(first.begin(), first.end());
687 for (
unsigned tries = 0; !frontier.empty(); ++tries) {
688 if (tries == maxTries) {
692 Choice choice = frontier.begin()->second;
693 frontier.erase(frontier.begin());
694 if (places(choice)) {
695 result.
sets.assign(choice.begin(), choice.end());
699 for (
unsigned tile = 0; tile < choice.size(); ++tile) {
700 if (choice[tile] + 1 >= bytes[tile].size())
702 Choice next = choice;
704 if (seen.insert(next).second)
705 frontier.insert({total(next), next});
virtual bool isBdChannelAccessible(int col, int row, uint32_t bd_id, int channel) const =0
Return true iff buffer descriptor bd_id on tile (col, row) can be submitted on channel channel.
virtual uint32_t getNumBDs(AIETileType tileType) const =0
Return the number of buffer descriptors for a given tile type.
virtual uint32_t getNumDestSwitchboxConnections(int col, int row, WireBundle bundle) const =0
Return the number of destinations of connections inside a switchbox.
virtual uint32_t getNumSourceSwitchboxConnections(int col, int row, WireBundle bundle) const =0
Return the number of sources of connections inside a switchbox.
llvm::DenseMap< int, int64_t > at(const AIETargetModel &target, int col, int row, llvm::ArrayRef< mlir::Operation * > tiles={}) const
By channel, the ids held at (col, row) by tiles and by every tile with those coordinates.
llvm::SmallVector< std::pair< int, int > > positions() const
Coordinates of the placed tiles that hold BD ids.
DMAChannelAnalysis(DeviceOp &device)
int getDMAChannelIndex(TileLike tile, DMAChannelDir dir, bool requiresAdjacentTileAccessChannels, mlir::Operation *owner=nullptr)
Next free channel of tile in dir, or -1 when the tile has none left.
static std::optional< unsigned > nextPoolToWalk(llvm::ArrayRef< BDPlanEnd > ends, llvm::ArrayRef< unsigned > poolOf, llvm::ArrayRef< BDWalkPool > pools, llvm::ArrayRef< bool > whole)
The walkable pool not yet whole to walk next: the deepest, then the one with the smallest objects,...
mlir::Operation * getDMAChannelOwner(TileLike tile, DMAChannelDir dir, int channel)
Operation reserving or routing this channel; null if none.
bool isChannelFree(TileLike tile, DMAChannelDir dir, int channel)
Whether first-free assignment could hand out channel: nothing reserves it and no explicit flow routes...
static std::optional< llvm::SmallVector< int > > planBDChannels(const AIETargetModel &target, int col, int row, llvm::ArrayRef< BDPlanEnd > ends, llvm::function_ref< bool(DMAChannelDir, int)> free, llvm::function_ref< int64_t(int)> spent)
A channel of the tile at (col, row) for each of ends: its pinned one, else one free leaves that no ot...
static int64_t countBDs(DMAStartOp start)
static llvm::SmallVector< BDGroup > bdGroups(const AIETargetModel &target, int col, int row, int numChannels)
static WalkChoice searchWalkProduct(llvm::ArrayRef< llvm::SmallVector< int64_t > > bytes, llvm::function_ref< bool(llvm::ArrayRef< unsigned >)> places, unsigned maxTries)
Tries the choices of one set per tile, bytes[tile] giving each of its sets' bytes walked whole,...
static llvm::SmallVector< mlir::Block * > chainOf(DMAStartOp start)
Blocks of the BD chain start begins, following next_bd.
static BDWalkSets walkSetsThatFit(const AIETargetModel &target, int col, int row, llvm::ArrayRef< BDPlanEnd > ends, llvm::ArrayRef< unsigned > poolOf, llvm::ArrayRef< BDWalkPool > pools, llvm::function_ref< bool(DMAChannelDir, int)> free, llvm::function_ref< int64_t(int)> spent, unsigned maxSets=std::numeric_limits< unsigned >::max())
Every set of walkable pools whose walk lets planBDChannels fit ends (poolOf gives each end's pool),...
static int getDMAChannelLimit(TileLike tile, DMAChannelDir dir, bool requiresAdjacentTileAccessChannels)
Exclusive upper bound on channel indices eligible for this transfer.
mlir::LogicalResult checkAIEStreamIndex(TileLike tile, DMAChannel chan, mlir::Operation *user, bool packet=false)
Claim a raw stream port for user, reporting on it when the port is taken; packet users may share it w...
int reservePinnedChannel(TileLike tile, DMAChannelDir dir, int channel, mlir::Operation *owner=nullptr, bool shareable=false)
Claim channel for (tile, dir) so first-free assignment cannot take it.
void forEachRuntimePinnedBdId(AIE::DeviceOp device, llvm::function_ref< void(Operation *op, Operation *tile, std::optional< int > channel, int32_t id)> pinned)
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)
struct DMAChannel { DMAChannelDir direction; int channel; bool operator==(const DMAChannel &rhs) const { return std::tie(direction, channel)==std::tie(rhs.direction, rhs.channel); } } DMAChannel
Channels among 0..numChannels-1 at (col, row), grouped by whichever BD ids any two in a group share,...
llvm::SmallVector< int > channels
A DMA end of one tile: its direction, the BD ids it takes, the exclusive upper bound on the channels ...
A pool whose ends a BD plan weighs: how many objects it holds, the bytes of one, and whether it can b...
walkSetsThatFit's result; channelShort when the ends do not fit the tile's channels even taking no BD...
llvm::SmallVector< int64_t > bytes
The bytes each set walks whole.
llvm::SmallVector< llvm::SmallVector< unsigned > > sets
One walkSetsThatFit set per mem tile of a spill component (memTileSpillComponents),...
llvm::SmallVector< unsigned > sets