Merge branch 'dev'

This commit is contained in:
Matt Guthaus 2019-01-30 14:16:52 -08:00
commit d735c095d2
11 changed files with 46 additions and 47 deletions

View File

@ -11,9 +11,9 @@ import sys
def check(check, str): def check(check, str):
(frame, filename, line_number, function_name, lines,
index) = inspect.getouterframes(inspect.currentframe())[1]
if not check: if not check:
(frame, filename, line_number, function_name, lines,
index) = inspect.getouterframes(inspect.currentframe())[1]
sys.stderr.write("ERROR: file {0}: line {1}: {2}\n".format( sys.stderr.write("ERROR: file {0}: line {1}: {2}\n".format(
os.path.basename(filename), line_number, str)) os.path.basename(filename), line_number, str))
log("ERROR: file {0}: line {1}: {2}\n".format( log("ERROR: file {0}: line {1}: {2}\n".format(

View File

@ -1,4 +1,4 @@
word_size = 8 word_size = 32
num_words = 128 num_words = 128
tech_name = "scn4m_subm" tech_name = "scn4m_subm"

View File

@ -732,25 +732,18 @@ class VlsiLayout:
Return all gshapes on a given layer in [llx, lly, urx, ury] format and Return all gshapes on a given layer in [llx, lly, urx, ury] format and
user units. user units.
""" """
boundaries = [] boundaries = set()
for TreeUnit in self.xyTree: for TreeUnit in self.xyTree:
#print(TreeUnit[0]) #print(TreeUnit[0])
boundaries.extend(self.getShapesInStructure(layer,TreeUnit)) boundaries.update(self.getShapesInStructure(layer,TreeUnit))
# Remove duplicates without defining a hash
# (could be sped up by creating hash and using list(set())
new_boundaries = []
for boundary in boundaries:
if boundary not in new_boundaries:
new_boundaries.append(boundary)
# Convert to user units # Convert to user units
boundaries = [] user_boundaries = []
for boundary in new_boundaries: for boundary in boundaries:
boundaries.append([boundary[0]*self.units[0],boundary[1]*self.units[0], user_boundaries.append([boundary[0]*self.units[0],boundary[1]*self.units[0],
boundary[2]*self.units[0],boundary[3]*self.units[0]]) boundary[2]*self.units[0],boundary[3]*self.units[0]])
return boundaries return user_boundaries
def getShapesInStructure(self,layer,structure): def getShapesInStructure(self,layer,structure):
@ -764,7 +757,9 @@ class VlsiLayout:
boundaries = [] boundaries = []
for boundary in self.structures[str(structureName)].boundaries: for boundary in self.structures[str(structureName)].boundaries:
# FIXME: Right now, this only supports rectangular shapes! # FIXME: Right now, this only supports rectangular shapes!
#debug.check(len(boundary.coordinates)==5,"Non-rectangular shape.") # We should trigger an error but some FreePDK45 library cells contain paths.
# These get saved fine, but we cannot parse them as blockages...
#debug.check(len(boundary.coordinates)==5,"Non-rectangular shapes are not supported.")
if len(boundary.coordinates)!=5: if len(boundary.coordinates)!=5:
continue continue
if layer==boundary.drawingLayer: if layer==boundary.drawingLayer:
@ -774,9 +769,9 @@ class VlsiLayout:
boundaryRect=[left_bottom[0],left_bottom[1],right_top[0],right_top[1]] boundaryRect=[left_bottom[0],left_bottom[1],right_top[0],right_top[1]]
# perform the rotation # perform the rotation
boundaryRect=self.transformRectangle(boundaryRect,structureuVector,structurevVector) boundaryRect=self.transformRectangle(boundaryRect,structureuVector,structurevVector)
# add the offset # add the offset and make it a tuple
boundaryRect=[boundaryRect[0]+structureOrigin[0].item(),boundaryRect[1]+structureOrigin[1].item(), boundaryRect=(boundaryRect[0]+structureOrigin[0].item(),boundaryRect[1]+structureOrigin[1].item(),
boundaryRect[2]+structureOrigin[0].item(),boundaryRect[3]+structureOrigin[1].item()] boundaryRect[2]+structureOrigin[0].item(),boundaryRect[3]+structureOrigin[1].item())
boundaries.append(boundaryRect) boundaries.append(boundaryRect)
return boundaries return boundaries

View File

@ -21,8 +21,8 @@ class grid:
""" Initialize the map and define the costs. """ """ Initialize the map and define the costs. """
# list of the source/target grid coordinates # list of the source/target grid coordinates
self.source = [] self.source = set()
self.target = [] self.target = set()
self.track_width = track_width self.track_width = track_width
self.track_widths = [self.track_width, self.track_width, 1.0] self.track_widths = [self.track_width, self.track_width, 1.0]
@ -71,7 +71,8 @@ class grid:
self.map[n].path=value self.map[n].path=value
def clear_blockages(self): def clear_blockages(self):
self.set_blocked(set(self.map.keys()),False) for k in self.map:
self.map[k].blocked=False
def set_source(self,n,value=True): def set_source(self,n,value=True):
if isinstance(n, (list,tuple,set,frozenset)): if isinstance(n, (list,tuple,set,frozenset)):
@ -80,7 +81,7 @@ class grid:
else: else:
self.add_map(n) self.add_map(n)
self.map[n].source=value self.map[n].source=value
self.source.append(n) self.source.add(n)
def set_target(self,n,value=True): def set_target(self,n,value=True):
if isinstance(n, (list,tuple,set,frozenset)): if isinstance(n, (list,tuple,set,frozenset)):
@ -89,7 +90,7 @@ class grid:
else: else:
self.add_map(n) self.add_map(n)
self.map[n].target=value self.map[n].target=value
self.target.append(n) self.target.add(n)
def add_source(self,track_list,value=True): def add_source(self,track_list,value=True):
@ -121,7 +122,7 @@ class grid:
for item in n: for item in n:
self.add_map(item) self.add_map(item)
else: else:
if n not in self.map.keys(): if n not in self.map:
self.map[n]=grid_cell() self.map[n]=grid_cell()

View File

@ -204,7 +204,7 @@ class router(router_tech):
continue continue
# Combine if at least 1 grid cell is adjacent # Combine if at least 1 grid cell is adjacent
if pg1.adjacent(pg2): if pg1.adjacent(pg2):
if not index1 in adjacent_pins.keys(): if not index1 in adjacent_pins:
adjacent_pins[index1] = set([index2]) adjacent_pins[index1] = set([index2])
else: else:
adjacent_pins[index1].add(index2) adjacent_pins[index1].add(index2)
@ -341,7 +341,7 @@ class router(router_tech):
# Block all of the pin components (some will be unblocked if they're a source/target) # Block all of the pin components (some will be unblocked if they're a source/target)
# Also block the previous routes # Also block the previous routes
for name in self.pin_groups.keys(): for name in self.pin_groups:
blockage_grids = {y for x in self.pin_groups[name] for y in x.grids} blockage_grids = {y for x in self.pin_groups[name] for y in x.grids}
self.set_blockages(blockage_grids,True) self.set_blockages(blockage_grids,True)
blockage_grids = {y for x in self.pin_groups[name] for y in x.blockages} blockage_grids = {y for x in self.pin_groups[name] for y in x.blockages}
@ -745,7 +745,7 @@ class router(router_tech):
group_map = {} group_map = {}
for pin in pin_list: for pin in pin_list:
gid = group_id[pin] gid = group_id[pin]
if gid not in group_map.keys(): if gid not in group_map:
group_map[gid] = pin_group(name=pin_name, pin_set=[], router=self) group_map[gid] = pin_group(name=pin_name, pin_set=[], router=self)
# We always add it to the first set since they are touching # We always add it to the first set since they are touching
group_map[gid].pins[0].add(pin) group_map[gid].pins[0].add(pin)
@ -803,7 +803,7 @@ class router(router_tech):
put a rectangle over it. It does not enclose grid squares that are blocked put a rectangle over it. It does not enclose grid squares that are blocked
by other shapes. by other shapes.
""" """
for pin_name in self.pin_groups.keys(): for pin_name in self.pin_groups:
debug.info(1,"Enclosing pins for {}".format(pin_name)) debug.info(1,"Enclosing pins for {}".format(pin_name))
for pg in self.pin_groups[pin_name]: for pg in self.pin_groups[pin_name]:
pg.enclose_pin() pg.enclose_pin()
@ -1091,7 +1091,7 @@ class router(router_tech):
if show_all_grids: if show_all_grids:
self.rg.add_all_grids() self.rg.add_all_grids()
for g in self.rg.map.keys(): for g in self.rg.map:
self.annotate_grid(g) self.annotate_grid(g)
if show_blockages: if show_blockages:
@ -1105,12 +1105,11 @@ class router(router_tech):
height=ur.y-ll.y) height=ur.y-ll.y)
if show_blockage_grids: if show_blockage_grids:
self.set_blockages(self.blocked_grids,True) self.set_blockages(self.blocked_grids,True)
grid_keys=self.rg.map.keys() for g in self.rg.map:
for g in grid_keys:
self.annotate_grid(g) self.annotate_grid(g)
if show_enclosures: if show_enclosures:
for key in self.pin_groups.keys(): for key in self.pin_groups:
for pg in self.pin_groups[key]: for pg in self.pin_groups[key]:
if not pg.enclosed: if not pg.enclosed:
continue continue

View File

@ -62,7 +62,8 @@ class signal_grid(grid):
# We set a cost bound of the HPWL for run-time. This can be # We set a cost bound of the HPWL for run-time. This can be
# over-ridden if the route fails due to pruning a feasible solution. # over-ridden if the route fails due to pruning a feasible solution.
cost_bound = detour_scale*self.cost_to_target(self.source[0])*grid.PREFERRED_COST any_source_element = next(iter(self.source))
cost_bound = detour_scale*self.cost_to_target(any_source_element)*grid.PREFERRED_COST
# Check if something in the queue is already a source and a target! # Check if something in the queue is already a source and a target!
for s in self.source: for s in self.source:
@ -142,10 +143,9 @@ class signal_grid(grid):
Either point can have positive or negative coordinates. Either point can have positive or negative coordinates.
Include the via penalty if there is one. Include the via penalty if there is one.
""" """
hpwl = max(abs(src.x-dest.x),abs(dest.x-src.x)) hpwl = abs(src.x-dest.x)
hpwl += max(abs(src.y-dest.y),abs(dest.y-src.y)) hpwl += abs(src.y-dest.y)
hpwl += max(abs(src.z-dest.z),abs(dest.z-src.z)) if src.x!=dest.x and src.y!=dest.y:
if src.x!=dest.x or src.y!=dest.y:
hpwl += grid.VIA_COST hpwl += grid.VIA_COST
return hpwl return hpwl
@ -154,7 +154,8 @@ class signal_grid(grid):
Find the cheapest HPWL distance to any target point ignoring Find the cheapest HPWL distance to any target point ignoring
blockages for A* search. blockages for A* search.
""" """
cost = self.hpwl(source,self.target[0]) any_target_element = next(iter(self.target))
cost = self.hpwl(source,any_target_element)
for t in self.target: for t in self.target:
cost = min(self.hpwl(source,t),cost) cost = min(self.hpwl(source,t),cost)

View File

@ -20,8 +20,8 @@ class supply_grid(signal_grid):
def reinit(self): def reinit(self):
""" Reinitialize everything for a new route. """ """ Reinitialize everything for a new route. """
self.source = [] self.source = set()
self.target = [] self.target = set()
# Reset all the cells in the map # Reset all the cells in the map
for p in self.map.values(): for p in self.map.values():
p.reset() p.reset()

View File

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
python3 -m cProfile -o profile.dat ./openram.py example_config_scn4m_subm.py -v python3 -m cProfile -o profile.dat ./openram.py example_configs/medium_config_scn4m_subm.py -v | tee -i medium.log
echo "Run view_profile.py to view results" echo "Run view_profile.py to view results"

View File

@ -1,6 +1,9 @@
#!/usr/bin/env python3
import pstats import pstats
p = pstats.Stats(profile.dat) p = pstats.Stats("profile.dat")
p.strip_dirs() p.strip_dirs()
p.sort_stats(cumulative) #p.sort_stats("cumulative")
p.print_stats(50) p.sort_stats("tottime")
#p.print_stats(50)
p.print_stats()