Skip to content

Commit

Permalink
Merge pull request #6401 from AcKoucher/mpl2-relaxation
Browse files Browse the repository at this point in the history
mpl2: apply constraint relaxation until we find a reasonable split when using PAR
  • Loading branch information
eder-matheus authored Dec 26, 2024
2 parents 96f5a5f + 0132faa commit 957f81a
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions src/mpl2/src/clusterEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,33 +1432,44 @@ void ClusteringEngine::breakLargeFlatCluster(Cluster* parent)
}

const int seed = 0;
const float balance_constraint = 1.0;
constexpr float default_balance_constraint = 1.0f;
float balance_constraint = default_balance_constraint;
const int num_parts = 2; // We use two-way partitioning here
const int num_vertices = static_cast<int>(vertex_weight.size());
std::vector<float> hyperedge_weights(hyperedges.size(), 1.0f);

debugPrint(logger_,
MPL,
"multilevel_autoclustering",
1,
"Breaking flat cluster {} with TritonPart",
parent->getName());
// Due to the discrepancy that may exist between the weight of vertices
// that represent macros/std cells, the partitioner may fail to meet the
// balance constraint. This may cause the output to be completely unbalanced
// and lead to infinite partitioning recursion. To handle that, we relax
// the constraint until we find a reasonable split.
constexpr float balance_constraint_relaxation_factor = 10.0f;
std::vector<int> solution;
do {
debugPrint(
logger_,
MPL,
"multilevel_autoclustering",
1,
"Attempting flat cluster {} partitioning with balance constraint = {}",
parent->getName(),
balance_constraint);

std::vector<int> part
= triton_part_->PartitionKWaySimpleMode(num_parts,
balance_constraint,
seed,
hyperedges,
vertex_weight,
hyperedge_weights);
if (balance_constraint >= 90) {
logger_->error(
MPL, 45, "Cannot find a balanced partitioning for the clusters.");
}

if (partitionerSolutionIsFullyUnbalanced(part, num_other_cluster_vertices)) {
logger_->error(MPL,
37,
"Couldn't break flat cluster {} with PAR. The solution is "
"fully unbalanced.",
parent->getName());
}
solution = triton_part_->PartitionKWaySimpleMode(num_parts,
balance_constraint,
seed,
hyperedges,
vertex_weight,
hyperedge_weights);

balance_constraint += balance_constraint_relaxation_factor;
} while (partitionerSolutionIsFullyUnbalanced(solution,
num_other_cluster_vertices));

parent->clearLeafStdCells();
parent->clearLeafMacros();
Expand All @@ -1470,7 +1481,7 @@ void ClusteringEngine::breakLargeFlatCluster(Cluster* parent)

for (int i = num_other_cluster_vertices; i < num_vertices; i++) {
odb::dbInst* inst = insts[i - num_other_cluster_vertices];
if (part[i] == 0) {
if (solution[i] == 0) {
parent->addLeafInst(inst);
} else {
cluster_part_1->addLeafInst(inst);
Expand Down

0 comments on commit 957f81a

Please sign in to comment.