From 6e0311efcaea8020d3e137e2708ec188eef8a74c Mon Sep 17 00:00:00 2001 From: Arjen Roodselaar Date: Sat, 17 Dec 2022 15:50:14 -0800 Subject: Timeout when legal placement can't be found for cell --- common/place/placer_heap.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/place/placer_heap.cc b/common/place/placer_heap.cc index 0dfc29e6..22b97a6c 100644 --- a/common/place/placer_heap.cc +++ b/common/place/placer_heap.cc @@ -862,6 +862,7 @@ class HeAPPlacer int radius = 0; int iter = 0; int iter_at_radius = 0; + int total_iters_for_cell = 0; bool placed = false; BelId bestBel; int best_inp_len = std::numeric_limits::max(); @@ -880,9 +881,9 @@ class HeAPPlacer while (!placed) { // Set a conservative timeout - if (iter > std::max(10000, 3 * int(ctx->cells.size()))) - log_error("Unable to find legal placement for cell '%s', check constraints and utilisation.\n", - ctx->nameOf(ci)); + if (total_iters_for_cell > std::max(10000, 3 * int(ctx->cells.size()))) + log_error("Unable to find legal placement for cell '%s' after %d attempts, check constraints and utilisation.\n", + ctx->nameOf(ci), total_iters_for_cell); // Determine a search radius around the solver location (which increases over time) that is clamped to // the region constraint for the cell (if applicable) @@ -1084,6 +1085,8 @@ class HeAPPlacer break; } } + + total_iters_for_cell++; } } auto endt = std::chrono::high_resolution_clock::now(); -- cgit v1.2.3 From 2712cbf6e4289eb9c1830e367d68072e3d1f7564 Mon Sep 17 00:00:00 2001 From: Arjen Roodselaar Date: Mon, 19 Dec 2022 14:00:19 -0800 Subject: Increase timeout --- common/place/placer_heap.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/place/placer_heap.cc b/common/place/placer_heap.cc index 22b97a6c..4ee9b909 100644 --- a/common/place/placer_heap.cc +++ b/common/place/placer_heap.cc @@ -879,9 +879,11 @@ class HeAPPlacer } while (!placed) { + // Set a conservative timeout. This is a rather large number and could probably be + // shaved down, but for now it will keep the process from running indefinite. + int timeout_limit = (int(ctx->cells.size()) * int(ctx->cells.size()) / 8) + 1; - // Set a conservative timeout - if (total_iters_for_cell > std::max(10000, 3 * int(ctx->cells.size()))) + if (total_iters_for_cell > std::max(10000, timeout_limit)) log_error("Unable to find legal placement for cell '%s' after %d attempts, check constraints and utilisation.\n", ctx->nameOf(ci), total_iters_for_cell); -- cgit v1.2.3 From d5299f144f0dc8cdcca9195d8ffbbd5a77cff77e Mon Sep 17 00:00:00 2001 From: Arjen Roodselaar Date: Mon, 19 Dec 2022 22:58:52 -0800 Subject: Add --no-placer-timeout flag to override timeout during refinement --- common/kernel/command.cc | 4 ++++ common/place/placer_heap.cc | 12 +++++++----- common/place/placer_heap.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/common/kernel/command.cc b/common/kernel/command.cc index c548509f..22000299 100644 --- a/common/kernel/command.cc +++ b/common/kernel/command.cc @@ -189,6 +189,7 @@ po::options_description CommandHandler::getGeneralOptions() general.add_options()("placer-heap-critexp", po::value(), "placer heap criticality exponent (int, default: 2)"); general.add_options()("placer-heap-timingweight", po::value(), "placer heap timing weight (int, default: 10)"); + general.add_options()("no-placer-timeout", "allow the placer to attempt placement without timeout"); #if !defined(__wasm) general.add_options()("parallel-refine", "use new experimental parallelised engine for placement refinement"); @@ -328,6 +329,9 @@ void CommandHandler::setupContext(Context *ctx) if (vm.count("placer-heap-timingweight")) ctx->settings[ctx->id("placerHeap/timingWeight")] = std::to_string(vm["placer-heap-timingweight"].as()); + if (vm.count("no-placer-timeout")) + ctx->settings[ctx->id("placerHeap/noTimeout")] = true; + if (vm.count("parallel-refine")) ctx->settings[ctx->id("placerHeap/parallelRefine")] = true; diff --git a/common/place/placer_heap.cc b/common/place/placer_heap.cc index 4ee9b909..69edd325 100644 --- a/common/place/placer_heap.cc +++ b/common/place/placer_heap.cc @@ -828,6 +828,11 @@ class HeAPPlacer // Strict placement legalisation, performed after the initial HeAP spreading void legalise_placement_strict(bool require_validity = false) { + int placement_timeout = cfg.no_placement_timeout ? 0 : + // Set a conservative timeout. This is a rather large number and could probably be + // shaved down, but for now it will keep the process from running indefinite. + std::max(10000, (int(ctx->cells.size()) * int(ctx->cells.size()) / 8) + 1); + auto startt = std::chrono::high_resolution_clock::now(); // Unbind all cells placed in this solution @@ -879,11 +884,7 @@ class HeAPPlacer } while (!placed) { - // Set a conservative timeout. This is a rather large number and could probably be - // shaved down, but for now it will keep the process from running indefinite. - int timeout_limit = (int(ctx->cells.size()) * int(ctx->cells.size()) / 8) + 1; - - if (total_iters_for_cell > std::max(10000, timeout_limit)) + if (placement_timeout > 0 && total_iters_for_cell > placement_timeout) log_error("Unable to find legal placement for cell '%s' after %d attempts, check constraints and utilisation.\n", ctx->nameOf(ci), total_iters_for_cell); @@ -1818,6 +1819,7 @@ PlacerHeapCfg::PlacerHeapCfg(Context *ctx) timing_driven = ctx->setting("timing_driven"); solverTolerance = 1e-5; placeAllAtOnce = false; + no_placement_timeout = ctx->setting("placerHeap/noTimeout", false); hpwl_scale_x = 1; hpwl_scale_y = 1; diff --git a/common/place/placer_heap.h b/common/place/placer_heap.h index 9c62869e..680e1dc7 100644 --- a/common/place/placer_heap.h +++ b/common/place/placer_heap.h @@ -42,6 +42,7 @@ struct PlacerHeapCfg float solverTolerance; bool placeAllAtOnce; bool parallelRefine; + bool no_placement_timeout; int hpwl_scale_x, hpwl_scale_y; int spread_scale_x, spread_scale_y; -- cgit v1.2.3 From 923458a2c90ee295cf6502a83ca6182d1d281f48 Mon Sep 17 00:00:00 2001 From: Arjen Roodselaar Date: Tue, 20 Dec 2022 11:15:06 -0800 Subject: Allow setting cell placement timeout --- common/kernel/command.cc | 8 +++++--- common/place/placer_heap.cc | 19 ++++++++++--------- common/place/placer_heap.h | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/common/kernel/command.cc b/common/kernel/command.cc index 22000299..6d2dc939 100644 --- a/common/kernel/command.cc +++ b/common/kernel/command.cc @@ -189,7 +189,8 @@ po::options_description CommandHandler::getGeneralOptions() general.add_options()("placer-heap-critexp", po::value(), "placer heap criticality exponent (int, default: 2)"); general.add_options()("placer-heap-timingweight", po::value(), "placer heap timing weight (int, default: 10)"); - general.add_options()("no-placer-timeout", "allow the placer to attempt placement without timeout"); + general.add_options()("placer-heap-cell-placement-timeout", po::value(), + "allow placer to attempt up to the given number of iterations to place the cell (int, default: design size^2 / 8, 0 for no timeout)"); #if !defined(__wasm) general.add_options()("parallel-refine", "use new experimental parallelised engine for placement refinement"); @@ -329,8 +330,9 @@ void CommandHandler::setupContext(Context *ctx) if (vm.count("placer-heap-timingweight")) ctx->settings[ctx->id("placerHeap/timingWeight")] = std::to_string(vm["placer-heap-timingweight"].as()); - if (vm.count("no-placer-timeout")) - ctx->settings[ctx->id("placerHeap/noTimeout")] = true; + if (vm.count("placer-heap-cell-placement-timeout")) + ctx->settings[ctx->id("placerHeap/cellPlacementTimeout")] = + std::to_string(std::max(0, vm["placer-heap-cell-placement-timeout"].as())); if (vm.count("parallel-refine")) ctx->settings[ctx->id("placerHeap/parallelRefine")] = true; diff --git a/common/place/placer_heap.cc b/common/place/placer_heap.cc index 69edd325..ae04118b 100644 --- a/common/place/placer_heap.cc +++ b/common/place/placer_heap.cc @@ -218,7 +218,10 @@ class HeAPPlacer heap_runs.push_back(all_buckets); // The main HeAP placer loop - log_info("Running main analytical placer.\n"); + if (cfg.cell_placement_timeout > 0) + log_info("Running main analytical placer, max placement attempts per cell = %d.\n", cfg.cell_placement_timeout); + else + log_info("Running main analytical placer.\n"); while (stalled < 5 && (solved_hpwl <= legal_hpwl * 0.8)) { // Alternate between particular bel types and all bels for (auto &run : heap_runs) { @@ -828,11 +831,6 @@ class HeAPPlacer // Strict placement legalisation, performed after the initial HeAP spreading void legalise_placement_strict(bool require_validity = false) { - int placement_timeout = cfg.no_placement_timeout ? 0 : - // Set a conservative timeout. This is a rather large number and could probably be - // shaved down, but for now it will keep the process from running indefinite. - std::max(10000, (int(ctx->cells.size()) * int(ctx->cells.size()) / 8) + 1); - auto startt = std::chrono::high_resolution_clock::now(); // Unbind all cells placed in this solution @@ -884,8 +882,8 @@ class HeAPPlacer } while (!placed) { - if (placement_timeout > 0 && total_iters_for_cell > placement_timeout) - log_error("Unable to find legal placement for cell '%s' after %d attempts, check constraints and utilisation.\n", + if (cfg.cell_placement_timeout > 0 && total_iters_for_cell > cfg.cell_placement_timeout) + log_error("Unable to find legal placement for cell '%s' after %d attempts, check constraints and utilisation. Use `--placer-heap-cell-placement-timeout` to change the number of attempts.\n", ctx->nameOf(ci), total_iters_for_cell); // Determine a search radius around the solver location (which increases over time) that is clamped to @@ -1819,7 +1817,10 @@ PlacerHeapCfg::PlacerHeapCfg(Context *ctx) timing_driven = ctx->setting("timing_driven"); solverTolerance = 1e-5; placeAllAtOnce = false; - no_placement_timeout = ctx->setting("placerHeap/noTimeout", false); + cell_placement_timeout = ctx->setting("placerHeap/cellPlacementTimeout", + // Set a conservative default. This is a rather large number and could probably + // be shaved down, but for now it will keep the process from running indefinite. + std::max(10000, (int(ctx->cells.size()) * int(ctx->cells.size()) / 8) + 1)); hpwl_scale_x = 1; hpwl_scale_y = 1; diff --git a/common/place/placer_heap.h b/common/place/placer_heap.h index 680e1dc7..e554a8e0 100644 --- a/common/place/placer_heap.h +++ b/common/place/placer_heap.h @@ -42,7 +42,7 @@ struct PlacerHeapCfg float solverTolerance; bool placeAllAtOnce; bool parallelRefine; - bool no_placement_timeout; + int cell_placement_timeout; int hpwl_scale_x, hpwl_scale_y; int spread_scale_x, spread_scale_y; -- cgit v1.2.3 From be1f700b0b3099dd7762bf8cbe23ecca4b77fe5b Mon Sep 17 00:00:00 2001 From: Arjen Roodselaar Date: Tue, 20 Dec 2022 13:10:37 -0800 Subject: Set divisor instead of absolute value --- common/kernel/command.cc | 2 +- common/place/placer_heap.cc | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/common/kernel/command.cc b/common/kernel/command.cc index 6d2dc939..65aa0299 100644 --- a/common/kernel/command.cc +++ b/common/kernel/command.cc @@ -190,7 +190,7 @@ po::options_description CommandHandler::getGeneralOptions() "placer heap criticality exponent (int, default: 2)"); general.add_options()("placer-heap-timingweight", po::value(), "placer heap timing weight (int, default: 10)"); general.add_options()("placer-heap-cell-placement-timeout", po::value(), - "allow placer to attempt up to the given number of iterations to place the cell (int, default: design size^2 / 8, 0 for no timeout)"); + "allow placer to attempt up to max(10000, total cells^2 / N) iterations to place a cell (int N, default: 8, 0 for no timeout)"); #if !defined(__wasm) general.add_options()("parallel-refine", "use new experimental parallelised engine for placement refinement"); diff --git a/common/place/placer_heap.cc b/common/place/placer_heap.cc index ae04118b..781a7646 100644 --- a/common/place/placer_heap.cc +++ b/common/place/placer_heap.cc @@ -1817,10 +1817,15 @@ PlacerHeapCfg::PlacerHeapCfg(Context *ctx) timing_driven = ctx->setting("timing_driven"); solverTolerance = 1e-5; placeAllAtOnce = false; - cell_placement_timeout = ctx->setting("placerHeap/cellPlacementTimeout", - // Set a conservative default. This is a rather large number and could probably - // be shaved down, but for now it will keep the process from running indefinite. - std::max(10000, (int(ctx->cells.size()) * int(ctx->cells.size()) / 8) + 1)); + + int timeout_divisor = ctx->setting("placerHeap/cellPlacementTimeout", 8); + if (timeout_divisor > 0) { + // Set a conservative default. This is a rather large number and could probably + // be shaved down, but for now it will keep the process from running indefinite. + cell_placement_timeout = std::max(10000, (int(ctx->cells.size()) * int(ctx->cells.size()) / timeout_divisor)); + } else { + cell_placement_timeout = 0; + } hpwl_scale_x = 1; hpwl_scale_y = 1; -- cgit v1.2.3