Skip to content

Commit

Permalink
Add new type of callback to reduce frequency of routing-driven calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Coloquinte committed Jan 31, 2024
1 parent 07d8cc6 commit 7161e00
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions pycoloquinte/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ PYBIND11_MODULE(coloquinte_pybind, m) {
.value("LowerBound", PlacementStep::LowerBound)
.value("UpperBound", PlacementStep::UpperBound)
.value("Detailed", PlacementStep::Detailed)
.value("PenaltyUpdate", PlacementStep::PenaltyUpdate)
.export_values();

py::class_<ColoquinteParameters>(m, "ColoquinteParameters")
Expand Down
15 changes: 14 additions & 1 deletion src/coloquinte.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct Rectangle {
/**
* @brief Step of the placement process, for use in callbacks
*/
enum class PlacementStep { LowerBound, UpperBound, Detailed };
enum class PlacementStep { LowerBound, UpperBound, Detailed, PenaltyUpdate };

/**
* @brief Cost model to use when doing legalization
Expand Down Expand Up @@ -435,6 +435,19 @@ struct GlobalPlacerParameters {
*/
double distanceTolerance;

/**
* @brief Distance between lower and upper bound placement at which we start
* doing rounting and timing driven placement by calling PenaltyUpdate
* callbacks
*/
double penaltyUpdateDistance;

/**
* @brief Ratio to decrease the distance between lower and upper bound placement
* before we retry calling PenaltyUpdate callbacks
*/
double penaltyUpdateBackoff;

/**
* @brief Blending between lower-bound and upper-bound placement at export
* time; 0 to use lower bound, 1 to use upper bound
Expand Down
10 changes: 10 additions & 0 deletions src/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ GlobalPlacerParameters::GlobalPlacerParameters(int effort)
nbInitialSteps = 0;
nbStepsBeforeRoughLegalization = 1;
distanceTolerance = 2.0;
penaltyUpdateDistance = 10.0;
penaltyUpdateBackoff = 2.0;
// TODO: find best parameter
exportBlending = 0.99;
noise = 1.0e-4;
Expand Down Expand Up @@ -423,6 +425,14 @@ void GlobalPlacerParameters::check() const {
throw std::runtime_error(
"Noise should be a very small non-negative number");
}
if (penaltyUpdateDistance <= 0.0f) {
throw std::runtime_error(
"Invalid penalty update distance (should be positive)");
}
if (penaltyUpdateBackoff < 1.0f) {
throw std::runtime_error(
"Invalid penalty update backoff (should be at least 1)");
}
}

void LegalizationParameters::check() const {
Expand Down
5 changes: 5 additions & 0 deletions src/place_global/place_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ void GlobalPlacer::run() {
penalty_ = params_.global.penalty.initialValue;
approximationDistance_ = initialApproximationDistance();
penaltyCutoffDistance_ = initialPenaltyCutoffDistance();
double nextPenaltyUpdateDistance = penaltyUpdateDistance();

float lb = valueLB();
float ub = std::numeric_limits<float>::infinity();
Expand All @@ -171,6 +172,10 @@ void GlobalPlacer::run() {
std::cout << std::endl;
break;
}
if (dist < nextPenaltyUpdateDistance) {
callback(PlacementStep::PenaltyUpdate, xPlacementUB_, yPlacementUB_);
nextPenaltyUpdateDistance /= params_.global.penaltyUpdateBackoff;
}
for (int i = 0; i < params_.global.nbStepsBeforeRoughLegalization; ++i) {
if (i != 0) {
std::cout << "#" << step_ << ":\t........\t........";
Expand Down
10 changes: 9 additions & 1 deletion src/place_global/place_global.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ class GlobalPlacer {
return params_.global.distanceTolerance * averageCellLength_;
}

/**
* @brief Distance between upper and lower bound at which we start routing
* and timing driven placement
*/
float penaltyUpdateDistance() const {
return params_.global.penaltyUpdateDistance * averageCellLength_;
}

/**
* @brief Compute the penalty forces for this iteration
*/
Expand Down Expand Up @@ -148,4 +156,4 @@ class GlobalPlacer {
std::optional<PlacementCallback> callback_;
};

} // namespace coloquinte
} // namespace coloquinte

0 comments on commit 7161e00

Please sign in to comment.