Commit 802f5eb7 by Dinple

fixes

parent d690cd79
...@@ -347,6 +347,10 @@ class PlacementCost(object): ...@@ -347,6 +347,10 @@ class PlacementCost(object):
def get_cost(self) -> float: def get_cost(self) -> float:
"""
Compute wirelength cost from wirelength
"""
return 0.0 return 0.0
def get_area(self) -> float: def get_area(self) -> float:
...@@ -745,7 +749,7 @@ class PlacementCost(object): ...@@ -745,7 +749,7 @@ class PlacementCost(object):
""" """
Compute Adjacency Matrix (Unclustered PORTs) Compute Adjacency Matrix (Unclustered PORTs)
""" """
#[MACRO][macro][PORT] #[MACRO][macro]
module_indices = self.hard_macro_indices + self.soft_macro_indices module_indices = self.hard_macro_indices + self.soft_macro_indices
#[Grid Cell] => [PORT] #[Grid Cell] => [PORT]
...@@ -763,10 +767,10 @@ class PlacementCost(object): ...@@ -763,10 +767,10 @@ class PlacementCost(object):
# NOTE: in pb.txt, netlist input count exceed certain threshold will be ommitted # NOTE: in pb.txt, netlist input count exceed certain threshold will be ommitted
macro_adj = [0] * (len(module_indices) + len(clustered_ports)) * (len(module_indices) + len(clustered_ports)) macro_adj = [0] * (len(module_indices) + len(clustered_ports)) * (len(module_indices) + len(clustered_ports))
cell_location = [0] * len(clustered_ports)
# instantiate macros # instantiate macros
for row_idx, module_idx in enumerate(module_indices): for row_idx, module_idx in enumerate(module_indices):
# row index
# store temp module # store temp module
curr_module = self.modules_w_pins[module_idx] curr_module = self.modules_w_pins[module_idx]
# get module name # get module name
...@@ -786,15 +790,23 @@ class PlacementCost(object): ...@@ -786,15 +790,23 @@ class PlacementCost(object):
if h_module_name in curr_module.get_connection(): if h_module_name in curr_module.get_connection():
entry += curr_module.get_connection()[h_module_name] entry += curr_module.get_connection()[h_module_name]
macro_adj[row_idx * (self.hard_macro_cnt + self.soft_macro_cnt) + col_idx] = entry macro_adj[row_idx * (len(module_indices) + len(clustered_ports)) + col_idx] = entry
macro_adj[col_idx * (self.hard_macro_cnt + self.soft_macro_cnt) + row_idx] = entry macro_adj[col_idx * (len(module_indices) + len(clustered_ports)) + row_idx] = entry
# instantiate clustered ports # instantiate clustered ports
for cluster_idx, cluster_cell in enumerate(clustered_ports): for row_idx, cluster_cell in enumerate(clustered_ports):
# add cell location
for port in clustered_ports[cluster_cell]: cell_location[row_idx] = cluster_cell[0] * self.grid_row + cluster_cell[1]
# relocate to after macros
row_idx += len(module_indices)
# for each port within a grid cell
for curr_port in clustered_ports[cluster_cell]:
# get module name # get module name
curr_port_name = port.get_name() curr_port_name = curr_port.get_name()
# print("curr_port_name", curr_port_name)
# print("connections", curr_port.get_connection())
# assuming ports only connects to macros # assuming ports only connects to macros
for col_idx, h_module_idx in enumerate(module_indices): for col_idx, h_module_idx in enumerate(module_indices):
# col index # col index
...@@ -803,18 +815,19 @@ class PlacementCost(object): ...@@ -803,18 +815,19 @@ class PlacementCost(object):
h_module = self.modules_w_pins[h_module_idx] h_module = self.modules_w_pins[h_module_idx]
# get connected module name # get connected module name
h_module_name = h_module.get_name() h_module_name = h_module.get_name()
if curr_module_name in h_module.get_connection():
entry += h_module.get_connection()[curr_port_name]
if h_module_name in curr_module.get_connection(): # print("other connections", h_module.get_connection(), curr_port_name)
entry += curr_module.get_connection()[h_module_name]
macro_adj[row_idx * (self.hard_macro_cnt + self.soft_macro_cnt + cluster_idx) + col_idx] = entry
macro_adj[col_idx * (self.hard_macro_cnt + self.soft_macro_cnt + cluster_idx) + row_idx] = entry
if curr_port_name in h_module.get_connection():
return macro_adj entry += h_module.get_connection()[curr_port_name]
if h_module_name in curr_port.get_connection():
entry += curr_port.get_connection()[h_module_name]
macro_adj[row_idx * (len(module_indices) + len(clustered_ports)) + col_idx] += entry
macro_adj[col_idx * (len(module_indices) + len(clustered_ports)) + row_idx] += entry
return macro_adj, sorted(cell_location)
def get_node_location(self): def get_node_location(self):
pass pass
...@@ -862,12 +875,12 @@ class PlacementCost(object): ...@@ -862,12 +875,12 @@ class PlacementCost(object):
np.linspace(0, self.width, self.grid_col + 1)) np.linspace(0, self.width, self.grid_col + 1))
ax.plot(x, y, c='b', alpha=0.1) # use plot, not scatter ax.plot(x, y, c='b', alpha=0.1) # use plot, not scatter
ax.plot(np.transpose(x), np.transpose(y), c='b', alpha=0.1) # add this here ax.plot(np.transpose(x), np.transpose(y), c='b', alpha=0.2) # add this here
# Construct module blocks # Construct module blocks
for mod in self.modules_w_pins: for mod in self.modules_w_pins:
if mod.get_type() == 'PORT': if mod.get_type() == 'PORT':
plt.plot(*mod.get_pos(),'ro', markersize=1) plt.plot(*mod.get_pos(),'ro', markersize=2)
elif mod.get_type() == 'MACRO': elif mod.get_type() == 'MACRO':
ax.add_patch(Rectangle((mod.get_pos()[0] - mod.get_width()/2, mod.get_pos()[1] - mod.get_height()/2),\ ax.add_patch(Rectangle((mod.get_pos()[0] - mod.get_width()/2, mod.get_pos()[1] - mod.get_height()/2),\
mod.get_width(), mod.get_height(),\ mod.get_width(), mod.get_height(),\
......
...@@ -8,6 +8,7 @@ np.set_printoptions(threshold=sys.maxsize) ...@@ -8,6 +8,7 @@ np.set_printoptions(threshold=sys.maxsize)
FLAGS = flags.FLAGS 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/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"
...@@ -17,10 +18,10 @@ class CircuitDataBaseTest(): ...@@ -17,10 +18,10 @@ class CircuitDataBaseTest():
# NETLIST_PATH = "./Plc_client/test/ariane133/netlist.pb.txt" # NETLIST_PATH = "./Plc_client/test/ariane133/netlist.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 = 1599.99 # CANVAS_WIDTH = 1599.99
...@@ -29,10 +30,10 @@ class CircuitDataBaseTest(): ...@@ -29,10 +30,10 @@ class CircuitDataBaseTest():
# GRID_ROW = 50 # GRID_ROW = 50
# Sample clustered # Sample clustered
# CANVAS_WIDTH = 80 CANVAS_WIDTH = 500
# CANVAS_HEIGHT = 80 CANVAS_HEIGHT = 500
# GRID_COL = 5 GRID_COL = 5
# GRID_ROW = 5 GRID_ROW = 5
def test_proxy_cost(self): def test_proxy_cost(self):
# Google's Binary Executable # Google's Binary Executable
...@@ -47,10 +48,16 @@ class CircuitDataBaseTest(): ...@@ -47,10 +48,16 @@ class CircuitDataBaseTest():
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(self.plc_os.display_canvas())
print(self.plc_os.get_wirelength(), self.plc.get_wirelength())
assert int(self.plc_os.get_wirelength()) == int(self.plc.get_wirelength()) assert int(self.plc_os.get_wirelength()) == int(self.plc.get_wirelength())
assert int(sum(self.plc_os.get_grid_cells_density())) == int(sum(self.plc.get_grid_cells_density())) assert int(sum(self.plc_os.get_grid_cells_density())) == int(sum(self.plc.get_grid_cells_density()))
assert int(self.plc_os.get_density_cost()) == int(self.plc.get_density_cost()) assert int(self.plc_os.get_density_cost()) == int(self.plc.get_density_cost())
print("os density", self.plc_os.get_density_cost())
print("gl density", self.plc.get_density_cost())
print("wirelength cost", self.plc.get_wirelength(), self.plc.get_cost())
def test_metadata(self): def test_metadata(self):
# Google's Binary Executable # Google's Binary Executable
...@@ -85,8 +92,23 @@ class CircuitDataBaseTest(): ...@@ -85,8 +92,23 @@ class CircuitDataBaseTest():
self.plc_os.set_macro_routing_allocation(3.0, 4.0) self.plc_os.set_macro_routing_allocation(3.0, 4.0)
assert self.plc.get_macro_routing_allocation() == self.plc_os.get_macro_routing_allocation() assert self.plc.get_macro_routing_allocation() == self.plc_os.get_macro_routing_allocation()
assert sum(self.plc.get_macro_adjacency()) == sum(self.plc_os.get_macro_adjacency()) plc_macroadj = self.plc.get_macro_adjacency()
assert sum(self.plc.get_macro_and_clustered_port_adjacency()[0]) == sum(self.plc_os.get_macro_and_clustered_port_adjacency()) plcos_macroadj = self.plc_os.get_macro_adjacency()
# print("diff macro", np.nonzero(np.array(plc_macroadj) - np.array(plcos_macroadj)))
# print(self.plc_os.get_macro_and_clustered_port_adjacency())
# print(self.plc.get_macro_and_clustered_port_adjacency()[0])
# print("gl number of clustered ports found:", self.plc.get_macro_and_clustered_port_adjacency()[0])
# print("our number of clustered ports found:", self.plc_os.get_macro_and_clustered_port_adjacency()[0])
# print(self.plc_os.display_canvas())
# print("count", self.plc_os.soft_macro_cnt, self.plc_os.hard_macro_cnt, self.plc_os.port_cnt)
# compare both macro and clustered ports array
for plc_adj, plcos_adj in zip(self.plc.get_macro_and_clustered_port_adjacency(), self.plc_os.get_macro_and_clustered_port_adjacency()):
# print("diff macro cluster", np.nonzero(np.array(plc_adj) - np.array(plcos_adj)))
assert sum(plc_adj) == sum(plcos_adj)
def test_miscellaneous(self): def test_miscellaneous(self):
# Google's Binary Executable # Google's Binary Executable
......
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