MLIR-AIE 1.4.6.dev
xilinx::AIE::DMAChannelAnalysis Class Reference

Which DMA channels of each tile are already spoken for, so that a channel is handed out at most once across everything that programs one. More...

#include "aie/Dialect/AIE/Transforms/AIEDMAChannelAnalysis.h"

Collaboration diagram for xilinx::AIE::DMAChannelAnalysis:

Classes

struct  ChannelClaim
 A channel claimed by index: by a DMA program start, a runtime task or a shim allocation (owner), on tile. More...
struct  BDPlanEnd
 A DMA end of one tile: its direction, the BD ids it takes, the exclusive upper bound on the channels it may take, and the channel it pins, if any, which every end pinning it shares. More...
struct  BDGroup
 Channels among 0..numChannels-1 at (col, row), grouped by whichever BD ids any two in a group share, transitively. More...
struct  BDWalkPool
 A pool whose ends a BD plan weighs: how many objects it holds, the bytes of one, and whether it can be walked whole, its ends then taking one BD id each. More...
struct  BDWalkSets
 walkSetsThatFit's result; channelShort when the ends do not fit the tile's channels even taking no BD ids, fits false when no set does. More...
struct  WalkChoice
 One walkSetsThatFit set per mem tile of a spill component (memTileSpillComponents), by index; placed when its buffers place, stopped when the search gave up at maxTries tries. More...
class  TakenBDs
 The BD ids tiles' own programs hold before objectFIFOs take theirs: the chains DMA programs start by index, on their channels, and each id a runtime sequence pins (AIEX::forEachRuntimePinnedBdId), once per tile, on the lowest channel up to its own reaching it (aie-reserve-runtime-bd-ids keeps static BDs off those). More...

Public Member Functions

 DMAChannelAnalysis (DeviceOp &device)
llvm::ArrayRef< ChannelClaim > getChannelClaims () const
 The channels taken by index rather than through a route endpoint, in the order the claims were made.
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.
bool isChannelFree (TileLike tile, DMAChannelDir dir, int channel)
 Whether first-free assignment could hand out channel: nothing reserves it and no explicit flow routes it.
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.
mlir::Operation * getDMAChannelOwner (TileLike tile, DMAChannelDir dir, int channel)
 Operation reserving or routing this channel; null if none.
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 with other packets.

Static Public Member Functions

static int getDMAChannelLimit (TileLike tile, DMAChannelDir dir, bool requiresAdjacentTileAccessChannels)
 Exclusive upper bound on channel indices eligible for this transfer.
static llvm::SmallVector< BDGroup > bdGroups (const AIETargetModel &target, int col, int row, int numChannels)
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 other end of its direction takes; and, for every set of channels sharing BD ids, the ends on them plus the ids spent on each channel within those ids fit those ids.
static std::optional< llvm::SmallVector< int > > planBDChannels (llvm::ArrayRef< BDGroup > tileGroups, llvm::ArrayRef< BDPlanEnd > ends, llvm::function_ref< bool(DMAChannelDir, int)> free, llvm::function_ref< int64_t(int)> spent)
 The same, given the tile's bdGroups.
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, then the one whose ends take the most BD ids; pools order decides only between pools alike in all three.
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), ordered by the bytes the set walks whole, then its size, then its members in nextPoolToWalk's order; at most maxSets of them, cheapest first (unbounded by default).
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, in order of total bytes walked, then the tiles' set indices in turn, until places (the caller's buffer search over the component) accepts one; the first choice when none does.
static llvm::SmallVector< mlir::Block * > chainOf (DMAStartOp start)
 Blocks of the BD chain start begins, following next_bd.
static int64_t countBDs (DMAStartOp start)

Static Public Attributes

static constexpr unsigned kMaxWalkPlacements = 1024

Detailed Description

Which DMA channels of each tile are already spoken for, so that a channel is handed out at most once across everything that programs one.

Definition at line 27 of file AIEDMAChannelAnalysis.h.

Constructor & Destructor Documentation

◆ DMAChannelAnalysis()

DMAChannelAnalysis::DMAChannelAnalysis ( DeviceOp & device)

Definition at line 41 of file AIEDMAChannelAnalysis.cpp.

Member Function Documentation

◆ bdGroups()

◆ chainOf()

SmallVector< Block * > DMAChannelAnalysis::chainOf ( DMAStartOp start)
static

Blocks of the BD chain start begins, following next_bd.

Definition at line 257 of file AIEDMAChannelAnalysis.cpp.

Referenced by countBDs().

◆ checkAIEStreamIndex()

LogicalResult DMAChannelAnalysis::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 with other packets.

Definition at line 238 of file AIEDMAChannelAnalysis.cpp.

◆ countBDs()

int64_t DMAChannelAnalysis::countBDs ( DMAStartOp start)
static

Definition at line 272 of file AIEDMAChannelAnalysis.cpp.

References chainOf().

Referenced by xilinx::AIE::DMAChannelAnalysis::TakenBDs::TakenBDs().

◆ getChannelClaims()

llvm::ArrayRef< ChannelClaim > xilinx::AIE::DMAChannelAnalysis::getChannelClaims ( ) const
inline

The channels taken by index rather than through a route endpoint, in the order the claims were made.

A shareable one may appear more than once.

Definition at line 79 of file AIEDMAChannelAnalysis.h.

Referenced by xilinx::AIE::SequentialPlacer::place().

◆ getDMAChannelIndex()

int DMAChannelAnalysis::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.

A channel an explicit flow routes is not free. A channel reaching an adjacent MemTile's memory must come from the target's restricted range at every compatible physical position.

Definition at line 173 of file AIEDMAChannelAnalysis.cpp.

References getDMAChannelLimit(), isChannelFree(), and reservePinnedChannel().

◆ getDMAChannelLimit()

int DMAChannelAnalysis::getDMAChannelLimit ( TileLike tile,
DMAChannelDir dir,
bool requiresAdjacentTileAccessChannels )
static

Exclusive upper bound on channel indices eligible for this transfer.

Definition at line 134 of file AIEDMAChannelAnalysis.cpp.

References xilinx::AIE::getTargetModel().

Referenced by getDMAChannelIndex(), and reservePinnedChannel().

◆ getDMAChannelOwner()

Operation * DMAChannelAnalysis::getDMAChannelOwner ( TileLike tile,
DMAChannelDir dir,
int channel )

Operation reserving or routing this channel; null if none.

Definition at line 227 of file AIEDMAChannelAnalysis.cpp.

◆ isChannelFree()

bool DMAChannelAnalysis::isChannelFree ( TileLike tile,
DMAChannelDir dir,
int channel )

Whether first-free assignment could hand out channel: nothing reserves it and no explicit flow routes it.

Definition at line 186 of file AIEDMAChannelAnalysis.cpp.

Referenced by getDMAChannelIndex().

◆ nextPoolToWalk()

std::optional< unsigned > DMAChannelAnalysis::nextPoolToWalk ( llvm::ArrayRef< BDPlanEnd > ends,
llvm::ArrayRef< unsigned > poolOf,
llvm::ArrayRef< BDWalkPool > pools,
llvm::ArrayRef< bool > whole )
static

The walkable pool not yet whole to walk next: the deepest, then the one with the smallest objects, then the one whose ends take the most BD ids; pools order decides only between pools alike in all three.

Nothing when none is left.

Definition at line 554 of file AIEDMAChannelAnalysis.cpp.

Referenced by walkSetsThatFit().

◆ planBDChannels() [1/2]

std::optional< llvm::SmallVector< int > > xilinx::AIE::DMAChannelAnalysis::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 )
static

A channel of the tile at (col, row) for each of ends: its pinned one, else one free leaves that no other end of its direction takes; and, for every set of channels sharing BD ids, the ends on them plus the ids spent on each channel within those ids fit those ids.

Nothing when no assignment fits.

Referenced by walkSetsThatFit().

◆ planBDChannels() [2/2]

std::optional< llvm::SmallVector< int > > xilinx::AIE::DMAChannelAnalysis::planBDChannels ( llvm::ArrayRef< BDGroup > tileGroups,
llvm::ArrayRef< BDPlanEnd > ends,
llvm::function_ref< bool(DMAChannelDir, int)> free,
llvm::function_ref< int64_t(int)> spent )
static

The same, given the tile's bdGroups.

◆ reservePinnedChannel()

int DMAChannelAnalysis::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.

Returns the channel, or -1 when it is out of range or already claimed; the caller reports, since it knows which endpoint asked. shareable claimants join a channel other shareable ones hold.

Definition at line 193 of file AIEDMAChannelAnalysis.cpp.

References getDMAChannelLimit().

Referenced by getDMAChannelIndex().

◆ searchWalkProduct()

DMAChannelAnalysis::WalkChoice DMAChannelAnalysis::searchWalkProduct ( llvm::ArrayRef< llvm::SmallVector< int64_t > > bytes,
llvm::function_ref< bool(llvm::ArrayRef< unsigned >)> places,
unsigned maxTries )
static

Tries the choices of one set per tile, bytes[tile] giving each of its sets' bytes walked whole, in order of total bytes walked, then the tiles' set indices in turn, until places (the caller's buffer search over the component) accepts one; the first choice when none does.

Definition at line 667 of file AIEDMAChannelAnalysis.cpp.

References xilinx::AIE::DMAChannelAnalysis::WalkChoice::placed, xilinx::AIE::DMAChannelAnalysis::WalkChoice::sets, and xilinx::AIE::DMAChannelAnalysis::WalkChoice::stopped.

◆ walkSetsThatFit()

DMAChannelAnalysis::BDWalkSets DMAChannelAnalysis::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() )
static

Every set of walkable pools whose walk lets planBDChannels fit ends (poolOf gives each end's pool), ordered by the bytes the set walks whole, then its size, then its members in nextPoolToWalk's order; at most maxSets of them, cheapest first (unbounded by default).

Empty when the ends fit unwalked. At most 12 pools are walkable: each draws a channel of its own, and more ends than channels make channelShort. aie-objectfifo-allocate and the SA placer both walk by this; the SA only ever takes the first set, so it should pass maxSets=1.

Definition at line 572 of file AIEDMAChannelAnalysis.cpp.

References xilinx::AIE::DMAChannelAnalysis::BDWalkSets::bytes, xilinx::AIE::DMAChannelAnalysis::BDWalkSets::channelShort, xilinx::AIE::DMAChannelAnalysis::BDWalkPool::depth, xilinx::AIE::DMAChannelAnalysis::BDWalkSets::fits, nextPoolToWalk(), xilinx::AIE::DMAChannelAnalysis::BDWalkPool::objectBytes, planBDChannels(), and xilinx::AIE::DMAChannelAnalysis::BDWalkSets::sets.

Member Data Documentation

◆ kMaxWalkPlacements

unsigned xilinx::AIE::DMAChannelAnalysis::kMaxWalkPlacements = 1024
staticconstexpr

Definition at line 208 of file AIEDMAChannelAnalysis.h.


The documentation for this class was generated from the following files: