Peano
create-plots.py
Go to the documentation of this file.
1 import matplotlib.pyplot as plt
2 import os.path
3 import sys
4 from fileinput import filename
5 
6 
7 D = [2,3]
8 H = [ 0.5, 0.2, 0.1, 0.05, 0.02, 0.01, 0.005, 0.002, 0.001 ]
9 Flops = [ 1, 100, 10000, 1000000 ]
10 Color = [ "#ff0000", "#00ff00", "#0000ff", "#a0a000", "#a000a0", "#00a0a0", "#998899", "#aa8888", "#88aa88", "#8888aa" ]
11 BenchmarkIterations = 20
12 
13 
14 
15 def filter_file(filename):
16  if os.path.exists( filename ):
17  print( "found " + filename + " write " + filename + ".filter" )
18  input_file = open(filename, "r")
19  output_file = open(filename, "w")
20  for line in file:
21  if ("start parallel traversals" in line) or ("local unrefined cells" in line) or "terminated successfully" in line:
22  output_file.write( line )
23 
24 
25 def get_shared_memory_file_name(cores,d,h,flops):
26  return "shared-memory-" + str(cores) + "-cores-" + str(d) + "d-" + str(h) + "-" + str(flops) + "-flops.out"
27 
28 
29 def get_distributed_memory_file_name(nodes,d,h,flops):
30  return "distributed-memory-" + str(nodes) + "-nodes-" + str(d) + "d-" + str(h) + "-" + str(flops) + "-flops.out"
31 
32 
34  for d in [2,3]:
35  for h in H:
36  for flops in Flops:
37  for cores in range(1,64):
38  filename = get_shared_memory_file_name(cores,d,h,flops)
39  filter_file(filename)
40 
41 
42 def parse_file(filename):
43  """
44  return a tuple of new entry plus max cells. First entry in tuple is 0.0 if no data found
45  """
46  file = open(filename, "r")
47  start_time = 0
48  new_entry = 0.0
49  max_cells = 0
50  for line in file:
51  if "start parallel traversals" in line:
52  start_time = int( line.split(" ")[0] )
53  if "local unrefined cells" in line:
54  max_cells = float( line.split("=")[-1] )
55  if "terminated successfully" in line:
56  time = int( line.split(" ")[0] )
57  new_entry = (time - start_time)
58  return (new_entry,max_cells)
59 
60 
61 def normalise_raw_times(time_data,max_cells):
62  """
63  Divides each entry through max number of cells and iterations
64  """
65  return [i/BenchmarkIterations/max_cells for i in time_data]
66 
68  for d in [2,3]:
69  plt.clf()
70  max_cores = 0
71  max_serial_time = 0.0
72  min_serial_time = 65536.0
73  max_cores=0
74  for h in H:
75  for flops in Flops:
76  max_cells = 0.0
77  ydata = []
78  xdata = []
79  for cores in range(1,64):
80  found_file = False
81  filename = get_shared_memory_file_name(cores,d,h,flops)
82  if os.path.exists( filename+".filter" ):
83  found_file = True
84  filename += ".filter"
85  elif os.path.exists( filename ):
86  found_file = True
87 
88  if found_file:
89  print( "found " + filename )
90 
91  (new_entry,cells) = parse_file(filename)
92  if new_entry>0.0:
93  max_cells = max(cells,max_cells)
94  max_cores = max(cores,max_cores)
95  xdata.append(cores)
96  ydata.append(new_entry)
97  if cores==1:
98  max_serial_time = max(max_serial_time, new_entry/max_cells)
99  min_serial_time = min(min_serial_time, new_entry/max_cells)
100 
101  if len(xdata)>0:
102  ydata_calibrated = normalise_raw_times(ydata,max_cells)
103  #if H.index(h)==0 or Flops.index(flops)==0:
104  plt.plot(
105  xdata, ydata_calibrated,
106  label="h=" + str(h) + ",#flops/cell=" + str(flops),
107  color=Color[H.index(h)],
108  marker=Flops.index(flops)+4
109  )
110  #else:
111  # plt.plot(
112  # xdata, ydata_calibrated,
113  # color=Color[H.index(h)],
114  # marker=Flops.index(flops)+4
115  # )
116 
117  xdata = range(1,max_cores)
118  plt.plot(
119  xdata, [max_serial_time/i for i in xdata],
120  "--", color="#000000"
121  )
122  plt.plot(
123  xdata, [min_serial_time/i for i in xdata],
124  "--", color="#000000"
125  )
126 
127  plt.legend()
128  plt.xlabel( "cores" )
129  plt.ylabel( "time/cell [t]=ms" )
130  plt.xscale( "log", basex=2 )
131  plt.yscale( "log", basey=2 )
132  xtics = [ 1 ]
133  xlabels = [ "serial" ]
134  while xtics[-1] < max_cores:
135  xtics.append( xtics[-1]*2 )
136  xlabels.append( str(xtics[-1]) )
137  plt.xticks( xtics, xlabels )
138  plt.title( "shared memory scaling " + str(d) + "d" )
139  plt.savefig( "shared-memory-" + str(d) + "d.pdf" )
140  plt.savefig( "shared-memory-" + str(d) + "d.png" )
141 
142 
143 if __name__ == "__main__":
144  if len(sys.argv)!=3:
145  print( "Usage: python " + sys.argv[0] + " [option] [target]")
146  print( "" )
147  print( "With option from" )
148  print( " filter filters out files, i.e. throws away all entries which are not required" )
149  print( " create-plots generate plots" )
150  print( "" )
151  print( "With option from" )
152  print( " shared-memory process shared memory data" )
153  print( " distributed-memory process distributed memory data" )
154  elif sys.argv[1]=="create-plots" and sys.argv[2]=="shared-memory":
156  elif sys.argv[1]=="filter" and sys.argv[2]=="shared-memory":
158  elif sys.argv[1]=="create-plots" and sys.argv[2]=="distributed-memory":
159  plot_distributed_memory()
160  elif sys.argv[1]=="filter" and sys.argv[2]=="distributed-memory":
161  filter_distributed_memory()
162  else:
163  print( "Invalid option. Run without arguments for usage message" )
164 
165 
static double min(double const x, double const y)
str
Definition: ccz4.py:55
def plot_shared_memory()
Definition: create-plots.py:67
def parse_file(filename)
return a tuple of new entry plus max cells.
Definition: create-plots.py:42
def normalise_raw_times(time_data, max_cells)
Divides each entry through max number of cells and iterations.
Definition: create-plots.py:61
def filter_shared_memory()
Definition: create-plots.py:33
def get_distributed_memory_file_name(nodes, d, h, flops)
Definition: create-plots.py:29
def filter_file(filename)
Definition: create-plots.py:15
def get_shared_memory_file_name(cores, d, h, flops)
Definition: create-plots.py:25