CIRCT
20.0.0git
|
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>
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 | |
PlacementCell * | getLeaf (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 |
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.
|
private |
Definition at line 132 of file DeviceDB.h.
|
private |
Definition at line 133 of file DeviceDB.h.
|
private |
Definition at line 135 of file DeviceDB.h.
|
private |
Definition at line 134 of file DeviceDB.h.
|
private |
Definition at line 136 of file DeviceDB.h.
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.
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::PlacementDB | ( | mlir::ModuleOp | topMod, |
const PrimitiveDB & | seed | ||
) |
Definition at line 76 of file DeviceDB.cpp.
References addDesignPlacements(), circt::msft::PrimitiveDB::foreach(), getLeaf(), and seeded.
|
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().
|
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().
DynInstDataOpInterface circt::msft::PlacementDB::getInstanceAt | ( | PhysLocationAttr | ) |
Lookup the instance at a particular location.
|
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().
PhysLocationAttr circt::msft::PlacementDB::getNearestFreeInColumn | ( | PrimitiveType | prim, |
uint64_t | column, | ||
uint64_t | nearestToY | ||
) |
Find the nearest unoccupied primitive location to 'nearestToY' in 'column'.
|
private |
Definition at line 115 of file DeviceDB.cpp.
References getLeaf(), and circt::msft::PlacementDB::PlacementCell::locOp.
Referenced by addPlacements().
|
private |
Move it.
Definition at line 285 of file DeviceDB.cpp.
References assert(), getLeaf(), circt::msft::PlacementDB::PlacementCell::locOp, and movePlacementCheck().
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.
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.
|
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().
PDRegPhysLocationOp circt::msft::PlacementDB::place | ( | DynamicInstanceOp | inst, |
LocationVectorAttr | , | ||
Location | srcLoc | ||
) |
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.
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.
|
private |
Remove the placement from the DB.
void circt::msft::PlacementDB::removePlacement | ( | PDPhysLocationOp | ) |
Remove the placement from the DB and IR. Erases the op.
void circt::msft::PlacementDB::removePlacement | ( | PDRegPhysLocationOp | ) |
Remove the placement from the DB and IR. Erases the op.
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().
void PlacementDB::walkRegionPlacements | ( | function_ref< void(PDPhysRegionOp)> | callback | ) |
Walk the region placement information.
Definition at line 421 of file DeviceDB.cpp.
References regionPlacements.
|
private |
Definition at line 129 of file DeviceDB.h.
|
private |
Definition at line 142 of file DeviceDB.h.
Referenced by getLeaf().
|
private |
Definition at line 143 of file DeviceDB.h.
Referenced by addPlacements(), placeIn(), and walkRegionPlacements().
|
private |
Definition at line 144 of file DeviceDB.h.
Referenced by getLeaf(), and PlacementDB().
|
private |
Definition at line 130 of file DeviceDB.h.
Referenced by addDesignPlacements().