|
10 | 10 | import argparse
|
11 | 11 |
|
12 | 12 | import analyze
|
13 |
| -from analyze import Logs |
| 13 | +from analyze import Logs, Block |
14 | 14 |
|
15 | 15 | # Some reference point to compute occupancies against.
|
16 | 16 | # This would ideally be the maximum possible occupancy so that the .cost property will never be negative
|
|
19 | 19 | SPILL_COST_WEIGHT = 0
|
20 | 20 |
|
21 | 21 |
|
| 22 | +class BlockProcessingError(Exception): |
| 23 | + block: Block |
| 24 | + |
| 25 | + def __init__(self, message: str, block: Block): |
| 26 | + self.block = block |
| 27 | + super().__init__(f'{message}:\n{block.raw_log}') |
| 28 | + |
| 29 | + |
22 | 30 | @dataclass
|
23 | 31 | class DagInfo:
|
24 | 32 | id: str
|
@@ -137,32 +145,30 @@ def extract_dag_info(logs: Logs) -> Dict[str, List[List[DagInfo]]]:
|
137 | 145 |
|
138 | 146 | for block in blocks:
|
139 | 147 | try:
|
140 |
| - best_result = block.single('BestResult') |
141 |
| - is_optimal = best_result['optimal'] |
142 |
| - except KeyError: |
143 | 148 | try:
|
| 149 | + best_result = block.single('BestResult') |
| 150 | + is_optimal = best_result['optimal'] |
| 151 | + except KeyError: |
144 | 152 | best_result = block['HeuristicResult'][-1]
|
145 | 153 | is_optimal = best_result['cost'] == 0 or \
|
146 | 154 | 'INFO: Marking SLIL list schedule as optimal due to zero PERP.' in block.raw_log
|
147 |
| - except KeyError: |
148 |
| - print('ERROR: unable to extract BestResult or HeuristicResult from block', file=sys.stderr) |
149 |
| - print(block.raw_log) |
150 |
| - exit(2) |
151 |
| - |
152 |
| - target_occ = block.single('TargetOccupancy')['target'] if 'TargetOccupancy' in block else None |
153 |
| - |
154 |
| - dags.setdefault(block.name, []).append(DagInfo( |
155 |
| - id=block.name, |
156 |
| - benchmark=block.benchmark, |
157 |
| - num_instructions=block.single('ProcessDag')['num_instructions'], |
158 |
| - pass_num=pass_num(block), |
159 |
| - lower_bound=block['CostLowerBound'][-1]['cost'], |
160 |
| - relative_cost=best_result['cost'], |
161 |
| - length=best_result['length'], |
162 |
| - is_optimal=is_optimal, |
163 |
| - spill_cost=best_result['spill_cost'], |
164 |
| - target_occupancy=target_occ, |
165 |
| - )) |
| 155 | + |
| 156 | + target_occ = block.single('TargetOccupancy')['target'] if 'TargetOccupancy' in block else None |
| 157 | + |
| 158 | + dags.setdefault(block.name, []).append(DagInfo( |
| 159 | + id=block.name, |
| 160 | + benchmark=block.benchmark, |
| 161 | + num_instructions=block.single('ProcessDag')['num_instructions'], |
| 162 | + pass_num=pass_num(block), |
| 163 | + lower_bound=block['CostLowerBound'][-1]['cost'], |
| 164 | + relative_cost=best_result['cost'], |
| 165 | + length=best_result['length'], |
| 166 | + is_optimal=is_optimal, |
| 167 | + spill_cost=best_result['spill_cost'], |
| 168 | + target_occupancy=target_occ, |
| 169 | + )) |
| 170 | + except Exception as ex: |
| 171 | + raise BlockProcessingError('Failed when processing block', block) from ex |
166 | 172 |
|
167 | 173 | for k, block_passes in dags.items():
|
168 | 174 | # Safe to modify dags while iterating because we use .items() to get a copy
|
|
0 commit comments