Change the iter count based timeout

This commit is contained in:
Kelvin Chung 2025-05-23 12:19:40 +01:00
parent 496df84b3b
commit de38bd34fb
3 changed files with 11 additions and 11 deletions

View File

@ -396,6 +396,8 @@ po::options_description CommandHandler::getGeneralOptions()
general.add_options()("parallel-refine", "use new experimental parallelised engine for placement refinement");
#endif
general.add_options()("router1-timeout", po::value<int>(), "Timeout for router1 in iteration count (default: 0, no timeout)");
general.add_options()("router2-heatmap", po::value<std::string>(),
"prefix for router2 resource congestion heatmaps");
@ -539,7 +541,7 @@ void CommandHandler::setupContext(Context *ctx)
ctx->settings[ctx->id("placerHeap/parallelRefine")] = true;
if (vm.count("router1-timeout")) {
ctx->settings[ctx->id("router1/timeout")] = vm["router1-timeout"].as<int>();
ctx->settings[ctx->id("router1/maxIterCnt")] = std::to_string(std::max(0, vm["router1-timeout"].as<int>()));
}
if (vm.count("router2-heatmap"))

View File

@ -1146,7 +1146,7 @@ NEXTPNR_NAMESPACE_BEGIN
Router1Cfg::Router1Cfg(Context *ctx)
{
maxIterCnt = ctx->setting<int>("router1/maxIterCnt", 200);
maxIterCnt = ctx->setting<int>("router1/maxIterCnt", 0);
cleanupReroute = ctx->setting<bool>("router1/cleanupReroute", true);
fullCleanupReroute = ctx->setting<bool>("router1/fullCleanupReroute", true);
useEstimate = ctx->setting<bool>("router1/useEstimate", true);
@ -1199,18 +1199,17 @@ bool router1(Context *ctx, const Router1Cfg &cfg)
last_arcs_with_ripup = router.arcs_with_ripup;
last_arcs_without_ripup = router.arcs_without_ripup;
ctx->yield();
if (cfg.timeout){
if (curr_time - rstart > std::chrono::seconds(cfg.timeout)) {
log_error("Timeout reached, stopping routing.\n");
}
}
#ifndef NDEBUG
router.check();
#endif
}
if (cfg.maxIterCnt){
if (iter_cnt > cfg.maxIterCnt) {
log_error("Max iteration count reached, stopping routing.\n");
}
}
if (ctx->debug)
log("-- %d --\n", iter_cnt);

View File

@ -36,7 +36,6 @@ struct Router1Cfg
delay_t netRipupPenalty;
delay_t reuseBonus;
delay_t estimatePrecision;
int timeout;
};
extern bool router1(Context *ctx, const Router1Cfg &cfg);