Skip to content

Commit

Permalink
split_heuristic_estimate_performance config option; defaults to True
Browse files Browse the repository at this point in the history
  • Loading branch information
mkannwischer committed Jul 11, 2024
1 parent 1c0284b commit 8d71da0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
19 changes: 13 additions & 6 deletions slothy/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,15 @@ def split_heuristic_preprocess_naive_interleaving_by_latency(self):
"read config.split_heuristic_preprocess_naive_interleaving_by_latency otherwise.")
return self._split_heuristic_preprocess_naive_interleaving_by_latency

@property
def split_heuristic_estimate_performance(self):
"""After applying the split heuristic, run SLOTHY again on the entire code to estimate the
performance and display un-used issue slots in the output."""
if not self.split_heuristic:
raise InvalidConfig("Did you forget to set config.split_heuristic=True? Shouldn't" \
"read config.split_heuristic_estimate_performance otherwise.")
return self._split_heuristic_estimate_performance

@property
def flexible_lifetime_start(self):
"""Internal property indicating whether the lifetime interval of a register
Expand Down Expand Up @@ -1063,6 +1072,7 @@ def __init__(self, Arch, Target):
self._split_heuristic_repeat = 1
self._split_heuristic_preprocess_naive_interleaving = False
self._split_heuristic_preprocess_naive_interleaving_by_latency = False
self._split_heuristic_estimate_performance = True

self._compiler_binary = "gcc"
self._compiler_include_paths = None
Expand Down Expand Up @@ -1247,15 +1257,12 @@ def split_heuristic_region(self, val):
@split_heuristic_preprocess_naive_interleaving.setter
def split_heuristic_preprocess_naive_interleaving(self, val):
self._split_heuristic_preprocess_naive_interleaving = val
@split_heuristic_preprocess_naive_interleaving.setter
def split_heuristic_preprocess_naive_interleaving(self, val):
self._split_heuristic_preprocess_naive_interleaving = val
@split_heuristic_preprocess_naive_interleaving_by_latency.setter
def split_heuristic_preprocess_naive_interleaving_by_latency(self, val):
self._split_heuristic_preprocess_naive_interleaving_by_latency = val
@split_heuristic_preprocess_naive_interleaving_by_latency.setter
def split_heuristic_preprocess_naive_interleaving_by_latency(self, val):
self._split_heuristic_preprocess_naive_interleaving_by_latency = val
@split_heuristic_estimate_performance.setter
def split_heuristic_estimate_performance(self, val):
self._split_heuristic_estimate_performance = val
@split_heuristic_repeat.setter
def split_heuristic_repeat(self, val):
self._split_heuristic_repeat = val
47 changes: 24 additions & 23 deletions slothy/core/heuristics.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,29 +773,30 @@ def not_empty(x):
res.selfcheck(log.getChild("split_heuristic_full"))

# Estimate performance of final code
conf2 = conf.copy()
conf2.constraints.allow_renaming = False
conf2.constraints.allow_reordering = False
conf2.variable_size = True
stall_res = Heuristics.optimize_binsearch(res.code,
logger.getChild("split_estimtate_perf"), conf2)
if stall_res.success is False:
log.error("Stall-estimate for final code after split heuristic failed -- should not happen? Maybe increase timeout? Just returning the result without stall-estimate.")
else:
res2 = Result(conf2)
res2.orig_code = orig_body
res2.code = res.code_raw
res2.codesize_with_bubbles = stall_res.codesize_with_bubbles
res2.success = True
# Compose actual code reordering from split heuristic with bubble-introducing (order-preserving) map
res2.reordering_with_bubbles = { i: stall_res.reordering_with_bubbles[
res.reordering_with_bubbles[i]] for i in range(res.codesize) }
res2.input_renamings = { s:s for s in inputs }
res2.output_renamings = { s:s for s in outputs }
res2.valid = True
res2.selfcheck(log.getChild("split_heuristic_full_with_stalls"))

res = res2
if conf.split_heuristic_estimate_performance:
conf2 = conf.copy()
conf2.constraints.allow_renaming = False
conf2.constraints.allow_reordering = False
conf2.variable_size = True
stall_res = Heuristics.optimize_binsearch(res.code,
logger.getChild("split_estimtate_perf"), conf2)
if stall_res.success is False:
log.error("Stall-estimate for final code after split heuristic failed -- should not happen? Maybe increase timeout? Just returning the result without stall-estimate.")
else:
res2 = Result(conf2)
res2.orig_code = orig_body
res2.code = res.code_raw
res2.codesize_with_bubbles = stall_res.codesize_with_bubbles
res2.success = True
# Compose actual code reordering from split heuristic with bubble-introducing (order-preserving) map
res2.reordering_with_bubbles = { i: stall_res.reordering_with_bubbles[
res.reordering_with_bubbles[i]] for i in range(res.codesize) }
res2.input_renamings = { s:s for s in inputs }
res2.output_renamings = { s:s for s in outputs }
res2.valid = True
res2.selfcheck(log.getChild("split_heuristic_full_with_stalls"))

res = res2

return res

Expand Down

0 comments on commit 8d71da0

Please sign in to comment.