mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-27 13:45:19 -04:00
Docker: Plot total times of benchmarks
This commit is contained in:
parent
0542fe1253
commit
ac5e2791ec
3 changed files with 33 additions and 16 deletions
|
|
@ -4,32 +4,40 @@
|
|||
|
||||
import re
|
||||
import sys
|
||||
from typing import Dict
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
# ======================================================================================
|
||||
def main():
|
||||
if len(sys.argv) < 4 or (len(sys.argv) - 1) % 3 != 0:
|
||||
def main() -> None:
|
||||
if len(sys.argv) < 5 or (len(sys.argv) - 1) % 4 != 0:
|
||||
print(
|
||||
"Usage: plot_performance.py <title_1> <plot_1> <file_1> ... "
|
||||
"<title_N> <plot_N> <file_N>"
|
||||
"Usage: plot_performance.py <title_1> <prefix_1> <postfix_1> <file_1> ... "
|
||||
"<title_N> <prefix_N> <postfix_N> <file_N>"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
titles, plots, timings = [], [], []
|
||||
for i in range((len(sys.argv) - 1) // 3):
|
||||
titles.append(sys.argv[3 * i + 1])
|
||||
plots.append(sys.argv[3 * i + 2])
|
||||
timings.append(parse_timings(sys.argv[3 * i + 3]))
|
||||
titles, prefixes, postfixes, timings = [], [], [], []
|
||||
for i in range((len(sys.argv) - 1) // 4):
|
||||
titles.append(sys.argv[4 * i + 1])
|
||||
prefixes.append(sys.argv[4 * i + 2])
|
||||
postfixes.append(sys.argv[4 * i + 3])
|
||||
timings.append(parse_timings(sys.argv[4 * i + 4]))
|
||||
|
||||
routines = list(set(r for t in timings for r in list(t.keys())[:6]))
|
||||
routines.remove("total")
|
||||
routines.sort(reverse=True, key=lambda r: timings[0].get(r, 0.0))
|
||||
|
||||
for titel, plot, timing in zip(titles, plots, timings):
|
||||
timing["rest"] = timing["total"] - sum([timing.get(r, 0.0) for r in routines])
|
||||
for title, prefix, postfix, timing in zip(titles, prefixes, postfixes, timings):
|
||||
print(
|
||||
f'PlotPoint: plot="total_timings_{postfix}", name="{prefix}", label="{prefix}", y={timing["total"]}, yerr=0.0'
|
||||
)
|
||||
print("")
|
||||
|
||||
full_title = f"Timings of {titel}"
|
||||
for title, prefix, postfix, timing in zip(titles, prefixes, postfixes, timings):
|
||||
timing["rest"] = timing["total"] - sum([timing.get(r, 0.0) for r in routines])
|
||||
plot = f"{prefix}_timings_{postfix}"
|
||||
full_title = f"Timings of {title}"
|
||||
print(f'Plot: name="{plot}", title="{full_title}", ylabel="time [s]"')
|
||||
for r in ["rest"] + routines:
|
||||
t = timing.get(r, 0.0)
|
||||
|
|
@ -38,11 +46,12 @@ def main():
|
|||
|
||||
|
||||
# ======================================================================================
|
||||
def parse_timings(out_fn):
|
||||
def parse_timings(out_fn: str) -> Dict[str, float]:
|
||||
output = open(out_fn, encoding="utf8").read()
|
||||
|
||||
pattern = r"\n( -+\n - +-\n - +T I M I N G +-\n([^\n]*\n){4}.*? -+)\n"
|
||||
match = re.search(pattern, output, re.DOTALL)
|
||||
assert match
|
||||
report_lines = match.group(1).split("\n")[7:-1]
|
||||
print("\nFrom {}:\n{}\n".format(out_fn, match.group(0).strip()))
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ run_test mypy --strict ./tools/precommit/check_file_properties.py
|
|||
run_test mypy --strict ./tools/precommit/format_makefile.py
|
||||
run_test mypy --strict ./tools/precommit/format_input_file.py
|
||||
run_test mypy --strict ./tools/docker/generate_dockerfiles.py
|
||||
run_test mypy --strict ./tools/docker/scripts/plot_performance.py
|
||||
run_test mypy --strict ./tools/conventions/redirect_gfortran_output.py
|
||||
run_test mypy --strict ./tools/conventions/analyze_gfortran_ast.py
|
||||
run_test mypy --strict ./tests/do_regtest.py
|
||||
|
|
|
|||
|
|
@ -61,6 +61,10 @@ BENCHMARKS=(
|
|||
)
|
||||
|
||||
if [[ "${PROFILE}" == "toolchain" ]]; then
|
||||
echo 'Plot: name="total_timings_32omp", title="Total Timings with 32 OpenMP Threads", ylabel="time [s]"'
|
||||
echo 'Plot: name="total_timings_32mpi", title="Total Timings with 32 MPI Ranks", ylabel="time [s]"'
|
||||
echo ''
|
||||
|
||||
for INPUT in "${BENCHMARKS[@]}"; do
|
||||
INPUT_BASENAME=$(basename "${INPUT}")
|
||||
LABEL=${INPUT_BASENAME%.*}
|
||||
|
|
@ -72,12 +76,15 @@ if [[ "${PROFILE}" == "toolchain" ]]; then
|
|||
cd ..
|
||||
echo ""
|
||||
/opt/cp2k/plot_performance.py \
|
||||
"${LABEL} with 32 OpenMP Threads" "${LABEL}_timings_32omp" "${OUTPUT_OMP}" \
|
||||
"${LABEL} with 32 MPI Ranks" "${LABEL}_timings_32mpi" "${OUTPUT_MPI}"
|
||||
"${LABEL} with 32 OpenMP Threads" "${LABEL}" "32omp" "${OUTPUT_OMP}" \
|
||||
"${LABEL} with 32 MPI Ranks" "${LABEL}" "32mpi" "${OUTPUT_MPI}"
|
||||
echo ""
|
||||
done
|
||||
|
||||
elif [[ "${PROFILE}" == "toolchain_cuda_"* ]]; then
|
||||
echo 'Plot: name="total_timings_6cpu_1gpu", title="Total Timings with 6 CPU Cores and 1 GPU", ylabel="time [s]"'
|
||||
echo ''
|
||||
|
||||
for INPUT in "${BENCHMARKS[@]}"; do
|
||||
if [[ "$INPUT" == "QS_single_node/H2O-hyb.inp" ]]; then
|
||||
continue # Has no gpu acceleration, yet.
|
||||
|
|
@ -91,7 +98,7 @@ elif [[ "${PROFILE}" == "toolchain_cuda_"* ]]; then
|
|||
cd ..
|
||||
echo ""
|
||||
/opt/cp2k/plot_performance.py \
|
||||
"${LABEL} with 6 CPU Cores and 1 GPU" "${LABEL}_timings_6cpu_1gpu" "${OUTPUT}"
|
||||
"${LABEL} with 6 CPU Cores and 1 GPU" "${LABEL}" "6cpu_1gpu" "${OUTPUT}"
|
||||
echo ""
|
||||
done
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue