Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/autotuner/plotting/consider result validity #659

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions discopop_library/EmpiricalAutotuning/Autotuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
)
)
Expand All @@ -73,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]] = []
Expand Down Expand Up @@ -108,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:
Expand Down Expand Up @@ -149,6 +158,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,
)
)
Expand Down Expand Up @@ -231,10 +241,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)

Expand All @@ -255,6 +275,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

Expand Down
Loading