# HG changeset patch # User Nina Engelhardt # Date 1346153665 -7200 # Node ID 078abaff1bc33e616eda42cc0f9c9c008c05a748 # Parent 6d03033aca59e05dc86ebb2992e12c698dbb83b2 VSs SCG ver diff -r 6d03033aca59 -r 078abaff1bc3 scripts/ucc_and_loop_graph_treatment/column_view.py --- a/scripts/ucc_and_loop_graph_treatment/column_view.py Thu May 17 20:41:06 2012 +0200 +++ b/scripts/ucc_and_loop_graph_treatment/column_view.py Tue Aug 28 13:34:25 2012 +0200 @@ -10,6 +10,9 @@ __num_idle = 0 #graph.node['start']['numcores'] * 2 __vertical_scale_factor = 0.000001 #10000.0/float(total_height) + +__cache_miss_min = 0.0002 +__cache_miss_max = 0.0007 ### saving ### def save_computed_column_view(graph,num_cores,total_height,positioning,dependencies=None,filename=None): @@ -126,7 +129,7 @@ y2 = y1 + graph.node[node]['weight'] if node[0]>= __num_idle : if positioning != None: - mp=(float(graph.node[node]['cache_misses'])/float(graph.node['start']['largestcachemiss'])) + mp=min(1,max(0, graph.node[node]['cache_misses'] - __cache_miss_min)/__cache_miss_max) f = "rgb({0},{1},{2})".format(int(math.ceil(mp*255.0)),0,int(math.ceil((1.0-mp)*255.0))) #print f # f='blue' @@ -134,9 +137,9 @@ f='red' else: f='gray' - r = sf.Rect(x1,y1* vertical_scale_factor,x2,y2* vertical_scale_factor,fill=f,fill_opacity="40%") + r = sf.Rect(x1,y1* vertical_scale_factor,x2,y2* vertical_scale_factor,fill='gray') r2 = sf.Rect(x1,(y1+graph.node[node]['work_offset'])* vertical_scale_factor,x2,(y1+graph.node[node]['work_offset']+graph.node[node]['Work_end']-graph.node[node]['Work_start'])* vertical_scale_factor,fill=f, stroke_opacity=0) - s = sf.Text((x1+x2)/2 , (y1+y2)* vertical_scale_factor/2 ,str(node),text_anchor="middle",font_size=20) + s = sf.Text((x1+x2)/2 , (y1+y2)* vertical_scale_factor/2 ,str(node),text_anchor="middle",font_size=20) #str(node)+"\r\n{0}".format(graph.node[node]['cache_misses'] * (graph.node[node]['Work_end_instrs'] - graph.node[node]['Work_start_instrs'])) if graph.node[node].has_key('AssignerInvocation_start') and graph.node[node].has_key('Assigner_start'): h = graph.node[node]['Assigner_start'] - graph.node[node]['AssignerInvocation_start'] r1 = sf.Rect(x1,y1* vertical_scale_factor,x2,(y1+h)* vertical_scale_factor,fill='green',fill_opacity="70%") @@ -168,7 +171,7 @@ core2 = graph.node[b]['core'] x2 = core2 * num_cols * __column_width + offset * __column_width + 0.5 * __node_width y2 = (positioning[b] - graph.node[b]['weight']) * vertical_scale_factor - return sf.Line(x1,y1,x2,y2,style="stroke:rgb({0},{1},{2});stroke-width:5".format(int(color[0]*255),int(color[1]*255),int(color[2]*255))) + return sf.Line(x1,y1,x2,y2,style="stroke:rgb({0},{1},{2});stroke-width:2".format(int(color[0]*255),int(color[1]*255),int(color[2]*255))) diff -r 6d03033aca59 -r 078abaff1bc3 scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py --- a/scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py Thu May 17 20:41:06 2012 +0200 +++ b/scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py Tue Aug 28 13:34:25 2012 +0200 @@ -36,6 +36,8 @@ print len(d["hwDep"]), "Hardware constraints" g = loopgraph_from_dict(d) add_attributes_to_nodes_from_file(g,counterfile) + #print nx.simple_cycles(g) + #return #cont = raw_input("Calculate and show critical path (y/N)? ") #if not cont.startswith(('y','Y')): # sys.exit() @@ -55,7 +57,7 @@ print "(Difference:", dif, "- Relative Error:", 100*float(dif)/float(lend['end']),"%)" print g.node['start']['starttimes'] print g.node['start']['tscstarttimes'] - column_view.save_computed_column_view(g,g.node['start']['numcores'],lend['end'],lend,[d["commDep"], d["dynDep"], d["singDep"], d["ctlDep"]],"{0}.svg".format(sys.argv[1])) + column_view.save_computed_column_view(g,g.node['start']['numcores'],lend['end'],lend,[d["commDep"], d["dataDep"], d["ctlDep"]],"{0}.svg".format(sys.argv[1])) #column_view.save_comparative_column_view(g,g.node['start']['numcores'],max(actual_time,lend['end']),lend) #column_view.save_tsc_scale(g,g.node['start']['numcores'],lend['end']) return # @@ -102,6 +104,10 @@ if not d.has_key("commDep"): d["commDep"] = [] d["commDep"].append(( (int(row[1]),int(row[2])) , (int(row[3]),int(row[4])) )) + if row[0] == "dataDep": + if not d.has_key("dataDep"): + d["dataDep"] = [] + d["dataDep"].append(( (int(row[1]),int(row[2])) , (int(row[3]),int(row[4])) )) if row[0] == "dynDep": if not d.has_key("dynDep"): d["dynDep"] = [] @@ -149,6 +155,7 @@ if row[0] == "event": n = (int(row[2]),int(row[3])) g.node[n][row[1]] = int(row[4]) + g.node[n]["{0}_instrs".format(row[1])] = int(row[5]) g.node[n]["{0}_cache".format(row[1])] = int(row[6]) g.node[n]['core'] = int(row[7]) g.node[n]['weight'] = 0 @@ -165,9 +172,10 @@ cachem = 0 if g.node[n].has_key('Work_end_cache') and g.node[n].has_key('Work_start_cache'): cachem += g.node[n]['Work_end_cache'] - g.node[n]['Work_start_cache'] - g.node[n]['cache_misses'] = cachem - if cachem > largestcachemiss: - largestcachemiss = cachem + instrs = g.node[n]['Work_end_instrs'] - g.node[n]['Work_start_instrs'] + g.node[n]['cache_misses'] = float(cachem) / float(instrs) + if g.node[n]['cache_misses'] > largestcachemiss: + largestcachemiss = g.node[n]['cache_misses'] weight = 0 if g.node[n].has_key('Assigner_start') and g.node[n].has_key('AssignerInvocation_start'): weight += g.node[n]['Assigner_start'] - g.node[n]['AssignerInvocation_start'] @@ -207,6 +215,7 @@ g.node['start']['tscendtime']=max(tscendtimes.values()) g.node['start']['numcores']=highestcore+1 g.node['start']['largestcachemiss']=largestcachemiss + print "Largest cache miss ratio:",largestcachemiss def path_length(graph,path): @@ -279,6 +288,8 @@ if __name__ == "__main__": + import resource + resource.setrlimit(resource.RLIMIT_STACK, (2**29,-1)) sys.setrecursionlimit(20000) #try: main() diff -r 6d03033aca59 -r 078abaff1bc3 scripts/ucc_and_loop_graph_treatment/parse_ucc.py --- a/scripts/ucc_and_loop_graph_treatment/parse_ucc.py Thu May 17 20:41:06 2012 +0200 +++ b/scripts/ucc_and_loop_graph_treatment/parse_ucc.py Tue Aug 28 13:34:25 2012 +0200 @@ -11,6 +11,7 @@ def main(): sys.setrecursionlimit(10000) if len(sys.argv)<1: + print "Usage: ", sys.argv[0], "UCCfile [Counterfile]" sys.exit() uccfile = open(sys.argv[1]) d = read_from_file(uccfile) @@ -90,14 +91,14 @@ g.add_node("start") g.add_node("end") g.add_nodes_from(d["unit"]) - g.add_edges_from(d["ctlDep"]) - g.add_edges_from(d["commDep"]) + g.add_edges_from(d["ctlDep"], color=(0,0,0)) + g.add_edges_from(d["commDep"], color=(255,0,0)) for i,(senders,receivers) in enumerate(d["NtoN"]): g.add_node("NtoN"+str(i)) for node in senders: - g.add_edge(node,"NtoN0") + g.add_edge(node,"NtoN0",color=(0,255,0)) for node in receivers: - g.add_edge("NtoN0",node) + g.add_edge("NtoN0",node,color=(0,255,0)) for node in g: if node != "start" and node != "end": if len(g.predecessors(node)) == 0: @@ -132,9 +133,9 @@ ############ drawing ############ -__rank_height = 100 -__index_width = 100 -__node_radius = 40 +__rank_height = 120 +__index_width = 120 +__node_radius = 50 def save_ucc_as_svg(graph,rankd): @@ -159,7 +160,7 @@ cy = (rank + 1)*__rank_height node_positions[node] = (cx,cy) r = __node_radius - c = sf.Ellipse(cx,cy,0,r,r,stroke='black',fill='yellow') + c = sf.Ellipse(cx,cy,0,r,r,stroke='black',fill='silver') t = sf.Text(cx,cy,str(node),font_size=20) return sf.Fig(c,t) @@ -167,14 +168,18 @@ def draw_edges(graph,node_positions): f = sf.Fig() for edge in nx.edges(graph): - f.d.append(draw_edge(edge,node_positions)) + if graph.edge[edge[0]][edge[1]].has_key('color'): + color=graph.edge[edge[0]][edge[1]]['color'] + else: + color=(0,0,0) + f.d.append(draw_edge(edge,node_positions,color)) return f -def draw_edge(edge,node_positions): +def draw_edge(edge,node_positions,color=(0,0,0)): node1,node2 = edge x1,y1 = node_positions[node1] x2,y2 = node_positions[node2] - return sf.Line(x1,y1,x2,y2,style="stroke:rgb(0,0,0);stroke-width:3") + return sf.Line(x1,y1,x2,y2,style="stroke:rgb"+repr(color)+";stroke-width:3") @@ -255,7 +260,7 @@ ############ drawing ############ -__column_width = 110 +__column_width = 150 __node_width = 100 def save_ucc_with_weight(graph, lend, rankd): @@ -292,23 +297,27 @@ if y1 == y2: y2 = y1+1 node_positions[node] = (x1,y1,x2,y2) - r = sf.Rect(x1,y1,x2,y2,stroke='black',fill='yellow') + r = sf.Rect(x1,y1,x2,y2,stroke='black',fill='silver') t = sf.Text((x1+x2)/2.0 , (y1+y2)/2.0 ,str(node),text_anchor="middle",font_size=20) return sf.Fig(r,t) def draw_edges_with_weight(graph,node_positions): f = sf.Fig() for edge in nx.edges(graph): - f.d.append(draw_edge_with_weight(edge,node_positions)) + if graph.edge[edge[0]][edge[1]].has_key('color'): + color=graph.edge[edge[0]][edge[1]]['color'] + else: + color=(0,0,0) + f.d.append(draw_edge_with_weight(edge,node_positions,color)) return f -def draw_edge_with_weight(edge,node_positions): +def draw_edge_with_weight(edge,node_positions,color): node1,node2 = edge x1_1,y1_1,x2_1,y2_1 = node_positions[node1] x1_2,y1_2,x2_2,y2_2 = node_positions[node2] m1 = (x1_1 + x2_1) / 2 m2 = (x1_2 + x2_2) / 2 - return sf.Line(m1,y2_1,m2,y1_2,style="stroke:rgb(0,0,0);stroke-width:3") + return sf.Line(m1,y2_1,m2,y1_2,style="stroke:rgb"+repr(color)+";stroke-width:3") ##########################