Skip to content

Commit

Permalink
Fix binary search routine for functional_only runs
Browse files Browse the repository at this point in the history
  • Loading branch information
hanno-becker committed Jul 17, 2024
1 parent b9fc7e7 commit a5c0402
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions slothy/core/heuristics.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,14 @@ def optimize_binsearch(source, logger, conf, **kwargs):
The Result object for the succceeding optimization with the smallest
number of stalls.
"""
flexible = not conf.constraints.functional_only

if conf.variable_size:
return Heuristics.optimize_binsearch_internal(source, logger, conf, **kwargs)
return Heuristics.optimize_binsearch_internal(source, logger, conf,
flexible=flexible, **kwargs)

return Heuristics.optimize_binsearch_external(source, logger, conf, **kwargs)
return Heuristics.optimize_binsearch_external(source, logger, conf,
flexible=flexible, **kwargs)

@staticmethod
def _log_reoptimization_failure(log):
Expand Down Expand Up @@ -201,7 +205,7 @@ def optimize_binsearch_external(source, logger, conf, flexible=True, **kwargs):
return core.result

@staticmethod
def optimize_binsearch_internal(source, logger, conf, **kwargs):
def optimize_binsearch_internal(source, logger, conf, flexible=True, **kwargs):
"""Internally optimize for minimum number of stalls, and potentially a secondary objective.
This finds the minimum number of stalls for which a one-shot SLOTHY optimization succeeds.
Expand All @@ -213,11 +217,21 @@ def optimize_binsearch_internal(source, logger, conf, **kwargs):
logger: The logger to be used.
conf: The configuration to apply. This is fixed for all one-shot SLOTHY
runs invoked by this call, except for variation of stall count.
flexible: Indicates whether the number of stalls should be minimized
through a binary search, or whether a single one-shot SLOTHY optimization
for a fixed number of stalls (encoded in the configuration) should be
conducted.
Returns:
A Result object representing the final optimization result.
"""

if not flexible:
core = SlothyBase(conf.arch, conf.target, logger=logger,config=conf)
if not core.optimize(source):
raise SlothyException("Optimization failed")
return core.result

logger.info("Perform internal binary search for minimal number of stalls...")

start_attempt = conf.constraints.stalls_first_attempt
Expand Down

0 comments on commit a5c0402

Please sign in to comment.