Skip to content
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

mpl2: apply constraint relaxation until we find a reasonable split when using PAR #6401

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 30 additions & 24 deletions src/mpl2/src/clusterEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,33 +1432,39 @@ 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());

std::vector<int> part
= triton_part_->PartitionKWaySimpleMode(num_parts,
balance_constraint,
seed,
hyperedges,
vertex_weight,
hyperedge_weights);

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());
}
// 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);

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));
maliberty marked this conversation as resolved.
Show resolved Hide resolved

parent->clearLeafStdCells();
parent->clearLeafMacros();
Expand All @@ -1470,7 +1476,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
Loading