Skip to content

[AP][PartialLegalizer] Added Bi-Partitioning Spreader #2917

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

Merged
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
27 changes: 27 additions & 0 deletions doc/src/vpr/command_line_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,16 @@ Analytical Placement is generally split into three stages:

Analytical Placement is experimental and under active development.

.. option:: --ap_global_placer {quadratic-bipartitioning-lookahead | quadratic-flowbased-lookahead}

Controls which Global Placer to use in the AP Flow.

* ``quadratic-bipartitioning-lookahead`` Use a Global Placer which uses a quadratic solver and a bi-partitioning lookahead legalizer. Anchor points are used to spread the solved solution to the legalized solution.

* ``quadratic-flowbased-lookahead`` Use a Global Placer which uses a quadratic solver and a multi-commodity-flow-based lookahead legalizer. Anchor points are used to spread the solved solution to the legalized solution.

**Default:** ``quadratic-bipartitioning-lookahead``

.. option:: --ap_full_legalizer {naive | appack}

Controls which Full Legalizer to use in the AP Flow.
Expand All @@ -1208,6 +1218,23 @@ Analytical Placement is generally split into three stages:

**Default:** ``annealer``

.. option:: --ap_verbosity <int>

Controls the verbosity of the AP flow output.
Larger values produce more detailed output, which may be useful for
debugging the algorithms in the AP flow.

* ``1 <= verbosity < 10`` Print standard, stage-level messages. This will
print messages at the GP, FL, or DP level.

* ``10 <= verbosity < 20`` Print more detailed messages of what is happening
within stages. For example, show high-level information on the legalization
iterations within the Global Placer.

* ``20 <= verbosity`` Print very detailed messages on intra-stage algorithms.

**Default:** ``1``


.. _router_options:

Expand Down
3 changes: 3 additions & 0 deletions libs/libvtrutil/src/vtr_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ class Rect {
///@brief Returns true if other is contained within the rectangle (including all edges)
bool contains(const Rect<T>& other) const;

///@brief Returns true if other strictly overlaps this rectangle (two rectangles that only share an edge do not overlap)
bool strictly_overlaps(const Rect<T>& other) const;

/**
* @brief Checks whether the rectangle is empty
*
Expand Down
6 changes: 6 additions & 0 deletions libs/libvtrutil/src/vtr_geometry.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ bool Rect<T>::contains(const Rect<T>& other) const {
&& other.ymin() >= ymin() && other.ymax() <= ymax();
}

template<class T>
bool Rect<T>::strictly_overlaps(const Rect<T>& other) const {
return xmin() < other.xmax() && xmax() > other.xmin()
&& ymax() > other.ymin() && ymin() < other.ymax();
}

template<class T>
bool Rect<T>::empty() const {
return xmax() <= xmin() || ymax() <= ymin();
Expand Down
16 changes: 11 additions & 5 deletions vpr/src/analytical_place/analytical_placement_flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ static void convert_flat_to_partial_placement(const FlatPlacementInfo& flat_plac
* @brief If a flat placement is provided, skips the Global Placer and
* converts it to a partial placement. Otherwise, runs the Global Placer.
*/
static PartialPlacement run_global_placer(const AtomNetlist& atom_nlist, const APNetlist& ap_netlist, const Prepacker& prepacker, const DeviceContext& device_ctx) {
static PartialPlacement run_global_placer(const t_ap_opts& ap_opts,
const AtomNetlist& atom_nlist,
const APNetlist& ap_netlist,
const Prepacker& prepacker,
const DeviceContext& device_ctx) {
if (g_vpr_ctx.atom().flat_placement_info().valid) {
VTR_LOG("Flat Placement is provided in the AP flow, skipping the Global Placement.\n");
PartialPlacement p_placement(ap_netlist);
Expand All @@ -125,13 +129,14 @@ static PartialPlacement run_global_placer(const AtomNetlist& atom_nlist, const A
return p_placement;
} else {
// Run the Global Placer
std::unique_ptr<GlobalPlacer> global_placer = make_global_placer(e_global_placer::SimPL,
std::unique_ptr<GlobalPlacer> global_placer = make_global_placer(ap_opts.global_placer_type,
ap_netlist,
prepacker,
atom_nlist,
device_ctx.grid,
device_ctx.logical_block_types,
device_ctx.physical_tile_types);
device_ctx.physical_tile_types,
ap_opts.log_verbosity);
return global_placer->place();
}
}
Expand All @@ -156,7 +161,9 @@ void run_analytical_placement_flow(t_vpr_setup& vpr_setup) {
print_ap_netlist_stats(ap_netlist);

// Run the Global Placer.
PartialPlacement p_placement = run_global_placer(atom_nlist,
const t_ap_opts& ap_opts = vpr_setup.APOpts;
PartialPlacement p_placement = run_global_placer(ap_opts,
atom_nlist,
ap_netlist,
prepacker,
device_ctx);
Expand All @@ -171,7 +178,6 @@ void run_analytical_placement_flow(t_vpr_setup& vpr_setup) {
device_ctx.grid.get_num_layers()));

// Run the Full Legalizer.
const t_ap_opts& ap_opts = vpr_setup.APOpts;
std::unique_ptr<FullLegalizer> full_legalizer = make_full_legalizer(ap_opts.full_legalizer_type,
ap_netlist,
atom_nlist,
Expand Down
12 changes: 12 additions & 0 deletions vpr/src/analytical_place/ap_flow_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@

#pragma once

/**
* @brief The type of a Global Placer.
*
* The Analytical Placement flow may implement different Global Placers. This
* enum can select between these different Global Placers.
*/
enum class e_ap_global_placer {
// Global placers based on the the SimPL paper.
SimPL_BiParitioning, ///< Global Placer based on the SimPL technique to Global Placement. Uses a quadratic solver and a bi-partitioning Partial Legalizer.
SimPL_FlowBased ///< Global Placer based on the SimPL technique to Global Placement. Uses a quadratic solver and a multi-commodity-flow-baed Partial Legalizer.
};

/**
* @brief The type of a Full Legalizer.
*
Expand Down
36 changes: 26 additions & 10 deletions vpr/src/analytical_place/global_placer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <memory>
#include <vector>
#include "analytical_solver.h"
#include "ap_flow_enums.h"
#include "ap_netlist.h"
#include "atom_netlist.h"
#include "device_grid.h"
Expand All @@ -22,36 +23,50 @@
#include "vtr_log.h"
#include "vtr_time.h"

std::unique_ptr<GlobalPlacer> make_global_placer(e_global_placer placer_type,
std::unique_ptr<GlobalPlacer> make_global_placer(e_ap_global_placer placer_type,
const APNetlist& ap_netlist,
const Prepacker& prepacker,
const AtomNetlist& atom_netlist,
const DeviceGrid& device_grid,
const std::vector<t_logical_block_type>& logical_block_types,
const std::vector<t_physical_tile_type>& physical_tile_types) {
const std::vector<t_physical_tile_type>& physical_tile_types,
int log_verbosity) {
// Based on the placer type passed in, build the global placer.
switch (placer_type) {
case e_global_placer::SimPL:
return std::make_unique<SimPLGlobalPlacer>(ap_netlist,
case e_ap_global_placer::SimPL_BiParitioning:
return std::make_unique<SimPLGlobalPlacer>(e_partial_legalizer::BI_PARTITIONING,
ap_netlist,
prepacker,
atom_netlist,
device_grid,
logical_block_types,
physical_tile_types);
physical_tile_types,
log_verbosity);
case e_ap_global_placer::SimPL_FlowBased:
return std::make_unique<SimPLGlobalPlacer>(e_partial_legalizer::FLOW_BASED,
ap_netlist,
prepacker,
atom_netlist,
device_grid,
logical_block_types,
physical_tile_types,
log_verbosity);
default:
VPR_FATAL_ERROR(VPR_ERROR_AP,
"Unrecognized global placer type");

}
}

SimPLGlobalPlacer::SimPLGlobalPlacer(const APNetlist& ap_netlist,
SimPLGlobalPlacer::SimPLGlobalPlacer(e_partial_legalizer partial_legalizer_type,
const APNetlist& ap_netlist,
const Prepacker& prepacker,
const AtomNetlist& atom_netlist,
const DeviceGrid& device_grid,
const std::vector<t_logical_block_type>& logical_block_types,
const std::vector<t_physical_tile_type>& physical_tile_types)
: GlobalPlacer(ap_netlist) {
const std::vector<t_physical_tile_type>& physical_tile_types,
int log_verbosity)
: GlobalPlacer(ap_netlist, log_verbosity) {
// This can be a long method. Good to time this to see how long it takes to
// construct the global placer.
vtr::ScopedStartFinishTimer global_placer_building_timer("Constructing Global Placer");
Expand All @@ -67,9 +82,10 @@ SimPLGlobalPlacer::SimPLGlobalPlacer(const APNetlist& ap_netlist,
physical_tile_types,
log_verbosity_);
// Build the partial legalizer
partial_legalizer_ = make_partial_legalizer(e_partial_legalizer::FLOW_BASED,
partial_legalizer_ = make_partial_legalizer(partial_legalizer_type,
ap_netlist_,
density_manager_);
density_manager_,
log_verbosity_);
}

/**
Expand Down
22 changes: 10 additions & 12 deletions vpr/src/analytical_place/global_placer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#pragma once

#include <memory>
#include "ap_flow_enums.h"
#include "flat_placement_density_manager.h"
#include "partial_legalizer.h"

// Forward declarations
class APNetlist;
Expand All @@ -24,13 +26,6 @@ class PartialLegalizer;
class Prepacker;
struct PartialPlacement;

/**
* @brief Enumeration of all of the global placers currently implemented in VPR.
*/
enum class e_global_placer {
SimPL // Global placer based on the SimPL paper.
};

/**
* @brief The Global Placer base class
*
Expand All @@ -52,7 +47,7 @@ class GlobalPlacer {
* @param log_verbosity The verbosity of log messages in the Global
* Placer.
*/
GlobalPlacer(const APNetlist& ap_netlist, int log_verbosity = 1)
GlobalPlacer(const APNetlist& ap_netlist, int log_verbosity)
: ap_netlist_(ap_netlist),
log_verbosity_(log_verbosity) {}

Expand All @@ -78,13 +73,14 @@ class GlobalPlacer {
/**
* @brief A factory method which creates a Global Placer of the given type.
*/
std::unique_ptr<GlobalPlacer> make_global_placer(e_global_placer placer_type,
std::unique_ptr<GlobalPlacer> make_global_placer(e_ap_global_placer placer_type,
const APNetlist& ap_netlist,
const Prepacker& prepacker,
const AtomNetlist& atom_netlist,
const DeviceGrid& device_grid,
const std::vector<t_logical_block_type>& logical_block_types,
const std::vector<t_physical_tile_type>& physical_tile_types);
const std::vector<t_physical_tile_type>& physical_tile_types,
int log_verbosity);

/**
* @brief A Global Placer based on the SimPL work for analytical ASIC placement.
Expand Down Expand Up @@ -140,12 +136,14 @@ class SimPLGlobalPlacer : public GlobalPlacer {
*
* Constructs the solver and partial legalizer.
*/
SimPLGlobalPlacer(const APNetlist& ap_netlist,
SimPLGlobalPlacer(e_partial_legalizer partial_legalizer_type,
const APNetlist& ap_netlist,
const Prepacker& prepacker,
const AtomNetlist& atom_netlist,
const DeviceGrid& device_grid,
const std::vector<t_logical_block_type>& logical_block_types,
const std::vector<t_physical_tile_type>& physical_tile_types);
const std::vector<t_physical_tile_type>& physical_tile_types,
int log_verbosity);

/**
* @brief Run a SimPL-like global placement algorithm
Expand Down
Loading