Commit 949ea496 by Dinple

runnable on CT ver 1.0

parent 4eed8ea6
...@@ -197,7 +197,7 @@ class CircuitEnv(object): ...@@ -197,7 +197,7 @@ class CircuitEnv(object):
self._observation_extractor = observation_extractor.ObservationExtractor( self._observation_extractor = observation_extractor.ObservationExtractor(
plc=self._plc) plc=self._plc)
print(getframeinfo(currentframe()).lineno, '\n', np.array(self._plc.get_node_mask(13333)).reshape(35,33)) # print(getframeinfo(currentframe()).lineno, '\n', np.array(self._plc.get_node_mask(13333)).reshape(35,33))
if self._make_soft_macros_square: if self._make_soft_macros_square:
# It is better to make the shape of soft macros square before using # It is better to make the shape of soft macros square before using
# analytical std cell placers like FD. # analytical std cell placers like FD.
...@@ -218,10 +218,10 @@ class CircuitEnv(object): ...@@ -218,10 +218,10 @@ class CircuitEnv(object):
self._sorted_node_indices = placement_util.get_ordered_node_indices( self._sorted_node_indices = placement_util.get_ordered_node_indices(
mode='descending_size_macro_first', plc=self._plc) mode='descending_size_macro_first', plc=self._plc)
print(len(self._sorted_node_indices)) # print(len(self._sorted_node_indices))
self._sorted_soft_macros = self._sorted_node_indices[self._num_hard_macros:] self._sorted_soft_macros = self._sorted_node_indices[self._num_hard_macros:]
print(len(self._sorted_soft_macros)) # print(len(self._sorted_soft_macros))
# Generate a map from actual macro_index to its position in # Generate a map from actual macro_index to its position in
# self.macro_indices. Needed because node adjacency matrix is in the same # self.macro_indices. Needed because node adjacency matrix is in the same
......
...@@ -1568,7 +1568,7 @@ class PlacementCost(object): ...@@ -1568,7 +1568,7 @@ class PlacementCost(object):
if (cell_region == 1).all(): if (cell_region == 1).all():
temp_node_mask[i][j] = 1 temp_node_mask[i][j] = 1
return temp_node_mask return temp_node_mask.flatten()
def get_node_mask(self, node_idx: int, node_name: str=None) -> list: def get_node_mask(self, node_idx: int, node_name: str=None) -> list:
""" """
...@@ -1589,13 +1589,17 @@ class PlacementCost(object): ...@@ -1589,13 +1589,17 @@ class PlacementCost(object):
self.grid_width = float(self.width/self.grid_col) self.grid_width = float(self.width/self.grid_col)
self.grid_height = float(self.height/self.grid_row) self.grid_height = float(self.height/self.grid_row)
# print(self.grid_col, self.grid_row)
# print(mod_w*mod_h)
for i in range(self.grid_row): for i in range(self.grid_row):
for j in range(self.grid_col): for j in range(self.grid_col):
# try every location # try every location
# construct block based on current module # construct block based on current module
temp_x = i * self.grid_width + (self.grid_width/2) temp_x = j * self.grid_width + (self.grid_width/2)
temp_y = j * self.grid_height + (self.grid_height/2) temp_y = i * self.grid_height + (self.grid_height/2)
mod_block = Block( mod_block = Block(
x_max=temp_x + (mod_w/2), x_max=temp_x + (mod_w/2),
...@@ -1603,10 +1607,11 @@ class PlacementCost(object): ...@@ -1603,10 +1607,11 @@ class PlacementCost(object):
x_min=temp_x - (mod_w/2), x_min=temp_x - (mod_w/2),
y_min=temp_y - (mod_h/2) y_min=temp_y - (mod_h/2)
) )
# check OOB # check OOB
if self.__overlap_area( if abs(self.__overlap_area(
block_i=canvas_block, block_j=mod_block) != (mod_w*mod_h): block_i=canvas_block, block_j=mod_block) - (mod_w*mod_h)) > 1e-8:
# print(i, j, self.__overlap_area(
# block_i=canvas_block, block_j=mod_block))
temp_node_mask[i][j] = 0 temp_node_mask[i][j] = 0
else: else:
for pmod_idx in self.placed_macro: for pmod_idx in self.placed_macro:
...@@ -1627,7 +1632,7 @@ class PlacementCost(object): ...@@ -1627,7 +1632,7 @@ class PlacementCost(object):
if self.__overlap_area(block_i=pmod_block, block_j=mod_block) > 0: if self.__overlap_area(block_i=pmod_block, block_j=mod_block) > 0:
temp_node_mask[i][j] = 0 temp_node_mask[i][j] = 0
return temp_node_mask return temp_node_mask.flatten()
def get_node_type(self, node_idx: int) -> str: def get_node_type(self, node_idx: int) -> str:
...@@ -2056,6 +2061,7 @@ class PlacementCost(object): ...@@ -2056,6 +2061,7 @@ class PlacementCost(object):
if not mod.get_fix_flag(): if not mod.get_fix_flag():
mod.set_placed_flag(True) mod.set_placed_flag(True)
self.placed_macro.remove(node_idx)
# update flag # update flag
self.FLAG_UPDATE_CONGESTION = True self.FLAG_UPDATE_CONGESTION = True
self.FLAG_UPDATE_DENSITY = True self.FLAG_UPDATE_DENSITY = True
...@@ -2076,6 +2082,7 @@ class PlacementCost(object): ...@@ -2076,6 +2082,7 @@ class PlacementCost(object):
if mod.get_placed_flag(): if mod.get_placed_flag():
mod.set_placed_flag(False) mod.set_placed_flag(False)
self.placed_macro = []
# update flag # update flag
self.FLAG_UPDATE_CONGESTION = True self.FLAG_UPDATE_CONGESTION = True
self.FLAG_UPDATE_DENSITY = True self.FLAG_UPDATE_DENSITY = True
......
...@@ -586,8 +586,10 @@ class PlacementCostTest(): ...@@ -586,8 +586,10 @@ class PlacementCostTest():
NODE_TO_PLACE_IDX = 0 NODE_TO_PLACE_IDX = 0
CELL_TO_PLACE_IDX = 6 CELL_TO_PLACE_IDX = 6
print("MASK FOR PLACING FIRST NODE:") print("MASK FOR PLACING FIRST NODE:")
self.plc_util_os.display_canvas(annotate=False)
print(np.flip(np.array(self.plc_util_os.get_node_mask(NODE_TO_PLACE_IDX)).reshape(self.GRID_ROW,self.GRID_COL), axis=0)) print(np.flip(np.array(self.plc_util_os.get_node_mask(NODE_TO_PLACE_IDX)).reshape(self.GRID_ROW,self.GRID_COL), axis=0))
print(np.flip(np.array(self.plc_util.get_node_mask(NODE_TO_PLACE_IDX)).reshape(self.GRID_ROW,self.GRID_COL), axis=0)) print(np.flip(np.array(self.plc_util.get_node_mask(NODE_TO_PLACE_IDX)).reshape(self.GRID_ROW,self.GRID_COL), axis=0))
exit(0)
self.plc_util_os.place_node(NODE_TO_PLACE_IDX, CELL_TO_PLACE_IDX) self.plc_util_os.place_node(NODE_TO_PLACE_IDX, CELL_TO_PLACE_IDX)
self.plc_util.place_node(NODE_TO_PLACE_IDX, CELL_TO_PLACE_IDX) self.plc_util.place_node(NODE_TO_PLACE_IDX, CELL_TO_PLACE_IDX)
...@@ -630,11 +632,15 @@ class PlacementCostTest(): ...@@ -630,11 +632,15 @@ class PlacementCostTest():
# print(np.array2string(env._current_mask.reshape(128, 128)), sep=']') # print(np.array2string(env._current_mask.reshape(128, 128)), sep=']')
# env_os = environment.CircuitEnv( env_os = environment.CircuitEnv(
# _plc=plc_client_os, _plc=plc_client_os,
# create_placement_cost_fn=placement_util.create_placement_cost, create_placement_cost_fn=placement_util.create_placement_cost,
# netlist_file=self.NETLIST_PATH, netlist_file=self.NETLIST_PATH,
# init_placement=self.PLC_PATH) init_placement=self.PLC_PATH)
# print(np.array(env_os._plc.get_node_mask(13333)).reshape(33,35))
# print(np.array(env._plc.get_node_mask(13333)).reshape(33,35))
assert (env_os._get_mask() == env._get_mask()).all()
print(env_os._get_obs().keys())
print(" ++++++++++++++++++++++++++++++") print(" ++++++++++++++++++++++++++++++")
print(" +++ TEST ENVIRONMENT: PASS +++") print(" +++ TEST ENVIRONMENT: PASS +++")
...@@ -692,12 +698,12 @@ def main(args): ...@@ -692,12 +698,12 @@ def main(args):
smooth=args.smooth) smooth=args.smooth)
# PCT.test_metadata() # PCT.test_metadata()
PCT.test_proxy_cost() # PCT.test_proxy_cost()
# 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.test_environment() PCT.test_environment()
if __name__ == '__main__': if __name__ == '__main__':
app.run(main, flags_parser=parse_flags) app.run(main, flags_parser=parse_flags)
\ No newline at end of file
...@@ -23,13 +23,13 @@ node { ...@@ -23,13 +23,13 @@ node {
attr { attr {
key: "x" key: "x"
value { value {
f: 399 f: 300
} }
} }
attr { attr {
key: "y" key: "y"
value { value {
f: 399 f: 300
} }
} }
attr { attr {
...@@ -44,7 +44,7 @@ node { ...@@ -44,7 +44,7 @@ node {
attr { attr {
key: "height" key: "height"
value { value {
f: 50 f: 200
} }
} }
attr { attr {
...@@ -74,7 +74,7 @@ node { ...@@ -74,7 +74,7 @@ node {
attr { attr {
key: "width" key: "width"
value { value {
f: 50 f: 200
} }
} }
} }
...@@ -96,31 +96,31 @@ node { ...@@ -96,31 +96,31 @@ node {
attr { attr {
key: "x_offset" key: "x_offset"
value { value {
f: -25 f: -75
} }
} }
attr { attr {
key: "y_offset" key: "y_offset"
value { value {
f: -25 f: -75
} }
} }
attr { attr {
key: "x" key: "x"
value { value {
f: 374 f: 0
} }
} }
attr { attr {
key: "y" key: "y"
value { value {
f: 374 f: 0
} }
} }
attr { attr {
key: "weight" key: "weight"
value { value {
f: 1000 f: 1
} }
} }
} }
...@@ -141,31 +141,31 @@ node { ...@@ -141,31 +141,31 @@ node {
attr { attr {
key: "x_offset" key: "x_offset"
value { value {
f: -25 f: -75
} }
} }
attr { attr {
key: "y_offset" key: "y_offset"
value { value {
f: 25 f: 75
} }
} }
attr { attr {
key: "x" key: "x"
value { value {
f: 374 f: 0
} }
} }
attr { attr {
key: "y" key: "y"
value { value {
f: 424 f: 0
} }
} }
attr { attr {
key: "weight" key: "weight"
value { value {
f: 1000 f: 1
} }
} }
} }
...@@ -186,25 +186,25 @@ node { ...@@ -186,25 +186,25 @@ node {
attr { attr {
key: "x_offset" key: "x_offset"
value { value {
f: 25 f: 75
} }
} }
attr { attr {
key: "y_offset" key: "y_offset"
value { value {
f: -25 f: -75
} }
} }
attr { attr {
key: "x" key: "x"
value { value {
f: 75 f: 0
} }
} }
attr { attr {
key: "y" key: "y"
value { value {
f: 25 f: 0
} }
} }
} }
...@@ -225,25 +225,25 @@ node { ...@@ -225,25 +225,25 @@ node {
attr { attr {
key: "x_offset" key: "x_offset"
value { value {
f: 25 f: 75
} }
} }
attr { attr {
key: "y_offset" key: "y_offset"
value { value {
f: 25 f: 75
} }
} }
attr { attr {
key: "x" key: "x"
value { value {
f: 75 f: 0
} }
} }
attr { attr {
key: "y" key: "y"
value { value {
f: 75 f: 0
} }
} }
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# Routes used by macros, hor : 51.79 ver : 51.79 # Routes used by macros, hor : 51.79 ver : 51.79
# Smoothing factor : 2 # Smoothing factor : 2
# Overlap threshold : 0.004 # Overlap threshold : 0.004
#s #
# #
# #
# Counts of node types: # Counts of node types:
......
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