Skip to content

Commit b36ad94

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

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

util/gt_analysis/gt_cmp.py

+47
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,40 @@ 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+
if fin_id not in blk:
96+
return 0
97+
return sum(ev['superior_edges'] for ev in blk[fin_id])
98+
99+
100+
def edges_added_for_blk(blk: Block) -> int:
101+
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)
102+
103+
104+
def _edges_removed_for_blk(blk: Block, fin_id: str) -> int:
105+
if fin_id not in blk:
106+
return 0
107+
try:
108+
return sum(ev['removed_edges'] for ev in blk[fin_id])
109+
except KeyError:
110+
return 0
111+
112+
113+
def edges_removed_for_blk(blk: Block) -> int:
114+
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)
115+
116+
117+
def edges_rp_rejected_for_blk(blk: Block) -> int:
118+
if RP_ILP_GT_FINISHED not in blk:
119+
return 0
120+
return sum(ev['failed_rp'] for ev in blk[RP_ILP_GT_FINISHED])
121+
122+
89123
def compute_stats(nogt: Logs, gt: Logs, *, pass_num: int, total_compile_time_seconds):
90124
nogt_all, gt_all = nogt, gt
91125

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

110144
'Total Compile Time (s) (all benchsuite) (No GT)': total_compile_time_seconds(nogt_all),
111145
'Total Compile Time (s) (all benchsuite) (GT)': total_compile_time_seconds(gt_all),
146+
112147
'Total Sched Time (No GT)': sched_time(nogt),
113148
'Total Sched Time (GT)': sched_time(gt),
114149
'Enum Time (No GT)': utils.sum_stat_for_all(enum_time_for_blk, nogt),
@@ -118,12 +153,24 @@ def compute_stats(nogt: Logs, gt: Logs, *, pass_num: int, total_compile_time_sec
118153
'Heuristic Time (No GT)': compile_times.heuristic_time(nogt),
119154
'Heuristic Time (GT)': compile_times.heuristic_time(gt),
120155
'Total GT Time': utils.sum_stat_for_all(total_gt_elapsed_for_blk, gt),
156+
'Edges Added': utils.sum_stat_for_all(edges_added_for_blk, gt),
157+
'Edges Removed': utils.sum_stat_for_all(edges_removed_for_blk, gt),
158+
'Edges Rejected by RP': utils.sum_stat_for_all(edges_rp_rejected_for_blk, gt),
121159

122160
'Total Sched Time (opt. blks only) (No GT)': sched_time(nogt_opt),
123161
'Total Sched Time (opt. blks only) (GT)': sched_time(gt_opt),
124162
'Enum Time (opt. blocks only) (No GT)': utils.sum_stat_for_all(enum_time_for_blk, nogt_opt),
125163
'Enum Time (opt. blocks only) (GT)': utils.sum_stat_for_all(enum_time_for_blk, gt_opt),
126164

165+
'Lower Bound Time (opt. blocks only) (No GT)': compile_times.first_lower_bound_time(nogt_opt),
166+
'Lower Bound Time (opt. blocks only) (GT)': compile_times.first_lower_bound_time(gt_opt),
167+
'Heuristic Time (opt. blocks only) (No GT)': compile_times.heuristic_time(nogt_opt),
168+
'Heuristic Time (opt. blocks only) (GT)': compile_times.heuristic_time(gt_opt),
169+
'Total GT Time (opt. blocks only)': utils.sum_stat_for_all(total_gt_elapsed_for_blk, gt_opt),
170+
'Edges Added (opt. blocks only)': utils.sum_stat_for_all(edges_added_for_blk, gt_opt),
171+
'Edges Removed (opt. blocks only)': utils.sum_stat_for_all(edges_removed_for_blk, gt_opt),
172+
'Edges Rejected by RP (opt. blocks only)': utils.sum_stat_for_all(edges_rp_rejected_for_blk, gt_opt),
173+
127174
'Block Cost - Relative (No GT)': nogt_rel,
128175
'Block Cost - Relative (GT)': gt_rel,
129176
'Block Cost (No GT)': utils.sum_stat_for_all(block_stats.block_cost, nogt),

0 commit comments

Comments
 (0)