Skip to content

Commit ff1b875

Browse files
committed
Added energibridge integration
TODO: add readme information
1 parent 36f4388 commit ff1b875

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

examples/energibridge-profiling/RunnerConfig.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ def __init__(self):
5858
def create_run_table_model(self) -> RunTableModel:
5959
"""Create and return the run_table model here. A run_table is a List (rows) of tuples (columns),
6060
representing each run performed"""
61-
#sampling_factor = FactorModel("sampling", [1, 10, 50, 100, 200, 500, 1000])
61+
sampling_factor = FactorModel("sampling", [10, 50, 100, 200, 500, 1000])
6262
self.run_table_model = RunTableModel(
63-
# factors = [sampling_factor],
64-
data_columns=['avg_cpu', 'total_energy']
63+
factors = [sampling_factor],
64+
data_columns=['avg_cpu_usage_0', 'package_energy']
6565
)
6666
return self.run_table_model
6767

@@ -93,11 +93,18 @@ def start_run(self, context: RunnerContext) -> None:
9393

9494
def start_measurement(self, context: RunnerContext) -> None:
9595
"""Perform any activity required for starting measurements."""
96+
sampling_interval = context.run_variation['sampling']
9697

97-
profiler_cmd = f'sudo energibridge -o {context.run_dir / "energibridge.csv"} --summary python primer.py'
98+
profiler_cmd = f'sudo energibridge \
99+
--interval {sampling_interval} \
100+
--max-execution 20 \
101+
--output {context.run_dir / "energibridge.csv"} \
102+
--summary \
103+
python3 examples/energibridge-profiling/primer.py'
98104

99-
time.sleep(1) # allow the process to run a little before measuring
100-
self.profiler = subprocess.Popen(shlex.split(profiler_cmd))
105+
#time.sleep(1) # allow the process to run a little before measuring
106+
energibridge_log = open(f'{context.run_dir}/energibridge.log', 'w')
107+
self.profiler = subprocess.Popen(shlex.split(profiler_cmd), stdout=energibridge_log)
101108

102109
def interact(self, context: RunnerContext) -> None:
103110
"""Perform any interaction with the running target system here, or block here until the target finishes."""
@@ -110,15 +117,16 @@ def interact(self, context: RunnerContext) -> None:
110117
def stop_measurement(self, context: RunnerContext) -> None:
111118
"""Perform any activity here required for stopping measurements."""
112119

113-
os.kill(self.profiler.pid, signal.SIGINT) # graceful shutdown of energibridge
120+
#os.kill(self.profiler.pid, signal.SIGINT) # graceful shutdown of energibridge
114121
self.profiler.wait()
115122

116123
def stop_run(self, context: RunnerContext) -> None:
117124
"""Perform any activity here required for stopping the run.
118125
Activities after stopping the run should also be performed here."""
119126

120-
self.target.kill()
121-
self.target.wait()
127+
#self.target.kill()
128+
#self.target.wait()
129+
pass
122130

123131
def populate_run_data(self, context: RunnerContext) -> Optional[Dict[str, Any]]:
124132
"""Parse and process any measurement data here.
@@ -127,10 +135,10 @@ def populate_run_data(self, context: RunnerContext) -> Optional[Dict[str, Any]]:
127135

128136
# energibridge.csv - Power consumption of the whole system
129137
# energibridge.csv-PID.csv - Power consumption of that specific process
130-
df = pd.read_csv(context.run_dir / f"energibridge.csv-{self.target.pid}.csv")
138+
df = pd.read_csv(context.run_dir / f"energibridge.csv")
131139
run_data = {
132-
'avg_cpu': round(df['CPU Utilization'].sum(), 3),
133-
'total_energy': round(df['CPU Power'].sum(), 3),
140+
'avg_cpu_usage_0': round(df['CPU_USAGE_0'].sum(), 3),
141+
'package_energy': round(df['PACKAGE_ENERGY (J)'].sum(), 3),
134142
}
135143
return run_data
136144

examples/energibridge-profiling/primer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
import os
42
import struct
53

0 commit comments

Comments
 (0)