Mercurial > cgi-bin > hgwebdir.cgi > VMS > 2__runs_and_data
changeset 21:3092eb030708
cleaned up visualization code
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Thu, 29 Mar 2012 18:40:59 +0200 |
| parents | 0175af93cc54 |
| children | 13a3ee4c9608 |
| files | scripts/ucc_and_loop_graph_treatment/column_view.py scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py |
| diffstat | 2 files changed, 86 insertions(+), 42 deletions(-) [+] |
line diff
1.1 --- a/scripts/ucc_and_loop_graph_treatment/column_view.py Mon Mar 12 15:27:28 2012 +0100 1.2 +++ b/scripts/ucc_and_loop_graph_treatment/column_view.py Thu Mar 29 18:40:59 2012 +0200 1.3 @@ -1,19 +1,18 @@ 1.4 #!/usr/bin/python 1.5 1.6 import svgfig as sf 1.7 +import colorsys 1.8 1.9 -__column_width = 100 1.10 +__column_width = 110 1.11 +__node_width = 100 1.12 1.13 +__num_idle = 0 #graph.node['start']['numcores'] * 2 1.14 1.15 - 1.16 -def fig_from_node(graph,node,positioning=None): 1.17 +def fig_from_node(graph,node,num_cols,offset,positioning=None): 1.18 """Build globally positioned node representation.""" 1.19 core = graph.node[node]['core'] 1.20 - if positioning==None: 1.21 - x1 = core * 3 * __column_width + __column_width 1.22 - else: 1.23 - x1 = core * 3 * __column_width + 2 * __column_width 1.24 - x2 = x1 + __column_width 1.25 + x1 = core * num_cols * __column_width + offset * __column_width 1.26 + x2 = x1 + __node_width 1.27 if positioning != None: 1.28 y1 = positioning[node] - graph.node[node]['weight'] 1.29 elif graph.node[node].has_key('AssignerInvocation_start'): 1.30 @@ -29,26 +28,27 @@ 1.31 else: 1.32 raise NameError('Node insufficiently annotated') 1.33 y2 = y1 + graph.node[node]['weight'] 1.34 - if node[0]>= 2*graph.node['start']['numcores']: 1.35 + if node[0]>= __num_idle : 1.36 if positioning != None: 1.37 f='blue' 1.38 else: 1.39 f='red' 1.40 else: 1.41 f='gray' 1.42 - r = sf.Rect(x1,y1,x2,y2,fill=f) 1.43 - s = sf.Text((x1+x2)/2 , (y1+y2)/2 ,str(node),text_anchor="middle") 1.44 + r = sf.Rect(x1,y1,x2,y2,fill=f,fill_opacity="40%") 1.45 + r2 = sf.Rect(x1,y1+graph.node[node]['work_offset'],x2,y1+graph.node[node]['work_offset']+graph.node[node]['Work_end']-graph.node[node]['Work_start'],fill=f, stroke_opacity=0) 1.46 + s = sf.Text((x1+x2)/2 , (y1+y2)/2 ,str(node),text_anchor="middle",font_size=20) 1.47 if graph.node[node].has_key('AssignerInvocation_start') and graph.node[node].has_key('Assigner_start'): 1.48 h = graph.node[node]['Assigner_start'] - graph.node[node]['AssignerInvocation_start'] 1.49 r1 = sf.Rect(x1,y1,x2,y1+h,fill='green',fill_opacity="70%") 1.50 - return sf.Fig(r,r1,s) 1.51 - return sf.Fig(r,s) 1.52 + return sf.Fig(r,r1,r2,s) 1.53 + return sf.Fig(r,r2,s) 1.54 1.55 -def tsc_fig_from_node(graph,node,maxh): 1.56 +def tsc_fig_from_node(graph,node,num_cols,offset,maxh): 1.57 tscstarttime = graph.node['start']['tscstarttime'] 1.58 core = graph.node[node]['core'] 1.59 - x1 = 3 * core * __column_width 1.60 - x2 = x1 + __column_width 1.61 + x1 = num_cols * core * __column_width + offset * __column_width 1.62 + x2 = x1 + __node_width 1.63 y1 = graph.node[node]['Timestamp_start'] - tscstarttime 1.64 if graph.node[node].has_key('Timestamp_end'): 1.65 y2 = graph.node[node]['Timestamp_end'] - tscstarttime 1.66 @@ -67,43 +67,81 @@ 1.67 pass 1.68 return sf.Fig(r,s),maxh 1.69 1.70 -def fig_nodes(graph,vertical_scale_factor,positioning=None): 1.71 +def fig_nodes(graph,vertical_scale_factor,num_cols,offset,positioning=None): 1.72 """Build all nodes.""" 1.73 nodes = [] 1.74 for node in graph: 1.75 if node != 'start' and node != 'end': 1.76 try: 1.77 - nodes.append(fig_from_node(graph,node,positioning=positioning)) 1.78 + nodes.append(fig_from_node(graph,node,num_cols,offset,positioning=positioning)) 1.79 except Exception as e: 1.80 print node,e 1.81 - return sf.Fig(*nodes,trans="x,{0}*y".format(vertical_scale_factor)) 1.82 + return sf.Fig(*nodes)#,trans="x,{0}*y".format(vertical_scale_factor)) 1.83 1.84 -def save_column_view(graph,num_cores,total_height,positioning=None): 1.85 - vertical_scale_factor = 10000.0/float(total_height) 1.86 - f = sf.Fig(fig_nodes(graph,vertical_scale_factor,positioning=positioning)) 1.87 - f.d.append(get_tsc_scale(graph,num_cores,total_height)) 1.88 - if positioning!=None: 1.89 - f.d.append(fig_nodes(graph,vertical_scale_factor)) 1.90 - w = 3*__column_width*num_cores 1.91 - c = sf.canvas(f.SVG(),width="{0}px".format(w),height="10000px",viewBox='0 0 {0} 10000'.format(w)) 1.92 - c.save() 1.93 - 1.94 -def get_tsc_scale(graph,num_cores,total_height): 1.95 +def get_tsc_scale(graph,num_cores,num_cols,offset): 1.96 nodes=sf.Fig() 1.97 maxh = 0 1.98 for node in graph: 1.99 if node != 'start' and node != 'end': 1.100 try: 1.101 - n , maxh = tsc_fig_from_node(graph,node,maxh) 1.102 + n , maxh = tsc_fig_from_node(graph,node,num_cols,offset,maxh) 1.103 nodes.d.append(n) 1.104 except Exception as e: 1.105 print node,e 1.106 - nodes.trans = "x,{0}*y".format(10000.0/float(total_height)) 1.107 + #nodes.trans = "x,{0}*y".format(10000.0/float(total_height)) 1.108 return nodes 1.109 1.110 +def draw_dep(graph,num_cores,num_cols,offset,positioning,dep,color=(0,0,0)): 1.111 + a,b = dep 1.112 + core1 = graph.node[a]['core'] 1.113 + x1 = core1 * num_cols * __column_width + offset * __column_width + 0.5 * __column_width 1.114 + y1 = positioning[a] 1.115 + core2 = graph.node[b]['core'] 1.116 + x2 = core2 * num_cols * __column_width + offset * __column_width + 0.5 * __column_width 1.117 + y2 = positioning[b] - graph.node[b]['weight'] 1.118 + return sf.Line(x1,y1,x2,y2,style="stroke:rgb({},{},{});stroke-width:3".format(int(color[0]*255),int(color[1]*255),int(color[2]*255))) 1.119 + 1.120 + 1.121 +def draw_cross_core_deps(graph,num_cores,num_cols,offset,positioning,dependencies): 1.122 + f = sf.Fig() 1.123 + hue = 0 1.124 + hue_incr = 1.0/len(dependencies) 1.125 + for depl in dependencies: 1.126 + for a,b in depl: 1.127 + if graph.node[a]['core'] != graph.node[b]['core']: 1.128 + f.d.append(draw_dep(graph,num_cores,num_cols,offset,positioning,(a,b),colorsys.hsv_to_rgb(hue,1,1))) 1.129 + hue = hue + hue_incr 1.130 + return f 1.131 + 1.132 +def save_comparative_column_view(graph,num_cores,total_height,positioning=None): 1.133 + if positioning == None: 1.134 + num_cols = 2 1.135 + else: 1.136 + num_cols = 3 1.137 + vertical_scale_factor = 10000.0/float(total_height) 1.138 + f = sf.Fig() 1.139 + f.d.append(get_tsc_scale(graph,num_cores,num_cols,0)) 1.140 + f.d.append(fig_nodes(graph,num_cols,1,positioning=positioning)) 1.141 + if positioning!=None: 1.142 + f.d.append(fig_nodes(graph,num_cols,2)) 1.143 + w = __num_cols*__column_width*num_cores 1.144 + f.trans = "x,{0}*y".format(10000.0/float(total_height)) 1.145 + c = sf.canvas(f.SVG(),width="{0}px".format(w),height="10000px",viewBox='0 0 {0} 10000'.format(w)) 1.146 + c.save() 1.147 + 1.148 +def save_computed_column_view(graph,num_cores,total_height,positioning,dependencies=None): 1.149 + vertical_scale_factor = 10000.0/float(total_height) 1.150 + __num_cols = 1 1.151 + f = sf.Fig(fig_nodes(graph,vertical_scale_factor,1,0,positioning)) 1.152 + if dependencies != None: 1.153 + f.d.append(draw_cross_core_deps(graph,num_cores,1,0,positioning,dependencies)) 1.154 + f.trans = "x,{0}*y".format(10000.0/float(total_height)) 1.155 + w = __num_cols*__column_width*num_cores 1.156 + c = sf.canvas(f.SVG(),width="{0}px".format(w),height="10000px",viewBox='0 0 {0} 10000'.format(w)) 1.157 + c.save() 1.158 + 1.159 def save_tsc_scale(graph,num_cores,total_height): 1.160 - nodes = get_tsc_scale(graph,num_cores,total_height) 1.161 - w = 3*__column_width*num_cores 1.162 - #h = maxh 1.163 + nodes = get_tsc_scale(graph,num_cores,1,0,total_height) 1.164 + w = __column_width*num_cores 1.165 c = sf.canvas(nodes.SVG(),width="{0}px".format(w),height="{0}px".format(10000),viewBox='0 0 {0} {1}'.format(w,10000)) 1.166 c.save('tsc.svg')
2.1 --- a/scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py Mon Mar 12 15:27:28 2012 +0100 2.2 +++ b/scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py Thu Mar 29 18:40:59 2012 +0200 2.3 @@ -65,6 +65,7 @@ 2.4 n = (int(row[2]),int(row[3])) 2.5 g.node[n][row[1]] = int(row[4]) 2.6 g.node[n]['core'] = int(row[6]) 2.7 + g.node[n]['weight'] = 0 2.8 g.node["start"]['weight'] = 0 2.9 g.node["end"]['weight'] = 0 2.10 starttimes = {} 2.11 @@ -81,6 +82,7 @@ 2.12 weight += g.node[n]['Assigner_end'] - g.node[n]['Assigner_start'] 2.13 if g.node[n].has_key('Work_start') and g.node[n].has_key('Assigner_end'): 2.14 weight += g.node[n]['Work_start'] - g.node[n]['Assigner_end'] 2.15 + g.node[n]['work_offset'] = weight 2.16 if g.node[n].has_key('Work_end') and g.node[n].has_key('Work_start'): 2.17 weight += g.node[n]['Work_end'] - g.node[n]['Work_start'] 2.18 if g.node[n].has_key('AppResponderInvocation_start') and g.node[n].has_key('Work_end'): 2.19 @@ -157,7 +159,11 @@ 2.20 except KeyError: 2.21 print node, nlend 2.22 exit(0) 2.23 - lend[end] = path_to_here + graph.node[end]['weight'] 2.24 + try: 2.25 + lend[end] = path_to_here + graph.node[end]['weight'] 2.26 + except KeyError: 2.27 + print end, "'weight'" 2.28 + exit(0) 2.29 return lend,predd 2.30 2.31 def get_path(predd,end): 2.32 @@ -203,7 +209,7 @@ 2.33 print "(Difference:", dif, "- Relative Error:", 100*float(dif)/float(lend['end']),"%)" 2.34 print g.node['start']['starttimes'] 2.35 print g.node['start']['tscstarttimes'] 2.36 - column_view.save_column_view(g,g.node['start']['numcores'],max(actual_time,lend['end']),lend) 2.37 + column_view.save_computed_column_view(g,g.node['start']['numcores'],max(actual_time,lend['end']),lend,[d["commDep"], d["dynDep"], d["ctlDep"]]) 2.38 #column_view.save_tsc_scale(g,g.node['start']['numcores'],lend['end']) 2.39 return # 2.40 print "Node \tCalculated\t Actual\tCore\tDifference\tNon-cumulative part" 2.41 @@ -247,8 +253,8 @@ 2.42 2.43 2.44 if __name__ == "__main__": 2.45 - sys.setrecursionlimit(10000) 2.46 - try: 2.47 - main() 2.48 - except Exception as e: 2.49 - print e 2.50 + sys.setrecursionlimit(20000) 2.51 + #try: 2.52 + main() 2.53 + #except Exception as e: 2.54 + # print e
