Last active
January 31, 2024 16:08
-
-
Save tdulcet/13f7996b42e080e30a1ea46b0958082d to your computer and use it in GitHub Desktop.
Compares the performance of GpuOwl commits/versions with multiple exponents. Saves the results in a `bench.csv` file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright © 2022 Teal Dulcet | |
# Compare the performance of GpuOwl commits with multiple exponents | |
# Run: ./performance.sh | |
# set -e | |
# Exponents | |
EXPONENTS=(106928347) | |
# EXPONENTS=( 63929989 116509969 340789957 ) | |
# EXPONENTS=( 63000083 113000033 367000099 ) | |
# EXPONENTS=( 57000991 63000083 67000177 73004279 76000207 84000017 95000011 103246861 113000033 125939521 131000021 144202441 150000029 169000061 187101781 205000013 223000051 247001701 260001727 283000171 295000007 331000037 367000099 403000007 438000131 487001743 509000099 559001657 580001651 650004253 720000049 791000053 861000113 960009689 999999929 1100000017 1138000001 1250000029 1410000023 1553000003 1690000133 1891000019 1960000019 2147483563 2236000033 2500000057 2770000019 3045000031 3315000037 ) | |
# Number of iterations | |
ITERS=10000 | |
# Device number | |
DEVICE=0 | |
# GpuOwl arguments | |
ARGS=( | |
-device $DEVICE | |
) | |
if command -v clinfo >/dev/null; then | |
mapfile -t TOTAL_GPU_MEM < <(clinfo --raw | sed -n 's/.*CL_DEVICE_GLOBAL_MEM_SIZE *//p') | |
for i in "${!TOTAL_GPU_MEM[@]}"; do | |
TOTAL_GPU_MEM[i]=$((TOTAL_GPU_MEM[i] / 1024 / 1024)) | |
done | |
elif command -v nvidia-smi >/dev/null && nvidia-smi >/dev/null; then | |
mapfile -t TOTAL_GPU_MEM < <(nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits | grep -iv 'not supported') | |
fi | |
maxAlloc="$(echo "${TOTAL_GPU_MEM[DEVICE]}" | awk '{ printf "%d", $1 * 0.9 }')M" | |
{ | |
printf ',%s' "${EXPONENTS[@]}" | |
echo | |
} >>bench.csv | |
if [[ -d gpuowl ]]; then | |
echo -e "GpuOwl is already downloaded\n" | |
else | |
echo -e "Downloading GpuOwl\n" | |
git clone https://github.com/preda/gpuowl.git | |
fi | |
cd gpuowl | |
START=$(git rev-list --count HEAD..master) | |
END=$(($(git rev-list --count 14c60f9224d2a2fd2a190d277b7eb74ced23b01c..master) + 10)) | |
time for ((i = START; i < END; ++i)); do | |
echo -n "$(git describe --tags --long --always)" >>../bench.csv | |
printf "%'d\t" "$i" | |
sed -i 's/--dirty //' Makefile | |
sed -i 's/-Wall -O2/-Wall -g -O3/' Makefile | |
# sed -i 's/-O3/-O3 -flto -funsafe-math-optimizations -ffinite-math-only/' Makefile | |
sed -i 's/-O3/-O3 -flto/' Makefile | |
for file in B1Accumulator.h Task.cpp; do | |
if [[ -e $file ]] && ! grep -q '^#include <optional>' $file; then | |
sed -i '/^#include <cassert>/a #include <optional>' $file | |
fi | |
done | |
for file in Pm1Plan.cpp B1Accumulator.cpp; do | |
if [[ ! -e $file ]] && grep -q $file Makefile; then | |
sed -i "s/$file //" Makefile | |
fi | |
done | |
if make -s -j "$(nproc)"; then | |
args=("${ARGS[@]}") | |
output=$(./gpuowl -h) | |
if echo "$output" | grep -q '^-unsafeMath'; then | |
args+=(-unsafeMath) | |
# elif echo "$output" | grep -q '^-safeMath'; then | |
# args+=(-safeMath) | |
fi | |
if echo "$output" | grep -q '^-maxAlloc'; then | |
args+=(-maxAlloc "$maxAlloc") | |
fi | |
for e in "${EXPONENTS[@]}"; do | |
printf "\tExponent: %'d\n" "$e" | |
output=$( | |
set -x | |
./gpuowl -prp "$e" -iters $ITERS -nospin "${args[@]}" | |
) | |
echo "$output" | grep -i '[[:digit:]]\{6,\} \(LL\|P1\|OK\|EE\)\? \+[[:digit:]]\{4,\}\|check\|jacobi\|error\| E :\|exception\|exiting' | |
if output=$(echo "$output" | grep '[[:digit:]]\{7,\} \(LL\|P1\|OK\|EE\)\? \+[[:digit:]]\{5,\}' | grep $ITERS); then | |
RE='([[:digit:]]+) us/it;?' | |
if [[ $output =~ $RE ]]; then | |
output=${BASH_REMATCH[1]} | |
fi | |
fi | |
echo -n ",$output" >>../bench.csv | |
# sleep 1 | |
done | |
fi | |
echo >>../bench.csv | |
git reset --hard -q | |
git clean -fdx -q | |
git checkout -f -q HEAD~1 | |
done # | tee -a ../performance.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment