From ae6644aabdec7832db98df81e39e8014f2e498e4 Mon Sep 17 00:00:00 2001 From: liulixinkerry Date: Tue, 23 Apr 2024 12:16:11 +0800 Subject: [PATCH] add bin heuristic and handle nan --- src/core/route_force.py | 2 +- src/database.py | 11 +++++++++++ src/param_scheduler.py | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/core/route_force.py b/src/core/route_force.py index 0cf0791..2b13028 100644 --- a/src/core/route_force.py +++ b/src/core/route_force.py @@ -259,7 +259,7 @@ def run_gr_and_fft_main( def run_gr_and_fft(args, logger, data, rawdb, gpdb, ps, grdb=None, skip_m1_route=True, run_fft=False, visualize=False, report_gr_metrics_only=False, given_gr_params={}): - route_size = 512 + route_size = min(512, args.num_bin_y) iteration = ps.iter - 1 # ps.iter is increased before running GR optimization die_ratio = (data.__ori_die_hx__ - data.__ori_die_lx__) / (data.__ori_die_hy__ - data.__ori_die_ly__) route_xSize = route_size if die_ratio <= 1 else round(route_size / die_ratio) diff --git a/src/database.py b/src/database.py index a5b430e..52faa10 100644 --- a/src/database.py +++ b/src/database.py @@ -166,6 +166,17 @@ class PlaceData(object): self.__num_pins__ = pin_id2node_id.shape[0] self.__num_nets__ = hyperedge_list_end.shape[0] + if self.__ori_die_hy__ / self.__row_height__ < args.num_bin_y: + num_rows = math.floor(self.__ori_die_hy__ / self.__row_height__) + new_num_bin_y = int(2 ** math.floor(math.log2(num_rows))) + new_num_bin_x = int(round(args.num_bin_x / args.num_bin_y * new_num_bin_y)) + logger.warning( + "Given num_bin_y %d is larger than num_rows %d." + "Use (num_bin_x=%d, num_bin_y=%d) instead" % + (args.num_bin_y, num_rows, new_num_bin_x, new_num_bin_y) + ) + args.num_bin_x = new_num_bin_x + args.num_bin_y = new_num_bin_y self.__num_bin_x__ = args.num_bin_x self.__num_bin_y__ = args.num_bin_y diff --git a/src/param_scheduler.py b/src/param_scheduler.py index aac3c08..79f49bc 100644 --- a/src/param_scheduler.py +++ b/src/param_scheduler.py @@ -403,6 +403,14 @@ class ParamScheduler: and self.recorder.hpwl[ptr] > self.best_metric["hpwl"] * 2 ): return True + if ( + math.isnan(self.recorder.overflow[ptr]) or + math.isnan(self.recorder.hpwl[ptr]) + ): + self.__logger__.warning( + "Detect NAN value in Iteration %d. Kill the optimization process." % ptr + ) + return True return False def check_plateau(self, x, window=10, threshold=0.001):