diff --git a/tools/docker/scripts/plot_performance.py b/tools/docker/scripts/plot_performance.py index 896ee0267b..9df1b7d62c 100755 --- a/tools/docker/scripts/plot_performance.py +++ b/tools/docker/scripts/plot_performance.py @@ -8,29 +8,39 @@ from collections import OrderedDict # ====================================================================================== def main(): - if len(sys.argv) != 5: - print("Usage: plot_performance.py <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 = {} diff --git a/tools/docker/scripts/test_performance.sh b/tools/docker/scripts/test_performance.sh index e2ed2d4320..eaf8967b10 100755 --- a/tools/docker/scripts/test_performance.sh +++ b/tools/docker/scripts/test_performance.sh @@ -60,7 +60,7 @@ for INPUT in "${BENCHMARKS[@]}"; do run_benchmark 32 1 "${INPUT_BASENAME}" "${OUTPUT_OMP}" cd .. echo "" - /workspace/plot_performance.py "${LABEL}" "${LABEL}" "${OUTPUT_OMP}" "${OUTPUT_MPI}" + /workspace/plot_performance.py 32 "${LABEL}" "${LABEL}" "${OUTPUT_OMP}" "${OUTPUT_MPI}" echo "" done