|
2 | 2 | import logging
|
3 | 3 | from collections import namedtuple
|
4 | 4 | from time import perf_counter
|
| 5 | +from warnings import warn |
5 | 6 |
|
6 | 7 | from kernel_tuner import util
|
7 | 8 | from kernel_tuner.runners.runner import Runner
|
@@ -127,8 +128,26 @@ def run(self, parameter_space, tuning_options):
|
127 | 128 | results.append(result)
|
128 | 129 | continue
|
129 | 130 |
|
130 |
| - # if the element is not in the cache, raise an error |
131 |
| - check = util.check_restrictions(tuning_options.restrictions, dict(zip(tuning_options['tune_params'].keys(), element)), True) |
| 131 | + # if the configuration is not in the cache and not within restrictions, simulate an InvalidConfig with warning |
| 132 | + params_dict = dict(zip(tuning_options['tune_params'].keys(), element)) |
| 133 | + check = util.check_restrictions(tuning_options.restrictions, params_dict, True) |
| 134 | + if not check: |
| 135 | + result = params_dict |
| 136 | + result['compile_time'] = 0 |
| 137 | + result['verification_time'] = 0 |
| 138 | + result['benchmark_time'] = 0 |
| 139 | + result['strategy_time'] = self.last_strategy_time |
| 140 | + |
| 141 | + total_time = 1000 * (perf_counter() - self.start_time) |
| 142 | + self.start_time = perf_counter() |
| 143 | + result['framework_time'] = total_time - self.last_strategy_time |
| 144 | + |
| 145 | + result[tuning_options.objective] = util.InvalidConfig() |
| 146 | + results.append(result) |
| 147 | + warn(f"Configuration {element} not in cache, does not pass restrictions. Will be treated as an InvalidConfig, but make sure you are evaluating the correct cache file.") |
| 148 | + continue |
| 149 | + |
| 150 | + # if the configuration is not in the cache and passes restrictions, return a ValueError |
132 | 151 | err_string = f"kernel configuration {element} not in cache, does {'' if check else 'not '}pass extra restriction check ({check})"
|
133 | 152 | logging.debug(err_string)
|
134 | 153 | raise ValueError(f"{err_string} - in simulation mode, all configurations must be present in the cache")
|
|
0 commit comments