aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2020-01-14 13:35:18 +0000
committerDavid Shah <dave@ds0.me>2020-02-03 11:38:31 +0000
commit7ac43e5f0039a07dd95c7377426d926e6705790a (patch)
tree55b314eb5223139eba7b7fc888d708833254636d /common
parent72367e6cfd3f36768288d6a5b03e670351ea8f8c (diff)
downloadnextpnr-7ac43e5f0039a07dd95c7377426d926e6705790a.tar.gz
nextpnr-7ac43e5f0039a07dd95c7377426d926e6705790a.tar.bz2
nextpnr-7ac43e5f0039a07dd95c7377426d926e6705790a.zip
router2: Profile nets by route time
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'common')
-rw-r--r--common/router2.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/common/router2.cc b/common/router2.cc
index 88e9746e..d190904f 100644
--- a/common/router2.cc
+++ b/common/router2.cc
@@ -39,6 +39,8 @@
NEXTPNR_NAMESPACE_BEGIN
+#define RUNTIME_PROFILE
+
namespace {
struct Router2
{
@@ -59,6 +61,7 @@ struct Router2
ArcBounds bb;
// Coordinates of the center of the net, used for the weight-to-average
int cx, cy, hpwl;
+ int total_route_us = 0;
};
struct PerWireData
@@ -627,6 +630,10 @@ struct Router2
ROUTE_LOG_DBG("Routing net '%s'...\n", ctx->nameOf(net));
+#ifdef RUNTIME_PROFILE
+ auto rstart = std::chrono::high_resolution_clock::now();
+#endif
+
// Nothing to do if net is undriven
if (net->driver.cell == nullptr)
return true;
@@ -669,6 +676,11 @@ struct Router2
}
}
}
+#ifdef RUNTIME_PROFILE
+ auto rend = std::chrono::high_resolution_clock::now();
+ nets.at(net->udata).total_route_us +=
+ (std::chrono::duration_cast<std::chrono::microseconds>(rend - rstart).count());
+#endif
return !have_failures;
}
#undef ROUTE_LOG_DBG
@@ -977,6 +989,18 @@ struct Router2
++iter;
curr_cong_weight *= 2;
} while (!failed_nets.empty());
+#ifdef RUNTIME_PROFILE
+ std::vector<std::pair<int, IdString>> nets_by_runtime;
+ for (auto &n : nets_by_udata) {
+ nets_by_runtime.emplace_back(nets.at(n->udata).total_route_us, n->name);
+ }
+ std::sort(nets_by_runtime.begin(), nets_by_runtime.end(), std::greater<std::pair<int, IdString>>());
+ log_info("1000 slowest nets by runtime:\n");
+ for (int i = 0; i < std::min(int(nets_by_runtime.size()), 1000); i++) {
+ log(" %80s %6d %.1fms\n", nets_by_runtime.at(i).second.c_str(ctx),
+ int(ctx->nets.at(nets_by_runtime.at(i).second)->users.size()), nets_by_runtime.at(i).first / 1000.0);
+ }
+#endif
}
};
} // namespace