Commit 7474f481 by Dinple

Overhaul WIP + plugging plc_client_os into placement_util WIP

parent fdeb44ce
...@@ -31,7 +31,7 @@ import numpy as np ...@@ -31,7 +31,7 @@ import numpy as np
# Internal gfile dependencies # Internal gfile dependencies
# done
def nodes_of_types(plc: plc_client.PlacementCost, def nodes_of_types(plc: plc_client.PlacementCost,
type_list: List[str]) -> Iterator[int]: type_list: List[str]) -> Iterator[int]:
"""Yields the index of a node of certain types.""" """Yields the index of a node of certain types."""
...@@ -76,7 +76,7 @@ def restore_macro_orientations(plc: plc_client.PlacementCost, ...@@ -76,7 +76,7 @@ def restore_macro_orientations(plc: plc_client.PlacementCost,
for node_index, orientation in macro_orientations.items(): for node_index, orientation in macro_orientations.items():
plc.update_macro_orientation(node_index, orientation) plc.update_macro_orientation(node_index, orientation)
#
def extract_attribute_from_comments(attribute: str, def extract_attribute_from_comments(attribute: str,
filenames: List[str]) -> Optional[str]: filenames: List[str]) -> Optional[str]:
"""Parses the files' comments section, tries to extract the attribute. """Parses the files' comments section, tries to extract the attribute.
...@@ -104,7 +104,7 @@ def extract_attribute_from_comments(attribute: str, ...@@ -104,7 +104,7 @@ def extract_attribute_from_comments(attribute: str,
break break
return None return None
#done
def get_blockages_from_comments( def get_blockages_from_comments(
filenames: Union[str, List[str]]) -> Optional[List[List[float]]]: filenames: Union[str, List[str]]) -> Optional[List[List[float]]]:
"""Returns list of blockages if they exist in the file's comments section.""" """Returns list of blockages if they exist in the file's comments section."""
...@@ -130,7 +130,7 @@ def get_blockages_from_comments( ...@@ -130,7 +130,7 @@ def get_blockages_from_comments(
if blockages: if blockages:
return blockages return blockages
#done
def extract_sizes_from_comments( def extract_sizes_from_comments(
filenames: List[str]) -> Optional[Tuple[float, float, int, int]]: filenames: List[str]) -> Optional[Tuple[float, float, int, int]]:
"""Parses the file's comments section, tries to extract canvas/grid sizes. """Parses the file's comments section, tries to extract canvas/grid sizes.
...@@ -793,7 +793,7 @@ def create_placement_cost_using_common_arguments( ...@@ -793,7 +793,7 @@ def create_placement_cost_using_common_arguments(
for filename in [netlist_file, init_placement]: for filename in [netlist_file, init_placement]:
if filename is None: if filename is None:
continue continue
blockages = get_blockages_from_comments(filename) blockages = get_blockages_from_comments([filename])
# Only read blockages from one file. # Only read blockages from one file.
if blockages: if blockages:
break break
...@@ -964,6 +964,8 @@ def main(): ...@@ -964,6 +964,8 @@ def main():
netlist_file = os.path.join(test_netlist_dir,'netlist.pb.txt') netlist_file = os.path.join(test_netlist_dir,'netlist.pb.txt')
init_placement = os.path.join(test_netlist_dir,'initial.plc') init_placement = os.path.join(test_netlist_dir,'initial.plc')
plc = create_placement_cost(netlist_file=netlist_file, init_placement=init_placement) plc = create_placement_cost(netlist_file=netlist_file, init_placement=init_placement)
plc = create_placement_cost_using_common_arguments(netlist_file=netlist_file, init_placement=init_placement,
grid_cols=10, grid_rows=10, congestion_smooth_range=2.0, overlap_threshold=0.004, use_incremental_cost=False)
# plc.nodes_of_types() # plc.nodes_of_types()
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -86,6 +86,8 @@ class PlacementCost(object): ...@@ -86,6 +86,8 @@ class PlacementCost(object):
self.hard_macros_to_inpins = {} self.hard_macros_to_inpins = {}
self.soft_macros_to_inpins = {} self.soft_macros_to_inpins = {}
# unknown
self.use_incremental_cost = False
# blockage # blockage
self.blockages = [] self.blockages = []
# read netlist # read netlist
...@@ -1444,12 +1446,18 @@ class PlacementCost(object): ...@@ -1444,12 +1446,18 @@ class PlacementCost(object):
return self.modules_w_pins[node_idx].get_type() return self.modules_w_pins[node_idx].get_type()
except IndexError: except IndexError:
# NOTE: Google's API return NONE if out of range # NOTE: Google's API return NONE if out of range
print("[INDEX OUT OF RANGE ERROR] Can not process index at {}".format(node_idx)) print("[INDEX OUT OF RANGE WARNING] Can not process index at {}".format(node_idx))
return None return None
def make_soft_macros_square(self): def make_soft_macros_square(self):
pass pass
def set_use_incremental_cost(self, use_incremental_cost):
self.use_incremental_cost = use_incremental_cost
def get_use_incremental_cost(self):
return self.use_incremental_cost
def get_macro_adjacency(self) -> list: def get_macro_adjacency(self) -> list:
""" """
Compute Adjacency Matrix Compute Adjacency Matrix
......
...@@ -238,12 +238,14 @@ class PlacementCostTest(): ...@@ -238,12 +238,14 @@ class PlacementCostTest():
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)
# TODO: Setting blockage has no effect on proxy cost computation # TODO: [IGNORE] Setting blockage has no effect on proxy cost computation
self.plc.create_blockage(0, 0, 400, 400, 1) if False:
self.plc.create_blockage(0, 0, 200, 200, 1) self.plc.create_blockage(0, 0, 400, 400, 1)
print(self.plc.get_blockages()) self.plc.create_blockage(0, 0, 200, 200, 1)
print(self.plc.make_soft_macros_square()) print(self.plc.get_blockages())
print(self.plc_os.get_soft_macros_count()) print(self.plc.make_soft_macros_square())
print(self.plc.set_use_incremental_cost(True))
print(self.plc_os.get_soft_macros_count())
# HPWL # HPWL
try: try:
......
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