From 34fe6cd319667bfd5e91fb9c936b5b93a46d4abe Mon Sep 17 00:00:00 2001 From: Lin Guo Date: Tue, 17 Sep 2024 00:41:30 -0700 Subject: [PATCH 1/2] Move tuned-adm to builtin repo Also update the active profile query to check all nodes. --- .../builtin/modifiers/tuned-adm/modifier.py | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 var/ramble/repos/builtin/modifiers/tuned-adm/modifier.py diff --git a/var/ramble/repos/builtin/modifiers/tuned-adm/modifier.py b/var/ramble/repos/builtin/modifiers/tuned-adm/modifier.py new file mode 100644 index 000000000..c1bedaaae --- /dev/null +++ b/var/ramble/repos/builtin/modifiers/tuned-adm/modifier.py @@ -0,0 +1,76 @@ +# Copyright 2022-2024 The Ramble Authors +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +import os + +from ramble.modkit import * + + +class TunedAdm(BasicModifier): + """Define a modifier for TunedAdm + + This modifier is used to select a specific tuned profile. + It also records the selected profile as a FOM. + """ + + name = "tuned-adm" + + tags("system-info", "sysinfo", "platform-info") + + maintainers("douglasjacobsen") + + mode("standard", description="Standard execution mode for tuned-adm") + + software_spec("pdsh", pkg_spec="pdsh", package_manager="spack*") + + required_variable("hostlist") + + modifier_variable( + "tuned-profile", + default="google-hpc-compute-throughput", + description="tuned profile to use", + mode="standard", + ) + + register_builtin("set_tuning_profile") + + def set_tuning_profile(self): + return [ + "pdsh -w {hostlist} sudo tuned-adm profile {tuned-profile}", + "pdsh -w {hostlist} sudo tuned-adm active > {experiment_run_dir}/tuning_profile", + ] + + def _prepare_analysis(self, workspace): + profile_path = os.path.join( + self.expander.expand_var("{experiment_run_dir}"), + "tuning_profile", + ) + + if not os.path.exists(profile_path): + return + + profiles = set() + with open(profile_path) as f: + + for line in f.readlines(): + if "active profile:" in line: + profiles.add(line.split(":")[-1].strip()) + profiles_str = ",".join(profiles) + + if profiles: + with open(profile_path, "a") as f: + profiles_str = ",".join(profiles) + f.write(f"Applied profiles: {profiles_str}") + + figure_of_merit( + "Tuning Profile", + fom_regex=r"Applied profiles:\s*(?P.*)", + log_file="{experiment_run_dir}/tuning_profile", + group_name="profile", + units="", + ) From ce85dc22e06c9c154074cf09c7d993a0f64d9fe6 Mon Sep 17 00:00:00 2001 From: Lin Guo Date: Tue, 17 Sep 2024 17:07:58 -0700 Subject: [PATCH 2/2] Add success_criteria --- .../builtin/modifiers/tuned-adm/modifier.py | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/var/ramble/repos/builtin/modifiers/tuned-adm/modifier.py b/var/ramble/repos/builtin/modifiers/tuned-adm/modifier.py index c1bedaaae..f510dc18d 100644 --- a/var/ramble/repos/builtin/modifiers/tuned-adm/modifier.py +++ b/var/ramble/repos/builtin/modifiers/tuned-adm/modifier.py @@ -11,6 +11,9 @@ from ramble.modkit import * +SUCCESS_STRING = "Status: SUCCESS" + + class TunedAdm(BasicModifier): """Define a modifier for TunedAdm @@ -46,16 +49,14 @@ def set_tuning_profile(self): ] def _prepare_analysis(self, workspace): - profile_path = os.path.join( - self.expander.expand_var("{experiment_run_dir}"), - "tuning_profile", - ) + run_dir = self.expander.expand_var("{experiment_run_dir}") + read_profile_path = os.path.join(run_dir, "tuning_profile") - if not os.path.exists(profile_path): + if not os.path.exists(read_profile_path): return profiles = set() - with open(profile_path) as f: + with open(read_profile_path) as f: for line in f.readlines(): if "active profile:" in line: @@ -63,14 +64,25 @@ def _prepare_analysis(self, workspace): profiles_str = ",".join(profiles) if profiles: - with open(profile_path, "a") as f: + expected_profile = self.expander.expand_var("{tuned-profile}") + write_profile_path = os.path.join(run_dir, "all_tuning_profiles") + with open(write_profile_path, "w+") as f: profiles_str = ",".join(profiles) - f.write(f"Applied profiles: {profiles_str}") + f.write(f"Applied profiles: {profiles_str}\n") + if len(profiles) == 1 and profiles_str == expected_profile: + f.write(SUCCESS_STRING) figure_of_merit( "Tuning Profile", fom_regex=r"Applied profiles:\s*(?P.*)", - log_file="{experiment_run_dir}/tuning_profile", + log_file="{experiment_run_dir}/all_tuning_profiles", group_name="profile", units="", ) + + success_criteria( + "Expected tuning profile applied", + mode="string", + match=SUCCESS_STRING, + file="{experiment_run_dir}/all_tuning_profiles", + )