Skip to content

Commit cbbc8ec

Browse files
authored
Benchmarks report grind time (#589)
1 parent 3aac2c3 commit cbbc8ec

File tree

9 files changed

+61
-30
lines changed

9 files changed

+61
-30
lines changed

benchmarks/5eq_rk3_weno3_hllc/case.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
# Configuring case dictionary
177177
print(json.dumps({
178178
# Logistics ================================================
179-
'run_time_info' : 'T',
179+
'run_time_info' : 'F',
180180
# ==========================================================
181181

182182
# Computational Domain Parameters ==========================
@@ -193,7 +193,7 @@
193193
'dt' : dt,
194194
't_step_start' : 0,
195195
't_step_stop' : int(60*(95*size + 5)),
196-
't_step_save' : int(12*(95*size + 5)),
196+
't_step_save' : int(60*(95*size + 5)),
197197
# ==========================================================
198198

199199
# Simulation Algorithm Parameters ==========================

benchmarks/hypo_hll/case.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# Configuring case dictionary
3131
print(json.dumps({
3232
# Logistics ================================================
33-
'run_time_info' : 'T',
33+
'run_time_info' : 'F',
3434
# ==========================================================
3535

3636
# Computational Domain Parameters ==========================
@@ -46,7 +46,7 @@
4646
'dt' : 1e-8,
4747
't_step_start' : 0,
4848
't_step_stop' : int(60*(95*size + 5)),
49-
't_step_save' : int(12*(95*size + 5)),
49+
't_step_save' : int(60*(95*size + 5)),
5050
# ==========================================================
5151

5252
# Simulation Algorithm Parameters ==========================

benchmarks/ibm/case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
'dt' : mydt,
5151
't_step_start' : 0,
5252
't_step_stop' : int(40*(95*size + 5)),
53-
't_step_save' : int(8*(95*size + 5)),
53+
't_step_save' : int(40*(95*size + 5)),
5454
# ==========================================================
5555

5656
# Simulation Algorithm Parameters ==========================

benchmarks/viscous_weno5_sgb_acoustic/case.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393

9494
# Configuring case dictionary
9595
print(json.dumps({
96-
# Logistics ================================================
97-
'run_time_info' : 'T',
96+
# Logistics ================================================
97+
'run_time_info' : 'F',
9898
# ==========================================================
9999

100100
# Computational Domain Parameters ==========================
@@ -112,9 +112,9 @@
112112
'dt' : dt,
113113
't_step_start' : 0,
114114
't_step_stop' : int(30*(25*size + 5)),
115-
't_step_save' : int(6*(25*size + 5)),
115+
't_step_save' : int(30*(25*size + 5)),
116116
# ==========================================================
117-
117+
118118
# Simulation Algorithm Parameters ==========================
119119
'num_patches' : 2,
120120
'model_eqns' : 2,

src/simulation/m_start_up.fpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,8 @@ contains
11341134
real(kind(0d0)), intent(inout) :: start, finish
11351135
integer, intent(inout) :: nt
11361136

1137+
real(kind(0d0)) :: grind_time
1138+
11371139
call s_mpi_barrier()
11381140

11391141
if (num_procs > 1) then
@@ -1152,29 +1154,33 @@ contains
11521154
time_final = maxval(proc_time)
11531155
io_time_final = maxval(io_proc_time)
11541156
end if
1155-
print *, "Performance: ", time_final*1.0d9/(sys_size*maxval((/1,m_glb/))*maxval((/1,n_glb/))*maxval((/1,p_glb/))), " ns/gp/eq/rhs"
1157+
1158+
grind_time = time_final*1.0d9/(sys_size*maxval((/1,m_glb/))*maxval((/1,n_glb/))*maxval((/1,p_glb/)))
1159+
1160+
print *, "Performance:", grind_time, "ns/gp/eq/rhs"
11561161
inquire (FILE='time_data.dat', EXIST=file_exists)
11571162
if (file_exists) then
11581163
open (1, file='time_data.dat', position='append', status='old')
1159-
write (1, *) num_procs, time_final
1160-
close (1)
11611164
else
11621165
open (1, file='time_data.dat', status='new')
1163-
write (1, *) num_procs, time_final
1164-
close (1)
1166+
write (1, '(A10, A15, A15)') "Ranks", "s/step", "ns/gp/eq/rhs"
11651167
end if
11661168

1169+
write (1, '(I10, 2(F15.8))') num_procs, time_final, grind_time
1170+
1171+
close (1)
1172+
11671173
inquire (FILE='io_time_data.dat', EXIST=file_exists)
11681174
if (file_exists) then
11691175
open (1, file='io_time_data.dat', position='append', status='old')
1170-
write (1, *) num_procs, io_time_final
1171-
close (1)
11721176
else
11731177
open (1, file='io_time_data.dat', status='new')
1174-
write (1, *) num_procs, io_time_final
1175-
close (1)
1178+
write (1, '(A10, A15)') "Ranks", "s/step"
11761179
end if
11771180

1181+
write (1, '(I10, F15.8)') num_procs, io_time_final
1182+
close (1)
1183+
11781184
end if
11791185

11801186
end subroutine s_save_performance_metrics

toolchain/bootstrap/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
log "(venv) Running$MAGENTA pylint$COLOR_RESET on$MAGENTA MFC$COLOR_RESET's $MAGENTA""toolchain$COLOR_RESET."
44

5-
pylint -d R1722,W0718,C0301,C0116,C0115,C0114,C0410,W0622,W0640,C0103,W1309,C0411,W1514,R0401 "$(pwd)/toolchain/"
5+
pylint -d R1722,W0718,C0301,C0116,C0115,C0114,C0410,W0622,W0640,C0103,W1309,C0411,W1514,R0401,W0511 "$(pwd)/toolchain/"
66

77
exit $?

toolchain/mfc/bench.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from .printer import cons
66
from .state import ARG, CFG
7-
from .build import get_targets, DEFAULT_TARGETS
7+
from .build import get_targets, DEFAULT_TARGETS, SIMULATION
88
from .common import system, MFC_BENCH_FILEPATH, MFC_SUBDIR, format_list_to_string
99
from .common import file_load_yaml, file_dump_yaml, create_directory
1010
from .common import MFCException
@@ -77,6 +77,9 @@ def bench(targets = None):
7777
cons.unindent()
7878

7979

80+
# TODO: This function is too long and not nicely written at all. Someone should
81+
# refactor it...
82+
# pylint: disable=too-many-branches
8083
def diff():
8184
lhs, rhs = file_load_yaml(ARG("lhs")), file_load_yaml(ARG("rhs"))
8285

@@ -132,15 +135,32 @@ def _lock_to_str(lock):
132135

133136
continue
134137

135-
if (float(f"{lhs_summary[target.name]}") <= 0.0) or math.isnan(float(f"{lhs_summary[target.name]}")):
138+
if not math.isfinite(lhs_summary[target.name]["exec"]) or not math.isfinite(rhs_summary[target.name]["exec"]):
136139
err = 1
137-
cons.print(f"lhs_summary reports non-positive or NaN runtime for {target.name} - Case: {slug}")
140+
cons.print(f"lhs_summary or rhs_summary reports non-real exec time for {target.name} - Case: {slug}")
138141

139-
if (float(f"{rhs_summary[target.name]}") <= 0.0) or math.isnan(float(f"{rhs_summary[target.name]}")):
142+
exec_time_speedup = "N/A"
143+
try:
144+
exec_time_speedup = f'{lhs_summary[target.name]["exec"] / rhs_summary[target.name]["exec"]:.2f}'
145+
except Exception as _:
140146
err = 1
141-
cons.print(f"rhs_summary reports non-positive or NaN runtime for {target.name} - Case: {slug}")
147+
cons.print(f"lhs_summary or rhs_summary reports non-real exec time for {target.name} - Case: {slug}")
142148

143-
speedups[i] = f"{lhs_summary[target.name] / rhs_summary[target.name]:.2f}x"
149+
speedups[i] = f"Exec: {exec_time_speedup}"
150+
151+
if target == SIMULATION:
152+
grind_time_speedup = "N/A"
153+
if not math.isfinite(lhs_summary[target.name]["grind"]) or not math.isfinite(rhs_summary[target.name]["grind"]):
154+
err = 1
155+
cons.print(f"lhs_summary or rhs_summary reports non-real grind time for {target.name} - Case: {slug}")
156+
157+
try:
158+
grind_time_speedup = f'{lhs_summary[target.name]["grind"] / rhs_summary[target.name]["grind"]:.2f}'
159+
except Exception as _:
160+
err = 1
161+
cons.print(f"lhs_summary or rhs_summary reports non-real grind time for {target.name} - Case: {slug}")
162+
163+
speedups[i] += f" & Grind: {grind_time_speedup}"
144164

145165
table.add_row(f"[magenta]{slug}[/magenta]", *speedups)
146166

toolchain/mfc/run/run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from mako.lookup import TemplateLookup
66
from mako.template import Template
77

8-
from ..build import get_targets, build, REQUIRED_TARGETS
8+
from ..build import get_targets, build, REQUIRED_TARGETS, SIMULATION
99
from ..printer import cons
1010
from ..state import ARG, ARGS, CFG
1111
from ..common import MFCException, isspace, file_read, does_command_exist
@@ -101,6 +101,7 @@ def __generate_job_script(targets, case: input.MFCInputFile):
101101
env=env,
102102
case=case,
103103
MFC_ROOTDIR=MFC_ROOTDIR,
104+
SIMULATION=SIMULATION,
104105
qsystem=queues.get_system(),
105106
profiler=shlex.join(__profiler_prepend())
106107
)

toolchain/templates/include/helpers.mako

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ END
7474
export CRAY_ACC_MODULE='${target.get_staging_dirpath(case)}/simulation-wg256.lld.exe'
7575
fi
7676
77-
cd "${os.path.dirname(input)}"
77+
cd '${os.path.dirname(input)}'
7878
7979
t_${target.name}_start=$(python3 -c 'import time; print(time.time())')
8080
% else:
@@ -102,10 +102,14 @@ END
102102
103103
% if output_summary:
104104
105-
cd "${MFC_ROOTDIR}"
105+
cd '${MFC_ROOTDIR}'
106106
107-
cat >>"${output_summary}" <<EOL
108-
${target.name}: $(echo "$t_${target.name}_stop - $t_${target.name}_start" | bc -l)
107+
cat >>'${output_summary}' <<EOL
108+
${target.name}:
109+
exec: $(echo "$t_${target.name}_stop - $t_${target.name}_start" | bc -l)
110+
% if target == SIMULATION:
111+
grind: $(cat '${os.path.join(os.path.dirname(input), 'time_data.dat')}' | tail -n 1 | awk '{print $NF}')
112+
% endif
109113
EOL
110114
111115
cd - > /dev/null

0 commit comments

Comments
 (0)