-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.py
105 lines (88 loc) · 7.04 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from utils import *
from src import run_placement_main, Flute
def get_option():
parser = argparse.ArgumentParser('Xplace')
# general setting
parser.add_argument('--dataset_root', type=str, default='data/raw', help='the parent folder of dataset')
parser.add_argument('--dataset', type=str, default='ispd2015_fix', help='dataset name')
parser.add_argument('--design_name', type=str, default='mgc_superblue12', help='design name')
parser.add_argument('--custom_path', type=str, default='', help='custom design path, set it as token1:path1,token2:path2 e.g. lef:data/test.lef,def:data/test.def,design_name:mydesign,benchmark:mybenchmark')
parser.add_argument('--custom_json', type=str, default='', help='custom json path, support multi-lefs.')
parser.add_argument('--given_solution', type=str, default='', help='Given placement solution. Will overwrite other given .pl and .def.')
parser.add_argument('--load_from_raw', type=str2bool, default=True, help='If True, parse and load from benchmark files. If False, load from pt')
parser.add_argument('--run_all', type=str2bool, default=False, help='If True, run all designs in the given dataset. If False, run the given design_name only.')
parser.add_argument('--seed', type=int, default=0, help='seed to initialize all the random modules')
parser.add_argument('--gpu', type=int, default=0, help='gpu id')
parser.add_argument('--num_threads', type=int, default=20, help='threads')
parser.add_argument('--deterministic', type=str2bool, default=True, help='use deterministic mode')
# global placement params
parser.add_argument('--global_placement', type=str2bool, default=True, help='perform gp')
parser.add_argument('--lr', type=float, default=0.01, help='learning rate')
parser.add_argument('--inner_iter', type=int, default=10000, help='#inner iters')
parser.add_argument('--wa_coeff', type=float, default=4.0, help='wa coeff')
parser.add_argument('--num_bin_x', type=int, default=512, help='#binX for density function')
parser.add_argument('--num_bin_y', type=int, default=512, help='#binY for density function')
parser.add_argument('--density_weight', type=float, default=8e-5, help='the weight of density loss')
parser.add_argument('--density_weight_coef', type=float, default=1.05, help='the ratio of density_weight')
parser.add_argument('--target_density', type=float, default=1.0, help='placement target density')
parser.add_argument('--use_filler', type=str2bool, default=True, help='placement filler')
parser.add_argument('--noise_ratio', type=float, default=0.025, help='noise ratio for initialization')
parser.add_argument('--ignore_net_degree', type=int, default=100, help='threshold of net degree to ignore in wirelength calculation')
parser.add_argument('--use_eplace_nesterov', type=str2bool, default=True, help='enable eplace nesterov optimizer')
parser.add_argument('--clamp_node', type=str2bool, default=True, help='enable eplace node clamp trick')
parser.add_argument('--use_precond', type=str2bool, default=True, help='apply precond')
parser.add_argument('--stop_overflow', type=float, default=0.07, help='stop overflow in scheduler')
parser.add_argument('--enable_skip_update', type=str2bool, default=True, help='enable skip update')
parser.add_argument('--enable_sample_force', type=str2bool, default=True, help='enable sample force')
parser.add_argument("--mixed_size", type=str2bool, default=False, help="enable mixed size placement")
# global routing params
parser.add_argument('--use_cell_inflate', type=str2bool, default=False, help='use cell inflation')
parser.add_argument('--min_area_inc', type=float, default=0.01, help='threshold of terminating inflation')
parser.add_argument('--use_route_force', type=str2bool, default=False, help='use routing force')
parser.add_argument('--route_freq', type=int, default=1000, help='routing freq')
parser.add_argument('--num_route_iter', type=int, default=400, help='number of routing iters')
parser.add_argument('--route_weight', type=float, default=0, help='the weight of route')
parser.add_argument('--congest_weight', type=float, default=0, help='the weight of congested force')
parser.add_argument('--pseudo_weight', type=float, default=0, help='the weight of pseudo net')
parser.add_argument('--visualize_cgmap', type=str2bool, default=False, help='visualize congestion map')
# detailed placement and evaluation
parser.add_argument('--legalization', type=str2bool, default=True, help='perform lg')
parser.add_argument('--detail_placement', type=str2bool, default=True, help='perform dp')
parser.add_argument('--dp_engine', type=str, default="default", help='choose dp engine')
parser.add_argument('--eval_by_external', type=str2bool, default=False, help='eval dp sol by external binary')
parser.add_argument('--eval_engine', type=str, default="ntuplace4dr", help='choose eval engine')
parser.add_argument('--final_route_eval', type=str2bool, default=False, help='eval placement solution by GR')
# logging and saver
parser.add_argument('--log_freq', type=int, default=100)
parser.add_argument('--verbose_cpp_log', type=str2bool, default=False, help='verbose cpp log for debugging')
parser.add_argument('--cpp_log_level', type=int, default=2, help='0: DEBUG, 1: VERBOSE, 2:INFO')
parser.add_argument('--result_dir', type=str, default='result', help='log/model root directory')
parser.add_argument('--exp_id', type=str, default='', help='experiment id')
parser.add_argument('--log_dir', type=str, default='log', help='log directory')
parser.add_argument('--log_name', type=str, default='test.log', help='log file name')
parser.add_argument('--eval_dir', type=str, default='eval', help='visualization directory')
# placement output
parser.add_argument('--draw_placement', type=str2bool, default=False, help='draw placement')
parser.add_argument('--write_placement', type=str2bool, default=True, help='write placement result')
parser.add_argument('--write_global_placement', type=str2bool, default=False, help='write global placement result')
parser.add_argument('--output_dir', type=str, default="output", help='output directory')
parser.add_argument('--output_prefix', type=str, default="placement", help='prefix of placement output file')
args = parser.parse_args()
args.exp_id = datetime.datetime.now().strftime('%Y-%m-%d-%H:%M:%S') + args.exp_id
if args.dataset == "ispd2015":
print("We haven't yet support fence region in ispd2015, use ispd2015_fix instead")
args.dataset = "ispd2015_fix"
if args.dataset == "ispd2019":
print("We haven't yet support fence region in ispd2019, use ispd2019_no_fence instead")
args.dataset = "ispd2019_no_fence"
if args.custom_path != "":
get_custom_design_params(args)
return args
def main():
args = get_option()
logger = setup_logger(args, sys.argv)
set_random_seed(args)
Flute.register(args.num_threads)
run_placement_main(args, logger)
if __name__ == "__main__":
main()