Commit 8988a64b by Dinple

get_cost() implementation done

parent 802f5eb7
...@@ -42,6 +42,9 @@ class PlacementCost(object): ...@@ -42,6 +42,9 @@ class PlacementCost(object):
self.hrouting_alloc = 0.0 self.hrouting_alloc = 0.0
self.vrouting_alloc = 0.0 self.vrouting_alloc = 0.0
# net information
self.net_cnt = 0
# All modules look-up table # All modules look-up table
self.modules = [] self.modules = []
self.modules_w_pins = [] self.modules_w_pins = []
...@@ -194,11 +197,16 @@ class PlacementCost(object): ...@@ -194,11 +197,16 @@ class PlacementCost(object):
x = attr_dict['x'][1], x = attr_dict['x'][1],
y = attr_dict['y'][1], y = attr_dict['y'][1],
macro_name = attr_dict['macro_name'][1]) macro_name = attr_dict['macro_name'][1])
if 'weight' in attr_dict.keys():
soft_macro_pin.set_weight(float(attr_dict['weight'][1]))
if input_list: if input_list:
if 'weight' in attr_dict.keys():
self.net_cnt += 1 * float(attr_dict['weight'][1])
else:
self.net_cnt += 1
soft_macro_pin.add_sinks(input_list) soft_macro_pin.add_sinks(input_list)
if 'weight' in attr_dict.keys():
soft_macro_pin.set_weight(float(attr_dict['weight'][1]))
self.modules_w_pins.append(soft_macro_pin) self.modules_w_pins.append(soft_macro_pin)
# mapping node_name ==> node idx # mapping node_name ==> node idx
...@@ -247,6 +255,7 @@ class PlacementCost(object): ...@@ -247,6 +255,7 @@ class PlacementCost(object):
hard_macro_pin.set_weight(float(attr_dict['weight'][1])) hard_macro_pin.set_weight(float(attr_dict['weight'][1]))
if input_list: if input_list:
self.net_cnt += 1
hard_macro_pin.add_sinks(input_list) hard_macro_pin.add_sinks(input_list)
self.modules_w_pins.append(hard_macro_pin) self.modules_w_pins.append(hard_macro_pin)
...@@ -273,7 +282,9 @@ class PlacementCost(object): ...@@ -273,7 +282,9 @@ class PlacementCost(object):
side = attr_dict['side'][1]) side = attr_dict['side'][1])
if input_list: if input_list:
self.net_cnt += 1
port.add_sinks(input_list) port.add_sinks(input_list)
# ports does not have pins so update connection immediately
port.add_connections(input_list) port.add_connections(input_list)
self.modules_w_pins.append(port) self.modules_w_pins.append(port)
...@@ -350,8 +361,17 @@ class PlacementCost(object): ...@@ -350,8 +361,17 @@ class PlacementCost(object):
""" """
Compute wirelength cost from wirelength Compute wirelength cost from wirelength
""" """
# temp_net_cnt = math.floor(self.net_cnt * 0.15)
return 0.0
# if temp_net_cnt == 0:
# temp_net_cnt = 1
# unknown_threshold = 100
# if self.net_cnt <= unknown_threshold:
# return self.get_wirelength() / ((self.get_canvas_width_height()[0] + self.get_canvas_width_height()[1]) * temp_net_cnt)
# else:
return self.get_wirelength() / ((self.get_canvas_width_height()[0] + self.get_canvas_width_height()[1]) * self.net_cnt)
def get_area(self) -> float: def get_area(self) -> float:
""" """
...@@ -431,7 +451,6 @@ class PlacementCost(object): ...@@ -431,7 +451,6 @@ class PlacementCost(object):
else: else:
total_hpwl += (abs(max(x_coord) - min(x_coord))\ total_hpwl += (abs(max(x_coord) - min(x_coord))\
+ abs(max(y_coord) - min(y_coord))) + abs(max(y_coord) - min(y_coord)))
return total_hpwl return total_hpwl
def get_congestion_cost(self) -> float: def get_congestion_cost(self) -> float:
......
...@@ -14,8 +14,8 @@ class CircuitDataBaseTest(): ...@@ -14,8 +14,8 @@ class CircuitDataBaseTest():
# 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"
# Google's Ariane # Google's Ariane
# CANVAS_WIDTH = 356.592 # CANVAS_WIDTH = 356.592
...@@ -24,16 +24,16 @@ class CircuitDataBaseTest(): ...@@ -24,16 +24,16 @@ class CircuitDataBaseTest():
# GRID_ROW = 33 # GRID_ROW = 33
# Ariane133 # Ariane133
# CANVAS_WIDTH = 1599.99 CANVAS_WIDTH = 1599.99
# CANVAS_HEIGHT = 1598.8 CANVAS_HEIGHT = 1598.8
# GRID_COL = 50 GRID_COL = 50
# GRID_ROW = 50 GRID_ROW = 50
# Sample clustered # Sample clustered
CANVAS_WIDTH = 500 # CANVAS_WIDTH = 500
CANVAS_HEIGHT = 500 # CANVAS_HEIGHT = 500
GRID_COL = 5 # GRID_COL = 4
GRID_ROW = 5 # GRID_ROW = 4
def test_proxy_cost(self): def test_proxy_cost(self):
# Google's Binary Executable # Google's Binary Executable
...@@ -48,16 +48,17 @@ class CircuitDataBaseTest(): ...@@ -48,16 +48,17 @@ 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.display_canvas())
print(self.plc_os.get_wirelength(), self.plc.get_wirelength()) 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())
print("os wl cost", self.plc_os.get_cost())
print("gl wl cost", self.plc.get_cost())
assert abs(self.plc.get_cost() - self.plc_os.get_cost()) <= 10e-3
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("os density cost", self.plc_os.get_density_cost())
print("gl density", self.plc.get_density_cost()) print("gl density cost", 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
......
...@@ -68,6 +68,7 @@ node { ...@@ -68,6 +68,7 @@ node {
} }
node { node {
name: "Grp_2/Poutput_single_0" name: "Grp_2/Poutput_single_0"
input: "Grp_3/Pinput"
attr { attr {
key: "macro_name" key: "macro_name"
value { value {
...@@ -83,7 +84,7 @@ node { ...@@ -83,7 +84,7 @@ node {
attr { attr {
key: "x" key: "x"
value { value {
f: 20 f: 4
} }
} }
attr { attr {
...@@ -95,7 +96,7 @@ node { ...@@ -95,7 +96,7 @@ node {
attr { attr {
key: "y" key: "y"
value { value {
f: 45 f: 4
} }
} }
attr { attr {
...@@ -122,6 +123,46 @@ node { ...@@ -122,6 +123,46 @@ node {
attr { attr {
key: "x" key: "x"
value { value {
f: 4
}
}
attr {
key: "x_offset"
value {
f: 0
}
}
attr {
key: "y"
value {
f: 4
}
}
attr {
key: "y_offset"
value {
f: 0
}
}
}
node {
name: "Grp_3/Poutput_single_0"
input: "Grp_2/Pinput"
attr {
key: "macro_name"
value {
placeholder: "Grp_3"
}
}
attr {
key: "type"
value {
placeholder: "macro_pin"
}
}
attr {
key: "x"
value {
f: 20 f: 20
} }
} }
...@@ -134,7 +175,7 @@ node { ...@@ -134,7 +175,7 @@ node {
attr { attr {
key: "y" key: "y"
value { value {
f: 45 f: 20
} }
} }
attr { attr {
...@@ -144,3 +185,42 @@ node { ...@@ -144,3 +185,42 @@ node {
} }
} }
} }
node {
name: "Grp_3/Pinput"
attr {
key: "macro_name"
value {
placeholder: "Grp_3"
}
}
attr {
key: "type"
value {
placeholder: "macro_pin"
}
}
attr {
key: "x"
value {
f: 20
}
}
attr {
key: "x_offset"
value {
f: 0
}
}
attr {
key: "y"
value {
f: 20
}
}
attr {
key: "y_offset"
value {
f: 0
}
}
}
\ No newline at end of file
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