Skip to content

Commit 5dd8ffe

Browse files
author
Inkedstinct
committed
[NLD] : Fix bias that would lead to higher consumption for later tools as they were tested one after the other (increasing temperatures)
1 parent 0acfd58 commit 5dd8ffe

File tree

2 files changed

+203
-44
lines changed

2 files changed

+203
-44
lines changed

templates/benchmark.sh

Lines changed: 188 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,210 @@ set -ueo pipefail
55
{% include "oar_directives.sh" %}
66

77
SECONDS=0
8-
########################
9-
### INSTALL PACKAGES ###
10-
########################
8+
9+
1110
{% include "install_packages.sh" %}
11+
{% include "rust_setup.sh" %}
12+
13+
{% if codecarbon_alone || codecarbon_and_perf %}
14+
${SUDO_CMD}apt install -y python3.12-venv stress-ng python3-pip
15+
cd /tmp
16+
git clone https://github.com/mlco2/codecarbon.git
17+
python3.12 -m venv codecarbon/
18+
source codecarbon/bin/activate
19+
sed -i 's/Timer(self.interval, self._run)/Timer(self.interval\/1000, self._run)/' codecarbon/codecarbon/external/scheduler.py
20+
pip install /tmp/codecarbon
21+
${SUDO_CMD}ln -s /home/nleblond/.local/bin/codecarbon /usr/local/bin/codecarbon
22+
{% endif %}
23+
24+
25+
{% if alumet_alone || alumet_and_perf %}
26+
${SUDO_CMD}apt install -y build-essential libssl-dev pkg-config
27+
cd /tmp
28+
git clone https://github.com/alumet-dev/alumet.git
29+
git config --global --add safe.directory /tmp/alumet
30+
cd alumet
31+
git checkout "v0.7.0"
32+
cd app-agent
33+
cargo build --release --features local_x86
34+
${SUDO_CMD}ln -s $(realpath ../target/release/alumet-local-agent) /usr/local/bin/alumet
35+
cd /home/nleblond
36+
alumet regen-config
37+
{% endif %}
38+
39+
{% if scaphandre_alone || scaphandre_and_perf %}
40+
${SUDO_CMD}apt install -y build-essential libssl-dev pkg-config
41+
cd /tmp
42+
git clone https://github.com/hubblo-org/scaphandre.git
43+
git clone https://github.com/borntyping/rust-riemann_client.git
44+
git config --global --add safe.directory /tmp/rust-riemann_client
45+
git config --global --add safe.directory /tmp/scaphandre
46+
sed -i 's/\#!\[rustfmt::skip\]//' rust-riemann_client/src/proto/mod_pb.rs | head -10
47+
cd scaphandre
48+
git checkout "v1.0.1"
49+
sed -i 's/riemann_client = { version = "0.9.0"/riemann_client = { path = "..\/rust-riemann_client"/' Cargo.toml
50+
cargo build --release
51+
${SUDO_CMD}ln -s $(realpath ./target/release/scaphandre) /usr/local/bin/scaphandre
52+
cd /home/nleblond
53+
{% endif %}
54+
55+
{% if vjoule_alone || vjoule_and_perf %}
56+
cd /tmp
57+
wget https://github.com/davidson-consulting/vjoule/releases/download/v1.3.0/vjoule-tools_1.3.0.deb
58+
dpkg -i vjoule-tools_1.3.0.deb
59+
${SUDO_CMD}systemctl start vjoule_service
60+
cd /home/nleblond
61+
62+
${SUDO_CMD}systemctl status vjoule_service
63+
sleep 30
64+
${SUDO_CMD}systemctl status vjoule_service
65+
{% endif %}
1266

13-
#################################
14-
### CREATES RESULTS_DIRECTORY ###
15-
#################################
1667
{% include "results_directory_preparation.sh" %}
1768

69+
70+
get_average_temperature() {
71+
NB_SENSORS=$(sensors | grep "Package id" | wc -l)
72+
SUM_TEMP=$(sensors | grep "Package id" | awk '{print $4}' | cut -d'+' -f2 | cut -d'.' -f1 | paste -sd'+' | bc)
73+
AVG_TMP=$(( SUM_TEMP / NB_SENSORS ))
74+
echo $AVG_TMP
75+
}
76+
77+
{% include "baseline_consumption.sh" %}
78+
79+
{% include "warmup.sh" %}
80+
81+
{% for target_frequency in target_frequencies %}
82+
83+
PERF_AND_HWPC_FREQUENCY_FILE="{{ results_directory }}/frequency_{{ target_frequency }}_perf_and_hwpc"
84+
PERF_AND_HWPC_FREQUENCY_TEMPERATURES_FILE="{{ results_directory }}/temperatures_frequency_{{ target_frequency }}_perf_and_hwpc.csv"
85+
HWPC_AND_PERF_FREQUENCY_DIR="{{ results_directory }}/frequency_{{ target_frequency }}_hwpc_and_perf"
86+
touch $PERF_AND_HWPC_FREQUENCY_FILE
87+
mkdir -p $HWPC_AND_PERF_FREQUENCY_DIR
88+
echo "temperature_start,temperature_stop,iteration" > $PERF_AND_HWPC_FREQUENCY_TEMPERATURES_FILE
89+
90+
PERF_AND_CODECARBON_FREQUENCY_FILE="{{ results_directory }}/frequency_{{ target_frequency }}_perf_and_codecarbon"
91+
PERF_AND_CODECARBON_FREQUENCY_TEMPERATURES_FILE="{{ results_directory }}/temperatures_frequency_{{ target_frequency }}_perf_and_codecarbon.csv"
92+
CODECARBON_AND_PERF_FREQUENCY_FILE="{{ results_directory }}/frequency_{{ target_frequency }}_codecarbon_and_perf.csv"
93+
touch $PERF_AND_CODECARBON_FREQUENCY_FILE
94+
echo "domain,timestamp,energy,iteration" > $CODECARBON_AND_PERF_FREQUENCY_FILE
95+
echo "temperature_start,temperature_stop,iteration" > $PERF_AND_CODECARBON_FREQUENCY_TEMPERATURES_FILE
96+
97+
PERF_AND_ALUMET_FREQUENCY_FILE="{{ results_directory }}/frequency_{{ target_frequency }}_perf_and_alumet"
98+
PERF_AND_ALUMET_FREQUENCY_TEMPERATURES_FILE="{{ results_directory }}/temperatures_frequency_{{ target_frequency }}_perf_and_alumet.csv"
99+
ALUMET_AND_PERF_FREQUENCY_FILE="{{ results_directory }}/frequency_{{ target_frequency }}_alumet_and_perf.csv"
100+
ALUMET_AND_PERF_FREQUENCY_DIR="{{ results_directory }}/frequency_{{ target_frequency }}_alumet_and_perf"
101+
touch $PERF_AND_ALUMET_FREQUENCY_FILE
102+
echo "domain,timestamp,energy,iteration" > $ALUMET_AND_PERF_FREQUENCY_FILE
103+
echo "temperature_start,temperature_stop,iteration" > $PERF_AND_ALUMET_FREQUENCY_TEMPERATURES_FILE
104+
mkdir -p $ALUMET_AND_PERF_FREQUENCY_DIR
105+
106+
PERF_AND_SCAPHANDRE_FREQUENCY_FILE="{{ results_directory }}/frequency_{{ target_frequency }}_perf_and_scaphandre"
107+
PERF_AND_SCAPHANDRE_FREQUENCY_TEMPERATURES_FILE="{{ results_directory }}/temperatures_frequency_{{ target_frequency }}_perf_and_scaphandre.csv"
108+
SCAPHANDRE_AND_PERF_FREQUENCY_FILE="{{ results_directory }}/frequency_{{ target_frequency }}_scaphandre_and_perf.csv"
109+
touch $PERF_AND_SCAPHANDRE_FREQUENCY_FILE
110+
echo "domain,timestamp,energy,iteration" > $SCAPHANDRE_AND_PERF_FREQUENCY_FILE
111+
echo "temperature_start,temperature_stop,iteration" > $PERF_AND_SCAPHANDRE_FREQUENCY_TEMPERATURES_FILE
112+
113+
PERF_AND_VJOULE_FREQUENCY_FILE="{{ results_directory }}/frequency_{{ target_frequency }}_perf_and_vjoule"
114+
PERF_AND_VJOULE_FREQUENCY_TEMPERATURES_FILE="{{ results_directory }}/temperatures_frequency_{{ target_frequency }}_perf_and_vjoule.csv"
115+
VJOULE_AND_PERF_FREQUENCY_FILE="{{ results_directory }}/frequency_{{ target_frequency }}_vjoule_and_perf.csv"
116+
touch $PERF_AND_VJOULE_FREQUENCY_FILE
117+
echo "domain,timestamp,energy,iteration" > $VJOULE_AND_PERF_FREQUENCY_FILE
118+
echo "temperature_start,temperature_stop,iteration" > $PERF_AND_VJOULE_FREQUENCY_TEMPERATURES_FILE
119+
120+
for i in {1..{{ nb_iterations_frequencies }}}; do
121+
export i=$i
122+
123+
{% if frequencies_benchmark %}
124+
{% include "frequencies_benchmark.sh" %}
125+
{% endif %}
126+
127+
done
128+
129+
{% endfor %}
130+
131+
132+
{% for core_value in core_values %}
133+
CORE_VALUE={{ core_value }}
134+
{% for cpu_ops_per_core in cpu_ops_per_core_list %}
135+
CPU_OPS_PER_CORE={{ cpu_ops_per_core }}
136+
137+
touch {{ results_directory }}/perf_and_hwpc_{{ core_value }}_{{ cpu_ops_per_core }}
138+
mkdir -p {{ results_directory }}/hwpc_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}
139+
echo "temperature_start, temperature_stop, iteration" > {{ results_directory }}/perf_and_hwpc_{{ core_value }}_{{ cpu_ops_per_core }}_temperatures.csv
140+
141+
echo "domain,energy,iteration" > {{ results_directory }}/codecarbon_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}.csv
142+
echo "temperature_start, temperature_stop, iteration" > {{ results_directory }}/perf_and_codecarbon_{{ core_value }}_{{ cpu_ops_per_core }}_temperatures.csv
143+
touch {{ results_directory }}/perf_and_codecarbon_${CORE_VALUE}_${CPU_OPS_PER_CORE}
144+
145+
echo "domain,energy,iteration" > {{ results_directory }}/alumet_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}.csv
146+
echo "temperature_start, temperature_stop, iteration" > {{ results_directory }}/perf_and_alumet_{{ core_value }}_{{ cpu_ops_per_core }}_temperatures.csv
147+
mkdir -p {{ results_directory }}/alumet_and_perf_${CORE_VALUE}_${CPU_OPS_PER_CORE}
148+
touch {{ results_directory }}/perf_and_alumet_${CORE_VALUE}_${CPU_OPS_PER_CORE}
149+
150+
echo "domain,energy,iteration" > {{ results_directory }}/scaphandre_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}.csv
151+
echo "temperature_start, temperature_stop, iteration" > {{ results_directory }}/perf_and_scaphandre_{{ core_value }}_{{ cpu_ops_per_core }}_temperatures.csv
152+
touch {{ results_directory }}/perf_and_scaphandre_{{ core_value }}_{{ cpu_ops_per_core }}
153+
154+
touch {{ results_directory }}/vjoule_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}.csv
155+
echo "domain,energy,iteration" > {{ results_directory }}/vjoule_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}.csv
156+
touch {{ results_directory }}/perf_and_vjoule_{{ core_value }}_{{ cpu_ops_per_core }}
157+
echo "temperature_start, temperature_stop, iteration" > {{ results_directory }}/perf_and_vjoule_{{ core_value }}_{{ cpu_ops_per_core }}_temperatures.csv
158+
159+
for i in {1..{{ nb_iterations }}}; do
160+
18161
{% if perf_alone %}
19-
#################
20-
### ONLY PERF ###
21-
#################
22162
{% include "perf_alone.sh" %}
23163
{% endif %}
24164

25165
{% if hwpc_alone %}
26-
#################
27-
### ONLY HWPC ###
28-
#################
29166
{% include "hwpc_alone.sh" %}
30167
{% endif %}
31168

169+
{% if codecarbon_alone %}
170+
{% include "codecarbon_alone.sh" %}
171+
{% endif %}
172+
173+
{% if alumet_alone %}
174+
{% include "alumet_alone.sh" %}
175+
{% endif %}
176+
177+
{% if scaphandre_alone %}
178+
{% include "scaphandre_alone.sh" %}
179+
{% endif %}
180+
181+
{% if vjoule_alone %}
182+
{% include "vjoule_alone.sh" %}
183+
{% endif %}
184+
32185
{% if hwpc_and_perf %}
33-
###################
34-
### HWPC & PERF ###
35-
###################
36186
{% include "hwpc_and_perf.sh" %}
37187
{% endif %}
38188

39-
#############################
40-
### ZIP RESULTS_DIRECTORY ###
41-
#############################
189+
{% if codecarbon_and_perf %}
190+
{% include "codecarbon_and_perf.sh" %}
191+
{% endif %}
192+
193+
{% if alumet_and_perf %}
194+
{% include "alumet_and_perf.sh" %}
195+
{% endif %}
196+
197+
{% if scaphandre_and_perf %}
198+
{% include "scaphandre_and_perf.sh" %}
199+
{% endif %}
200+
201+
{% if vjoule_and_perf %}
202+
{% include "vjoule_and_perf.sh" %}
203+
{% endif %}
204+
205+
done
206+
207+
{% endfor %}
208+
{% endfor %}
209+
210+
42211
{% include "zip_results.sh" %}
43212

44-
############
45-
### EXIT ###
46-
############
47-
duration=$SECONDS
48-
echo "$(($diff / 3600)) hours, $((duration / 60)) minutes and $((duration % 60)) seconds elapsed."
213+
49214
{% include "exit.sh" %}

templates/hwpc_and_perf.sh

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
{% for core_value in core_values %}
2-
{% for cpu_ops_per_core in cpu_ops_per_core_list %}
3-
touch {{ results_directory }}/perf_and_hwpc_{{ core_value }}_{{ cpu_ops_per_core }}
4-
mkdir -p {{ results_directory }}/hwpc_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}
5-
for i in {1..{{ nb_iterations }}}; do
6-
### HWPC sensor dedicated to stress-ng with {{ core_value }} CPU * {{ cpu_ops_per_core }} OPS
7-
docker run --rm -d --net=host --privileged --pid=host --name {{ hwpc_and_perf_configs.get(core_value).unwrap().name }}_{{ cpu_ops_per_core }}_$i \
1+
### HWPC sensor dedicated to stress-ng with {{ core_value }} CPU * {{ cpu_ops_per_core }} OPS
2+
TEMPERATURE_START=$(get_average_temperature)
3+
docker run --rm -d --net=host --privileged --pid=host --name {{ hwpc_and_perf_configs.get(core_value).unwrap().name }}_{{ cpu_ops_per_core }}_$i \
84
-v /sys:/sys \
95
-v /var/lib/docker/containers:/var/lib/docker/containers:ro \
106
-v /tmp/power-api-sensor-reporting:/reporting \
@@ -15,18 +11,16 @@ for i in {1..{{ nb_iterations }}}; do
1511
-r {{ hwpc_and_perf_configs.get(core_value).unwrap().output.type }} -U {{ hwpc_home_directory }}/{{ results_directory }}/hwpc_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}/hwpc_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}_$i \
1612
{% if hwpc_alone_configs.get(core_value).unwrap().system.rapl.events.len() > 0 %} -s "rapl" {%~ for event in hwpc_alone_configs.get(core_value).unwrap().system.rapl.events %}-e "{{ event }}" {% endfor %}{% endif %} {% if hwpc_alone_configs.get(core_value).unwrap().system.msr.events.len() > 0 %} -s "msr" {%~ for event in hwpc_alone_configs.get(core_value).unwrap().system.msr.events %}-e "{{ event }}" {% endfor %} {% endif %} {% if hwpc_alone_configs.get(core_value).unwrap().system.core.events.len() > 0 %} -c "core" {%~ for event in hwpc_alone_configs.get(core_value).unwrap().system.core.events %}-e "{{ event }}" {% endfor %} {% endif %}
1713

18-
${SUDO_CMD}bash -c "perf stat -a -o /tmp/perf_and_hwpc_{{ core_value }}_{{ cpu_ops_per_core }}_$i {% for perf_event in perf_events.iter() %}-e {{ perf_event }} {% endfor %} & echo \$!" > /tmp/perf_pid_$i
19-
PERF_PID=$(cat /tmp/perf_pid_$i)
20-
while ! [[ -e "{{ results_directory }}/hwpc_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}/hwpc_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}_$i/rapl.csv" ]]; do sleep 0.02s ; done
21-
### PERF with {{ core_value }} CPU * {{ cpu_ops_per_core }} OPS
22-
stress-ng --cpu {{ core_value }} --cpu-ops {{ core_value * cpu_ops_per_core }} -q
23-
sleep 1s
14+
${SUDO_CMD}bash -c "perf stat -a -o /tmp/perf_and_hwpc_{{ core_value }}_{{ cpu_ops_per_core }}_$i {% for perf_event in perf_events.iter() %}-e {{ perf_event }} {% endfor %} & echo \$!" > /tmp/perf_pid_$i
15+
PERF_PID=$(cat /tmp/perf_pid_$i)
16+
while ! [[ -e "{{ results_directory }}/hwpc_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}/hwpc_and_perf_{{ core_value }}_{{ cpu_ops_per_core }}_$i/rapl.csv" ]]; do sleep 0.02s ; done
17+
### PERF with {{ core_value }} CPU * {{ cpu_ops_per_core }} OPS
18+
stress-ng --cpu {{ core_value }} --cpu-ops {{ core_value * cpu_ops_per_core }} -q
19+
sleep 1s
2420

25-
${SUDO_CMD}kill -2 $PERF_PID
26-
docker stop {{ hwpc_and_perf_configs.get(core_value).unwrap().name }}_{{ cpu_ops_per_core }}_$i
27-
cat /tmp/perf_and_hwpc_{{ core_value }}_{{ cpu_ops_per_core }}_$i >> {{ results_directory }}/perf_and_hwpc_{{ core_value }}_{{ cpu_ops_per_core }}
28-
sleep 15
29-
done
30-
31-
{% endfor %}
32-
{% endfor %}
21+
${SUDO_CMD}kill -2 $PERF_PID
22+
docker stop {{ hwpc_and_perf_configs.get(core_value).unwrap().name }}_{{ cpu_ops_per_core }}_$i
23+
TEMPERATURE_STOP=$(get_average_temperature)
24+
echo "$TEMPERATURE_START, $TEMPERATURE_STOP, $i" >> {{ results_directory }}/perf_and_hwpc_{{ core_value }}_{{ cpu_ops_per_core }}_temperatures.csv
25+
cat /tmp/perf_and_hwpc_{{ core_value }}_{{ cpu_ops_per_core }}_$i >> {{ results_directory }}/perf_and_hwpc_{{ core_value }}_{{ cpu_ops_per_core }}
26+
sleep 15

0 commit comments

Comments
 (0)