Skip to content

Commit 995a9cb

Browse files
Merge pull request #649 from linsword13/tuned-adm
Move tuned-adm to builtin repo
2 parents 5dbc9d0 + ce85dc2 commit 995a9cb

File tree

1 file changed

+88
-0
lines changed
  • var/ramble/repos/builtin/modifiers/tuned-adm

1 file changed

+88
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Copyright 2022-2024 The Ramble Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4+
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5+
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6+
# option. This file may not be copied, modified, or distributed
7+
# except according to those terms.
8+
9+
import os
10+
11+
from ramble.modkit import *
12+
13+
14+
SUCCESS_STRING = "Status: SUCCESS"
15+
16+
17+
class TunedAdm(BasicModifier):
18+
"""Define a modifier for TunedAdm
19+
20+
This modifier is used to select a specific tuned profile.
21+
It also records the selected profile as a FOM.
22+
"""
23+
24+
name = "tuned-adm"
25+
26+
tags("system-info", "sysinfo", "platform-info")
27+
28+
maintainers("douglasjacobsen")
29+
30+
mode("standard", description="Standard execution mode for tuned-adm")
31+
32+
software_spec("pdsh", pkg_spec="pdsh", package_manager="spack*")
33+
34+
required_variable("hostlist")
35+
36+
modifier_variable(
37+
"tuned-profile",
38+
default="google-hpc-compute-throughput",
39+
description="tuned profile to use",
40+
mode="standard",
41+
)
42+
43+
register_builtin("set_tuning_profile")
44+
45+
def set_tuning_profile(self):
46+
return [
47+
"pdsh -w {hostlist} sudo tuned-adm profile {tuned-profile}",
48+
"pdsh -w {hostlist} sudo tuned-adm active > {experiment_run_dir}/tuning_profile",
49+
]
50+
51+
def _prepare_analysis(self, workspace):
52+
run_dir = self.expander.expand_var("{experiment_run_dir}")
53+
read_profile_path = os.path.join(run_dir, "tuning_profile")
54+
55+
if not os.path.exists(read_profile_path):
56+
return
57+
58+
profiles = set()
59+
with open(read_profile_path) as f:
60+
61+
for line in f.readlines():
62+
if "active profile:" in line:
63+
profiles.add(line.split(":")[-1].strip())
64+
profiles_str = ",".join(profiles)
65+
66+
if profiles:
67+
expected_profile = self.expander.expand_var("{tuned-profile}")
68+
write_profile_path = os.path.join(run_dir, "all_tuning_profiles")
69+
with open(write_profile_path, "w+") as f:
70+
profiles_str = ",".join(profiles)
71+
f.write(f"Applied profiles: {profiles_str}\n")
72+
if len(profiles) == 1 and profiles_str == expected_profile:
73+
f.write(SUCCESS_STRING)
74+
75+
figure_of_merit(
76+
"Tuning Profile",
77+
fom_regex=r"Applied profiles:\s*(?P<profile>.*)",
78+
log_file="{experiment_run_dir}/all_tuning_profiles",
79+
group_name="profile",
80+
units="",
81+
)
82+
83+
success_criteria(
84+
"Expected tuning profile applied",
85+
mode="string",
86+
match=SUCCESS_STRING,
87+
file="{experiment_run_dir}/all_tuning_profiles",
88+
)

0 commit comments

Comments
 (0)