Skip to content

Commit f2b9bc2

Browse files
Merge pull request #3005 from AlexandreSinger/feature-ap-hot-fix
[AP][HotFix] Fixed Bug With Solver Putting Blocks Off-Device
2 parents 80604ef + c14996f commit f2b9bc2

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

vpr/src/analytical_place/analytical_solver.cpp

+14-5
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)