CIRCT  19.0.0git
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
circt::msft::PlacementDB Class Reference

A data structure to contain both the locations of the primitives on the device and instance assignments to said primitives locations, aka placements. More...

#include <DeviceDB.h>

Collaboration diagram for circt::msft::PlacementDB:
Collaboration graph
[legend]

Classes

struct  PlacementCell
 A memory slot. More...
 
struct  WalkOrder
 

Public Types

enum  Direction { NONE = 0 , ASC = 1 , DESC = 2 }
 Contains the order to iterate in each dimension for walkPlacements. More...
 

Public Member Functions

 PlacementDB (mlir::ModuleOp topMod)
 Create a placement db containing all the placements in 'topMod'. More...
 
 PlacementDB (mlir::ModuleOp topMod, const PrimitiveDB &seed)
 
PDPhysLocationOp place (DynamicInstanceOp inst, PhysLocationAttr, StringRef subpath, Location srcLoc)
 Assign an instance to a primitive. More...
 
PDRegPhysLocationOp place (DynamicInstanceOp inst, LocationVectorAttr, Location srcLoc)
 
PDPhysRegionOp placeIn (DynamicInstanceOp inst, DeclPhysicalRegionOp, StringRef subPath, Location srcLoc)
 Assign an operation to a physical region. Return false on failure. More...
 
void removePlacement (PDPhysLocationOp)
 Remove the placement from the DB and IR. Erases the op. More...
 
LogicalResult movePlacement (PDPhysLocationOp, PhysLocationAttr)
 Move a placement location to a new location. More...
 
void removePlacement (PDRegPhysLocationOp)
 Remove the placement from the DB and IR. Erases the op. More...
 
LogicalResult movePlacement (PDRegPhysLocationOp, LocationVectorAttr)
 Move a placement location to a new location. More...
 
DynInstDataOpInterface getInstanceAt (PhysLocationAttr)
 Lookup the instance at a particular location. More...
 
PhysLocationAttr getNearestFreeInColumn (PrimitiveType prim, uint64_t column, uint64_t nearestToY)
 Find the nearest unoccupied primitive location to 'nearestToY' in 'column'. More...
 
void walkPlacements (function_ref< void(PhysLocationAttr, DynInstDataOpInterface)>, std::tuple< int64_t, int64_t, int64_t, int64_t > bounds=std::make_tuple(-1, -1, -1, -1), std::optional< PrimitiveType > primType={}, std::optional< WalkOrder >={})
 Walk the placement information in some sort of reasonable order. More...
 
void walkRegionPlacements (function_ref< void(PDPhysRegionOp)>)
 Walk the region placement information. More...
 

Private Types

using DimDevType = DenseMap< PrimitiveType, PlacementCell >
 
using DimNumMap = DenseMap< size_t, DimDevType >
 
using DimYMap = DenseMap< size_t, DimNumMap >
 
using DimXMap = DenseMap< size_t, DimYMap >
 
using RegionPlacements = SmallVector< PDPhysRegionOp >
 

Private Member Functions

PlacementCellgetLeaf (PhysLocationAttr)
 Get the leaf node. More...
 
size_t addPlacements (DynamicInstanceOp inst)
 Load the placements from inst. More...
 
LogicalResult insertPlacement (DynInstDataOpInterface op, PhysLocationAttr)
 
size_t addDesignPlacements ()
 Load the database from the IR. More...
 
void removePlacement (DynInstDataOpInterface, PhysLocationAttr)
 Remove the placement from the DB. More...
 
LogicalResult movePlacementCheck (DynInstDataOpInterface op, PhysLocationAttr from, PhysLocationAttr to)
 Check to make sure the move is going to succeed. More...
 
void movePlacement (DynInstDataOpInterface op, PhysLocationAttr from, PhysLocationAttr to)
 Move it. More...
 

Private Attributes

MLIRContext * ctxt
 
mlir::ModuleOp topMod
 
DimXMap placements
 
RegionPlacements regionPlacements
 
bool seeded
 

Detailed Description

A data structure to contain both the locations of the primitives on the device and instance assignments to said primitives locations, aka placements.

Holds pointers into the IR, which may become invalid as a result of IR transforms. As a result, this class is intended to be short-lived – created just before loading placements and destroyed immediatetly after things are placed.

Definition at line 64 of file DeviceDB.h.

Member Typedef Documentation

◆ DimDevType

using circt::msft::PlacementDB::DimDevType = DenseMap<PrimitiveType, PlacementCell>
private

Definition at line 132 of file DeviceDB.h.

◆ DimNumMap

using circt::msft::PlacementDB::DimNumMap = DenseMap<size_t, DimDevType>
private

Definition at line 133 of file DeviceDB.h.

◆ DimXMap

using circt::msft::PlacementDB::DimXMap = DenseMap<size_t, DimYMap>
private

Definition at line 135 of file DeviceDB.h.

◆ DimYMap

using circt::msft::PlacementDB::DimYMap = DenseMap<size_t, DimNumMap>
private

Definition at line 134 of file DeviceDB.h.

◆ RegionPlacements

using circt::msft::PlacementDB::RegionPlacements = SmallVector<PDPhysRegionOp>
private

Definition at line 136 of file DeviceDB.h.

Member Enumeration Documentation

◆ Direction

Contains the order to iterate in each dimension for walkPlacements.

The dimensions are visited with columns first, then rows, then numbers within a cell.

Enumerator
NONE 
ASC 
DESC 

Definition at line 73 of file DeviceDB.h.

Constructor & Destructor Documentation

◆ PlacementDB() [1/2]

PlacementDB::PlacementDB ( mlir::ModuleOp  topMod)

Create a placement db containing all the placements in 'topMod'.

Definition at line 72 of file DeviceDB.cpp.

References addDesignPlacements().

◆ PlacementDB() [2/2]

PlacementDB::PlacementDB ( mlir::ModuleOp  topMod,
const PrimitiveDB seed 
)

Member Function Documentation

◆ addDesignPlacements()

size_t PlacementDB::addDesignPlacements ( )
private

Load the database from the IR.

Walk the entire design adding placements.

Return the number of placements which failed to load due to invalid specifications.

Definition at line 177 of file DeviceDB.cpp.

References addPlacements(), and topMod.

Referenced by PlacementDB().

◆ addPlacements()

size_t PlacementDB::addPlacements ( DynamicInstanceOp  inst)
private

Load the placements from inst.

Using the operation attributes, add the proper placements to the database.

Return the number of placements which weren't added due to conflicts.

Definition at line 149 of file DeviceDB.cpp.

References insertPlacement(), and regionPlacements.

Referenced by addDesignPlacements().

◆ getInstanceAt()

DynInstDataOpInterface circt::msft::PlacementDB::getInstanceAt ( PhysLocationAttr  )

Lookup the instance at a particular location.

◆ getLeaf()

PlacementDB::PlacementCell * PlacementDB::getLeaf ( PhysLocationAttr  loc)
private

Get the leaf node.

Abstract this out to make it easier to change the underlying data structure.

Definition at line 331 of file DeviceDB.cpp.

References placements, and seeded.

Referenced by insertPlacement(), movePlacement(), movePlacementCheck(), and PlacementDB().

◆ getNearestFreeInColumn()

PhysLocationAttr circt::msft::PlacementDB::getNearestFreeInColumn ( PrimitiveType  prim,
uint64_t  column,
uint64_t  nearestToY 
)

Find the nearest unoccupied primitive location to 'nearestToY' in 'column'.

◆ insertPlacement()

LogicalResult PlacementDB::insertPlacement ( DynInstDataOpInterface  op,
PhysLocationAttr  loc 
)
private

Definition at line 115 of file DeviceDB.cpp.

References getLeaf(), and circt::msft::PlacementDB::PlacementCell::locOp.

Referenced by addPlacements().

◆ movePlacement() [1/3]

void PlacementDB::movePlacement ( DynInstDataOpInterface  op,
PhysLocationAttr  from,
PhysLocationAttr  to 
)
private

◆ movePlacement() [2/3]

LogicalResult circt::msft::PlacementDB::movePlacement ( PDPhysLocationOp  ,
PhysLocationAttr   
)

Move a placement location to a new location.

Returns failure if something is already placed at the new location.

◆ movePlacement() [3/3]

LogicalResult circt::msft::PlacementDB::movePlacement ( PDRegPhysLocationOp  ,
LocationVectorAttr   
)

Move a placement location to a new location.

Returns failure if something is already placed at the new location.

◆ movePlacementCheck()

LogicalResult PlacementDB::movePlacementCheck ( DynInstDataOpInterface  op,
PhysLocationAttr  from,
PhysLocationAttr  to 
)
private

Check to make sure the move is going to succeed.

Definition at line 259 of file DeviceDB.cpp.

References getLeaf(), and circt::msft::PlacementDB::PlacementCell::locOp.

Referenced by movePlacement().

◆ place() [1/2]

PDRegPhysLocationOp circt::msft::PlacementDB::place ( DynamicInstanceOp  inst,
LocationVectorAttr  ,
Location  srcLoc 
)

◆ place() [2/2]

PDPhysLocationOp circt::msft::PlacementDB::place ( DynamicInstanceOp  inst,
PhysLocationAttr  ,
StringRef  subpath,
Location  srcLoc 
)

Assign an instance to a primitive.

Return null if another instance is already placed at that location.

◆ placeIn()

PDPhysRegionOp PlacementDB::placeIn ( DynamicInstanceOp  inst,
DeclPhysicalRegionOp  ,
StringRef  subPath,
Location  srcLoc 
)

Assign an operation to a physical region. Return false on failure.

Definition at line 133 of file DeviceDB.cpp.

References circt::calyx::direction::get(), and regionPlacements.

◆ removePlacement() [1/3]

void circt::msft::PlacementDB::removePlacement ( DynInstDataOpInterface  ,
PhysLocationAttr   
)
private

Remove the placement from the DB.

◆ removePlacement() [2/3]

void circt::msft::PlacementDB::removePlacement ( PDPhysLocationOp  )

Remove the placement from the DB and IR. Erases the op.

◆ removePlacement() [3/3]

void circt::msft::PlacementDB::removePlacement ( PDRegPhysLocationOp  )

Remove the placement from the DB and IR. Erases the op.

◆ walkPlacements()

void circt::msft::PlacementDB::walkPlacements ( function_ref< void(PhysLocationAttr, DynInstDataOpInterface)>  ,
std::tuple< int64_t, int64_t, int64_t, int64_t >  bounds = std::make_tuple(-1, -1, -1, -1),
std::optional< PrimitiveType >  primType = {},
std::optional< WalkOrder = {} 
)

Walk the placement information in some sort of reasonable order.

Bounds restricts the walk to a rectangle of [xmin, xmax, ymin, ymax] (inclusive), with -1 meaning unbounded.

Referenced by circtMSFTPlacementDBWalkPlacements().

◆ walkRegionPlacements()

void PlacementDB::walkRegionPlacements ( function_ref< void(PDPhysRegionOp)>  callback)

Walk the region placement information.

Definition at line 421 of file DeviceDB.cpp.

References regionPlacements.

Member Data Documentation

◆ ctxt

MLIRContext* circt::msft::PlacementDB::ctxt
private

Definition at line 129 of file DeviceDB.h.

◆ placements

DimXMap circt::msft::PlacementDB::placements
private

Definition at line 142 of file DeviceDB.h.

Referenced by getLeaf().

◆ regionPlacements

RegionPlacements circt::msft::PlacementDB::regionPlacements
private

Definition at line 143 of file DeviceDB.h.

Referenced by addPlacements(), placeIn(), and walkRegionPlacements().

◆ seeded

bool circt::msft::PlacementDB::seeded
private

Definition at line 144 of file DeviceDB.h.

Referenced by getLeaf(), and PlacementDB().

◆ topMod

mlir::ModuleOp circt::msft::PlacementDB::topMod
private

Definition at line 130 of file DeviceDB.h.

Referenced by addDesignPlacements().


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