ampere_research/trilinos/collect_data_ampere.sh
2024-10-22 00:50:41 -04:00

74 lines
2.2 KiB
Bash
Executable File

#! /bin/bash
power_baseline_time_s="$1"
solver="$2"
lin_alg="$3"
input_file="$4"
#filename="$@"
filename="${solver} ${lin_alg} ${input_file%.*}"
filename="${filename// /_}"
dest_dir="output/"
output_file="${dest_dir}${filename}".output
power_file="${dest_dir}${filename}"_power.output
function record_power {
echo "Recording power..."
sensors | awk '/CPU power:/ {printf "Socket"++count[$1] " "; print $3}' >> "$power_file"
}
function record_power_baseline {
echo "Recording power baseline..."
for i in $(seq 1 $power_baseline_time_s); do
record_power
sleep 1s
done
echo "Finished power baseline..."
}
mkdir "$dest_dir"
rm -v "$output_file"
rm -v "$power_file"
#apptainer run ./testing.sif stress -c 20 -t 10 & >> "$output_file"
#perf stat -d -d -d -M branch_misprediction_ratio apptainer run ./testing.sif stress -c 16 -t 10 > testing
program=(apptainer run --bind ../ampere_scratch:/mnt trilinos.sif
bash -c
"cd /mnt/Trilinos-trilinos-release-16-0-0/BUILD/packages/panzer/mini-em/example/BlockPrec/ && ./PanzerMiniEM_BlockPrec.exe"\
\ "--stacked-timer --solver=$solver --linAlgebra=$lin_alg --inputFile=$input_file")
# Power Stats
record_power_baseline
echo "Start" >> "$power_file"
"${program[@]}" | tee /dev/null &
pid=$!
# If this script is killed, kill the program above.
# NOTE: The trap isn't particularly useful since nodes are being used.
#trap "kill $pid 2> /dev/null" EXIT
# While program is running, record power.
while kill -0 $pid 2> /dev/null; do
record_power
sleep 1s
done
echo "End" >> "$power_file"
record_power_baseline
# Perf Stats
hostname | tee --append "$output_file"
echo "$@" | tee --append "$output_file"
echo "$output_file" | tee --append "$output_file"
echo "$power_file" | tee --append "$output_file"
perf stat -d -d -M branch_misprediction_ratio "${program[@]}" 2>&1 | tee --append "$output_file"
perf stat -M dtlb_walk_ratio,itlb_walk_ratio "${program[@]}" 2>&1 1>/dev/null | tee --append "$output_file"
perf stat -M l1d_cache_miss_ratio,l1i_cache_miss_ratio "${program[@]}" 2>&1 1>/dev/null | tee --append "$output_file"
perf stat -M l2_cache_miss_ratio,l2_tlb_miss_ratio,ll_cache_read_miss_ratio "${program[@]}" 2>&1 1>/dev/null | tee --append "$output_file"
# Disable the trap on a normal exit.
#trap - EXIT
wait