44 Parses one input file identified through file_name and returns two
45 lists: the first one is a list of the number of particles, the second gives
46 the timings. We only parse data from one kernel type identified through
53 file = open( file_name,
"r" )
56 if "Experiment:" in line:
57 number_of_particles = line.split(
"Experiment:" )[1].split(
"particles" )[0]
58 particle_counts.append( float(number_of_particles) )
59 if kernel_name
in line:
60 time = line.split( kernel_name +
":" )[1].split(
"(" )[0]
61 timings.append( float(time) )
63 assert len(particle_counts)==len(timings)
or len(timings)==0,
"array dimensions don't match: {} vs {} for kernel {} in {}".format(particle_counts, timings, kernel_name, file_name)
64 return particle_counts, timings
119 print(
"process file {}".format(filename) )
122 mpl.rcParams.update(params)
124 fig, ax = plt.subplots()
126 kernel_legend_handles = []
127 variants_legend_handles = []
128 for k, kernel
in enumerate(Kernels):
129 kernel_legend_handles += [Line2D([0], [0], marker=Symbols[k][-1], color=Colors[0], label=f
'{KernelName[kernel]}', linestyle=
'--')]
130 for im, implementation
in enumerate(ImplementationVariant[kernel]):
131 if 'gpu' in filename
and im > 2:
continue
133 kernel +
" " + implementation,
136 symbol = Symbols[ k % len(Symbols) ]
137 color = Colors[ im % len(Colors) ]
138 label = f
'{KernelName[kernel]} - {ImplementationVariantName[implementation]}'
146 markevery=(im,len(ImplementationVariant[kernel]))
149 for i, impl
in enumerate(ImplementationVariant[
'force']):
150 if 'gpu' in filename
and i > 2:
continue
151 variants_legend_handles += [Line2D([0], [0], marker=Symbols[0][-1], color=Colors[i], label=f
'... {ImplementationVariantName[impl]}', linestyle=
'--')]
153 plt.xlabel(
"Particles")
154 plt.ylabel(
"Time per particle update [t]=s")
156 plt.xscale(
'log', base=10)
157 plt.yscale(
'log', base=10)
160 plt.grid(
True, which=
'both')
162 filename = filename.replace(
'.log',
'')
164 if 'gi001' in filename:
165 plt.axvline(x = L2CacheSizeMap[
'gi001']/ParticleSize, color =
'k', linestyle =
'--')
166 elif 'gh003' in filename:
167 plt.axvline(x = L2CacheSizeMap[
'gh003']/ParticleSize, color =
'k', linestyle =
'--')
169 raise Exception(
"I don't know what CPU I'm working on!")
171 plt.ylim(1e-10, 1e-3)
173 plt.savefig(f
"{filename}.pdf")
174 plt.savefig(f
"{filename}.png")
177 fig, ax = plt.subplots(figsize=(15, 1.2), constrained_layout=
True)
181 other_legend = ax.legend(loc=
"center right", handles=variants_legend_handles, fontsize=20, ncol=2, frameon=
False)
182 ax.add_artist(other_legend)
184 plt.legend(loc=
"center left", handles=kernel_legend_handles, fontsize=20, ncol=3, frameon=
False)
186 plt.savefig(f
"{filename}-legend.pdf")
187 plt.savefig(f
"{filename}-legend.png")