Mercurial > cgi-bin > hgwebdir.cgi > VMS > 2__runs_and_data
changeset 25:078abaff1bc3
VSs SCG ver
author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
---|---|
date | Tue, 28 Aug 2012 13:34:25 +0200 |
parents | 6d03033aca59 |
children | 3adfef46f3a7 |
files | scripts/ucc_and_loop_graph_treatment/column_view.py scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py scripts/ucc_and_loop_graph_treatment/parse_ucc.py |
diffstat | 3 files changed, 47 insertions(+), 24 deletions(-) [+] |
line diff
1.1 --- a/scripts/ucc_and_loop_graph_treatment/column_view.py Thu May 17 20:41:06 2012 +0200 1.2 +++ b/scripts/ucc_and_loop_graph_treatment/column_view.py Tue Aug 28 13:34:25 2012 +0200 1.3 @@ -10,6 +10,9 @@ 1.4 __num_idle = 0 #graph.node['start']['numcores'] * 2 1.5 1.6 __vertical_scale_factor = 0.000001 #10000.0/float(total_height) 1.7 + 1.8 +__cache_miss_min = 0.0002 1.9 +__cache_miss_max = 0.0007 1.10 ### saving ### 1.11 1.12 def save_computed_column_view(graph,num_cores,total_height,positioning,dependencies=None,filename=None): 1.13 @@ -126,7 +129,7 @@ 1.14 y2 = y1 + graph.node[node]['weight'] 1.15 if node[0]>= __num_idle : 1.16 if positioning != None: 1.17 - mp=(float(graph.node[node]['cache_misses'])/float(graph.node['start']['largestcachemiss'])) 1.18 + mp=min(1,max(0, graph.node[node]['cache_misses'] - __cache_miss_min)/__cache_miss_max) 1.19 f = "rgb({0},{1},{2})".format(int(math.ceil(mp*255.0)),0,int(math.ceil((1.0-mp)*255.0))) 1.20 #print f 1.21 # f='blue' 1.22 @@ -134,9 +137,9 @@ 1.23 f='red' 1.24 else: 1.25 f='gray' 1.26 - r = sf.Rect(x1,y1* vertical_scale_factor,x2,y2* vertical_scale_factor,fill=f,fill_opacity="40%") 1.27 + r = sf.Rect(x1,y1* vertical_scale_factor,x2,y2* vertical_scale_factor,fill='gray') 1.28 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) 1.29 - s = sf.Text((x1+x2)/2 , (y1+y2)* vertical_scale_factor/2 ,str(node),text_anchor="middle",font_size=20) 1.30 + 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'])) 1.31 if graph.node[node].has_key('AssignerInvocation_start') and graph.node[node].has_key('Assigner_start'): 1.32 h = graph.node[node]['Assigner_start'] - graph.node[node]['AssignerInvocation_start'] 1.33 r1 = sf.Rect(x1,y1* vertical_scale_factor,x2,(y1+h)* vertical_scale_factor,fill='green',fill_opacity="70%") 1.34 @@ -168,7 +171,7 @@ 1.35 core2 = graph.node[b]['core'] 1.36 x2 = core2 * num_cols * __column_width + offset * __column_width + 0.5 * __node_width 1.37 y2 = (positioning[b] - graph.node[b]['weight']) * vertical_scale_factor 1.38 - 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))) 1.39 + 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))) 1.40 1.41 1.42
2.1 --- a/scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py Thu May 17 20:41:06 2012 +0200 2.2 +++ b/scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py Tue Aug 28 13:34:25 2012 +0200 2.3 @@ -36,6 +36,8 @@ 2.4 print len(d["hwDep"]), "Hardware constraints" 2.5 g = loopgraph_from_dict(d) 2.6 add_attributes_to_nodes_from_file(g,counterfile) 2.7 + #print nx.simple_cycles(g) 2.8 + #return 2.9 #cont = raw_input("Calculate and show critical path (y/N)? ") 2.10 #if not cont.startswith(('y','Y')): 2.11 # sys.exit() 2.12 @@ -55,7 +57,7 @@ 2.13 print "(Difference:", dif, "- Relative Error:", 100*float(dif)/float(lend['end']),"%)" 2.14 print g.node['start']['starttimes'] 2.15 print g.node['start']['tscstarttimes'] 2.16 - 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])) 2.17 + 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])) 2.18 #column_view.save_comparative_column_view(g,g.node['start']['numcores'],max(actual_time,lend['end']),lend) 2.19 #column_view.save_tsc_scale(g,g.node['start']['numcores'],lend['end']) 2.20 return # 2.21 @@ -102,6 +104,10 @@ 2.22 if not d.has_key("commDep"): 2.23 d["commDep"] = [] 2.24 d["commDep"].append(( (int(row[1]),int(row[2])) , (int(row[3]),int(row[4])) )) 2.25 + if row[0] == "dataDep": 2.26 + if not d.has_key("dataDep"): 2.27 + d["dataDep"] = [] 2.28 + d["dataDep"].append(( (int(row[1]),int(row[2])) , (int(row[3]),int(row[4])) )) 2.29 if row[0] == "dynDep": 2.30 if not d.has_key("dynDep"): 2.31 d["dynDep"] = [] 2.32 @@ -149,6 +155,7 @@ 2.33 if row[0] == "event": 2.34 n = (int(row[2]),int(row[3])) 2.35 g.node[n][row[1]] = int(row[4]) 2.36 + g.node[n]["{0}_instrs".format(row[1])] = int(row[5]) 2.37 g.node[n]["{0}_cache".format(row[1])] = int(row[6]) 2.38 g.node[n]['core'] = int(row[7]) 2.39 g.node[n]['weight'] = 0 2.40 @@ -165,9 +172,10 @@ 2.41 cachem = 0 2.42 if g.node[n].has_key('Work_end_cache') and g.node[n].has_key('Work_start_cache'): 2.43 cachem += g.node[n]['Work_end_cache'] - g.node[n]['Work_start_cache'] 2.44 - g.node[n]['cache_misses'] = cachem 2.45 - if cachem > largestcachemiss: 2.46 - largestcachemiss = cachem 2.47 + instrs = g.node[n]['Work_end_instrs'] - g.node[n]['Work_start_instrs'] 2.48 + g.node[n]['cache_misses'] = float(cachem) / float(instrs) 2.49 + if g.node[n]['cache_misses'] > largestcachemiss: 2.50 + largestcachemiss = g.node[n]['cache_misses'] 2.51 weight = 0 2.52 if g.node[n].has_key('Assigner_start') and g.node[n].has_key('AssignerInvocation_start'): 2.53 weight += g.node[n]['Assigner_start'] - g.node[n]['AssignerInvocation_start'] 2.54 @@ -207,6 +215,7 @@ 2.55 g.node['start']['tscendtime']=max(tscendtimes.values()) 2.56 g.node['start']['numcores']=highestcore+1 2.57 g.node['start']['largestcachemiss']=largestcachemiss 2.58 + print "Largest cache miss ratio:",largestcachemiss 2.59 2.60 2.61 def path_length(graph,path): 2.62 @@ -279,6 +288,8 @@ 2.63 2.64 2.65 if __name__ == "__main__": 2.66 + import resource 2.67 + resource.setrlimit(resource.RLIMIT_STACK, (2**29,-1)) 2.68 sys.setrecursionlimit(20000) 2.69 #try: 2.70 main()
3.1 --- a/scripts/ucc_and_loop_graph_treatment/parse_ucc.py Thu May 17 20:41:06 2012 +0200 3.2 +++ b/scripts/ucc_and_loop_graph_treatment/parse_ucc.py Tue Aug 28 13:34:25 2012 +0200 3.3 @@ -11,6 +11,7 @@ 3.4 def main(): 3.5 sys.setrecursionlimit(10000) 3.6 if len(sys.argv)<1: 3.7 + print "Usage: ", sys.argv[0], "UCCfile [Counterfile]" 3.8 sys.exit() 3.9 uccfile = open(sys.argv[1]) 3.10 d = read_from_file(uccfile) 3.11 @@ -90,14 +91,14 @@ 3.12 g.add_node("start") 3.13 g.add_node("end") 3.14 g.add_nodes_from(d["unit"]) 3.15 - g.add_edges_from(d["ctlDep"]) 3.16 - g.add_edges_from(d["commDep"]) 3.17 + g.add_edges_from(d["ctlDep"], color=(0,0,0)) 3.18 + g.add_edges_from(d["commDep"], color=(255,0,0)) 3.19 for i,(senders,receivers) in enumerate(d["NtoN"]): 3.20 g.add_node("NtoN"+str(i)) 3.21 for node in senders: 3.22 - g.add_edge(node,"NtoN0") 3.23 + g.add_edge(node,"NtoN0",color=(0,255,0)) 3.24 for node in receivers: 3.25 - g.add_edge("NtoN0",node) 3.26 + g.add_edge("NtoN0",node,color=(0,255,0)) 3.27 for node in g: 3.28 if node != "start" and node != "end": 3.29 if len(g.predecessors(node)) == 0: 3.30 @@ -132,9 +133,9 @@ 3.31 3.32 ############ drawing ############ 3.33 3.34 -__rank_height = 100 3.35 -__index_width = 100 3.36 -__node_radius = 40 3.37 +__rank_height = 120 3.38 +__index_width = 120 3.39 +__node_radius = 50 3.40 3.41 3.42 def save_ucc_as_svg(graph,rankd): 3.43 @@ -159,7 +160,7 @@ 3.44 cy = (rank + 1)*__rank_height 3.45 node_positions[node] = (cx,cy) 3.46 r = __node_radius 3.47 - c = sf.Ellipse(cx,cy,0,r,r,stroke='black',fill='yellow') 3.48 + c = sf.Ellipse(cx,cy,0,r,r,stroke='black',fill='silver') 3.49 t = sf.Text(cx,cy,str(node),font_size=20) 3.50 return sf.Fig(c,t) 3.51 3.52 @@ -167,14 +168,18 @@ 3.53 def draw_edges(graph,node_positions): 3.54 f = sf.Fig() 3.55 for edge in nx.edges(graph): 3.56 - f.d.append(draw_edge(edge,node_positions)) 3.57 + if graph.edge[edge[0]][edge[1]].has_key('color'): 3.58 + color=graph.edge[edge[0]][edge[1]]['color'] 3.59 + else: 3.60 + color=(0,0,0) 3.61 + f.d.append(draw_edge(edge,node_positions,color)) 3.62 return f 3.63 3.64 -def draw_edge(edge,node_positions): 3.65 +def draw_edge(edge,node_positions,color=(0,0,0)): 3.66 node1,node2 = edge 3.67 x1,y1 = node_positions[node1] 3.68 x2,y2 = node_positions[node2] 3.69 - return sf.Line(x1,y1,x2,y2,style="stroke:rgb(0,0,0);stroke-width:3") 3.70 + return sf.Line(x1,y1,x2,y2,style="stroke:rgb"+repr(color)+";stroke-width:3") 3.71 3.72 3.73 3.74 @@ -255,7 +260,7 @@ 3.75 3.76 ############ drawing ############ 3.77 3.78 -__column_width = 110 3.79 +__column_width = 150 3.80 __node_width = 100 3.81 3.82 def save_ucc_with_weight(graph, lend, rankd): 3.83 @@ -292,23 +297,27 @@ 3.84 if y1 == y2: 3.85 y2 = y1+1 3.86 node_positions[node] = (x1,y1,x2,y2) 3.87 - r = sf.Rect(x1,y1,x2,y2,stroke='black',fill='yellow') 3.88 + r = sf.Rect(x1,y1,x2,y2,stroke='black',fill='silver') 3.89 t = sf.Text((x1+x2)/2.0 , (y1+y2)/2.0 ,str(node),text_anchor="middle",font_size=20) 3.90 return sf.Fig(r,t) 3.91 3.92 def draw_edges_with_weight(graph,node_positions): 3.93 f = sf.Fig() 3.94 for edge in nx.edges(graph): 3.95 - f.d.append(draw_edge_with_weight(edge,node_positions)) 3.96 + if graph.edge[edge[0]][edge[1]].has_key('color'): 3.97 + color=graph.edge[edge[0]][edge[1]]['color'] 3.98 + else: 3.99 + color=(0,0,0) 3.100 + f.d.append(draw_edge_with_weight(edge,node_positions,color)) 3.101 return f 3.102 3.103 -def draw_edge_with_weight(edge,node_positions): 3.104 +def draw_edge_with_weight(edge,node_positions,color): 3.105 node1,node2 = edge 3.106 x1_1,y1_1,x2_1,y2_1 = node_positions[node1] 3.107 x1_2,y1_2,x2_2,y2_2 = node_positions[node2] 3.108 m1 = (x1_1 + x2_1) / 2 3.109 m2 = (x1_2 + x2_2) / 2 3.110 - return sf.Line(m1,y2_1,m2,y1_2,style="stroke:rgb(0,0,0);stroke-width:3") 3.111 + return sf.Line(m1,y2_1,m2,y1_2,style="stroke:rgb"+repr(color)+";stroke-width:3") 3.112 3.113 3.114 ##########################