Docker: Plot OpenMP timings individually instead of their ratio

This commit is contained in:
Ole Schütt 2021-03-03 19:47:31 +01:00 committed by Ole Schütt
parent ab1ce60aca
commit f2d27513a6
2 changed files with 27 additions and 15 deletions

View file

@ -8,29 +8,39 @@ from collections import OrderedDict
# ======================================================================================
def main():
if len(sys.argv) != 5:
print("Usage: plot_performance.py <title> <label> <output_omp> <output_mpi>")
if len(sys.argv) != 6:
print(
"Usage: plot_performance.py <nprocs> <title> <label> <output_omp> <output_mpi>"
)
sys.exit(1)
title, label, output_omp, output_mpi = sys.argv[1:]
nprocs, title, label, output_omp, output_mpi = sys.argv[1:]
timings_omp = parse_timings(output_omp)
timings_mpi = parse_timings(output_mpi)
routines = list(timings_omp.keys())[:6]
routines = list(set(list(timings_omp.keys())[:6] + list(timings_mpi.keys())[:6]))
routines.remove("total")
routines.sort(reverse=True, key=lambda r: timings_omp.get(r, 0.0))
full_title = f"Timings of {title} with OpenMP"
plot = f"{label}_timings"
sum_routines_omp = sum([timings_omp.get(r, 0.0) for r in routines])
sum_routines_mpi = sum([timings_mpi.get(r, 0.0) for r in routines])
timings_omp["rest"] = timings_omp["total"] - sum_routines_omp
timings_mpi["rest"] = timings_mpi["total"] - sum_routines_mpi
full_title = f"Timings of {title} with {nprocs} OpenMP Threads"
plot = f"{label}_timings_{nprocs}omp"
print(f'Plot: name="{plot}", title="{full_title}", ylabel="time [s]"')
for r in routines:
for r in ["rest"] + routines:
t = timings_omp[r]
print(f'PlotPoint: plot="{plot}", name="{r}", label="{r}", y={t}, yerr=0.0')
print("")
full_title = f"Parallel Efficiency of {title}"
plot = f"{label}_scaling"
print(f'Plot: name="{plot}", title="{full_title}", ylabel="MPI / OMP time"')
for r in routines:
e = timings_mpi[r] / timings_omp[r]
print(f'PlotPoint: plot="{plot}", name="{r}", label="{r}", y={e}, yerr=0.0')
full_title = f"Timings of {title} with {nprocs} MPI Ranks"
plot = f"{label}_timings_{nprocs}mpi"
print(f'Plot: name="{plot}", title="{full_title}", ylabel="time [s]"')
for r in ["rest"] + routines:
t = timings_mpi[r]
print(f'PlotPoint: plot="{plot}", name="{r}", label="{r}", y={t}, yerr=0.0')
print("")
# ======================================================================================
@ -38,7 +48,9 @@ def parse_timings(out_fn):
output = open(out_fn, encoding="utf8").read()
pattern = r"\n( -+\n - +-\n - +T I M I N G +-\n([^\n]*\n){4}.*? -+)\n"
report_lines = re.search(pattern, output, re.DOTALL).group(1).split("\n")[7:-1]
match = re.search(pattern, output, re.DOTALL)
report_lines = match.group(1).split("\n")[7:-1]
print("\nFrom {}:\n{}\n".format(out_fn, match.group(0).strip()))
# Extract average self time.
timings = {}