Skip to content

Commit f862b89

Browse files
committed
Calculate time spent in LB + heuristic
1 parent f3350b6 commit f862b89

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

util/analyze/lib/compile_times.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ def sched_time(logs):
2020
return sum(_block_time(blk) for blk in logs)
2121

2222

23+
def heuristic_time_for_blk(blk: Block) -> int:
24+
return blk.single('HeuristicResult')['elapsed']
25+
26+
27+
def heuristic_time(logs):
28+
return sum(heuristic_time_for_blk(b) for b in logs)
29+
30+
31+
def first_lower_bound_time_for_blk(blk: Block) -> int:
32+
return blk['CostLowerBound'][0]['elapsed']
33+
34+
35+
def first_lower_bound_time(logs):
36+
return sum(first_lower_bound_time_for_blk(blk) for blk in logs)
37+
38+
2339
_CPU2017_TIME_ELAPSED = re.compile(r"Elapsed compile for '(?P<bench>[^']+)': \S+ \((?P<elapsed>\d+)\)")
2440
_BACKUP_TIME_ELAPSED = re.compile(r'(?P<elapsed>\d+) total seconds elapsed')
2541
_PLAIDML_TIME_ELAPSED = re.compile(
@@ -30,9 +46,9 @@ def sched_time(logs):
3046
def shoc_total_compile_time_seconds(logs):
3147
try:
3248
elapsed = sum(int(m['elapsed'])
33-
for bench in logs.benchmarks
34-
for blk in bench
35-
for m in _SHOC_TIME_ELAPSED.finditer(blk.raw_log))
49+
for bench in logs.benchmarks
50+
for blk in bench
51+
for m in _SHOC_TIME_ELAPSED.finditer(blk.raw_log))
3652
return float(elapsed) * 1e-9
3753
except TypeError:
3854
raise KeyError('Logs must contain "Finished compiling; total ns = " output by the modified SHOC benchmark suite')

util/gt_analysis/gt_cmp.py

+4
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ def compute_stats(nogt: Logs, gt: Logs, *, pass_num: int, total_compile_time_sec
113113
'Total Sched Time (GT)': sched_time(gt),
114114
'Enum Time (No GT)': utils.sum_stat_for_all(enum_time_for_blk, nogt),
115115
'Enum Time (GT)': utils.sum_stat_for_all(enum_time_for_blk, gt),
116+
'Lower Bound Time (No GT)': compile_times.first_lower_bound_time(nogt),
117+
'Lower Bound Time (GT)': compile_times.first_lower_bound_time(gt),
118+
'Heuristic Time (No GT)': compile_times.heuristic_time(nogt),
119+
'Heuristic Time (GT)': compile_times.heuristic_time(gt),
116120
'Total GT Time': utils.sum_stat_for_all(total_gt_elapsed_for_blk, gt),
117121

118122
'Total Sched Time (opt. blks only) (No GT)': sched_time(nogt_opt),

0 commit comments

Comments
 (0)