Commit 47af9d1a by Dinple

fixed hpwl and density cost

parent a4637fb8
...@@ -388,7 +388,8 @@ class PlacementCost(object): ...@@ -388,7 +388,8 @@ class PlacementCost(object):
# store current node indx # store current node indx
self.port_indices.append(node_cnt-1) self.port_indices.append(node_cnt-1)
# mapping connection degree to each macros # 1. mapping connection degree to each macros
# 2. update offset based on Hard macro orientation
self.__update_connection() self.__update_connection()
# all hard macros are placed on canvas initially # all hard macros are placed on canvas initially
...@@ -440,6 +441,9 @@ class PlacementCost(object): ...@@ -440,6 +441,9 @@ class PlacementCost(object):
# Width and Height should be defined on the same one-line # Width and Height should be defined on the same one-line
_width = float(line_item[1]) _width = float(line_item[1])
_height = float(line_item[3]) _height = float(line_item[3])
elif all(it in line_item for it in ['Area', 'stdcell', 'macros']):
# Total core area of modules
_area = float(line_item[3])
elif "Area" in line_item: elif "Area" in line_item:
# Total core area of modules # Total core area of modules
_area = float(line_item[1]) _area = float(line_item[1])
...@@ -559,7 +563,7 @@ class PlacementCost(object): ...@@ -559,7 +563,7 @@ class PlacementCost(object):
try: try:
assert sorted(self.port_indices +\ assert sorted(self.port_indices +\
self.hard_macro_indices +\ self.hard_macro_indices +\
self.soft_macro_indices) == list(info_dict['node_plc'].keys()) self.soft_macro_indices) == sorted(list(info_dict['node_plc'].keys()))
except AssertionError: except AssertionError:
print('[ERROR PLC INDICES MISMATCH]', len(sorted(self.port_indices +\ print('[ERROR PLC INDICES MISMATCH]', len(sorted(self.port_indices +\
self.hard_macro_indices +\ self.hard_macro_indices +\
...@@ -621,6 +625,10 @@ class PlacementCost(object): ...@@ -621,6 +625,10 @@ class PlacementCost(object):
print("[ERROR UPDATE CONNECTION] MACRO pins not found") print("[ERROR UPDATE CONNECTION] MACRO pins not found")
continue continue
# also update pin offset based on macro orientation
orientation = macro.get_orientation()
self.update_macro_orientation(macro_idx, orientation)
# Soft macro # Soft macro
elif self.is_node_soft_macro(macro_idx): elif self.is_node_soft_macro(macro_idx):
if macro_name in self.soft_macros_to_inpins.keys(): if macro_name in self.soft_macros_to_inpins.keys():
...@@ -713,6 +721,7 @@ class PlacementCost(object): ...@@ -713,6 +721,7 @@ class PlacementCost(object):
pin_node_x_offset, pin_node_y_offset = pin_node.get_offset() pin_node_x_offset, pin_node_y_offset = pin_node.get_offset()
# Google's Plc client DOES NOT compute (node_position + pin_offset) when reading input # Google's Plc client DOES NOT compute (node_position + pin_offset) when reading input
return (ref_node_x + pin_node_x_offset, ref_node_y + pin_node_y_offset) return (ref_node_x + pin_node_x_offset, ref_node_y + pin_node_y_offset)
# return pin_node.get_pos()
def get_wirelength(self) -> float: def get_wirelength(self) -> float:
""" """
...@@ -744,20 +753,20 @@ class PlacementCost(object): ...@@ -744,20 +753,20 @@ class PlacementCost(object):
# retrieve sink object # retrieve sink object
sink = self.modules_w_pins[sink_idx] sink = self.modules_w_pins[sink_idx]
# only consider placed sink # only consider placed sink
ref_sink = self.modules_w_pins[self.get_ref_node_id(sink_idx)] # ref_sink = self.modules_w_pins[self.get_ref_node_id(sink_idx)]
# if not placed, skip this edge # if not placed, skip this edge
if not ref_sink.get_placed_flag(): # if not ref_sink.get_placed_flag():
x_coord.append(0) # x_coord.append(0)
y_coord.append(0) # y_coord.append(0)
else:# retrieve location # else:# retrieve location
x_coord.append(self.__get_pin_position(sink_idx)[0]) x_coord.append(self.__get_pin_position(sink_idx)[0])
y_coord.append(self.__get_pin_position(sink_idx)[1]) y_coord.append(self.__get_pin_position(sink_idx)[1])
elif curr_type == "MACRO_PIN": elif curr_type == "MACRO_PIN":
ref_mod = self.modules_w_pins[self.get_ref_node_id(mod_idx)] ref_mod = self.modules_w_pins[self.get_ref_node_id(mod_idx)]
# if not placed, skip this edge # # if not placed, skip this edge
if not ref_mod.get_placed_flag(): # if not ref_mod.get_placed_flag():
continue # continue
# get pin weight # get pin weight
weight_fact = mod.get_weight() weight_fact = mod.get_weight()
# add source position # add source position
...@@ -770,12 +779,12 @@ class PlacementCost(object): ...@@ -770,12 +779,12 @@ class PlacementCost(object):
# retrieve indx in modules_w_pins # retrieve indx in modules_w_pins
input_idx = self.mod_name_to_indices[sink_name] input_idx = self.mod_name_to_indices[sink_name]
sink_ref_mod = self.modules_w_pins[self.get_ref_node_id(mod_idx)] # sink_ref_mod = self.modules_w_pins[self.get_ref_node_id(mod_idx)]
# if not placed, skip this edge # if not placed, skip this edge
if not sink_ref_mod.get_placed_flag(): # if not sink_ref_mod.get_placed_flag():
x_coord.append(0) # x_coord.append(0)
y_coord.append(0) # y_coord.append(0)
else: # else:
# retrieve location # retrieve location
x_coord.append(self.__get_pin_position(input_idx)[0]) x_coord.append(self.__get_pin_position(input_idx)[0])
y_coord.append(self.__get_pin_position(input_idx)[1]) y_coord.append(self.__get_pin_position(input_idx)[1])
...@@ -1001,8 +1010,8 @@ class PlacementCost(object): ...@@ -1001,8 +1010,8 @@ class PlacementCost(object):
module = self.modules_w_pins[module_idx] module = self.modules_w_pins[module_idx]
# skipping unplaced module # skipping unplaced module
if not module.get_placed_flag(): # if not module.get_placed_flag():
continue # continue
module_h = module.get_height() module_h = module.get_height()
module_w = module.get_width() module_w = module.get_width()
...@@ -1958,6 +1967,47 @@ class PlacementCost(object): ...@@ -1958,6 +1967,47 @@ class PlacementCost(object):
mod.set_orientation(orientation) mod.set_orientation(orientation)
macro = self.modules_w_pins[node_idx]
macro_name = macro.get_name()
hard_macro_pins = self.hard_macros_to_inpins[macro_name]
orientation = macro.get_orientation()
# update all pin offset
for pin_name in hard_macro_pins:
pin = self.modules_w_pins[self.mod_name_to_indices[pin_name]]
x_offset, y_offset = pin.get_offset()
x_offset_org = x_offset
if orientation == "N":
pass
elif orientation == "FN":
x_offset = -x_offset
pin.set_offset(x_offset, y_offset)
elif orientation == "S":
x_offset = -x_offset
y_offset = -y_offset
pin.set_offset(x_offset, y_offset)
elif orientation == "FS":
y_offset = -y_offset
pin.set_offset(x_offset, y_offset)
elif orientation == "E":
x_offset = y_offset
y_offset = -x_offset_org
pin.set_offset(x_offset, y_offset)
elif orientation == "FE":
x_offset = -y_offset
y_offset = -x_offset_org
pin.set_offset(x_offset, y_offset)
elif orientation == "W":
x_offset = -y_offset
y_offset = x_offset_org
pin.set_offset(x_offset, y_offset)
elif orientation == "FW":
x_offset = y_offset
y_offset = x_offset_org
pin.set_offset(x_offset, y_offset)
def update_port_sides(self): def update_port_sides(self):
""" """
Define Port "Side" by its location on canvas Define Port "Side" by its location on canvas
...@@ -2713,6 +2763,10 @@ class PlacementCost(object): ...@@ -2713,6 +2763,10 @@ class PlacementCost(object):
def get_offset(self): def get_offset(self):
return self.x_offset, self.y_offset return self.x_offset, self.y_offset
def set_offset(self, x_offset, y_offset):
self.x_offset = x_offset
self.y_offset = y_offset
def get_name(self): def get_name(self):
return self.name return self.name
......
...@@ -429,19 +429,17 @@ class PlacementCostTest(): ...@@ -429,19 +429,17 @@ class PlacementCostTest():
print("[ERROR WIRELENGTH] Discrepancies found when computing wirelength -- GL {}, OS {}".format( print("[ERROR WIRELENGTH] Discrepancies found when computing wirelength -- GL {}, OS {}".format(
str(self.plc.get_cost()), self.plc_os.get_cost())) str(self.plc.get_cost()), self.plc_os.get_cost()))
# if remove all soft macros # # if remove all soft macros
soft_macro_indices = [ # soft_macro_indices = [
m for m in self.plc.get_macro_indices() if self.plc.is_node_soft_macro(m) # m for m in self.plc.get_macro_indices() if self.plc.is_node_soft_macro(m)
] # ]
for mod_idx in soft_macro_indices: # for mod_idx in soft_macro_indices:
self.plc_os.unplace_node(mod_idx) # self.plc_os.unplace_node(mod_idx)
self.plc.unplace_node(mod_idx) # self.plc.unplace_node(mod_idx)
print("GL WIRELENGTH: ", self.plc.get_wirelength()) print("GL WIRELENGTH: ", self.plc.get_wirelength())
print("OS WIRELENGTH: ", self.plc_os.get_wirelength()) print("OS WIRELENGTH: ", self.plc_os.get_wirelength())
print("GL WIRELENGTH: ", self.plc.get_wirelength())
print("OS WIRELENGTH: ", self.plc_os.get_wirelength())
def test_proxy_density(self): def test_proxy_density(self):
...@@ -980,15 +978,15 @@ def main(args): ...@@ -980,15 +978,15 @@ def main(args):
Uncomment any available tests Uncomment any available tests
""" """
# PCT.test_metadata() # PCT.test_metadata()
# PCT.test_proxy_cost() PCT.test_proxy_cost()
PCT.test_proxy_hpwl() # PCT.test_proxy_hpwl()
# PCT.test_proxy_density() # PCT.test_proxy_density()
# PCT.test_proxy_congestion() # PCT.test_proxy_congestion()
# PCT.test_placement_util(keep_save_file=False) # PCT.test_placement_util(keep_save_file=False)
# PCT.test_place_node() # PCT.test_place_node()
# PCT.test_miscellaneous() # PCT.test_miscellaneous()
# PCT.test_observation_extractor() # PCT.test_observation_extractor()
# PCT.view_canvas() PCT.view_canvas()
# PCT.test_environment() # PCT.test_environment()
......
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