timeout for router1

This commit is contained in:
Kelvin Chung 2025-05-23 10:28:55 +01:00
parent 900249033f
commit 496df84b3b
3 changed files with 12 additions and 0 deletions

View File

@ -538,6 +538,10 @@ void CommandHandler::setupContext(Context *ctx)
if (vm.count("parallel-refine"))
ctx->settings[ctx->id("placerHeap/parallelRefine")] = true;
if (vm.count("router1-timeout")) {
ctx->settings[ctx->id("router1/timeout")] = vm["router1-timeout"].as<int>();
}
if (vm.count("router2-heatmap"))
ctx->settings[ctx->id("router2/heatmap")] = vm["router2-heatmap"].as<std::string>();
if (vm.count("tmg-ripup") || vm.count("router2-tmg-ripup"))

View File

@ -1199,6 +1199,13 @@ 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

View File

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