This commit is contained in:
Andrew Zonenberg 2016-04-29 00:57:37 -07:00
commit fb87022dca
1 changed files with 30 additions and 0 deletions

View File

@ -40,6 +40,7 @@ struct QwpConfig
{
bool ltr;
bool alpha;
bool verbose;
double grid;
std::ofstream dump_file;
@ -47,6 +48,7 @@ struct QwpConfig
QwpConfig() {
ltr = false;
alpha = false;
verbose = false;
grid = 1.0 / 16;
}
};
@ -211,10 +213,16 @@ struct QwpWorker
//
// M := [AA Ay]
if (config.verbose)
log("> System size: %d^2\n", GetSize(nodes));
// Row major order
int N = GetSize(nodes), N1 = N+1;
vector<double> M(N * N1);
if (config.verbose)
log("> Edge constraints: %d\n", GetSize(edges));
// Edge constraints:
// A[i,:] := [ 0 0 .... 0 weight 0 ... 0 -weight 0 ... 0 0], y[i] := 0
//
@ -232,6 +240,9 @@ struct QwpWorker
M[idx2 + idx1*N1] += -weight * weight;
}
if (config.verbose)
log("> Node constraints: %d\n", GetSize(nodes));
// Node constraints:
// A[i,:] := [ 0 0 .... 0 weight 0 ... 0 0], y[i] := weight * pos
//
@ -263,6 +274,9 @@ struct QwpWorker
}
#endif
if (config.verbose)
log("> Solving\n");
// Solve "AA*x = Ay"
// (least squares fit for "A*x = y")
//
@ -277,6 +291,9 @@ struct QwpWorker
// gaussian elimination
for (int i = 0; i < N; i++)
{
if (config.verbose && ((i+1) % (N/15)) == 0)
log("> Solved %d%%: %d/%d\n", (100*(i+1))/N, i+1, N);
// find best row
int best_row = queue.front();
int best_row_queue_idx = 0;
@ -312,6 +329,9 @@ struct QwpWorker
}
}
if (config.verbose)
log("> Solved\n");
log_assert(queue.empty());
log_assert(GetSize(pivot_cache) == N);
@ -334,6 +354,9 @@ struct QwpWorker
}
#endif
if (config.verbose)
log("> Update nodes\n");
// update node positions
for (int i = 0; i < N; i++)
{
@ -778,6 +801,9 @@ struct QwpPass : public Pass {
log(" -dump <html_file_name>\n");
log(" Dump a protocol of the placement algorithm to the html file.\n");
log("\n");
log(" -v\n");
log(" Verbose solver output for profiling or debugging\n");
log("\n");
log("Note: This implementation of a quadratic wirelength placer uses exact\n");
log("dense matrix operations. It is only a toy-placer for small circuits.\n");
log("\n");
@ -799,6 +825,10 @@ struct QwpPass : public Pass {
config.alpha = true;
continue;
}
if (args[argidx] == "-v") {
config.verbose = true;
continue;
}
if (args[argidx] == "-grid" && argidx+1 < args.size()) {
config.grid = 1.0 / atoi(args[++argidx].c_str());
continue;