MLIR-AIE
Public Member Functions | Public Attributes | List of all members
AIEObjectFifoStatefulTransformPass Struct Reference
+ Inheritance diagram for AIEObjectFifoStatefulTransformPass:
+ Collaboration diagram for AIEObjectFifoStatefulTransformPass:

Public Member Functions

bool isSharedMemory (TileOp a, TileOp b, int *share_direction)
 Function that returns true if two tiles in the AIE array share a memory module.
 
bool requiresDMAs (ObjectFifoCreateOp createOp, int &share_direction)
 
void checkAndApplyViaSharedMemAttribute (ObjectFifoCreateOp createOp, int &share_direction)
 
std::optional< ObjectFifoLinkOp > getOptionalLinkOp (ObjectFifoCreateOp op)
 Function to retrieve ObjectFifoLinkOp of ObjectFifoCreateOp, if it belongs to one.
 
ObjectFifoCreateOp createObjectFifo (OpBuilder &builder, AIEObjectFifoType datatype, std::string name, Value prodTile, Value consTile, Attribute depth, BDDimLayoutArrayAttr dimensionsToStream, BDDimLayoutArrayArrayAttr dimensionsFromStreamPerConsumer)
 
std::vector< LockOp > createObjectFifoLocks (OpBuilder &builder, LockAnalysis &lockAnalysis, ObjectFifoCreateOp op, int numElem, int joinDistribFactor, TileOp creation_tile, int repeatCount)
 Function used to create objectFifo locks based on target architecture.
 
int calculateCurrentUsedMemory (TileOp targetTile, DenseMap< ObjectFifoCreateOp, std::vector< BufferOp > > &buffersPerFifo, std::vector< BufferOp > &buffers)
 Function to calculate total memory usage on a specific tile based on all buffers allocated to that tile from buffersPerFifo map.
 
std::map< ObjectFifoCreateOp, boolanalyzeCrossTileFIFOBuffers ()
 Function to analyze cross-tile buffer allocations in splitFifos Returns a simple map of (ObjectFifoCreateOp, bool) indicating cross-tile issues.
 
TileOp findOrCreateTile (OpBuilder &builder, DeviceOp &dev, TileOp hostTile, int col, int row)
 Helper function to find a tile at specific coordinates.
 
void createObjectFifoElements (OpBuilder &builder, LockAnalysis &lockAnalysis, ObjectFifoCreateOp op, int share_direction)
 Function used to create objectFifo elements and their locks.
 
Block * findEndOpBlock (Region &r)
 Function that returns a pointer to the block of a Region that contains the AIEEndOp.
 
template<typename MyOp >
void createBd (OpBuilder &builder, LockOp acqLock, int acqMode, LockAction acqLockAction, LockOp relLock, int relMode, MyOp buff, int offset, int len, Block *succ, BDDimLayoutArrayAttr dims, BDPadLayoutArrayAttr padDimensions)
 Function used to create a Bd block.
 
template<typename MyOp >
void createBdBlock (OpBuilder &builder, ObjectFifoCreateOp op, int lockMode, int acqNum, int relNum, MyOp buff, int offset, int len, DMAChannelDir channelDir, size_t lockIndex, Block *succ, BDDimLayoutArrayAttr dims, BDPadLayoutArrayAttr padDimensions, bool distribOrJoin=false)
 Function used to create a Bd block.
 
void createDMA (DeviceOp &device, OpBuilder &builder, ObjectFifoCreateOp op, DMAChannelDir channelDir, int channelIndex, int lockMode, BDDimLayoutArrayAttr dims, BDPadLayoutArrayAttr pad_dims)
 Function that either calls createAIETileDMA(), createShimDMA() or createMemTileDMA() based on op tile row value.
 
void createAIETileDMA (DeviceOp &device, OpBuilder &builder, ObjectFifoCreateOp op, DMAChannelDir channelDir, int channelIndex, int lockMode, BDDimLayoutArrayAttr dims)
 Function used to create a MemOp region with a DMA channel.
 
void createShimDMA (DeviceOp &device, OpBuilder &builder, ObjectFifoCreateOp op, DMAChannelDir channelDir, int channelIndex, int lockMode, BDDimLayoutArrayAttr dims)
 Function used to create a ShimDMAOp region with a DMA channel.
 
void createMemTileDMA (DeviceOp &device, OpBuilder &builder, ObjectFifoCreateOp op, DMAChannelDir channelDir, int channelIndex, int lockMode, BDDimLayoutArrayAttr dims, BDPadLayoutArrayAttr padDimensions)
 Function used to create a MemTileDMAOp region with a DMA channel.
 
int computeLCM (std::set< int > values)
 
LogicalResult unrollForLoops (DeviceOp &device, OpBuilder &builder, std::set< TileOp > objectFifoTiles)
 
void updateGlobalNextIndex (OpBuilder &builder, ObjectFifoReleaseOp relOp, BufferOp globalNextIndex, arith::ConstantOp index, arith::ConstantOp size)
 
LogicalResult dynamicGlobalObjectFifos (DeviceOp &device, OpBuilder &builder, std::set< TileOp > objectFifoTiles)
 
void createUseLocks (OpBuilder &builder, ObjectFifoCreateOp op, ObjectFifoPort port, DenseMap< std::pair< ObjectFifoCreateOp, int >, int > &acc, int numLocks, LockAction lockAction)
 Function used to create a UseLockOp based on input parameters.
 
int updateAndReturnIndex (DenseMap< std::pair< ObjectFifoCreateOp, int >, int > &map, std::pair< ObjectFifoCreateOp, int > pair)
 Function used to check whether op is already contained in map.
 
void addExternalBuffer (ObjectFifoCreateOp fifo, ExternalBufferOp buff)
 Function used to add an external buffer to the externalBuffersPerFifo map.
 
void detectExternalBuffers (DeviceOp &device, ObjectFifoCreateOp parent, ObjectFifoCreateOp child, Value tile)
 Function used to detect all external buffers associated with parent objectFifo and tile then map them to child objectFifo.
 
void replaceSplitFifo (ObjectFifoCreateOp originalOp, ObjectFifoCreateOp newOp, TileOp tile)
 Function used to replace uses of split objectFifos.
 
int findObjectFifoSize (DeviceOp &device, Value tile, ObjectFifoCreateOp objFifo)
 Function used to find the size of an objectFifo after split based on the maximum number of elements (of the original objectFifo) acquired by a process running on given tile.
 
void createObjectFifoAllocationInfo (OpBuilder &builder, MLIRContext *ctx, FlatSymbolRefAttr obj_fifo, int colIndex, DMAChannelDir channelDir, int channelIndex, bool plio)
 Function used to generate, from an objectFifo with a shimTile endpoint, a shimDMAAllocationOp containing the channelDir, channelIndex and shimTile col assigned by the objectFifo lowering.
 
void verifyObjectFifoLinks (DeviceOp &device)
 Function used to verify that an objectfifo is present in at most one ObjectFifoLinkOp.
 
void assignDMAChannelIndices (DMAChannelAnalysis &dmaAnalysis, const std::map< ObjectFifoCreateOp, bool > &crossTileInfos, std::map< ObjectFifoCreateOp, int > &fifo_dma_channel_index, bool assignCrossTileOnly)
 Helper function to assign DMA channel indices for FIFOs based on cross-tile conditions.
 
void runOnOperation () override
 

Public Attributes

DenseMap< ObjectFifoCreateOp, std::vector< BufferOp > > buffersPerFifo
 
DenseMap< ObjectFifoCreateOp, std::vector< ExternalBufferOp > > externalBuffersPerFifo
 
DenseMap< ObjectFifoCreateOp, std::vector< LockOp > > locksPerFifo
 
std::vector< std::pair< ObjectFifoCreateOp, std::vector< ObjectFifoCreateOp > > > splitFifos
 
DenseMap< ObjectFifoLinkOp, ObjectFifoCreateOp > objFifoLinks
 
std::vector< ObjectFifoCreateOp > splitBecauseLink
 

Detailed Description

Definition at line 144 of file AIEObjectFifoStatefulTransform.cpp.

Member Function Documentation

◆ addExternalBuffer()

void AIEObjectFifoStatefulTransformPass::addExternalBuffer ( ObjectFifoCreateOp  fifo,
ExternalBufferOp  buff 
)
inline

Function used to add an external buffer to the externalBuffersPerFifo map.

Definition at line 1550 of file AIEObjectFifoStatefulTransform.cpp.

◆ analyzeCrossTileFIFOBuffers()

std::map< ObjectFifoCreateOp, bool > AIEObjectFifoStatefulTransformPass::analyzeCrossTileFIFOBuffers ( )
inline

Function to analyze cross-tile buffer allocations in splitFifos Returns a simple map of (ObjectFifoCreateOp, bool) indicating cross-tile issues.

Definition at line 453 of file AIEObjectFifoStatefulTransform.cpp.

References buffersPerFifo, getOptionalLinkOp(), objFifoLinks, and splitFifos.

◆ assignDMAChannelIndices()

void AIEObjectFifoStatefulTransformPass::assignDMAChannelIndices ( DMAChannelAnalysis dmaAnalysis,
const std::map< ObjectFifoCreateOp, bool > &  crossTileInfos,
std::map< ObjectFifoCreateOp, int > &  fifo_dma_channel_index,
bool  assignCrossTileOnly 
)
inline

Helper function to assign DMA channel indices for FIFOs based on cross-tile conditions.

Definition at line 1660 of file AIEObjectFifoStatefulTransform.cpp.

References DMAChannelAnalysis::getDMAChannelIndex().

◆ calculateCurrentUsedMemory()

int AIEObjectFifoStatefulTransformPass::calculateCurrentUsedMemory ( TileOp  targetTile,
DenseMap< ObjectFifoCreateOp, std::vector< BufferOp > > &  buffersPerFifo,
std::vector< BufferOp > &  buffers 
)
inline

Function to calculate total memory usage on a specific tile based on all buffers allocated to that tile from buffersPerFifo map.

Definition at line 421 of file AIEObjectFifoStatefulTransform.cpp.

References buffersPerFifo.

Referenced by createObjectFifoElements().

◆ checkAndApplyViaSharedMemAttribute()

void AIEObjectFifoStatefulTransformPass::checkAndApplyViaSharedMemAttribute ( ObjectFifoCreateOp  createOp,
int &  share_direction 
)
inline
  • -1 if the shared memory module is that of the first input tile,
  • 1 if it is that of the second input tile

Definition at line 293 of file AIEObjectFifoStatefulTransform.cpp.

References isSharedMemory().

Referenced by requiresDMAs().

◆ computeLCM()

int AIEObjectFifoStatefulTransformPass::computeLCM ( std::set< int >  values)
inline

Definition at line 1183 of file AIEObjectFifoStatefulTransform.cpp.

Referenced by unrollForLoops().

◆ createAIETileDMA()

void AIEObjectFifoStatefulTransformPass::createAIETileDMA ( DeviceOp &  device,
OpBuilder &  builder,
ObjectFifoCreateOp  op,
DMAChannelDir  channelDir,
int  channelIndex,
int  lockMode,
BDDimLayoutArrayAttr  dims 
)
inline

Function used to create a MemOp region with a DMA channel.

It uses creatBdBlock(), see there for lockMode input.

Definition at line 832 of file AIEObjectFifoStatefulTransform.cpp.

References buffersPerFifo, findEndOpBlock(), getOptionalLinkOp(), and objFifoLinks.

Referenced by createDMA().

◆ createBd()

template<typename MyOp >
void AIEObjectFifoStatefulTransformPass::createBd ( OpBuilder &  builder,
LockOp  acqLock,
int  acqMode,
LockAction  acqLockAction,
LockOp  relLock,
int  relMode,
MyOp  buff,
int  offset,
int  len,
Block *  succ,
BDDimLayoutArrayAttr  dims,
BDPadLayoutArrayAttr  padDimensions 
)
inline

Function used to create a Bd block.

Definition at line 743 of file AIEObjectFifoStatefulTransform.cpp.

Referenced by createBdBlock().

◆ createBdBlock()

template<typename MyOp >
void AIEObjectFifoStatefulTransformPass::createBdBlock ( OpBuilder &  builder,
ObjectFifoCreateOp  op,
int  lockMode,
int  acqNum,
int  relNum,
MyOp  buff,
int  offset,
int  len,
DMAChannelDir  channelDir,
size_t  lockIndex,
Block *  succ,
BDDimLayoutArrayAttr  dims,
BDPadLayoutArrayAttr  padDimensions,
bool  distribOrJoin = false 
)
inline

Function used to create a Bd block.

If lockMode is 0 we create a consumerDMA (i.e. on producer tile) else a producerDMA (i.e. on consumer tile).

Definition at line 769 of file AIEObjectFifoStatefulTransform.cpp.

References createBd(), and locksPerFifo.

◆ createDMA()

void AIEObjectFifoStatefulTransformPass::createDMA ( DeviceOp &  device,
OpBuilder &  builder,
ObjectFifoCreateOp  op,
DMAChannelDir  channelDir,
int  channelIndex,
int  lockMode,
BDDimLayoutArrayAttr  dims,
BDPadLayoutArrayAttr  pad_dims 
)
inline

Function that either calls createAIETileDMA(), createShimDMA() or createMemTileDMA() based on op tile row value.

Definition at line 812 of file AIEObjectFifoStatefulTransform.cpp.

References createAIETileDMA(), createMemTileDMA(), and createShimDMA().

◆ createMemTileDMA()

void AIEObjectFifoStatefulTransformPass::createMemTileDMA ( DeviceOp &  device,
OpBuilder &  builder,
ObjectFifoCreateOp  op,
DMAChannelDir  channelDir,
int  channelIndex,
int  lockMode,
BDDimLayoutArrayAttr  dims,
BDPadLayoutArrayAttr  padDimensions 
)
inline

Function used to create a MemTileDMAOp region with a DMA channel.

It uses creatBdBlock(), see there for lockMode input.

Definition at line 1005 of file AIEObjectFifoStatefulTransform.cpp.

References buffersPerFifo, findEndOpBlock(), getOptionalLinkOp(), and objFifoLinks.

Referenced by createDMA().

◆ createObjectFifo()

ObjectFifoCreateOp AIEObjectFifoStatefulTransformPass::createObjectFifo ( OpBuilder &  builder,
AIEObjectFifoType  datatype,
std::string  name,
Value  prodTile,
Value  consTile,
Attribute  depth,
BDDimLayoutArrayAttr  dimensionsToStream,
BDDimLayoutArrayArrayAttr  dimensionsFromStreamPerConsumer 
)
inline

Definition at line 342 of file AIEObjectFifoStatefulTransform.cpp.

◆ createObjectFifoAllocationInfo()

void AIEObjectFifoStatefulTransformPass::createObjectFifoAllocationInfo ( OpBuilder &  builder,
MLIRContext *  ctx,
FlatSymbolRefAttr  obj_fifo,
int  colIndex,
DMAChannelDir  channelDir,
int  channelIndex,
bool  plio 
)
inline

Function used to generate, from an objectFifo with a shimTile endpoint, a shimDMAAllocationOp containing the channelDir, channelIndex and shimTile col assigned by the objectFifo lowering.

Definition at line 1627 of file AIEObjectFifoStatefulTransform.cpp.

◆ createObjectFifoElements()

void AIEObjectFifoStatefulTransformPass::createObjectFifoElements ( OpBuilder &  builder,
LockAnalysis lockAnalysis,
ObjectFifoCreateOp  op,
int  share_direction 
)
inline

Function used to create objectFifo elements and their locks.

It maps the input objectFifo to associated buffers and locks.

Definition at line 546 of file AIEObjectFifoStatefulTransform.cpp.

References buffersPerFifo, calculateCurrentUsedMemory(), createObjectFifoLocks(), findOrCreateTile(), getOptionalLinkOp(), isSharedMemory(), locksPerFifo, and objFifoLinks.

◆ createObjectFifoLocks()

std::vector< LockOp > AIEObjectFifoStatefulTransformPass::createObjectFifoLocks ( OpBuilder &  builder,
LockAnalysis lockAnalysis,
ObjectFifoCreateOp  op,
int  numElem,
int  joinDistribFactor,
TileOp  creation_tile,
int  repeatCount 
)
inline

Function used to create objectFifo locks based on target architecture.

Called by createObjectFifoElements().

Definition at line 355 of file AIEObjectFifoStatefulTransform.cpp.

References externalBuffersPerFifo, and LockAnalysis::getLockID().

Referenced by createObjectFifoElements().

◆ createShimDMA()

void AIEObjectFifoStatefulTransformPass::createShimDMA ( DeviceOp &  device,
OpBuilder &  builder,
ObjectFifoCreateOp  op,
DMAChannelDir  channelDir,
int  channelIndex,
int  lockMode,
BDDimLayoutArrayAttr  dims 
)
inline

Function used to create a ShimDMAOp region with a DMA channel.

It uses creatBdBlock(), see there for lockMode input.

Definition at line 931 of file AIEObjectFifoStatefulTransform.cpp.

References externalBuffersPerFifo, and findEndOpBlock().

Referenced by createDMA().

◆ createUseLocks()

void AIEObjectFifoStatefulTransformPass::createUseLocks ( OpBuilder &  builder,
ObjectFifoCreateOp  op,
ObjectFifoPort  port,
DenseMap< std::pair< ObjectFifoCreateOp, int >, int > &  acc,
int  numLocks,
LockAction  lockAction 
)
inline

Function used to create a UseLockOp based on input parameters.

acc is an accumulator map that tracks the indices of the next locks to acquire (or release). Uses op to find index of acc for next lockID. Updates acc.

Definition at line 1469 of file AIEObjectFifoStatefulTransform.cpp.

References xilinx::AIE::port, and xilinx::AIE::AIETargetModel::UsesSemaphoreLocks.

◆ detectExternalBuffers()

void AIEObjectFifoStatefulTransformPass::detectExternalBuffers ( DeviceOp &  device,
ObjectFifoCreateOp  parent,
ObjectFifoCreateOp  child,
Value  tile 
)
inline

Function used to detect all external buffers associated with parent objectFifo and tile then map them to child objectFifo.

Definition at line 1560 of file AIEObjectFifoStatefulTransform.cpp.

◆ dynamicGlobalObjectFifos()

LogicalResult AIEObjectFifoStatefulTransformPass::dynamicGlobalObjectFifos ( DeviceOp &  device,
OpBuilder &  builder,
std::set< TileOp >  objectFifoTiles 
)
inline

Definition at line 1328 of file AIEObjectFifoStatefulTransform.cpp.

References xilinx::AIE::port.

◆ findEndOpBlock()

Block * AIEObjectFifoStatefulTransformPass::findEndOpBlock ( Region &  r)
inline

Function that returns a pointer to the block of a Region that contains the AIEEndOp.

Definition at line 733 of file AIEObjectFifoStatefulTransform.cpp.

Referenced by createAIETileDMA(), createMemTileDMA(), and createShimDMA().

◆ findObjectFifoSize()

int AIEObjectFifoStatefulTransformPass::findObjectFifoSize ( DeviceOp &  device,
Value  tile,
ObjectFifoCreateOp  objFifo 
)
inline

Function used to find the size of an objectFifo after split based on the maximum number of elements (of the original objectFifo) acquired by a process running on given tile.

If no CoreOp exists for this tile return 0.

Definition at line 1588 of file AIEObjectFifoStatefulTransform.cpp.

◆ findOrCreateTile()

TileOp AIEObjectFifoStatefulTransformPass::findOrCreateTile ( OpBuilder &  builder,
DeviceOp &  dev,
TileOp  hostTile,
int  col,
int  row 
)
inline

Helper function to find a tile at specific coordinates.

If a tile is not found, it creates a new one and returns it. hostTile is the original tile from which we are searching for neighbors. we create the new tile below the hostTile

Definition at line 514 of file AIEObjectFifoStatefulTransform.cpp.

References xilinx::AIE::col, and xilinx::AIE::row.

Referenced by createObjectFifoElements().

◆ getOptionalLinkOp()

std::optional< ObjectFifoLinkOp > AIEObjectFifoStatefulTransformPass::getOptionalLinkOp ( ObjectFifoCreateOp  op)
inline

Function to retrieve ObjectFifoLinkOp of ObjectFifoCreateOp, if it belongs to one.

Definition at line 328 of file AIEObjectFifoStatefulTransform.cpp.

Referenced by analyzeCrossTileFIFOBuffers(), createAIETileDMA(), createMemTileDMA(), createObjectFifoElements(), and requiresDMAs().

◆ isSharedMemory()

bool AIEObjectFifoStatefulTransformPass::isSharedMemory ( TileOp  a,
TileOp  b,
int *  share_direction 
)
inline

Function that returns true if two tiles in the AIE array share a memory module.

share_direction is equal to:

  • -1 if the shared memory module is that of the first input tile,
  • 1 if it is that of the second input tile,
  • 0 is no memory module is shared.

Definition at line 168 of file AIEObjectFifoStatefulTransform.cpp.

References xilinx::AIE::getTargetModel().

Referenced by checkAndApplyViaSharedMemAttribute(), createObjectFifoElements(), and requiresDMAs().

◆ replaceSplitFifo()

void AIEObjectFifoStatefulTransformPass::replaceSplitFifo ( ObjectFifoCreateOp  originalOp,
ObjectFifoCreateOp  newOp,
TileOp  tile 
)
inline

Function used to replace uses of split objectFifos.

Definition at line 1570 of file AIEObjectFifoStatefulTransform.cpp.

◆ requiresDMAs()

bool AIEObjectFifoStatefulTransformPass::requiresDMAs ( ObjectFifoCreateOp  createOp,
int &  share_direction 
)
inline

◆ runOnOperation()

void AIEObjectFifoStatefulTransformPass::runOnOperation ( )
inlineoverride

Definition at line 1697 of file AIEObjectFifoStatefulTransform.cpp.

References xilinx::AIE::port.

◆ unrollForLoops()

LogicalResult AIEObjectFifoStatefulTransformPass::unrollForLoops ( DeviceOp &  device,
OpBuilder &  builder,
std::set< TileOp >  objectFifoTiles 
)
inline

Definition at line 1191 of file AIEObjectFifoStatefulTransform.cpp.

References computeLCM().

◆ updateAndReturnIndex()

int AIEObjectFifoStatefulTransformPass::updateAndReturnIndex ( DenseMap< std::pair< ObjectFifoCreateOp, int >, int > &  map,
std::pair< ObjectFifoCreateOp, int >  pair 
)
inline

Function used to check whether op is already contained in map.

If it is then return the associated int, if not create new entry and return 0.

Definition at line 1539 of file AIEObjectFifoStatefulTransform.cpp.

◆ updateGlobalNextIndex()

void AIEObjectFifoStatefulTransformPass::updateGlobalNextIndex ( OpBuilder &  builder,
ObjectFifoReleaseOp  relOp,
BufferOp  globalNextIndex,
arith::ConstantOp  index,
arith::ConstantOp  size 
)
inline

Definition at line 1307 of file AIEObjectFifoStatefulTransform.cpp.

◆ verifyObjectFifoLinks()

void AIEObjectFifoStatefulTransformPass::verifyObjectFifoLinks ( DeviceOp &  device)
inline

Function used to verify that an objectfifo is present in at most one ObjectFifoLinkOp.

Definition at line 1640 of file AIEObjectFifoStatefulTransform.cpp.

Member Data Documentation

◆ buffersPerFifo

DenseMap<ObjectFifoCreateOp, std::vector<BufferOp> > AIEObjectFifoStatefulTransformPass::buffersPerFifo

◆ externalBuffersPerFifo

DenseMap<ObjectFifoCreateOp, std::vector<ExternalBufferOp> > AIEObjectFifoStatefulTransformPass::externalBuffersPerFifo

Definition at line 149 of file AIEObjectFifoStatefulTransform.cpp.

Referenced by createObjectFifoLocks(), and createShimDMA().

◆ locksPerFifo

DenseMap<ObjectFifoCreateOp, std::vector<LockOp> > AIEObjectFifoStatefulTransformPass::locksPerFifo

Definition at line 152 of file AIEObjectFifoStatefulTransform.cpp.

Referenced by createBdBlock(), and createObjectFifoElements().

◆ objFifoLinks

DenseMap<ObjectFifoLinkOp, ObjectFifoCreateOp> AIEObjectFifoStatefulTransformPass::objFifoLinks

◆ splitBecauseLink

std::vector<ObjectFifoCreateOp> AIEObjectFifoStatefulTransformPass::splitBecauseLink

Definition at line 160 of file AIEObjectFifoStatefulTransform.cpp.

Referenced by requiresDMAs().

◆ splitFifos

std::vector<std::pair<ObjectFifoCreateOp, std::vector<ObjectFifoCreateOp> > > AIEObjectFifoStatefulTransformPass::splitFifos

Definition at line 154 of file AIEObjectFifoStatefulTransform.cpp.

Referenced by analyzeCrossTileFIFOBuffers().


The documentation for this struct was generated from the following file: