[core] now fabric tile cache both grid and gsb coord for pb
This commit is contained in:
parent
778d03610c
commit
0d03d7b483
|
@ -72,22 +72,31 @@ FabricTileId FabricTile::find_tile(const vtr::Point<size_t>& coord) const {
|
|||
}
|
||||
|
||||
bool FabricTile::pb_in_tile(const FabricTileId& tile_id,
|
||||
const DeviceRRGSB& device_rr_gsb,
|
||||
const vtr::Point<size_t>& coord) const {
|
||||
return !pb_coords_[tile_id].empty() && find_pb_index_in_tile(tile_id, device_rr_gsb, coord) != pb_coords_[tile_id].size();
|
||||
const vtr::Point<size_t>& coord,
|
||||
const bool& use_gsb_coord) const {
|
||||
if (use_gsb_coord) {
|
||||
return !pb_gsb_coords_[tile_id].empty() && find_pb_index_in_tile(tile_id, coord, use_gsb_coord) != pb_gsb_coords_[tile_id].size();
|
||||
}
|
||||
return !pb_coords_[tile_id].empty() && find_pb_index_in_tile(tile_id, coord) != pb_coords_[tile_id].size();
|
||||
}
|
||||
|
||||
size_t FabricTile::find_pb_index_in_tile(
|
||||
const FabricTileId& tile_id,
|
||||
const DeviceRRGSB& device_rr_gsb,
|
||||
const vtr::Point<size_t>& coord) const {
|
||||
const vtr::Point<size_t>& coord,
|
||||
const bool& use_gsb_coord) const {
|
||||
VTR_ASSERT(valid_tile_id(tile_id));
|
||||
for (size_t idx = 0; idx < pb_coords_[tile_id].size(); ++idx) {
|
||||
/* Convert gsb coordinate to actual pb coordinate */
|
||||
if (!device_rr_gsb.is_gsb_exist(pb_coords_[tile_id][idx])) {
|
||||
continue;
|
||||
if (use_gsb_coord) {
|
||||
for (size_t idx = 0; idx < pb_gsb_coords_[tile_id].size(); ++idx) {
|
||||
vtr::Point<size_t> curr_coord = pb_gsb_coords_[tile_id][idx];
|
||||
if (curr_coord == coord) {
|
||||
return idx;
|
||||
}
|
||||
vtr::Point<size_t> curr_coord = device_rr_gsb.get_gsb(pb_coords_[tile_id][idx]).get_grid_coordinate();
|
||||
}
|
||||
/* Not found, return an invalid index */
|
||||
return pb_gsb_coords_[tile_id].size();
|
||||
} else {
|
||||
for (size_t idx = 0; idx < pb_coords_[tile_id].size(); ++idx) {
|
||||
vtr::Point<size_t> curr_coord = pb_coords_[tile_id][idx];
|
||||
if (curr_coord == coord) {
|
||||
return idx;
|
||||
}
|
||||
|
@ -95,6 +104,7 @@ size_t FabricTile::find_pb_index_in_tile(
|
|||
/* Not found, return an invalid index */
|
||||
return pb_coords_[tile_id].size();
|
||||
}
|
||||
}
|
||||
|
||||
bool FabricTile::sb_in_tile(const FabricTileId& tile_id,
|
||||
const vtr::Point<size_t>& coord) const {
|
||||
|
@ -168,6 +178,7 @@ FabricTileId FabricTile::create_tile(const vtr::Point<size_t>& coord) {
|
|||
ids_.push_back(tile_id);
|
||||
coords_.push_back(coord);
|
||||
pb_coords_.emplace_back();
|
||||
pb_gsb_coords_.emplace_back();
|
||||
cbx_coords_.emplace_back();
|
||||
cby_coords_.emplace_back();
|
||||
sb_coords_.emplace_back();
|
||||
|
@ -233,9 +244,11 @@ bool FabricTile::set_tile_coordinate(const FabricTileId& tile_id,
|
|||
}
|
||||
|
||||
void FabricTile::add_pb_coordinate(const FabricTileId& tile_id,
|
||||
const vtr::Point<size_t>& coord) {
|
||||
const vtr::Point<size_t>& coord,
|
||||
const vtr::Point<size_t>& gsb_coord) {
|
||||
VTR_ASSERT(valid_tile_id(tile_id));
|
||||
pb_coords_[tile_id].push_back(coord);
|
||||
pb_gsb_coords_[tile_id].push_back(gsb_coord);
|
||||
}
|
||||
|
||||
void FabricTile::add_cb_coordinate(const FabricTileId& tile_id,
|
||||
|
@ -265,6 +278,7 @@ void FabricTile::clear() {
|
|||
ids_.clear();
|
||||
coords_.clear();
|
||||
pb_coords_.clear();
|
||||
pb_gsb_coords_.clear();
|
||||
cbx_coords_.clear();
|
||||
cby_coords_.clear();
|
||||
sb_coords_.clear();
|
||||
|
@ -283,6 +297,7 @@ bool FabricTile::equivalent_tile(const FabricTileId& tile_a,
|
|||
const DeviceRRGSB& device_rr_gsb) const {
|
||||
/* The number of cbx, cby and sb blocks should be the same */
|
||||
if (pb_coords_[tile_a].size() != pb_coords_[tile_b].size() ||
|
||||
pb_gsb_coords_[tile_a].size() != pb_gsb_coords_[tile_b].size() ||
|
||||
cbx_coords_[tile_a].size() != cbx_coords_[tile_b].size() ||
|
||||
cby_coords_[tile_a].size() != cby_coords_[tile_b].size() ||
|
||||
sb_coords_[tile_a].size() != sb_coords_[tile_b].size()) {
|
||||
|
@ -290,17 +305,12 @@ bool FabricTile::equivalent_tile(const FabricTileId& tile_a,
|
|||
}
|
||||
/* The pb of two tiles should be the same, otherwise not equivalent */
|
||||
for (size_t iblk = 0; iblk < pb_coords_[tile_a].size(); ++iblk) {
|
||||
if (device_rr_gsb.is_gsb_exist(pb_coords_[tile_a][iblk]) != device_rr_gsb.is_gsb_exist(pb_coords_[tile_b][iblk])) {
|
||||
return false;
|
||||
}
|
||||
if (device_rr_gsb.is_gsb_exist(pb_coords_[tile_a][iblk])) {
|
||||
vtr::Point<size_t> tile_a_pb_coord = device_rr_gsb.get_gsb(pb_coords_[tile_a][iblk]).get_sb_coordinate();
|
||||
vtr::Point<size_t> tile_b_pb_coord = device_rr_gsb.get_gsb(pb_coords_[tile_b][iblk]).get_sb_coordinate();
|
||||
vtr::Point<size_t> tile_a_pb_coord = pb_coords_[tile_a][iblk];
|
||||
vtr::Point<size_t> tile_b_pb_coord = pb_coords_[tile_b][iblk];
|
||||
if (generate_grid_block_module_name_in_top_module(std::string(), grids, tile_a_pb_coord) != generate_grid_block_module_name_in_top_module(std::string(), grids, tile_b_pb_coord)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Each CBx should have the same unique modules in the device rr_gsb */
|
||||
for (size_t iblk = 0; iblk < cbx_coords_[tile_a].size(); ++iblk) {
|
||||
if (device_rr_gsb.get_cb_unique_module_index(CHANX,
|
||||
|
|
|
@ -39,10 +39,10 @@ class FabricTile {
|
|||
/** @brief Return a list of unique tiles */
|
||||
std::vector<FabricTileId> unique_tiles() const;
|
||||
/** @brief Find the index of a programmable block in the internal list by a
|
||||
* given coordinate. */
|
||||
* given coordinate. Note that the coord can be either the one in device grid or the one of gsb which the programmable block belongs to */
|
||||
size_t find_pb_index_in_tile(const FabricTileId& tile_id,
|
||||
const DeviceRRGSB& device_rr_gsb,
|
||||
const vtr::Point<size_t>& coord) const;
|
||||
const vtr::Point<size_t>& coord,
|
||||
const bool& use_gsb_coord = false) const;
|
||||
/** @brief Find the index of a switch block in the internal list by a given
|
||||
* coordinate. */
|
||||
size_t find_sb_index_in_tile(const FabricTileId& tile_id,
|
||||
|
@ -52,11 +52,11 @@ class FabricTile {
|
|||
size_t find_cb_index_in_tile(const FabricTileId& tile_id,
|
||||
const t_rr_type& cb_type,
|
||||
const vtr::Point<size_t>& coord) const;
|
||||
/** @brief Check if a programmable block (with a coordinate) exists in a tile
|
||||
/** @brief Check if a programmable block (with a coordinate) exists in a tile. Note that the coord can be either the one in device grid or the one of gsb which the programmable block belongs to
|
||||
*/
|
||||
bool pb_in_tile(const FabricTileId& tile_id,
|
||||
const DeviceRRGSB& device_rr_gsb,
|
||||
const vtr::Point<size_t>& coord) const;
|
||||
const vtr::Point<size_t>& coord,
|
||||
const bool& use_gsb_coord = false) const;
|
||||
/** @brief Check if a switch block (with a coordinate) exists in a tile */
|
||||
bool sb_in_tile(const FabricTileId& tile_id,
|
||||
const vtr::Point<size_t>& coord) const;
|
||||
|
@ -71,7 +71,8 @@ class FabricTile {
|
|||
bool set_tile_coordinate(const FabricTileId& tile_id,
|
||||
const vtr::Point<size_t>& coord);
|
||||
void add_pb_coordinate(const FabricTileId& tile_id,
|
||||
const vtr::Point<size_t>& coord);
|
||||
const vtr::Point<size_t>& coord,
|
||||
const vtr::Point<size_t>& gsb_coord);
|
||||
void add_cb_coordinate(const FabricTileId& tile_id, const t_rr_type& cb_type,
|
||||
const vtr::Point<size_t>& coord);
|
||||
void add_sb_coordinate(const FabricTileId& tile_id,
|
||||
|
@ -105,8 +106,11 @@ class FabricTile {
|
|||
private: /* Internal Data */
|
||||
vtr::vector<FabricTileId, FabricTileId> ids_;
|
||||
vtr::vector<FabricTileId, vtr::Point<size_t>> coords_;
|
||||
/* Coordinates w.r.t. RRGSB */
|
||||
/* Coordinates w.r.t. RRGSB
|
||||
* Note that we keep two coordinates for the programmable block: regular one (in device grid) and the one in gsb. This is to ease the lookup/search for coordinates through both device grid and gsb. Client functions need one of the them depending on the scenario. In future, once we refactor the RRGSB organization (to follow bottom-left corner style). This limitation can be resolved.
|
||||
*/
|
||||
vtr::vector<FabricTileId, std::vector<vtr::Point<size_t>>> pb_coords_;
|
||||
vtr::vector<FabricTileId, std::vector<vtr::Point<size_t>>> pb_gsb_coords_;
|
||||
vtr::vector<FabricTileId, std::vector<vtr::Point<size_t>>> cbx_coords_;
|
||||
vtr::vector<FabricTileId, std::vector<vtr::Point<size_t>>> cby_coords_;
|
||||
vtr::vector<FabricTileId, std::vector<vtr::Point<size_t>>> sb_coords_;
|
||||
|
|
|
@ -78,7 +78,7 @@ static int build_fabric_tile_style_top_left(FabricTile& fabric_tile,
|
|||
|
||||
/* Add components: pb, cbx, cby, and sb if exists */
|
||||
if (!skip_add_pb) {
|
||||
fabric_tile.add_pb_coordinate(curr_tile_id, curr_gsb_coord);
|
||||
fabric_tile.add_pb_coordinate(curr_tile_id, curr_tile_coord, curr_gsb_coord);
|
||||
}
|
||||
/* The gsb coordinate is different than the grid coordinate when the
|
||||
* top-left style is considered
|
||||
|
|
|
@ -167,11 +167,11 @@ static int build_tile_module_port_and_nets_between_sb_and_pb(
|
|||
module_manager.module_port(sink_sb_module, sink_sb_port_id);
|
||||
|
||||
/* Check if the grid is inside the tile, if not, create ports */
|
||||
if (fabric_tile.pb_in_tile(fabric_tile_id, device_rr_gsb, grid_coordinate)) {
|
||||
if (fabric_tile.pb_in_tile(fabric_tile_id, grid_coordinate)) {
|
||||
VTR_LOGV(verbose, "Build intra-tile nets between switch block '%s' and programmable block '%s[%lu][%lu]'\n", sink_sb_module_name.c_str(), src_grid_module_name.c_str(), grid_coordinate.x(), grid_coordinate.y());
|
||||
if (!frame_view) {
|
||||
size_t src_grid_instance =
|
||||
pb_instances[fabric_tile.find_pb_index_in_tile(fabric_tile_id, device_rr_gsb,
|
||||
pb_instances[fabric_tile.find_pb_index_in_tile(fabric_tile_id,
|
||||
grid_coordinate)];
|
||||
|
||||
/* Source and sink port should match in size */
|
||||
|
@ -385,10 +385,10 @@ static int build_tile_module_port_and_nets_between_cb_and_pb(
|
|||
module_manager.module_port(sink_grid_module, sink_grid_port_id);
|
||||
|
||||
/* Check if the grid is inside the tile, if not, create ports */
|
||||
if (fabric_tile.pb_in_tile(fabric_tile_id, device_rr_gsb, grid_coordinate)) {
|
||||
if (fabric_tile.pb_in_tile(fabric_tile_id, grid_coordinate)) {
|
||||
if (!frame_view) {
|
||||
size_t sink_grid_instance =
|
||||
pb_instances[fabric_tile.find_pb_index_in_tile(fabric_tile_id, device_rr_gsb,
|
||||
pb_instances[fabric_tile.find_pb_index_in_tile(fabric_tile_id,
|
||||
grid_coordinate)];
|
||||
|
||||
/* Source and sink port should match in size */
|
||||
|
@ -1000,10 +1000,8 @@ static int build_tile_module(
|
|||
/* Add instance of programmable block */
|
||||
std::vector<size_t>
|
||||
pb_instances; /* Keep tracking the instance id of each pb */
|
||||
for (vtr::Point<size_t> grid_gsb_coord :
|
||||
for (vtr::Point<size_t> grid_coord :
|
||||
fabric_tile.pb_coordinates(fabric_tile_id)) {
|
||||
const RRGSB& grid_rr_gsb = device_rr_gsb.get_gsb(grid_gsb_coord);
|
||||
vtr::Point<size_t> grid_coord = grid_rr_gsb.get_grid_coordinate();
|
||||
t_physical_tile_type_ptr phy_tile =
|
||||
grids.get_physical_type(grid_coord.x(), grid_coord.y());
|
||||
VTR_LOGV(verbose, "Try to find pb at [%lu][%lu]\n", grid_coord.x(), grid_coord.y());
|
||||
|
|
Loading…
Reference in New Issue