From a0dbd6a31ef2b50cdc4581461186fa335a0cb762 Mon Sep 17 00:00:00 2001 From: Lukas Rothenberger Date: Mon, 26 Aug 2024 13:20:07 +0200 Subject: [PATCH] fix(autotuner): consider result validity in plotting --- .../EmpiricalAutotuning/Autotuner.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/discopop_library/EmpiricalAutotuning/Autotuner.py b/discopop_library/EmpiricalAutotuning/Autotuner.py index 9ec0f90ca..79f05e69c 100644 --- a/discopop_library/EmpiricalAutotuning/Autotuner.py +++ b/discopop_library/EmpiricalAutotuning/Autotuner.py @@ -39,7 +39,7 @@ def get_unique_configuration_id() -> int: def run(arguments: AutotunerArguments) -> None: logger.info("Starting discopop autotuner.") - debug_stats: List[Tuple[List[SUGGESTION_ID], float, int, str]] = [] + debug_stats: List[Tuple[List[SUGGESTION_ID], float, int, bool, str]] = [] statistics_graph = StatisticsGraph() statistics_step_num = 0 @@ -57,6 +57,7 @@ def run(arguments: AutotunerArguments) -> None: [], cast(ExecutionResult, reference_configuration.execution_result).runtime, cast(ExecutionResult, reference_configuration.execution_result).return_code, + cast(ExecutionResult, reference_configuration.execution_result).result_valid, reference_configuration.root_path, ) ) @@ -149,6 +150,7 @@ def run(arguments: AutotunerArguments) -> None: current_config, cast(ExecutionResult, tmp_config.execution_result).runtime, cast(ExecutionResult, tmp_config.execution_result).return_code, + cast(ExecutionResult, tmp_config.execution_result).result_valid, tmp_config.root_path, ) ) @@ -231,10 +233,20 @@ def run(arguments: AutotunerArguments) -> None: # show debug stats stats_str = "Configuration measurements:\n" - stats_str += "[time]\t[applied suggestions]\t[return code]\t[path]\n" - for stats in sorted(debug_stats, key=lambda x: x[1], reverse=True): + stats_str += "[time]\t[applied suggestions]\t[return code]\t[result valid]\t[path]\n" + for stats in sorted(debug_stats, key=lambda x: (x[1]), reverse=True): stats_str += ( - str(round(stats[1], 3)) + "s" + "\t" + str(stats[0]) + "\t" + str(stats[2]) + "\t" + str(stats[3]) + "\n" + str(round(stats[1], 3)) + + "s" + + "\t" + + str(stats[0]) + + "\t" + + str(stats[2]) + + "\t" + + str(stats[3]) + + "\t" + + str(stats[4]) + + "\n" ) logger.info(stats_str) @@ -255,6 +267,8 @@ def run(arguments: AutotunerArguments) -> None: for stats in sorted(debug_stats, key=lambda x: x[1], reverse=False): if str(stats[2]) != "0": continue + if stats[3] == False: # skip invalid results + continue f.write(str(stats[0]) + "; " + str(round(stats[1], 3)) + "; " + str(stats[2]) + ";" + "\n") break