Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AP] Partial Legalizer #2765

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions vpr/src/analytical_place/analytical_placement_flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "full_legalizer.h"
#include "gen_ap_netlist_from_atoms.h"
#include "globals.h"
#include "partial_legalizer.h"
#include "partial_placement.h"
#include "prepack.h"
#include "user_place_constraints.h"
Expand Down Expand Up @@ -53,6 +54,7 @@ static void print_ap_netlist_stats(const APNetlist& netlist) {
VTR_LOG("\t\tAverage Fanout: %.2f\n", average_fanout);
VTR_LOG("\t\tHighest Fanout: %zu\n", highest_fanout);
VTR_LOG("\tPins: %zu\n", netlist.pins().size());
VTR_LOG("\n");
}

void run_analytical_placement_flow(t_vpr_setup& vpr_setup) {
Expand All @@ -77,11 +79,16 @@ void run_analytical_placement_flow(t_vpr_setup& vpr_setup) {
print_ap_netlist_stats(ap_netlist);

// Run the Global Placer
// For now, just runs the solver.
// For now, just runs the solver and partial legalizer 10 times arbitrarily.
PartialPlacement p_placement(ap_netlist);
std::unique_ptr<AnalyticalSolver> solver = make_analytical_solver(e_analytical_solver::QP_HYBRID,
ap_netlist);
solver->solve(0, p_placement);
std::unique_ptr<PartialLegalizer> legalizer = make_partial_legalizer(e_partial_legalizer::FLOW_BASED,
ap_netlist);
for (size_t i = 0; i < 10; i++) {
solver->solve(i, p_placement);
legalizer->legalize(p_placement);
}

// Verify that the partial placement is valid before running the full
// legalizer.
Expand Down
33 changes: 21 additions & 12 deletions vpr/src/analytical_place/full_legalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "vpr_error.h"
#include "vpr_types.h"
#include "vtr_assert.h"
#include "vtr_geometry.h"
#include "vtr_ndmatrix.h"
#include "vtr_strong_id.h"
#include "vtr_time.h"
Expand Down Expand Up @@ -122,9 +123,8 @@ class APClusterPlacer {
const t_physical_tile_loc& tile_loc,
int sub_tile) {
const DeviceContext& device_ctx = g_vpr_ctx.device();
// FIXME: THIS MUST TAKE INTO ACCOUNT THE CONSTRAINTS AS WELL!!!
// - Right now it is just implied.
// - Will work but is unstable.
const FloorplanningContext& floorplanning_ctx = g_vpr_ctx.floorplanning();
const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering();
const auto& block_locs = g_vpr_ctx.placement().block_locs();
auto& blk_loc_registry = g_vpr_ctx.mutable_placement().mutable_blk_loc_registry();
VTR_ASSERT(!is_block_placed(clb_blk_id, block_locs) && "Block already placed. Is this intentional?");
Expand All @@ -137,11 +137,24 @@ class APClusterPlacer {
if (device_ctx.grid.get_physical_type(tile_loc)->sub_tiles.size() == 0)
return false;
VTR_ASSERT(sub_tile >= 0 && sub_tile < device_ctx.grid.get_physical_type(tile_loc)->capacity);
// FIXME: Do this better.
// - May need to try all the sub-tiles in a location.
// - https://github.com/AlexandreSinger/vtr-verilog-to-routing/blob/feature-analytical-placer/vpr/src/place/initial_placement.cpp#L755
to_loc.sub_tile = sub_tile;
return try_place_macro(pl_macro, to_loc, blk_loc_registry);
// Check if this cluster is constrained and this location is legal.
if (is_cluster_constrained(clb_blk_id)) {
const auto& cluster_constraints = floorplanning_ctx.cluster_constraints;
if (cluster_constraints[clb_blk_id].is_loc_in_part_reg(to_loc))
return false;
}
// If the location is legal, try to exhaustively place it at this tile
// location. This should try all sub_tiles.
PartitionRegion pr;
vtr::Rect<int> rect(tile_loc.x, tile_loc.y, tile_loc.x, tile_loc.y);
pr.add_to_part_region(Region(rect, to_loc.layer));
const ClusteredNetlist& clb_nlist = cluster_ctx.clb_nlist;
t_logical_block_type_ptr block_type = clb_nlist.block_type(clb_blk_id);
enum e_pad_loc_type pad_loc_type = g_vpr_ctx.device().pad_loc_type;
// FIXME: This currently ignores the sub_tile. Was running into issues
// with trying to force clusters to specific sub_tiles.
return try_place_macro_exhaustively(pl_macro, pr, block_type,
pad_loc_type, blk_loc_registry);
}

// This is not the best way of doing things, but its the simplest. Given a
Expand Down Expand Up @@ -352,10 +365,6 @@ void FullLegalizer::place_clusters(const ClusteredNetlist& clb_nlist,
bool placed = ap_cluster_placer.place_cluster(cluster_blk_id, tile_loc, blk_sub_tile);
if (placed)
continue;
// FIXME: Should now try all sub-tiles at this tile location.
// - May need to try all the sub-tiles in a location.
// - however this may need to be done after.
// - https://github.com/AlexandreSinger/vtr-verilog-to-routing/blob/feature-analytical-placer/vpr/src/place/initial_placement.cpp#L755

// Add to list of unplaced clusters.
unplaced_clusters.push_back(cluster_blk_id);
Expand Down
Loading
Loading