Skip to content

Commit cd87540

Browse files
[AP] Created The APNetlist Class
Created an APNetlist class which contains the static information about the AP problem. This includes information on the connectivity of the atoms (molecules) and the fixed block locations.
1 parent d89d1d4 commit cd87540

16 files changed

+1367
-701
lines changed

vpr/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ include(CheckCXXSymbolExists)
5858

5959
#Collect the source files
6060
# FIXME: We really need to imrove this CMake file...
61+
# - Just use src/*/*/*.cpp -VB
6162
file(GLOB_RECURSE EXEC_SOURCES src/main.cpp)
6263
file(GLOB_RECURSE LIB_SOURCES src/*/*.cpp src/place/analytical_placement/*.cpp)
6364
file(GLOB_RECURSE LIB_HEADERS src/*/*.h src/place/analytical_placement/*.h)

vpr/src/place/analytical_placement/AnalyticalSolver.cpp

Lines changed: 239 additions & 152 deletions
Large diffs are not rendered by default.

vpr/src/place/analytical_placement/AnalyticalSolver.h

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,49 @@
22
#pragma once
33

44
#include <memory>
5-
#include <vector>
6-
#include "PartialPlacement.h"
75
#include "Eigen/Sparse"
6+
#include "ap_netlist_fwd.h"
7+
#include "vtr_strong_id.h"
8+
#include "vtr_vector.h"
9+
10+
class PartialPlacement;
11+
class APNetlist;
812

913
enum class e_analytical_solver {
1014
QP_HYBRID,
1115
B2B
1216
};
1317

18+
// A new strong ID for the AP rows.
19+
// This gives a linearized ID for each of the moveable blocks from 0 to the
20+
// number of moveable blocks.
21+
struct ap_row_id_tag {};
22+
typedef vtr::StrongId<ap_row_id_tag, size_t> APRowId;
23+
1424
// TODO: How should the hint be handled?
1525
// Perhaps the PartialPlacement could be used as a hint. Could have a flag
1626
// within detailing if the placement has been populated.
1727
class AnalyticalSolver {
1828
public:
1929
virtual ~AnalyticalSolver() {}
30+
AnalyticalSolver(const APNetlist &inetlist);
2031
virtual void solve(unsigned iteration, PartialPlacement &p_placement) = 0;
32+
33+
protected:
34+
const APNetlist& netlist;
35+
size_t num_moveable_blocks = 0;
36+
vtr::vector<APBlockId, APRowId> blk_id_to_row_id;
37+
vtr::vector<APRowId, APBlockId> row_id_to_blk_id;
2138
};
2239

23-
std::unique_ptr<AnalyticalSolver> make_analytical_solver(e_analytical_solver solver_type);
40+
std::unique_ptr<AnalyticalSolver> make_analytical_solver(e_analytical_solver solver_type, const APNetlist &netlist);
2441

2542
// TODO: There is no difference between the hybrid, clique, and star since the
2643
// the threshold acts as a mixing factor. 0 = star, inf = clique
2744
class QPHybridSolver : public AnalyticalSolver {
28-
// To implement the global placement step of HeAP or SimPL efficeintly, we will
29-
// need to store the matrices for the system of equations in the class.
30-
// TODO: Store a standard VTR matrix and pass that into Eigen using Map
45+
using AnalyticalSolver::AnalyticalSolver;
46+
47+
static constexpr size_t star_num_pins_threshold = 3;
3148
public:
3249
void solve(unsigned iteration, PartialPlacement &p_placement) final;
3350
// Constructor fills the following with no legalization
@@ -37,6 +54,7 @@ class QPHybridSolver : public AnalyticalSolver {
3754
};
3855

3956
class B2BSolver : public AnalyticalSolver {
57+
using AnalyticalSolver::AnalyticalSolver;
4058
public:
4159
void solve(unsigned iteration, PartialPlacement &p_placement) final;
4260
void b2b_solve_loop(unsigned iteration, PartialPlacement &p_placement);
@@ -45,10 +63,9 @@ class B2BSolver : public AnalyticalSolver {
4563
void initialize_placement_least_dense(PartialPlacement &p_placement);
4664
void populate_matrix(PartialPlacement &p_placement);
4765
void populate_matrix_anchor(PartialPlacement& p_placement, unsigned iteration);
48-
std::pair<size_t, size_t> boundNode(const std::vector<size_t> &node_id, const std::vector<double> &node_loc);
4966

50-
static inline const double epsilon = 1e-6;
51-
static inline const unsigned inner_iterations = 30;
67+
static constexpr double epsilon = 1e-6;
68+
static constexpr unsigned inner_iterations = 30;
5269

5370
// These are stored because there might be potential oppurtunities of reuse.
5471
// Also, it could be more efficient to allocate heap once and reusing it instead
@@ -59,8 +76,9 @@ class B2BSolver : public AnalyticalSolver {
5976
Eigen::VectorXd b_y;
6077
// They are being stored because legalizer will modified the placement passed in. While building the b2b model with anchors,
6178
// both the previously solved and legalized placement are needed, so we store them as a member.
62-
std::vector<double> node_loc_x_solved;
63-
std::vector<double> node_loc_y_solved;
64-
std::vector<double> node_loc_x_legalized;
65-
std::vector<double> node_loc_y_legalized;
79+
vtr::vector<APBlockId, double> block_x_locs_solved;
80+
vtr::vector<APBlockId, double> block_y_locs_solved;
81+
vtr::vector<APBlockId, double> block_x_locs_legalized;
82+
vtr::vector<APBlockId, double> block_y_locs_legalized;
6683
};
84+

0 commit comments

Comments
 (0)