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
913enum 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.
1727class AnalyticalSolver {
1828public:
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
2744class 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 ;
3148public:
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
3956class 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