13 #ifndef CIRCT_DIALECT_MSFT_DEVICEDB_H
14 #define CIRCT_DIALECT_MSFT_DEVICEDB_H
19 #include "mlir/IR/Operation.h"
20 #include "llvm/ADT/DenseMap.h"
39 void foreach (function_ref<
void(PhysLocationAttr)> callback)
const;
43 using DimNumMap = DenseMap<size_t, DimPrimitiveType>;
44 using DimYMap = DenseMap<size_t, DimNumMap>;
45 using DimXMap = DenseMap<size_t, DimYMap>;
81 PDPhysLocationOp
place(DynamicInstanceOp inst, PhysLocationAttr,
82 StringRef subpath, Location srcLoc);
83 PDRegPhysLocationOp
place(DynamicInstanceOp inst, LocationVectorAttr,
86 PDPhysRegionOp
placeIn(DynamicInstanceOp inst, DeclPhysicalRegionOp,
87 StringRef subPath, Location srcLoc);
107 uint64_t nearestToY);
114 std::tuple<int64_t, int64_t, int64_t, int64_t> bounds =
115 std::make_tuple(-1, -1, -1, -1),
116 std::optional<PrimitiveType> primType = {},
117 std::optional<WalkOrder> = {});
149 LogicalResult
insertPlacement(DynInstDataOpInterface op, PhysLocationAttr);
160 PhysLocationAttr from, PhysLocationAttr to);
162 void movePlacement(DynInstDataOpInterface op, PhysLocationAttr from,
163 PhysLocationAttr to);
A data structure to contain both the locations of the primitives on the device and instance assignmen...
void removePlacement(PDRegPhysLocationOp)
Remove the placement from the DB and IR. Erases the op.
LogicalResult movePlacementCheck(DynInstDataOpInterface op, PhysLocationAttr from, PhysLocationAttr to)
Check to make sure the move is going to succeed.
void removePlacement(PDPhysLocationOp)
Remove the placement from the DB and IR. Erases the op.
Direction
Contains the order to iterate in each dimension for walkPlacements.
DynInstDataOpInterface getInstanceAt(PhysLocationAttr)
Lookup the instance at a particular location.
size_t addPlacements(DynamicInstanceOp inst)
Load the placements from inst.
SmallVector< PDPhysRegionOp > RegionPlacements
LogicalResult movePlacement(PDPhysLocationOp, PhysLocationAttr)
Move a placement location to a new location.
DenseMap< size_t, DimNumMap > DimYMap
PDPhysLocationOp place(DynamicInstanceOp inst, PhysLocationAttr, StringRef subpath, Location srcLoc)
Assign an instance to a primitive.
size_t addDesignPlacements()
Load the database from the IR.
DenseMap< size_t, DimYMap > DimXMap
PlacementCell * getLeaf(PhysLocationAttr)
Get the leaf node.
DenseMap< PrimitiveType, PlacementCell > DimDevType
PlacementDB(mlir::ModuleOp topMod)
Create a placement db containing all the placements in 'topMod'.
void walkRegionPlacements(function_ref< void(PDPhysRegionOp)>)
Walk the region placement information.
PhysLocationAttr getNearestFreeInColumn(PrimitiveType prim, uint64_t column, uint64_t nearestToY)
Find the nearest unoccupied primitive location to 'nearestToY' in 'column'.
PDPhysRegionOp placeIn(DynamicInstanceOp inst, DeclPhysicalRegionOp, StringRef subPath, Location srcLoc)
Assign an operation to a physical region. Return false on failure.
void removePlacement(DynInstDataOpInterface, PhysLocationAttr)
Remove the placement from the DB.
LogicalResult movePlacement(PDRegPhysLocationOp, LocationVectorAttr)
Move a placement location to a new location.
PDRegPhysLocationOp place(DynamicInstanceOp inst, LocationVectorAttr, Location srcLoc)
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.
DenseMap< size_t, DimDevType > DimNumMap
LogicalResult insertPlacement(DynInstDataOpInterface op, PhysLocationAttr)
RegionPlacements regionPlacements
A data structure to contain locations of the primitives on the device.
DimPrimitiveType & getLeaf(PhysLocationAttr)
Get the leaf node.
DenseMap< size_t, DimYMap > DimXMap
LogicalResult addPrimitive(PhysLocationAttr)
Place a primitive at a location.
DenseMap< size_t, DimNumMap > DimYMap
bool isValidLocation(PhysLocationAttr)
Check to see if a primitive exists.
DenseSet< PrimitiveType > DimPrimitiveType
DenseMap< size_t, DimPrimitiveType > DimNumMap
PrimitiveDB(MLIRContext *)
Create a DB treating 'top' as the root module.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
DynInstDataOpInterface locOp