Skip to content

Commit 4e41742

Browse files
committed
Have validation-test.py output which block failed
1 parent 35de44c commit 4e41742

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

util/misc/validation-test.py

+29-23
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import argparse
1111

1212
import analyze
13-
from analyze import Logs
13+
from analyze import Logs, Block
1414

1515
# Some reference point to compute occupancies against.
1616
# This would ideally be the maximum possible occupancy so that the .cost property will never be negative
@@ -19,6 +19,14 @@
1919
SPILL_COST_WEIGHT = 0
2020

2121

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+
2230
@dataclass
2331
class DagInfo:
2432
id: str
@@ -137,32 +145,30 @@ def extract_dag_info(logs: Logs) -> Dict[str, List[List[DagInfo]]]:
137145

138146
for block in blocks:
139147
try:
140-
best_result = block.single('BestResult')
141-
is_optimal = best_result['optimal']
142-
except KeyError:
143148
try:
149+
best_result = block.single('BestResult')
150+
is_optimal = best_result['optimal']
151+
except KeyError:
144152
best_result = block['HeuristicResult'][-1]
145153
is_optimal = best_result['cost'] == 0 or \
146154
'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
166172

167173
for k, block_passes in dags.items():
168174
# Safe to modify dags while iterating because we use .items() to get a copy

0 commit comments

Comments
 (0)