Commit aab48da7 by ZhiangWang033

update FD

parent 11297173
...@@ -26,10 +26,10 @@ from visual_placement import VisualPlacement ...@@ -26,10 +26,10 @@ from visual_placement import VisualPlacement
# #
# Check Here !!! # Check Here !!!
# #
#sys.path.append('/home/zf4_projects/DREAMPlace/sakundu/GB/CT/circuit_training') sys.path.append('/home/zf4_projects/DREAMPlace/sakundu/GB/CT/circuit_training')
#sys.path.append('/home/zf4_projects/DREAMPlace/sakundu/GB/CT/') sys.path.append('/home/zf4_projects/DREAMPlace/sakundu/GB/CT/')
sys.path.append('xxxxx/CT/circuit_training') #sys.path.append('xxxxx/CT/circuit_training')
sys.path.append('xxxxx/CT/') #sys.path.append('xxxxx/CT/')
from absl import flags from absl import flags
from circuit_training.grouping import grid_size_selection from circuit_training.grouping import grid_size_selection
...@@ -1018,7 +1018,7 @@ class PBFNetlist: ...@@ -1018,7 +1018,7 @@ class PBFNetlist:
print("cost_wirelength = ", cost_wirelength, "cost_density = ", cost_density, "cost_congestion = ", cost_congestion) print("cost_wirelength = ", cost_wirelength, "cost_density = ", cost_density, "cost_congestion = ", cost_congestion)
return self.w_wirelength * cost_wirelength + self.w_density * cost_density + self.w_congestion * cost_congestion return self.w_wirelength * cost_wirelength + self.w_density * cost_density + self.w_congestion * cost_congestion
def FDPlacer(self, io_factor, num_steps, max_move_distance, attract_factor, repel_factor, debug_mode = True): def FDPlacer(self, io_factor, num_steps, max_move_distance, attract_factor, repel_factor, use_current_loc, debug_mode = True):
# io_factor is a scalar # io_factor is a scalar
# num_steps, max_move_distance, attract_factor, repel_factor are vectors of the same size # num_steps, max_move_distance, attract_factor, repel_factor are vectors of the same size
if (debug_mode == True): if (debug_mode == True):
...@@ -1026,6 +1026,7 @@ class PBFNetlist: ...@@ -1026,6 +1026,7 @@ class PBFNetlist:
print("Start Force-directed Placement") print("Start Force-directed Placement")
print("\n") print("\n")
# initialize # initialize
if (use_current_loc == False):
self.InitSoftMacros() self.InitSoftMacros()
for i in range(len(num_steps)): for i in range(len(num_steps)):
if (debug_mode == True): if (debug_mode == True):
...@@ -1180,7 +1181,7 @@ class PBFNetlist: ...@@ -1180,7 +1181,7 @@ class PBFNetlist:
class FDPlacer: class FDPlacer:
def __init__(self, design_name, run_dir, netlist_file, plc_file, io_factor, num_steps, attract_factor, repel_factor, move_distance_factors): def __init__(self, design_name, run_dir, netlist_file, plc_file, io_factor, num_steps, attract_factor, repel_factor, move_distance_factors, use_init_flag = False):
self.design_name = design_name self.design_name = design_name
self.open_source_flag = False self.open_source_flag = False
self.run_dir = run_dir self.run_dir = run_dir
...@@ -1191,6 +1192,7 @@ class FDPlacer: ...@@ -1191,6 +1192,7 @@ class FDPlacer:
self.attract_factor = attract_factor self.attract_factor = attract_factor
self.repel_factor = repel_factor self.repel_factor = repel_factor
self.move_distance_factors = move_distance_factors self.move_distance_factors = move_distance_factors
self.use_init_flag = use_init_flag
# final plc file # final plc file
self.final_netlist_pbf_file = self.run_dir + "/" + self.design_name + ".pb.txt.final" self.final_netlist_pbf_file = self.run_dir + "/" + self.design_name + ".pb.txt.final"
...@@ -1212,6 +1214,9 @@ class FDPlacer: ...@@ -1212,6 +1214,9 @@ class FDPlacer:
#self.plc.restore_placement(self.temp_plc_file) #self.plc.restore_placement(self.temp_plc_file)
self.plc.set_canvas_size(self.design.canvas_width, self.design.canvas_height) self.plc.set_canvas_size(self.design.canvas_width, self.design.canvas_height)
self.PlotFromPlc(self.open_source_flag)
self.FDPlacer(self.open_source_flag) self.FDPlacer(self.open_source_flag)
self.final_netlist_pbf_file = self.run_dir + "/" + self.design_name + ".pb.txt.final" self.final_netlist_pbf_file = self.run_dir + "/" + self.design_name + ".pb.txt.final"
self.final_plc_file = self.run_dir + "/" + self.design_name + ".plc.final" self.final_plc_file = self.run_dir + "/" + self.design_name + ".plc.final"
...@@ -1275,8 +1280,6 @@ class FDPlacer: ...@@ -1275,8 +1280,6 @@ class FDPlacer:
plt.xlim(lx, ux) plt.xlim(lx, ux)
plt.ylim(ly, uy) plt.ylim(ly, uy)
plt.axis("scaled") plt.axis("scaled")
plt.show()
if (figure_file == None): if (figure_file == None):
plt.show() plt.show()
...@@ -1286,7 +1289,7 @@ class FDPlacer: ...@@ -1286,7 +1289,7 @@ class FDPlacer:
### Call the FD placer in Circuit Training ### Call the FD placer in Circuit Training
def FDPlacer(self, open_source_flag = False): def FDPlacer(self, open_source_flag = False):
# parameter settings from Circuit Training # parameter settings from Circuit Training
use_current_loc = False use_current_loc = self.use_init_flag
move_stdcells = True move_stdcells = True
move_macros = False move_macros = False
log_scale_conns = False log_scale_conns = False
...@@ -1300,7 +1303,7 @@ class FDPlacer: ...@@ -1300,7 +1303,7 @@ class FDPlacer:
max_move_distance = [ f * canvas_size / s max_move_distance = [ f * canvas_size / s
for s, f in zip(num_steps, move_distance_factors)] for s, f in zip(num_steps, move_distance_factors)]
if (open_source_flag == True): if (open_source_flag == True):
self.design.FDPlacer(io_factor , num_steps, max_move_distance, attract_factor, repel_factor) self.design.FDPlacer(io_factor , num_steps, max_move_distance, attract_factor, repel_factor, use_current_loc)
else: else:
self.plc.optimize_stdcells(use_current_loc, move_stdcells, move_macros, self.plc.optimize_stdcells(use_current_loc, move_stdcells, move_macros,
log_scale_conns, use_sizes, io_factor, num_steps, max_move_distance, attract_factor, repel_factor) log_scale_conns, use_sizes, io_factor, num_steps, max_move_distance, attract_factor, repel_factor)
...@@ -1322,17 +1325,32 @@ class FDPlacer: ...@@ -1322,17 +1325,32 @@ class FDPlacer:
self.plc.save_placement(plc_file_name, info[0:-1]) self.plc.save_placement(plc_file_name, info[0:-1])
if __name__ == "__main__": if __name__ == "__main__":
# for simple testcases
design_name = "simple"
run_dir = "./simple_example" # please make sure this dir exists
netlist_file = run_dir + "/" + design_name + ".pb.txt"
plc_file = run_dir + "/" + design_name + ".plc"
io_factor = 0
num_steps = [1]
attract_factor = [0.0]
repel_factor = [1.0]
move_distance_factors = [0.1] # set the max_displacement to 50
use_current_loc = True
placer = FDPlacer(design_name, run_dir, netlist_file, plc_file, io_factor, num_steps, attract_factor, repel_factor, move_distance_factors, use_current_loc)
# for ariane testcases
design_name = "ariane" design_name = "ariane"
run_dir = "./ariane133" # please make sure this dir exists run_dir = "./ariane133" # please make sure this dir exists
netlist_file = run_dir + "/" + design_name + ".pb.txt" netlist_file = run_dir + "/" + design_name + ".pb.txt"
plc_file = run_dir + "/" + design_name + ".plc" plc_file = run_dir + "/" + design_name + ".plc"
io_factor = 1.0 io_factor = 1.0
num_steps = [10, 10, 10] num_steps = [100, 100, 100]
attract_factor = [100, 1.0e-3, 1.0e-5] attract_factor = [100, 1.0e-3, 1.0e-5]
repel_factor = [0, 1.0e6, 1.0e7] repel_factor = [0, 1.0e6, 1.0e7]
move_distance_factors = [1.0, 1.0, 1.0] move_distance_factors = [1.0, 1.0, 1.0]
placer = FDPlacer(design_name, run_dir, netlist_file, plc_file, io_factor, num_steps, attract_factor, repel_factor, move_distance_factors) placer = FDPlacer(design_name, run_dir, netlist_file, plc_file, io_factor, num_steps, attract_factor, repel_factor, move_distance_factors)
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
node {
name: "M0"
attr {
key: "type"
value {
placeholder: "MACRO"
}
}
attr {
key: "height"
value {
f: 50.0
}
}
attr {
key: "orientation"
value {
placeholder: ""N""
}
}
attr {
key: "width"
value {
f: 50.0
}
}
attr {
key: "x"
value {
f: 201.0
}
}
attr {
key: "y"
value {
f: 201.0
}
}
}
node {
name: "Grp_1"
attr {
key: "height"
value {
f: 50.0
}
}
attr {
key: "type"
value {
placeholder: "macro"
}
}
attr {
key: "width"
value {
f: 50.0
}
}
attr {
key: "x"
value {
f: 265.306122
}
}
attr {
key: "y"
value {
f: 265.306122
}
}
}
node {
name: "Grp_2"
attr {
key: "height"
value {
f: 50.0
}
}
attr {
key: "type"
value {
placeholder: "macro"
}
}
attr {
key: "width"
value {
f: 50.0
}
}
attr {
key: "x"
value {
f: 285.0
}
}
attr {
key: "y"
value {
f: 285.0
}
}
}
node {
name: "Grp_3"
attr {
key: "height"
value {
f: 50.0
}
}
attr {
key: "type"
value {
placeholder: "macro"
}
}
attr {
key: "width"
value {
f: 50.0
}
}
attr {
key: "x"
value {
f: 400.0
}
}
attr {
key: "y"
value {
f: 400.0
}
}
}
# Placement file for Circuit Training
# Source input file(s) : ./output_ariane_NanGate45/23cols_28rows/g500_ub5_nruns10_c5_r3_v3_rc1/netlist.pb.txt
# This file : ./output_ariane_NanGate45/23cols_28rows/g500_ub5_nruns10_c5_r3_v3_rc1/initial.plc
# Date : 2022-09-20 11:30:06
# Columns : 23 Rows : 28
# Width : 500 Height : 500
# Area : 1506097.566312155
# Wirelength : 3610985.229
# Wirelength cost : 0.0526
# Congestion cost : 0.7721
# Density cost : 0.7209
# Project : circuit_training
# Block : unset_block
# Routes per micron, hor : 11.285 ver : 12.605
# Routes used by macros, hor : 7.143 ver : 8.339
# Smoothing factor : 2
# Overlap threshold : 0.004
#
#
#
# Counts of node types:
# HARD_MACROs : 133
# HARD_MACRO_PINs : 7847
# MACROs : 943
# MACRO_PINs : 19658
# PORTs : 495
# SOFT_MACROs : 810
# SOFT_MACRO_PINs : 11811
# STDCELLs : 0
#
# User comments:
# Original source netlist with standard cells: /home/zf4_projects/DREAMPlace/sakundu/ABK_MP/08162022_flow_scripts/MacroPlacement/Flows/NanGate45/ariane133/run-20220816-035413/flow2_1.3/ariane.pb.txt
# Groups file: ./output_ariane_NanGate45/23cols_28rows/g500_ub5_nruns10_c5_r3_v3_rc1/groups.final
# worst 10 spread
# grp: 744 - spread: 278916.7518893204
# grp: 50 - spread: 268009.6376835485
# grp: 336 - spread: 223800.4868365636
# grp: 535 - spread: 207184.36226282385
# grp: 505 - spread: 197871.97286953646
# grp: 586 - spread: 190713.73374938426
# grp: 756 - spread: 184033.9279079139
# grp: 532 - spread: 173094.29808680012
# grp: 773 - spread: 170707.79035165644
# grp: 347 - spread: 168578.0558490756
#
#
# node_index x y orientation fixed
0 201.0 201.0 "N" 0
1 265.30612244898 265.30612244898 N 0
2 285.0 285.0 N 0
3 400.0 400.0 N 0
node {
name: "M0"
attr {
key: "height"
value {
f: 50
}
}
attr {
key: "orientation"
value {
placeholder: "N"
}
}
attr {
key: "type"
value {
placeholder: "MACRO"
}
}
attr {
key: "x"
value {
f: 201
}
}
attr {
key: "y"
value {
f: 201
}
}
attr {
key: "width"
value {
f: 50
}
}
}
node {
name: "Grp_1"
attr {
key: "height"
value {
f: 50
}
}
attr {
key: "type"
value {
placeholder: "macro"
}
}
attr {
key: "width"
value {
f: 50
}
}
attr {
key: "x"
value {
f: 250
}
}
attr {
key: "y"
value {
f: 250
}
}
}
node {
name: "Grp_2"
attr {
key: "height"
value {
f: 50
}
}
attr {
key: "type"
value {
placeholder: "macro"
}
}
attr {
key: "width"
value {
f: 50
}
}
attr {
key: "x"
value {
f: 335
}
}
attr {
key: "y"
value {
f: 335
}
}
}
node {
name: "Grp_3"
attr {
key: "height"
value {
f: 50
}
}
attr {
key: "type"
value {
placeholder: "macro"
}
}
attr {
key: "width"
value {
f: 50
}
}
attr {
key: "x"
value {
f: 350
}
}
attr {
key: "y"
value {
f: 350
}
}
}
node {
name: "M0"
attr {
key: "type"
value {
placeholder: "MACRO"
}
}
attr {
key: "height"
value {
f: 50.0
}
}
attr {
key: "orientation"
value {
placeholder: ""N""
}
}
attr {
key: "width"
value {
f: 50.0
}
}
attr {
key: "x"
value {
f: 201.0
}
}
attr {
key: "y"
value {
f: 201.0
}
}
}
node {
name: "Grp_1"
attr {
key: "height"
value {
f: 50.0
}
}
attr {
key: "type"
value {
placeholder: "macro"
}
}
attr {
key: "width"
value {
f: 50.0
}
}
attr {
key: "x"
value {
f: 250.0
}
}
attr {
key: "y"
value {
f: 250.0
}
}
}
node {
name: "Grp_2"
attr {
key: "height"
value {
f: 50.0
}
}
attr {
key: "type"
value {
placeholder: "macro"
}
}
attr {
key: "width"
value {
f: 50.0
}
}
attr {
key: "x"
value {
f: 335.0
}
}
attr {
key: "y"
value {
f: 335.0
}
}
}
node {
name: "Grp_3"
attr {
key: "height"
value {
f: 50.0
}
}
attr {
key: "type"
value {
placeholder: "macro"
}
}
attr {
key: "width"
value {
f: 50.0
}
}
attr {
key: "x"
value {
f: 350.0
}
}
attr {
key: "y"
value {
f: 350.0
}
}
}
# Placement file for Circuit Training
# Source input file(s) : ./output_ariane_NanGate45/23cols_28rows/g500_ub5_nruns10_c5_r3_v3_rc1/netlist.pb.txt
# This file : ./output_ariane_NanGate45/23cols_28rows/g500_ub5_nruns10_c5_r3_v3_rc1/initial.plc
# Date : 2022-09-20 11:30:06
# Columns : 23 Rows : 28
# Width : 500 Height : 500
# Area : 1506097.566312155
# Wirelength : 3610985.229
# Wirelength cost : 0.0526
# Congestion cost : 0.7721
# Density cost : 0.7209
# Project : circuit_training
# Block : unset_block
# Routes per micron, hor : 11.285 ver : 12.605
# Routes used by macros, hor : 7.143 ver : 8.339
# Smoothing factor : 2
# Overlap threshold : 0.004
#
#
#
# Counts of node types:
# HARD_MACROs : 133
# HARD_MACRO_PINs : 7847
# MACROs : 943
# MACRO_PINs : 19658
# PORTs : 495
# SOFT_MACROs : 810
# SOFT_MACRO_PINs : 11811
# STDCELLs : 0
#
# User comments:
# Original source netlist with standard cells: /home/zf4_projects/DREAMPlace/sakundu/ABK_MP/08162022_flow_scripts/MacroPlacement/Flows/NanGate45/ariane133/run-20220816-035413/flow2_1.3/ariane.pb.txt
# Groups file: ./output_ariane_NanGate45/23cols_28rows/g500_ub5_nruns10_c5_r3_v3_rc1/groups.final
# worst 10 spread
# grp: 744 - spread: 278916.7518893204
# grp: 50 - spread: 268009.6376835485
# grp: 336 - spread: 223800.4868365636
# grp: 535 - spread: 207184.36226282385
# grp: 505 - spread: 197871.97286953646
# grp: 586 - spread: 190713.73374938426
# grp: 756 - spread: 184033.9279079139
# grp: 532 - spread: 173094.29808680012
# grp: 773 - spread: 170707.79035165644
# grp: 347 - spread: 168578.0558490756
#
#
# node_index x y orientation fixed
# Placement file for Circuit Training
# Source input file(s) : ./output_ariane_NanGate45/23cols_28rows/g500_ub5_nruns10_c5_r3_v3_rc1/netlist.pb.txt
# This file : ./output_ariane_NanGate45/23cols_28rows/g500_ub5_nruns10_c5_r3_v3_rc1/initial.plc
# Date : 2022-09-20 11:30:06
# Columns : 23 Rows : 28
# Width : 500 Height : 500
# Area : 1506097.566312155
# Wirelength : 3610985.229
# Wirelength cost : 0.0526
# Congestion cost : 0.7721
# Density cost : 0.7209
# Project : circuit_training
# Block : unset_block
# Routes per micron, hor : 11.285 ver : 12.605
# Routes used by macros, hor : 7.143 ver : 8.339
# Smoothing factor : 2
# Overlap threshold : 0.004
#
#
#
# Counts of node types:
# HARD_MACROs : 133
# HARD_MACRO_PINs : 7847
# MACROs : 943
# MACRO_PINs : 19658
# PORTs : 495
# SOFT_MACROs : 810
# SOFT_MACRO_PINs : 11811
# STDCELLs : 0
#
# User comments:
# Original source netlist with standard cells: /home/zf4_projects/DREAMPlace/sakundu/ABK_MP/08162022_flow_scripts/MacroPlacement/Flows/NanGate45/ariane133/run-20220816-035413/flow2_1.3/ariane.pb.txt
# Groups file: ./output_ariane_NanGate45/23cols_28rows/g500_ub5_nruns10_c5_r3_v3_rc1/groups.final
# worst 10 spread
# grp: 744 - spread: 278916.7518893204
# grp: 50 - spread: 268009.6376835485
# grp: 336 - spread: 223800.4868365636
# grp: 535 - spread: 207184.36226282385
# grp: 505 - spread: 197871.97286953646
# grp: 586 - spread: 190713.73374938426
# grp: 756 - spread: 184033.9279079139
# grp: 532 - spread: 173094.29808680012
# grp: 773 - spread: 170707.79035165644
# grp: 347 - spread: 168578.0558490756
#
#
# node_index x y orientation fixed
0 201 201 N 0
1 250 250 N 0
2 335 335 N 0
3 350 350 N 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment