VMS/2__runs_and_data

changeset 23:8336ea9c3153

add colours for cache miss
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Tue, 08 May 2012 19:00:48 +0200
parents 13a3ee4c9608
children 6d03033aca59
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, 53 insertions(+), 30 deletions(-) [+]
line diff
     1.1 --- a/scripts/ucc_and_loop_graph_treatment/column_view.py	Wed Apr 11 15:18:24 2012 +0200
     1.2 +++ b/scripts/ucc_and_loop_graph_treatment/column_view.py	Tue May 08 19:00:48 2012 +0200
     1.3 @@ -2,24 +2,29 @@
     1.4  
     1.5  import svgfig as sf
     1.6  import colorsys
     1.7 +import math
     1.8  
     1.9 -__column_width = 110
    1.10 +__column_width = 150
    1.11  __node_width = 100
    1.12  
    1.13  __num_idle = 0 #graph.node['start']['numcores'] * 2
    1.14  
    1.15 +__vertical_scale_factor = 0.000001 #10000.0/float(total_height)
    1.16  ### saving ###
    1.17  
    1.18 -def save_computed_column_view(graph,num_cores,total_height,positioning,dependencies=None):
    1.19 -	vertical_scale_factor = 10000.0/float(total_height)
    1.20 +def save_computed_column_view(graph,num_cores,total_height,positioning,dependencies=None,filename=None):
    1.21 +	vertical_scale_factor = __vertical_scale_factor
    1.22  	__num_cols = 1
    1.23  	f = sf.Fig(fig_nodes(graph,vertical_scale_factor,1,0,positioning))
    1.24  	if dependencies != None:
    1.25  		f.d.append(draw_cross_core_deps(graph,num_cores,1,0,positioning,dependencies,vertical_scale_factor))
    1.26 -	#f.trans = "x,{0}*y".format(10000.0/float(total_height))
    1.27  	w = __num_cols*__column_width*num_cores
    1.28 -	c = sf.canvas(f.SVG(),width="{0}px".format(w),height="10000px",viewBox='0 0 {0} 10000'.format(w))
    1.29 -	c.save()
    1.30 +	h = vertical_scale_factor * total_height
    1.31 +	c = sf.canvas(f.SVG(),width="{0}px".format(w),height="{0}".format(h),viewBox='0 0 {0} {1}'.format(w,h))
    1.32 +	if filename != None:
    1.33 +		c.save(filename)
    1.34 +	else:
    1.35 +		c.save()
    1.36  
    1.37  def save_comparative_column_view(graph,num_cores,total_height,positioning=None):
    1.38  	if positioning == None:
    1.39 @@ -28,12 +33,11 @@
    1.40  		num_cols = 3
    1.41  	vertical_scale_factor = 10000.0/float(total_height)
    1.42  	f = sf.Fig()
    1.43 -	f.d.append(get_tsc_scale(graph,num_cores,num_cols,0))
    1.44 -	f.d.append(fig_nodes(graph,num_cols,1,positioning=positioning))
    1.45 +	f.d.append(get_tsc_scale(graph,num_cores,vertical_scale_factor,num_cols,0))
    1.46 +	f.d.append(fig_nodes(graph,vertical_scale_factor,num_cols,1,positioning=positioning))
    1.47  	if positioning!=None:
    1.48 -		f.d.append(fig_nodes(graph,num_cols,2))
    1.49 -	w = __num_cols*__column_width*num_cores
    1.50 -	f.trans = "x,{0}*y".format(10000.0/float(total_height))
    1.51 +		f.d.append(fig_nodes(graph,vertical_scale_factor,num_cols,2))
    1.52 +	w = num_cols*__column_width*num_cores
    1.53  	c = sf.canvas(f.SVG(),width="{0}px".format(w),height="10000px",viewBox='0 0 {0} 10000'.format(w))
    1.54  	c.save()
    1.55  
    1.56 @@ -49,20 +53,19 @@
    1.57  
    1.58  ### timestamp counter ###
    1.59  
    1.60 -def get_tsc_scale(graph,num_cores,num_cols,offset):
    1.61 +def get_tsc_scale(graph,num_cores,vertical_scale_factor,num_cols,offset):
    1.62  	nodes=sf.Fig()
    1.63  	maxh = 0
    1.64  	for node in graph:
    1.65  		if node != 'start' and node != 'end':
    1.66  			try:
    1.67 -				n , maxh = tsc_fig_from_node(graph,node,num_cols,offset,maxh)
    1.68 +				n , maxh = tsc_fig_from_node(graph,node,vertical_scale_factor,num_cols,offset,maxh)
    1.69  				nodes.d.append(n)
    1.70  			except Exception as e:
    1.71  				print node,e
    1.72 -	#nodes.trans = "x,{0}*y".format(10000.0/float(total_height))
    1.73  	return nodes
    1.74  
    1.75 -def tsc_fig_from_node(graph,node,num_cols,offset,maxh):
    1.76 +def tsc_fig_from_node(graph,node,vertical_scale_factor,num_cols,offset,maxh):
    1.77  	tscstarttime = graph.node['start']['tscstarttime']
    1.78  	core = graph.node[node]['core']
    1.79  	x1 = num_cols * core * __column_width + offset * __column_width
    1.80 @@ -72,12 +75,12 @@
    1.81  		y2 = graph.node[node]['Timestamp_end'] - tscstarttime
    1.82  	else:
    1.83  		y2 = y1 + graph.node[node]['weight']
    1.84 -	if node[0]>=2*graph.node['start']['numcores']:
    1.85 +	if node[0]>=__num_idle:
    1.86  		f='yellow'
    1.87  	else:
    1.88  		f='gray'
    1.89 -	r = sf.Rect(x1,y1,x2,y2,fill=f)
    1.90 -	s = sf.Text((x1+x2)/2 , (y1+y2)/2 ,str(node),text_anchor="middle",font_size=20)
    1.91 +	r = sf.Rect(x1,y1 * vertical_scale_factor,x2,y2 * vertical_scale_factor,fill=f)
    1.92 +	s = sf.Text((x1+x2)/2 , (y1+y2) * vertical_scale_factor/2 ,str(node),text_anchor="middle",font_size=20)
    1.93  	try:
    1.94  		if maxh < y2:
    1.95  			maxh = y2
    1.96 @@ -123,7 +126,10 @@
    1.97  	y2 = y1 + graph.node[node]['weight']
    1.98  	if node[0]>= __num_idle :
    1.99  		if positioning != None:
   1.100 -			f='blue'
   1.101 +			mp=(float(graph.node[node]['cache_misses'])/float(graph.node['start']['largestcachemiss']))
   1.102 +			f = "rgb({0},{1},{2})".format(int(math.ceil(mp*255.0)),0,int(math.ceil((1.0-mp)*255.0)))		
   1.103 +			#print f
   1.104 +#			f='blue'
   1.105  		else:
   1.106  			f='red'
   1.107  	else:
   1.108 @@ -143,24 +149,26 @@
   1.109  
   1.110  def draw_cross_core_deps(graph,num_cores,num_cols,offset,positioning,dependencies,vertical_scale_factor):
   1.111  	f = sf.Fig()
   1.112 -	hue = 0
   1.113 -	hue_incr = 1.0/len(dependencies)
   1.114 +	#hue = 0
   1.115 +	#hue_incr = 1.0/len(dependencies)
   1.116 +	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)]
   1.117  	for depl in dependencies:
   1.118 +		hue = hues.pop()
   1.119  		for a,b in depl:
   1.120  			if graph.node[a]['core'] != graph.node[b]['core']:
   1.121 -				f.d.append(draw_dep(graph,num_cores,num_cols,offset,positioning,(a,b),vertical_scale_factor,colorsys.hsv_to_rgb(hue,1,1)))
   1.122 -		hue = hue + hue_incr
   1.123 +				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)))
   1.124 +		#hue = hue + hue_incr
   1.125  	return f
   1.126  
   1.127  def draw_dep(graph,num_cores,num_cols,offset,positioning,dep,vertical_scale_factor,color=(0,0,0)):
   1.128  	a,b = dep
   1.129  	core1 = graph.node[a]['core']
   1.130 -	x1 = core1 * num_cols * __column_width + offset * __column_width + 0.5 * __column_width
   1.131 +	x1 = core1 * num_cols * __column_width + offset * __column_width + 0.5 * __node_width
   1.132  	y1 = positioning[a] * vertical_scale_factor
   1.133  	core2 = graph.node[b]['core']
   1.134 -	x2 = core2 * num_cols * __column_width + offset * __column_width + 0.5 * __column_width
   1.135 +	x2 = core2 * num_cols * __column_width + offset * __column_width + 0.5 * __node_width
   1.136  	y2 = (positioning[b] - graph.node[b]['weight']) * vertical_scale_factor
   1.137 -	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)))
   1.138 +	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.139  	
   1.140  
   1.141  
     2.1 --- a/scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py	Wed Apr 11 15:18:24 2012 +0200
     2.2 +++ b/scripts/ucc_and_loop_graph_treatment/parse_loop_graph.py	Tue May 08 19:00:48 2012 +0200
     2.3 @@ -55,7 +55,8 @@
     2.4  			print "(Difference:", dif, "- Relative Error:", 100*float(dif)/float(lend['end']),"%)"
     2.5  			print g.node['start']['starttimes']
     2.6  			print g.node['start']['tscstarttimes']
     2.7 -			column_view.save_computed_column_view(g,g.node['start']['numcores'],max(actual_time,lend['end']),lend,[d["commDep"], d["dynDep"], d["ctlDep"]])
     2.8 +			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.9 +			#column_view.save_comparative_column_view(g,g.node['start']['numcores'],max(actual_time,lend['end']),lend)
    2.10  			#column_view.save_tsc_scale(g,g.node['start']['numcores'],lend['end'])
    2.11  			return #
    2.12  			print "Node   \tCalculated\t    Actual\tCore\tDifference\tNon-cumulative part"
    2.13 @@ -105,6 +106,10 @@
    2.14  				if not d.has_key("dynDep"):
    2.15  					d["dynDep"] = []
    2.16  				d["dynDep"].append(( (int(row[1]),int(row[2])) , (int(row[3]),int(row[4])) ))
    2.17 +			if row[0] == "singDep":
    2.18 +				if not d.has_key("singDep"):
    2.19 +					d["singDep"] = []
    2.20 +				d["singDep"].append(( (int(row[1]),int(row[2])) , (int(row[3]),int(row[4])) ))
    2.21  			if row[0] == "hwDep":
    2.22  				if not d.has_key("hwDep"):
    2.23  					d["hwDep"] = []
    2.24 @@ -126,6 +131,8 @@
    2.25  		g.add_edges_from(d["commDep"])
    2.26  	if d.has_key("dynDep"):
    2.27  		g.add_edges_from(d["dynDep"])
    2.28 +	if d.has_key("singDep"):
    2.29 +		g.add_edges_from(d["singDep"])
    2.30  	if d.has_key("hwDep"):
    2.31  		g.add_edges_from(d["hwDep"])
    2.32  	for node in g:
    2.33 @@ -142,7 +149,8 @@
    2.34  		if row[0] == "event":
    2.35  			n = (int(row[2]),int(row[3]))
    2.36  			g.node[n][row[1]] = int(row[4])
    2.37 -			g.node[n]['core'] = int(row[6])
    2.38 +			g.node[n]["{0}_cache".format(row[1])] = int(row[6])
    2.39 +			g.node[n]['core'] = int(row[7])
    2.40  			g.node[n]['weight'] = 0
    2.41  	g.node["start"]['weight'] = 0
    2.42  	g.node["end"]['weight'] = 0
    2.43 @@ -150,9 +158,16 @@
    2.44  	tscstarttimes = {}
    2.45  	tscendtimes = {}
    2.46  	highestcore = 0
    2.47 +	largestcachemiss = 0
    2.48  	for n in g:
    2.49  		try:
    2.50  			if n!="start" and n!="end":
    2.51 +				cachem = 0
    2.52 +				if g.node[n].has_key('Work_end_cache') and g.node[n].has_key('Work_start_cache'):
    2.53 +					cachem += g.node[n]['Work_end_cache'] - g.node[n]['Work_start_cache']
    2.54 +				g.node[n]['cache_misses'] = cachem
    2.55 +				if cachem > largestcachemiss:
    2.56 +					largestcachemiss = cachem
    2.57  				weight = 0
    2.58  				if g.node[n].has_key('Assigner_start') and g.node[n].has_key('AssignerInvocation_start'):
    2.59  					weight += g.node[n]['Assigner_start'] - g.node[n]['AssignerInvocation_start']
    2.60 @@ -191,7 +206,7 @@
    2.61  	g.node['start']['tscstarttime']=min(tscstarttimes.values())
    2.62  	g.node['start']['tscendtime']=max(tscendtimes.values())
    2.63  	g.node['start']['numcores']=highestcore+1
    2.64 -
    2.65 +	g.node['start']['largestcachemiss']=largestcachemiss
    2.66  
    2.67  
    2.68  def path_length(graph,path):
     3.1 --- a/scripts/ucc_and_loop_graph_treatment/parse_ucc.py	Wed Apr 11 15:18:24 2012 +0200
     3.2 +++ b/scripts/ucc_and_loop_graph_treatment/parse_ucc.py	Tue May 08 19:00:48 2012 +0200
     3.3 @@ -197,7 +197,7 @@
     3.4  			n = (int(row[2]),int(row[3]))
     3.5  			if not events.has_key(n):
     3.6  				events[n]={}
     3.7 -			events[n][row[1]] = int(row[4])
     3.8 +			events[n][row[1]] = int(row[5])
     3.9  			if not inversealiases.has_key(aliases[n]):
    3.10  				inversealiases[aliases[n]]=set()
    3.11  			inversealiases[aliases[n]].add(n)