Skip to content

Commit

Permalink
Update validation-test.py for Adjusted PERP SCF
Browse files Browse the repository at this point in the history
  • Loading branch information
Quincunx271 committed Jul 26, 2021
1 parent 49ecbac commit 35de44c
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion util/misc/validation-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
import analyze
from analyze import Logs

# Some reference point to compute occupancies against.
# This would ideally be the maximum possible occupancy so that the .cost property will never be negative
OCCUPANCY_REFERENCE_POINT = 10

SPILL_COST_WEIGHT = 0


@dataclass
class DagInfo:
Expand All @@ -24,10 +30,20 @@ class DagInfo:
relative_cost: int
length: int
is_optimal: bool
# Spill cost is not absolute for SCF = TARGET. By recording the baseline, we can adjust the costs.
target_occupancy: Optional[int]
spill_cost: int

@property
def cost(self):
return self.lower_bound + self.relative_cost
cost = self.lower_bound + self.relative_cost
if self.target_occupancy is not None:
# TargetOcc - SC is a "complement"-like operation, meaning that it undoes itself.
actual_occupancy = self.target_occupancy - self.spill_cost
absolute_spill_cost = OCCUPANCY_REFERENCE_POINT - actual_occupancy
cost += SPILL_COST_WEIGHT * absolute_spill_cost

return cost


class MismatchKind(Enum):
Expand Down Expand Up @@ -133,6 +149,8 @@ def extract_dag_info(logs: Logs) -> Dict[str, List[List[DagInfo]]]:
print(block.raw_log)
exit(2)

target_occ = block.single('TargetOccupancy')['target'] if 'TargetOccupancy' in block else None

dags.setdefault(block.name, []).append(DagInfo(
id=block.name,
benchmark=block.benchmark,
Expand All @@ -142,6 +160,8 @@ def extract_dag_info(logs: Logs) -> Dict[str, List[List[DagInfo]]]:
relative_cost=best_result['cost'],
length=best_result['length'],
is_optimal=is_optimal,
spill_cost=best_result['spill_cost'],
target_occupancy=target_occ,
))

for k, block_passes in dags.items():
Expand Down Expand Up @@ -338,6 +358,8 @@ def print_small_summary(mismatches: List[Mismatch]):

parser.add_argument('-q', '--quiet', action='store_true',
help='Only print mismatch info, and only if there are mismatches')
parser.add_argument('--scw', '--spill-cost-weight', type=int, required=True,
help='The weight of the spill cost in the cost calculation. Only relevant if the reported spill costs are not absolute (e.g. SCF = TARGET); put any value otherwise.', dest='spill_cost_weight', metavar='SCW')
parser.add_argument('--no-summarize-largest-cost-difference', action='store_true',
help='Do not summarize the mismatches with the biggest difference in cost')
parser.add_argument('--no-summarize-smallest-mismatches', action='store_true',
Expand All @@ -358,6 +380,7 @@ def print_small_summary(mismatches: List[Mismatch]):
NUM_SMALLEST_BLOCKS_PRINT = args.num_smallest_mismatches_print
MISSING_LOWER_BOUND_DUMP_COUNT = args.missing_lb_dump_count
MISSING_LOWER_BOUND_DUMP_LINES = args.missing_lb_dump_lines
SPILL_COST_WEIGHT = args.spill_cost_weight

main(
args.first, args.second,
Expand Down

0 comments on commit 35de44c

Please sign in to comment.