-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathexecute-benchmark.sh
More file actions
executable file
·166 lines (109 loc) · 4.3 KB
/
Copy pathexecute-benchmark.sh
File metadata and controls
executable file
·166 lines (109 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status.
###################################################################################################
# Parameters
###################################################################################################
# $1: toggle gpflow yes/no
# $2: toggle gpytorch yes/no
# $3: toggle GPRat Cholesky yes/no
# $4: toggle GPRat Python yes/no
# $5: hardware cpu/gpu
# $6: vendor nvidia/amd/cpu
# $7: toggle GPRat CUDA/SYCL cuda/sycl only for NVIDIA GPUs
# Set global variables
HARDWARE=$5
VENDOR=$6
# Set variables relevant for GPRat
if [[ "$HARDWARE" == "cpu" ]]; then
GPRAT_TARGET="cpu"
GPRAT_USE_GPU=""
BUILD_DIR="build/release-linux"
elif [[ "$HARDWARE" == "gpu" ]]; then
GPRAT_USE_GPU="--use-gpu"
if [[ "$VENDOR" == "nvidia" ]]; then
if [[ "$7" == "cuda" ]]; then
GPRAT_TARGET="cuda"
BUILD_DIR="build/release-linux-cuda"
elif [[ "$7" == "sycl" ]]; then
GPRAT_TARGET="sycl"
BUILD_DIR="build/release-linux-sycl"
else
echo -e "\e[31mUnsupported GPRat target: ${5}\e[0m"
exit 1
fi
elif [[ "$VENDOR" == "amd" ]]; then
GPRAT_TARGET="sycl"
BUILD_DIR="build/release-linux-sycl"
else
echo -e "\e[31mUnsupported GPU vendor: ${VENDOR}\e[0m"
exit 1
fi
else
echo -e "\e[31mUnsupported hardware type: ${HARDWARE}\e[0m"
exit 1
fi
# Build joined suffixes without double/trailing underscores when parts are empty
join_parts() { local IFS=_; echo "$*" | tr -s '_' | sed 's/^_//;s/_$//'; }
HARDWARE_VENDOR=$(join_parts "$HARDWARE" "$VENDOR")
VENDOR_TARGET=$(join_parts "$VENDOR" "$GPRAT_TARGET")
# Create benchmark folder
mkdir -p benchmark_results_${HARDWARE_VENDOR}
# GPflow
if [[ "$1" == "yes" ]]; then
echo -e "\e[32mRunning GPflow benchmarks on ${HARDWARE} ${VENDOR}...\e[0m"
cd examples/gpflow_reference
./run_gpflow.sh ${HARDWARE} ${VENDOR} > /dev/null
cp output.csv ../../benchmark_results_${HARDWARE_VENDOR}/gpflow_${VENDOR_TARGET}.csv
rm -rf gpflow_${HARDWARE}_env
cd ../..
else
echo -e "\e[33mSkipping GPflow benchmarks.\e[0m"
fi
# GPyTorch
if [[ "$2" == "yes" ]]; then
echo -e "\e[32mRunning GPyTorch benchmarks on ${HARDWARE} ${VENDOR}...\e[0m"
cd examples/gpytorch_reference
./run_gpytorch.sh ${HARDWARE} ${VENDOR} > /dev/null
cp output.csv ../../benchmark_results_${HARDWARE_VENDOR}/gpytorch_${VENDOR_TARGET}.csv
rm -rf gpytorch_${HARDWARE}_env
cd ../..
else
echo -e "\e[33mSkipping GPyTorch benchmarks.\e[0m"
fi
# GPRat compile
if [[ "$3" == "yes" || $4 == "yes" ]]; then
echo -e "\e[32mCompiling GPRat for ${VENDOR} ${HARDWARE} with ${GPRAT_TARGET} target...\e[0m"
rm -rf build
./compile_gprat.sh cpp $GPRAT_TARGET release mkl > /dev/null
./compile_gprat.sh python $GPRAT_TARGET release mkl > /dev/null
else
echo -e "\e[33mNot compiling GPRat.\e[0m"
fi
# GPRat Cholesky
if [[ "$3" == "yes" ]]; then
echo -e "\e[32mRunning GPRat Cholesky benchmarks on ${VENDOR} ${HARDWARE} with ${GPRAT_TARGET} target...\e[0m"
cd examples/gprat_cpp
end_cores=$(python3 -c "import json; print(json.load(open('config.json'))['END_CORES'])")
core_count=$((end_cores * 2))
cd ../..
cd ${BUILD_DIR}/examples/gprat_cpp/
taskset -c 0-$core_count:2 ./gprat_cpp $GPRAT_USE_GPU > /dev/null
cp ../../../../examples/gprat_cpp/output.csv ../../../../benchmark_results_${HARDWARE_VENDOR}/gprat_cholesky_${VENDOR_TARGET}.csv
cd ../../../..
else
echo -e "\e[33mSkipping GPRat Cholesky benchmarks.\e[0m"
fi
# GPRat Python
if [[ "$4" == "yes" ]]; then
echo -e "\e[32mRunning GPRat Python benchmarks on ${VENDOR} ${HARDWARE} with ${GPRAT_TARGET} target...\e[0m"
cd examples/gprat_python
./run_gprat_python.sh ${GPRAT_TARGET} ${VENDOR} > /dev/null
cp output.csv ../../benchmark_results_${HARDWARE_VENDOR}/gprat_python_${VENDOR_TARGET}.csv
cd ../..
else
echo -e "\e[33mSkipping GPRat Python benchmarks.\e[0m"
fi
echo -e "\e[32mCopying results to home directory... \e[0m"
mkdir -p ${HOME}/GPRAT-BENCHMARKS
cp -r benchmark_results_${HARDWARE_VENDOR}/ ${HOME}/GPRAT-BENCHMARKS/
echo -e "\e[32mDone.\e[0m"