# HG changeset patch # User Nina Engelhardt # Date 1336496448 -7200 # Node ID 8336ea9c31531519c900d07ecf2f04df3a7abe17 # Parent 13a3ee4c9608f620fe4bdd5adae6bd5b73f5dc11 add colours for cache miss diff -r 13a3ee4c9608 -r 8336ea9c3153 scripts/ucc_and_loop_graph_treatment/column_view.py --- a/scripts/ucc_and_loop_graph_treatment/column_view.py Wed Apr 11 15:18:24 2012 +0200 +++ b/scripts/ucc_and_loop_graph_treatment/column_view.py Tue May 08 19:00:48 2012 +0200 @@ -2,24 +2,29 @@ import svgfig as sf import colorsys +import math -__column_width = 110 +__column_width = 150 __node_width = 100 __num_idle = 0 #graph.node['start']['numcores'] * 2 +__vertical_scale_factor = 0.000001 #10000.0/float(total_height) ### saving ### -def save_computed_column_view(graph,num_cores,total_height,positioning,dependencies=None): - vertical_scale_factor = 10000.0/float(total_height) +def save_computed_column_view(graph,num_cores,total_height,positioning,dependencies=None,filename=None): + vertical_scale_factor = __vertical_scale_factor __num_cols = 1 f = sf.Fig(fig_nodes(graph,vertical_scale_factor,1,0,positioning)) if dependencies != None: f.d.append(draw_cross_core_deps(graph,num_cores,1,0,positioning,dependencies,vertical_scale_factor)) - #f.trans = "x,{0}*y".format(10000.0/float(total_height)) w = __num_cols*__column_width*num_cores - c = sf.canvas(f.SVG(),width="{0}px".format(w),height="10000px",viewBox='0 0 {0} 10000'.format(w)) - c.save() + h = vertical_scale_factor * total_height + c = sf.canvas(f.SVG(),width="{0}px".format(w),height="{0}".format(h),viewBox='0 0 {0} {1}'.format(w,h)) + if filename != None: + c.save(filename) + else: + c.save() def save_comparative_column_view(graph,num_cores,total_height,positioning=None): if positioning == None: @@ -28,12 +33,11 @@ num_cols = 3 vertical_scale_factor = 10000.0/float(total_height) f = sf.Fig() - f.d.append(get_tsc_scale(graph,num_cores,num_cols,0)) - f.d.append(fig_nodes(graph,num_cols,1,positioning=positioning)) + f.d.append(get_tsc_scale(graph,num_cores,vertical_scale_factor,num_cols,0)) + f.d.append(fig_nodes(graph,vertical_scale_factor,num_cols,1,positioning=positioning)) if positioning!=None: - f.d.append(fig_nodes(graph,num_cols,2)) - w = __num_cols*__column_width*num_cores - f.trans = "x,{0}*y".format(10000.0/float(total_height)) + f.d.append(fig_nodes(graph,vertical_scale_factor,num_cols,2)) + w = num_cols*__column_width*num_cores c = sf.canvas(f.SVG(),width="{0}px".format(w),height="10000px",viewBox='0 0 {0} 10000'.format(w)) c.save() @@ -49,20 +53,19 @@ ### timestamp counter ### -def get_tsc_scale(graph,num_cores,num_cols,offset): +def get_tsc_scale(graph,num_cores,vertical_scale_factor,num_cols,offset): nodes=sf.Fig() maxh = 0 for node in graph: if node != 'start' and node != 'end': try: - n , maxh = tsc_fig_from_node(graph,node,num_cols,offset,maxh) + n , maxh = tsc_fig_from_node(graph,node,vertical_scale_factor,num_cols,offset,maxh) nodes.d.append(n) except Exception as e: print node,e - #nodes.trans = "x,{0}*y".format(10000.0/float(total_height)) return nodes -def tsc_fig_from_node(graph,node,num_cols,offset,maxh): +def tsc_fig_from_node(graph,node,vertical_scale_factor,num_cols,offset,maxh): tscstarttime = graph.node['start']['tscstarttime'] core = graph.node[node]['core'] x1 = num_cols * core * __column_width + offset * __column_width @@ -72,12 +75,12 @@ y2 = graph.node[node]['Timestamp_end'] - tscstarttime else: y2 = y1 + graph.node[node]['weight'] - if node[0]>=2*graph.node['start']['numcores']: + if node[0]>=__num_idle: f='yellow' else: f='gray' - r = sf.Rect(x1,y1,x2,y2,fill=f) - s = sf.Text((x1+x2)/2 , (y1+y2)/2 ,str(node),text_anchor="middle",font_size=20) + r = sf.Rect(x1,y1 * vertical_scale_factor,x2,y2 * vertical_scale_factor,fill=f) + s = sf.Text((x1+x2)/2 , (y1+y2) * vertical_scale_factor/2 ,str(node),text_anchor="middle",font_size=20) try: if maxh < y2: maxh = y2 @@ -123,7 +126,10 @@ y2 = y1 + graph.node[node]['weight'] if node[0]>= __num_idle : if positioning != None: - f='blue' + mp=(float(graph.node[node]['cache_misses'])/float(graph.node['start']['largestcachemiss'])) + 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' else: f='red' else: @@ -143,24 +149,26 @@ def draw_cross_core_deps(graph,num_cores,num_cols,offset,positioning,dependencies,vertical_scale_factor): f = sf.Fig() - hue = 0 - hue_incr = 1.0/len(dependencies) + #hue = 0 + #hue_incr = 1.0/len(dependencies) + hues = [(0.5,0.5,0.5),(1.0,0.0,1.0),(0.0,1.0,1.0),(1.0,1.0,0.0),(1.0,0.6,0.0),(0.0,1.0,0.0),(1.0,0.0,0.0)] for depl in dependencies: + hue = hues.pop() for a,b in depl: if graph.node[a]['core'] != graph.node[b]['core']: - f.d.append(draw_dep(graph,num_cores,num_cols,offset,positioning,(a,b),vertical_scale_factor,colorsys.hsv_to_rgb(hue,1,1))) - hue = hue + hue_incr + f.d.append(draw_dep(graph,num_cores,num_cols,offset,positioning,(a,b),vertical_scale_factor,hue))#colorsys.hsv_to_rgb(hue,1,1))) + #hue = hue + hue_incr return f def draw_dep(graph,num_cores,num_cols,offset,positioning,dep,vertical_scale_factor,color=(0,0,0)): a,b = dep core1 = graph.node[a]['core'] - x1 = core1 * num_cols * __column_width + offset * __column_width + 0.5 * __column_width + x1 = core1 * num_cols * __column_width + offset * __column_width + 0.5 * __node_width y1 = positioning[a] * vertical_scale_factor core2 = graph.node[b]['core'] - x2 = core2 * num_cols * __column_width + offset * __column_width + 0.5 * __column_width + 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:3".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:5".format(int(color[0]*255),int(color[1]*255),int(color[2]*255))) diff -r 13a3ee4c9608 -r 8336ea9c3153 scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py --- a/scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py Wed Apr 11 15:18:24 2012 +0200 +++ b/scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py Tue May 08 19:00:48 2012 +0200 @@ -55,7 +55,8 @@ 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'],max(actual_time,lend['end']),lend,[d["commDep"], d["dynDep"], d["ctlDep"]]) + 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_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 # print "Node \tCalculated\t Actual\tCore\tDifference\tNon-cumulative part" @@ -105,6 +106,10 @@ if not d.has_key("dynDep"): d["dynDep"] = [] d["dynDep"].append(( (int(row[1]),int(row[2])) , (int(row[3]),int(row[4])) )) + if row[0] == "singDep": + if not d.has_key("singDep"): + d["singDep"] = [] + d["singDep"].append(( (int(row[1]),int(row[2])) , (int(row[3]),int(row[4])) )) if row[0] == "hwDep": if not d.has_key("hwDep"): d["hwDep"] = [] @@ -126,6 +131,8 @@ g.add_edges_from(d["commDep"]) if d.has_key("dynDep"): g.add_edges_from(d["dynDep"]) + if d.has_key("singDep"): + g.add_edges_from(d["singDep"]) if d.has_key("hwDep"): g.add_edges_from(d["hwDep"]) for node in g: @@ -142,7 +149,8 @@ if row[0] == "event": n = (int(row[2]),int(row[3])) g.node[n][row[1]] = int(row[4]) - g.node[n]['core'] = int(row[6]) + g.node[n]["{0}_cache".format(row[1])] = int(row[6]) + g.node[n]['core'] = int(row[7]) g.node[n]['weight'] = 0 g.node["start"]['weight'] = 0 g.node["end"]['weight'] = 0 @@ -150,9 +158,16 @@ tscstarttimes = {} tscendtimes = {} highestcore = 0 + largestcachemiss = 0 for n in g: try: if n!="start" and n!="end": + 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 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'] @@ -191,7 +206,7 @@ g.node['start']['tscstarttime']=min(tscstarttimes.values()) g.node['start']['tscendtime']=max(tscendtimes.values()) g.node['start']['numcores']=highestcore+1 - + g.node['start']['largestcachemiss']=largestcachemiss def path_length(graph,path): diff -r 13a3ee4c9608 -r 8336ea9c3153 scripts/ucc_and_loop_graph_treatment/parse_ucc.py --- a/scripts/ucc_and_loop_graph_treatment/parse_ucc.py Wed Apr 11 15:18:24 2012 +0200 +++ b/scripts/ucc_and_loop_graph_treatment/parse_ucc.py Tue May 08 19:00:48 2012 +0200 @@ -197,7 +197,7 @@ n = (int(row[2]),int(row[3])) if not events.has_key(n): events[n]={} - events[n][row[1]] = int(row[4]) + events[n][row[1]] = int(row[5]) if not inversealiases.has_key(aliases[n]): inversealiases[aliases[n]]=set() inversealiases[aliases[n]].add(n)