Skip to content

Commit c14996f

Browse files
[AP][HotFix] Fixed Bug With Solver Putting Blocks Off-Device
After moving fixed blocks to the center of tiles, there is a very small chance that blocks go off the device due to rounding. This is such a small effect that it does not show up locally on my machine, but it shows up on CI. Clamping the positions of blocks after solving to be just within the device region.
1 parent 80604ef commit c14996f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

vpr/src/analytical_place/analytical_solver.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -819,13 +819,22 @@ void B2BSolver::store_solution_into_placement(Eigen::VectorXd& x_soln,
819819
for (size_t row_id_idx = 0; row_id_idx < num_moveable_blocks_; row_id_idx++) {
820820
// Since we are capping the number of iterations, the solver may not
821821
// have enough time to converge on a solution that is on the device.
822-
// We just clamp the solution to zero for now.
822+
// Set the solution to be within the device grid. To prevent round-off
823+
// errors causing the position to move outside of the device, we add a
824+
// small buffer (epsilon) to the position.
825+
// TODO: Create a helper method to clamp a position to just within the
826+
// device grid.
823827
// TODO: Should handle this better. If the solution is very negative
824828
// it may indicate a bug.
825-
if (x_soln[row_id_idx] < 0.0)
826-
x_soln[row_id_idx] = 0.0;
827-
if (y_soln[row_id_idx] < 0.0)
828-
y_soln[row_id_idx] = 0.0;
829+
double epsilon = 0.0001;
830+
if (x_soln[row_id_idx] < epsilon)
831+
x_soln[row_id_idx] = epsilon;
832+
if (x_soln[row_id_idx] >= device_grid_width_)
833+
x_soln[row_id_idx] = device_grid_width_ - epsilon;
834+
if (y_soln[row_id_idx] < epsilon)
835+
y_soln[row_id_idx] = epsilon;
836+
if (y_soln[row_id_idx] >= device_grid_height_)
837+
y_soln[row_id_idx] = device_grid_height_ - epsilon;
829838

830839
APRowId row_id = APRowId(row_id_idx);
831840
APBlockId blk_id = row_id_to_blk_id_[row_id];

0 commit comments

Comments
 (0)