From c067ada663d1e73a3be00f52abcc6761c8bd2700 Mon Sep 17 00:00:00 2001 From: Lukas Rothenberger Date: Mon, 26 Aug 2024 13:20:07 +0200 Subject: [PATCH 1/2] 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 From 195ee7ede646cd04f3b3af9106912a218f9fe441 Mon Sep 17 00:00:00 2001 From: Lukas Rothenberger Date: Mon, 26 Aug 2024 15:17:03 +0200 Subject: [PATCH 2/2] fix(autotuner): filtering of relevant loops --- discopop_library/EmpiricalAutotuning/Autotuner.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/discopop_library/EmpiricalAutotuning/Autotuner.py b/discopop_library/EmpiricalAutotuning/Autotuner.py index 79f05e69c..60f73752a 100644 --- a/discopop_library/EmpiricalAutotuning/Autotuner.py +++ b/discopop_library/EmpiricalAutotuning/Autotuner.py @@ -74,6 +74,16 @@ def run(arguments: AutotunerArguments) -> None: detection_result: DetectionResult = jsonpickle.decode(tmp_str) logger.debug("loaded suggestions") + # get metadata: highest average runtime in hotspot information. Used to filter relevant loops (1% runtime contribution) + max_avg_runtime = 0.0 + for hotspot_type in [HotspotType.YES, HotspotType.MAYBE, HotspotType.NO]: + if hotspot_information: + if hotspot_type not in hotspot_information: + continue + for info in hotspot_information[hotspot_type]: + if info[4] > max_avg_runtime: + max_avg_runtime = info[4] + # greedy search for best suggestion configuration: # for all hotspot types in descending importance: visited_configurations: List[List[SUGGESTION_ID]] = [] @@ -109,9 +119,7 @@ def run(arguments: AutotunerArguments) -> None: + "s" ) # check if the loop contributes more than 1% to the total runtime - loop_contributes_significantly = loop_tuple[4] > ( - cast(ExecutionResult, reference_configuration.execution_result).runtime / 100 - ) + loop_contributes_significantly = loop_tuple[4] > (max_avg_runtime / 100) if not loop_contributes_significantly: statistics_graph.add_child(loop_str, color=NodeColor.ORANGE) else: