-
Notifications
You must be signed in to change notification settings - Fork 428
[AP][Solver][3D] 3D AP Solver Support #3265
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
Open
AlexandreSinger
wants to merge
2
commits into
verilog-to-routing:master
Choose a base branch
from
AlexandreSinger:feature-3d-ap-solver
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -531,6 +531,16 @@ class B2BSolver : public AnalyticalSolver { | |
/// number, the solver will focus more on timing and less on wirelength. | ||
static constexpr double timing_slope_fac_ = 0.75; | ||
|
||
/// @brief For most FPGA architectures, the cost of moving horizontally is | ||
/// equivalent to the cost moving vertically (i.e. moving in increasing | ||
/// x-dimension has the same cost as moving the same amount in the | ||
/// y-dimension). However, for 3D FPGAs, moving between layers is | ||
/// much more expensive than moving in the x or y dimension. We account | ||
/// for this by adding a cost penalty factor to the "z"-dimension. | ||
/// TODO: This cost factor was randomly selected because it felt ok. Should | ||
/// choose a better factor that is chosen empirically. | ||
static constexpr double layer_distance_cost_fac_ = 10.0; | ||
|
||
public: | ||
B2BSolver(const APNetlist& ap_netlist, | ||
const DeviceGrid& device_grid, | ||
|
@@ -699,15 +709,41 @@ class B2BSolver : public AnalyticalSolver { | |
void update_linear_system_with_anchors(unsigned iteration); | ||
|
||
/** | ||
* @brief Store the x and y solutions in Eigen's vectors into the partial | ||
* placement object. | ||
* | ||
* Note: The x_soln and y_soln may be modified if it is found that the | ||
* solution is imposible (i.e. has negative positions). | ||
* @brief Solves the linear system of equations using the connectivity | ||
* matrix (A), the constant vector (b), and a guess for the solution. | ||
*/ | ||
void store_solution_into_placement(Eigen::VectorXd& x_soln, | ||
Eigen::VectorXd& y_soln, | ||
PartialPlacement& p_placement); | ||
Eigen::VectorXd solve_linear_system(Eigen::SparseMatrix<double> &A, | ||
Eigen::VectorXd &b, | ||
Eigen::VectorXd &guess); | ||
|
||
/** | ||
* @brief Store the solutions from the linear system into the partial | ||
* placement object for the given dimension. | ||
* | ||
* Note: The dim_soln may be modified if it is found that the solution is | ||
* imposible (e.g. has negative positions). | ||
* | ||
* @param dim_soln | ||
* The solution of the linear system for a given dimension. | ||
* @param block_dim_locs | ||
* The block locations in the partial placement for the dimension. | ||
* @param dim_max_pos | ||
* The maximum position allowed for the dimension. For example, for the | ||
* x-dimension, this would be the width of the device. This is used to | ||
* ensure that the positions do not go off device. | ||
*/ | ||
void store_solution_into_placement(Eigen::VectorXd &dim_soln, | ||
vtr::vector<APBlockId, double> &block_dim_locs, | ||
double dim_max_pos); | ||
|
||
/** | ||
* @brief Does the FPGA that the AP flow is currently targeting have more | ||
* than one die. Having multiple dies would imply that the solver | ||
* needs to add another dimension to solve for. | ||
*/ | ||
inline bool is_multi_die() const { | ||
return device_grid_num_layers_ > 1; | ||
} | ||
|
||
// The following are variables used to store the system of equations to be | ||
// solved in the x and y dimensions. The equations are of the form: | ||
|
@@ -720,22 +756,28 @@ class B2BSolver : public AnalyticalSolver { | |
Eigen::SparseMatrix<double> A_sparse_x; | ||
/// @brief The coefficient / connectivity matrix for the y dimension. | ||
Eigen::SparseMatrix<double> A_sparse_y; | ||
/// @brief The coefficient / connectivity matrix for the z dimension (layer dimension). | ||
Eigen::SparseMatrix<double> A_sparse_z; | ||
/// @brief The constant vector in the x dimension. | ||
Eigen::VectorXd b_x; | ||
/// @brief The constant vector in the y dimension. | ||
Eigen::VectorXd b_y; | ||
/// @brief The constant vector in the z dimension (layer dimension). | ||
Eigen::VectorXd b_z; | ||
|
||
// The following is the solution of the previous iteration of this solver. | ||
// They are updated at the end of solve() and are used as the starting point | ||
// for the next call to solve. | ||
vtr::vector<APBlockId, double> block_x_locs_solved; | ||
vtr::vector<APBlockId, double> block_y_locs_solved; | ||
vtr::vector<APBlockId, double> block_z_locs_solved; | ||
|
||
// The following are the legalized solution coming into the analytical solver | ||
// (other than the first iteration). These are stored to be used as anchor | ||
// blocks during the solver. | ||
vtr::vector<APBlockId, double> block_x_locs_legalized; | ||
vtr::vector<APBlockId, double> block_y_locs_legalized; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably want to say that for speed, the various _z values are ignored / not updated or used if a device has only one die. |
||
vtr::vector<APBlockId, double> block_z_locs_legalized; | ||
|
||
/// @brief The total number of CG iterations that this solver has performed | ||
/// so far. This can be a useful metric for the amount of work the | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not true for S10 and 7-series (different wiring supplies). Also may not be true for timing in many architectures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to get these cost factors from some Soheil/Amin code in the annealer (they compute prefix sums of wiring supply in each dimension; should be able to ask for total wiring in x or y or z from them.