Skip to content

Commit 3692651

Browse files
committed
Add GT edge metrics, repeat metrics for opt blocks
1 parent 64d6798 commit 3692651

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

util/gt_analysis/gt_cmp.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,34 @@ def blk_relative_cost(nogt, gt) -> Tuple[int, int]:
8686
return no_sum, yes_sum
8787

8888

89+
RP_GT_FINISHED = 'GraphTransRPNodeSuperiorityFinished'
90+
ILP_GT_FINISHED = 'GraphTransILPNodeSuperiorityFinished'
91+
RP_ILP_GT_FINISHED = 'GraphTransOccupancyPreservingILPNodeSuperiorityFinished'
92+
93+
94+
def _edges_added_for_blk(blk: Block, fin_id: str) -> int:
95+
return sum(ev['superior_edges'] for ev in blk[fin_id])
96+
97+
98+
def edges_added_for_blk(blk: Block) -> int:
99+
return _edges_added_for_blk(blk, RP_GT_FINISHED) + _edges_added_for_blk(blk, ILP_GT_FINISHED) + _edges_added_for_blk(blk, RP_ILP_GT_FINISHED)
100+
101+
102+
def _edges_removed_for_blk(blk: Block, fin_id: str) -> int:
103+
try:
104+
return sum(ev['removed_edges'] for ev in blk[fin_id])
105+
except KeyError:
106+
return 0
107+
108+
109+
def edges_removed_for_blk(blk: Block) -> int:
110+
return _edges_removed_for_blk(blk, RP_GT_FINISHED) + _edges_removed_for_blk(blk, ILP_GT_FINISHED) + _edges_removed_for_blk(blk, RP_ILP_GT_FINISHED)
111+
112+
113+
def edges_rp_rejected_for_blk(blk: Block) -> int:
114+
return sum(ev['failed_rp'] for ev in blk[RP_ILP_GT_FINISHED])
115+
116+
89117
def compute_stats(nogt: Logs, gt: Logs, *, pass_num: int, total_compile_time_seconds):
90118
nogt_all, gt_all = nogt, gt
91119

@@ -109,6 +137,7 @@ def compute_stats(nogt: Logs, gt: Logs, *, pass_num: int, total_compile_time_sec
109137

110138
'Total Compile Time (s) (all benchsuite) (No GT)': total_compile_time_seconds(nogt_all),
111139
'Total Compile Time (s) (all benchsuite) (GT)': total_compile_time_seconds(gt_all),
140+
112141
'Total Sched Time (No GT)': sched_time(nogt),
113142
'Total Sched Time (GT)': sched_time(gt),
114143
'Enum Time (No GT)': utils.sum_stat_for_all(enum_time_for_blk, nogt),
@@ -118,12 +147,24 @@ def compute_stats(nogt: Logs, gt: Logs, *, pass_num: int, total_compile_time_sec
118147
'Heuristic Time (No GT)': compile_times.heuristic_time(nogt),
119148
'Heuristic Time (GT)': compile_times.heuristic_time(gt),
120149
'Total GT Time': utils.sum_stat_for_all(total_gt_elapsed_for_blk, gt),
150+
'Edges Added': utils.sum_stat_for_all(edges_added_for_blk, gt),
151+
'Edges Removed': utils.sum_stat_for_all(edges_removed_for_blk, gt),
152+
'Edges Rejected by RP': utils.sum_stat_for_all(edges_rp_rejected_for_blk, gt),
121153

122154
'Total Sched Time (opt. blks only) (No GT)': sched_time(nogt_opt),
123155
'Total Sched Time (opt. blks only) (GT)': sched_time(gt_opt),
124156
'Enum Time (opt. blocks only) (No GT)': utils.sum_stat_for_all(enum_time_for_blk, nogt_opt),
125157
'Enum Time (opt. blocks only) (GT)': utils.sum_stat_for_all(enum_time_for_blk, gt_opt),
126158

159+
'Lower Bound Time (opt. blocks only) (No GT)': compile_times.first_lower_bound_time(nogt_opt),
160+
'Lower Bound Time (opt. blocks only) (GT)': compile_times.first_lower_bound_time(gt_opt),
161+
'Heuristic Time (opt. blocks only) (No GT)': compile_times.heuristic_time(nogt_opt),
162+
'Heuristic Time (opt. blocks only) (GT)': compile_times.heuristic_time(gt_opt),
163+
'Total GT Time (opt. blocks only)': utils.sum_stat_for_all(total_gt_elapsed_for_blk, gt_opt),
164+
'Edges Added (opt. blocks only)': utils.sum_stat_for_all(edges_added_for_blk, gt_opt),
165+
'Edges Removed (opt. blocks only)': utils.sum_stat_for_all(edges_removed_for_blk, gt_opt),
166+
'Edges Rejected by RP (opt. blocks only)': utils.sum_stat_for_all(edges_rp_rejected_for_blk, gt_opt),
167+
127168
'Block Cost - Relative (No GT)': nogt_rel,
128169
'Block Cost - Relative (GT)': gt_rel,
129170
'Block Cost (No GT)': utils.sum_stat_for_all(block_stats.block_cost, nogt),

0 commit comments

Comments
 (0)