Commit 5c5e93f5 by Dinple

congestion update

parent a279985c
...@@ -513,28 +513,29 @@ class PlacementCost(object): ...@@ -513,28 +513,29 @@ class PlacementCost(object):
return float(sum_cong / cong_cnt) return float(sum_cong / cong_cnt)
def get_congestion_cost(self): def get_congestion_cost(self):
return max(self.get_H_congestion_cost(), self.get_V_congestion_cost()) # return max(self.get_H_congestion_cost(), self.get_V_congestion_cost())
# temp_cong = [sum(x) for x in zip(self.V_routing_cong, self.H_routing_cong)] temp_cong = self.V_routing_cong + self.H_routing_cong
# occupied_cells = sorted([gc for gc in temp_cong if gc != 0.0], reverse=True) occupied_cells = sorted([gc for gc in temp_cong if gc != 0.0], reverse=True)
# cong_cost = 0.0 cong_cost = 0.0
# # take top 10% # take top 5%
# cong_cnt = math.floor(len(temp_cong) * 0.1) cong_cnt = math.floor(len(temp_cong) * 0.05)
if cong_cnt == 0: cong_cnt = 1
# # if grid cell smaller than 10, take the average over occupied cells # if grid cell smaller than 5, take the average over occupied cells
# if len(temp_cong) < 10: if len(temp_cong) < 5:
# cong_cost = float(sum(occupied_cells) / len(occupied_cells)) cong_cost = float(sum(occupied_cells) / len(occupied_cells))
# return cong_cost return cong_cost
# idx = 0 idx = 0
# sum_cong = 0 sum_cong = 0
# # take top 10% # take top 10%
# while idx < cong_cnt and idx < len(occupied_cells): while idx < cong_cnt and idx < len(occupied_cells):
# sum_cong += occupied_cells[idx] sum_cong += occupied_cells[idx]
# idx += 1 idx += 1
# return float(sum_cong / cong_cnt) return float(sum_cong / cong_cnt)
def __get_grid_cell_location(self, x_pos, y_pos): def __get_grid_cell_location(self, x_pos, y_pos):
""" """
...@@ -802,12 +803,18 @@ class PlacementCost(object): ...@@ -802,12 +803,18 @@ class PlacementCost(object):
for col_idx in range(col_min, col_max, 1): for col_idx in range(col_min, col_max, 1):
col = col_idx col = col_idx
row = source_gcell[0] row = source_gcell[0]
# ignore OOB
if row * self.grid_col + col > len(self.H_routing_cong):
continue
self.H_routing_cong[row * self.grid_col + col] += weight self.H_routing_cong[row * self.grid_col + col] += weight
# V routing # V routing
for row_idx in range(row_min, row_max, 1): for row_idx in range(row_min, row_max, 1):
row = row_idx row = row_idx
col = sink_gcell[1] col = sink_gcell[1]
# ignore OOB
if row * self.grid_col + col > len(self.V_routing_cong):
continue
self.V_routing_cong[row * self.grid_col + col] += weight self.V_routing_cong[row * self.grid_col + col] += weight
def __three_pin_net_routing(self, node_gcells, weight): def __three_pin_net_routing(self, node_gcells, weight):
...@@ -824,24 +831,36 @@ class PlacementCost(object): ...@@ -824,24 +831,36 @@ class PlacementCost(object):
for col_idx in range(temp_gcell_first_col, temp_gcell_second_col, 1): for col_idx in range(temp_gcell_first_col, temp_gcell_second_col, 1):
col = col_idx col = col_idx
row = temp_gcell_first_row row = temp_gcell_first_row
# ignore OOB
if row * self.grid_col + col > len(self.H_routing_cong):
continue
self.H_routing_cong[row * self.grid_col + col] += weight self.H_routing_cong[row * self.grid_col + col] += weight
# H routing (x2, y2) to (x3-1, y2) # H routing (x2, y2) to (x3-1, y2)
for col_idx in range(temp_gcell_second_col, temp_gcell_third_col, 1): for col_idx in range(temp_gcell_second_col, temp_gcell_third_col, 1):
col = col_idx col = col_idx
row = temp_gcell_second_row row = temp_gcell_second_row
# ignore OOB
if row * self.grid_col + col > len(self.H_routing_cong):
continue
self.H_routing_cong[row * self.grid_col + col] += weight self.H_routing_cong[row * self.grid_col + col] += weight
# V routing (x2,min(y1,y2)) to (x2, max(y1,y2)-1) # V routing (x2,min(y1,y2)) to (x2, max(y1,y2)-1)
for row_idx in range(min(temp_gcell_first_row, temp_gcell_second_row), max(temp_gcell_first_row, temp_gcell_second_row), 1): for row_idx in range(min(temp_gcell_first_row, temp_gcell_second_row), max(temp_gcell_first_row, temp_gcell_second_row), 1):
row = row_idx row = row_idx
col = temp_gcell_second_col col = temp_gcell_second_col
# ignore OOB
if row * self.grid_col + col > len(self.V_routing_cong):
continue
self.V_routing_cong[row * self.grid_col + col] += weight self.V_routing_cong[row * self.grid_col + col] += weight
# V routing (x3,min(y2,y3)) to (x3, max(y2,y3)-1) # V routing (x3,min(y2,y3)) to (x3, max(y2,y3)-1)
for row_idx in range(min(temp_gcell_second_row, temp_gcell_third_row), max(temp_gcell_second_row, temp_gcell_third_row), 1): for row_idx in range(min(temp_gcell_second_row, temp_gcell_third_row), max(temp_gcell_second_row, temp_gcell_third_row), 1):
row = row_idx row = row_idx
col = temp_gcell_third_col col = temp_gcell_third_col
# ignore OOB
if row * self.grid_col + col > len(self.V_routing_cong):
continue
self.V_routing_cong[row * self.grid_col + col] += weight self.V_routing_cong[row * self.grid_col + col] += weight
elif temp_gcell_first_row == temp_gcell_third_row: elif temp_gcell_first_row == temp_gcell_third_row:
...@@ -849,12 +868,18 @@ class PlacementCost(object): ...@@ -849,12 +868,18 @@ class PlacementCost(object):
for col_idx in range(temp_gcell_first_col, temp_gcell_third_col, 1): for col_idx in range(temp_gcell_first_col, temp_gcell_third_col, 1):
col = col_idx col = col_idx
row = temp_gcell_first_row row = temp_gcell_first_row
# ignore OOB
if row * self.grid_col + col > len(self.H_routing_cong):
continue
self.H_routing_cong[row * self.grid_col + col] += weight self.H_routing_cong[row * self.grid_col + col] += weight
# V routing from (x2, min(y1,y2)) to (x2, max(y1,y2)-1) # V routing from (x2, min(y1,y2)) to (x2, max(y1,y2)-1)
for row_idx in range(min(temp_gcell_first_row, temp_gcell_second_row), max(temp_gcell_first_row, temp_gcell_second_row), 1): for row_idx in range(min(temp_gcell_first_row, temp_gcell_second_row), max(temp_gcell_first_row, temp_gcell_second_row), 1):
row = row_idx row = row_idx
col = temp_gcell_second_col col = temp_gcell_second_col
# ignore OOB
if row * self.grid_col + col > len(self.V_routing_cong):
continue
self.V_routing_cong[row * self.grid_col + col] += weight self.V_routing_cong[row * self.grid_col + col] += weight
elif temp_gcell_first_row > temp_gcell_third_row and temp_gcell_third_row > temp_gcell_second_row: elif temp_gcell_first_row > temp_gcell_third_row and temp_gcell_third_row > temp_gcell_second_row:
...@@ -862,18 +887,27 @@ class PlacementCost(object): ...@@ -862,18 +887,27 @@ class PlacementCost(object):
for col_idx in range(temp_gcell_first_col, temp_gcell_third_col, 1): for col_idx in range(temp_gcell_first_col, temp_gcell_third_col, 1):
col = col_idx col = col_idx
row = temp_gcell_third_row row = temp_gcell_third_row
# ignore OOB
if row * self.grid_col + col > len(self.H_routing_cong):
continue
self.H_routing_cong[row * self.grid_col + col] += weight self.H_routing_cong[row * self.grid_col + col] += weight
# V routing from (x1,y3) to (x1,y1-1) # V routing from (x1,y3) to (x1,y1-1)
for row_idx in range(temp_gcell_third_row, temp_gcell_first_row, 1): for row_idx in range(temp_gcell_third_row, temp_gcell_first_row, 1):
row = row_idx row = row_idx
col = temp_gcell_first_col col = temp_gcell_first_col
# ignore OOB
if row * self.grid_col + col > len(self.V_routing_cong):
continue
self.V_routing_cong[row * self.grid_col + col] += weight self.V_routing_cong[row * self.grid_col + col] += weight
# V routing from (x2, min(y2,y3)) to (x2, max(y2,y3)-1) # V routing from (x2, min(y2,y3)) to (x2, max(y2,y3)-1)
for row_idx in range(min(temp_gcell_second_row, temp_gcell_third_row), max(temp_gcell_second_row, temp_gcell_third_row), 1): for row_idx in range(min(temp_gcell_second_row, temp_gcell_third_row), max(temp_gcell_second_row, temp_gcell_third_row), 1):
row = row_idx row = row_idx
col = temp_gcell_second_col col = temp_gcell_second_col
# ignore OOB
if row * self.grid_col + col > len(self.V_routing_cong):
continue
self.V_routing_cong[row * self.grid_col + col] += weight self.V_routing_cong[row * self.grid_col + col] += weight
elif temp_gcell_third_row > temp_gcell_first_row and temp_gcell_first_row > temp_gcell_second_row: elif temp_gcell_third_row > temp_gcell_first_row and temp_gcell_first_row > temp_gcell_second_row:
...@@ -881,18 +915,27 @@ class PlacementCost(object): ...@@ -881,18 +915,27 @@ class PlacementCost(object):
for col_idx in range(temp_gcell_first_row, temp_gcell_third_col, 1): for col_idx in range(temp_gcell_first_row, temp_gcell_third_col, 1):
col = col_idx col = col_idx
row = temp_gcell_third_row row = temp_gcell_third_row
# ignore OOB
if row * self.grid_col + col > len(self.H_routing_cong):
continue
self.H_routing_cong[row * self.grid_col + col] += weight self.H_routing_cong[row * self.grid_col + col] += weight
# V routing from (x1,y3) to (x1,y1-1) # V routing from (x1,y3) to (x1,y1-1)
for row_idx in range(temp_gcell_third_col, temp_gcell_first_col, 1): for row_idx in range(temp_gcell_third_col, temp_gcell_first_col, 1):
row = row_idx row = row_idx
col = temp_gcell_first_col col = temp_gcell_first_col
# ignore OOB
if row * self.grid_col + col > len(self.V_routing_cong):
continue
self.V_routing_cong[row * self.grid_col + col] += weight self.V_routing_cong[row * self.grid_col + col] += weight
# V routing from (x2, min(y2,y3)) to (x2, max(y2,y3)-1) # V routing from (x2, min(y2,y3)) to (x2, max(y2,y3)-1)
for row_idx in range(min(temp_gcell_second_row, temp_gcell_third_row), max(temp_gcell_second_row, temp_gcell_third_row), 1): for row_idx in range(min(temp_gcell_second_row, temp_gcell_third_row), max(temp_gcell_second_row, temp_gcell_third_row), 1):
row = row_idx row = row_idx
col = temp_gcell_second_col col = temp_gcell_second_col
# ignore OOB
if row * self.grid_col + col > len(self.V_routing_cong):
continue
self.V_routing_cong[row * self.grid_col + col] += weight self.V_routing_cong[row * self.grid_col + col] += weight
def __macro_route_over_grid_cell(self, mod_x, mod_y, mod_w, mod_h): def __macro_route_over_grid_cell(self, mod_x, mod_y, mod_w, mod_h):
......
...@@ -11,44 +11,47 @@ FLAGS = flags.FLAGS ...@@ -11,44 +11,47 @@ FLAGS = flags.FLAGS
class CircuitDataBaseTest(): class CircuitDataBaseTest():
# NETLIST_PATH = "./Plc_client/test/sample_clustered_uniform_two_soft/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/sample_clustered_uniform_two_soft/netlist.pb.txt"
NETLIST_PATH = "./Plc_client/test/ariane_hard2soft/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/ariane_hard2soft/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/ariane_soft2hard/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/ariane_soft2hard/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/ariane_port2soft/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/ariane_port2soft/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/sample_clustered_nomacro/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/sample_clustered_nomacro/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/sample_clustered_macroxy/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/sample_clustered_macroxy/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/ariane/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/ariane/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/ariane133/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/ariane133/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/testcases/TC1_MP1_0_0_P2_0_1.pb.txt" NETLIST_PATH = "./Plc_client/test/testcases/TC1_MP1_0_0_P2_0_1.pb.txt"
# NETLIST_PATH = "./Plc_client/test/testcases/TC24_MP1_0_0_MP2_4_4.pb.txt" # NETLIST_PATH = "./Plc_client/test/testcases/TC24_MP1_0_0_MP2_4_4.pb.txt"
# NETLIST_PATH = "./Plc_client/test/0P1M1m/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/0P1M1m/netlist.pb.txt"
NETLIST_PATH = "./Plc_client/test/0P2M0m/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/0P2M0m/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/0P3M0m/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/0P3M0m/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/0P4M0m/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/0P4M0m/netlist.pb.txt"
# NETLIST_PATH = "./Plc_client/test/testcases_xm/TC_MP1_4_1_MP2_2_2_MP3_3_4_MP4_0_0.pb.txt" # NETLIST_PATH = "./Plc_client/test/testcases_xm/TC_MP1_4_1_MP2_2_2_MP3_3_4_MP4_0_0.pb.txt"
# Google's Ariane # Google's Ariane
# CANVAS_WIDTH = 356.592 CANVAS_WIDTH = 356.592
# CANVAS_HEIGHT = 356.640 CANVAS_HEIGHT = 356.640
# GRID_COL = 35 GRID_COL = 35
# GRID_ROW = 33 GRID_ROW = 33
# Ariane133 # Ariane133
# CANVAS_WIDTH = 1430.723 # CANVAS_WIDTH = 1599.99
# CANVAS_HEIGHT = 1430.723 # CANVAS_HEIGHT = 1600.06
# GRID_COL = 24 # GRID_COL = 24
# GRID_ROW = 21 # GRID_ROW = 21
# Sample clustered # Sample clustered
CANVAS_WIDTH = 400 # CANVAS_WIDTH = 400
CANVAS_HEIGHT = 400 # CANVAS_HEIGHT = 400
GRID_COL = 4 # GRID_COL = 4
GRID_ROW = 4 # GRID_ROW = 4
# PMm # PMm
# CANVAS_WIDTH = 100 CANVAS_WIDTH = 100
# CANVAS_HEIGHT = 100 CANVAS_HEIGHT = 100
# GRID_COL = 5 GRID_COL = 3
# GRID_ROW = 5 GRID_ROW = 3
def __init__(self, NETLIST_PATH) -> None:
self.NETLIST_PATH = NETLIST_PATH
def test_proxy_congestion(self): def test_proxy_congestion(self):
# Google's Binary Executable # Google's Binary Executable
...@@ -62,24 +65,26 @@ class CircuitDataBaseTest(): ...@@ -62,24 +65,26 @@ class CircuitDataBaseTest():
self.plc.set_macro_routing_allocation(10, 10) self.plc.set_macro_routing_allocation(10, 10)
self.plc_os.set_macro_routing_allocation(10, 10) self.plc_os.set_macro_routing_allocation(10, 10)
self.plc.set_congestion_smooth_range(1.0) self.plc.set_congestion_smooth_range(2.0)
self.plc_os.set_congestion_smooth_range(1.0) self.plc_os.set_congestion_smooth_range(2.0)
self.plc.set_canvas_size(self.CANVAS_WIDTH, self.CANVAS_HEIGHT) self.plc.set_canvas_size(self.CANVAS_WIDTH, self.CANVAS_HEIGHT)
self.plc.set_placement_grid(self.GRID_COL, self.GRID_ROW) self.plc.set_placement_grid(self.GRID_COL, self.GRID_ROW)
self.plc_os.set_canvas_size(self.CANVAS_WIDTH, self.CANVAS_HEIGHT) self.plc_os.set_canvas_size(self.CANVAS_WIDTH, self.CANVAS_HEIGHT)
self.plc_os.set_placement_grid(self.GRID_COL, self.GRID_ROW) self.plc_os.set_placement_grid(self.GRID_COL, self.GRID_ROW)
print("Name: ", self.plc.get_source_filename().rsplit("/", 1)[1])
self.plc_os.display_canvas() self.plc_os.display_canvas()
start = time.time() # start = time.time()
temp_gl_h = self.plc.get_horizontal_routing_congestion() temp_gl_h = self.plc.get_horizontal_routing_congestion()
temp_os_h = self.plc_os.get_horizontal_routing_congestion() temp_os_h = self.plc_os.get_horizontal_routing_congestion()
# print(np.array(temp_gl_h).reshape(self.GRID_COL, self.GRID_ROW)) # print(np.array(temp_gl_h).reshape(self.GRID_COL, self.GRID_ROW))
# print(np.array(temp_os_h).reshape(self.GRID_COL, self.GRID_ROW)) # print(np.array(temp_os_h).reshape(self.GRID_COL, self.GRID_ROW))
# print("GL H Congestion: ", temp_gl_h) print("GL H Congestion: ", temp_gl_h)
# print("OS H Congestion: ", temp_os_h) print("OS H Congestion: ", temp_os_h)
temp_gl_v = self.plc.get_vertical_routing_congestion() temp_gl_v = self.plc.get_vertical_routing_congestion()
temp_os_v = self.plc_os.get_vertical_routing_congestion() temp_os_v = self.plc_os.get_vertical_routing_congestion()
...@@ -87,17 +92,17 @@ class CircuitDataBaseTest(): ...@@ -87,17 +92,17 @@ class CircuitDataBaseTest():
# print(np.array(temp_gl_v).reshape(self.GRID_COL, self.GRID_ROW)) # print(np.array(temp_gl_v).reshape(self.GRID_COL, self.GRID_ROW))
# print(np.array(temp_os_v).reshape(self.GRID_COL, self.GRID_ROW)) # print(np.array(temp_os_v).reshape(self.GRID_COL, self.GRID_ROW))
# print("GL V Congestion: ", self.plc.get_vertical_routing_congestion()) print("GL V Congestion: ", self.plc.get_vertical_routing_congestion())
# print("OS V Congestion: ", self.plc_os.get_vertical_routing_congestion()) print("OS V Congestion: ", self.plc_os.get_vertical_routing_congestion())
# print("Congestion: ", self.plc.get_congestion_cost()) # end = time.time()
end = time.time() # print("time elapsed:", end - start)
print("time elapsed:", end - start)
for idx in range(len(temp_gl_h)): # for idx in range(len(temp_gl_h)):
print("gl, os:", temp_gl_h[idx], temp_os_h[idx], temp_gl_v[idx], temp_os_v[idx]) # print("gl, os:", temp_gl_h[idx], temp_os_h[idx], temp_gl_v[idx], temp_os_v[idx])
print("congestion summation gl os", sum(temp_gl_h), sum(temp_os_h), sum(temp_gl_v), sum(temp_os_v)) # print("congestion summation gl os", sum(temp_gl_h), sum(temp_os_h), sum(temp_gl_v), sum(temp_os_v))
print("congestion gl, os", self.plc.get_congestion_cost(), self.plc_os.get_congestion_cost()) print("congestion GL: ", self.plc.get_congestion_cost())
print("congestion OS: ", self.plc_os.get_congestion_cost())
def test_proxy_cost(self): def test_proxy_cost(self):
# Google's Binary Executable # Google's Binary Executable
...@@ -215,7 +220,8 @@ class CircuitDataBaseTest(): ...@@ -215,7 +220,8 @@ class CircuitDataBaseTest():
def main(argv): def main(argv):
temp = CircuitDataBaseTest() args = sys.argv[1:]
temp = CircuitDataBaseTest(args[0])
temp.test_proxy_congestion() temp.test_proxy_congestion()
# temp.test_proxy_cost() # temp.test_proxy_cost()
# temp.test_metadata() # temp.test_metadata()
......
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