]> git.proxmox.com Git - ceph.git/blob - ceph/src/erasure-code/jerasure/gf-complete/tools/test_simd.sh
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / erasure-code / jerasure / gf-complete / tools / test_simd.sh
1 #!/bin/bash -e
2
3 # this scripts has a number of tests for SIMD. It can be invoked
4 # on the host or on a QEMU machine.
5
6 script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7 host_cpu=`uname -p`
8 results=${script_dir}/test_simd.results
9 nprocs=$(grep -c ^processor /proc/cpuinfo)
10
11 # runs unit tests and save the results
12 test_unit(){
13 { ./configure && make clean && make; } || { echo "Compile FAILED" >> ${results}; return 1; }
14 make -j$nprocs check || { echo "gf_methods $i FAILED" >> ${results}; ((++failed)); }
15 cat tools/test-suite.log >> ${results} || true
16 }
17
18 # build with DEBUG_FUNCTIONS and save all methods selected
19 # to a results file
20 test_functions() {
21 failed=0
22
23 { ./configure --enable-debug-func && make clean && make; } || { echo "Compile FAILED" >> ${results}; return 1; }
24 for i in 128 64 32 16 8 4; do
25 { ${script_dir}/gf_methods $i -ACD -X >> ${results}; } || { echo "gf_methods $i FAILED" >> ${results}; ((++failed)); }
26 done
27
28 return ${failed}
29 }
30
31 # build with DEBUG_CPU_FUNCTIONS and print out CPU detection
32 test_detection() {
33 failed=0
34
35 { ./configure --enable-debug-cpu && make clean && make; } || { echo "Compile FAILED" >> ${results}; return 1; }
36 { ${script_dir}/gf_methods 32 -ACD -L | grep '#' >> ${results}; } || { echo "gf_methods $i FAILED" >> ${results}; ((++failed)); }
37
38 return ${failed}
39 }
40
41 compile_arm() {
42 failed=0
43
44 echo -n "Compiling with NO SIMD support..." >> ${results}
45 { ./configure --disable-neon && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
46
47 echo -n "Compiling with FULL SIMD support..." >> ${results}
48 { ./configure && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
49
50 return ${failed}
51 }
52
53 compile_intel() {
54 failed=0
55
56 echo -n "Compiling with NO SIMD support..." >> ${results}
57 { ./configure && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
58
59 echo -n "Compiling with SSE2 only..." >> ${results}
60 export ax_cv_have_sse_ext=no
61 export ax_cv_have_sse2_ext=yes
62 export ax_cv_have_sse3_ext=no
63 export ax_cv_have_ssse3_ext=no
64 export ax_cv_have_sse41_ext=no
65 export ax_cv_have_sse42_ext=no
66 export ax_cv_have_pclmuldq_ext=no
67 { ./configure && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
68
69 echo -n "Compiling with SSE2,SSE3 only..." >> ${results}
70 export ax_cv_have_sse_ext=no
71 export ax_cv_have_sse2_ext=yes
72 export ax_cv_have_sse3_ext=yes
73 export ax_cv_have_ssse3_ext=no
74 export ax_cv_have_sse41_ext=no
75 export ax_cv_have_sse42_ext=no
76 export ax_cv_have_pclmuldq_ext=no
77 { ./configure && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
78
79 echo -n "Compiling with SSE2,SSE3,SSSE3 only..." >> ${results}
80 export ax_cv_have_sse_ext=no
81 export ax_cv_have_sse2_ext=yes
82 export ax_cv_have_sse3_ext=yes
83 export ax_cv_have_ssse3_ext=yes
84 export ax_cv_have_sse41_ext=no
85 export ax_cv_have_sse42_ext=no
86 export ax_cv_have_pclmuldq_ext=no
87 { ./configure && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
88
89 echo -n "Compiling with SSE2,SSE3,SSSE3,SSE4_1 only..." >> ${results}
90 export ax_cv_have_sse_ext=no
91 export ax_cv_have_sse2_ext=yes
92 export ax_cv_have_sse3_ext=yes
93 export ax_cv_have_ssse3_ext=yes
94 export ax_cv_have_sse41_ext=yes
95 export ax_cv_have_sse42_ext=no
96 export ax_cv_have_pclmuldq_ext=no
97 { ./configure && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
98
99 echo -n "Compiling with SSE2,SSE3,SSSE3,SSE4_2 only..." >> ${results}
100 export ax_cv_have_sse_ext=no
101 export ax_cv_have_sse2_ext=yes
102 export ax_cv_have_sse3_ext=yes
103 export ax_cv_have_ssse3_ext=yes
104 export ax_cv_have_sse41_ext=no
105 export ax_cv_have_sse42_ext=yes
106 export ax_cv_have_pclmuldq_ext=no
107 { ./configure && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
108
109 echo -n "Compiling with FULL SIMD support..." >> ${results}
110 export ax_cv_have_sse_ext=no
111 export ax_cv_have_sse2_ext=yes
112 export ax_cv_have_sse3_ext=yes
113 export ax_cv_have_ssse3_ext=yes
114 export ax_cv_have_sse41_ext=yes
115 export ax_cv_have_sse42_ext=yes
116 export ax_cv_have_pclmuldq_ext=yes
117 { ./configure && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
118
119 return ${failed}
120 }
121
122 # test that we can compile the source code with different
123 # SIMD options. We assume that we are running on processor
124 # full SIMD support
125 test_compile() {
126 case $host_cpu in
127 aarch64*|arm*) compile_arm ;;
128 i[[3456]]86*|x86_64*|amd64*) compile_intel ;;
129 esac
130 }
131
132 # disable through build flags
133 runtime_arm_flags() {
134 failed=0
135
136 echo "====NO SIMD support..." >> ${1}
137 { ./configure --disable-neon --enable-debug-func && make clean && make; } || { echo "Compile FAILED" >> ${1}; return 1; }
138 for i in 128 64 32 16 8 4; do
139 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
140 done
141
142 echo "====FULL SIMD support..." >> ${1}
143 { ./configure --enable-debug-func && make clean && make; } || { echo "Compile FAILED" >> ${1}; return 1; }
144 for i in 128 64 32 16 8 4; do
145 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
146 done
147
148 return ${failed}
149 }
150
151 # build once with FULL SIMD and disable at runtime through environment
152 runtime_arm_env() {
153 failed=0
154
155 { ./configure --enable-debug-func && make clean && make; } || { echo "Compile FAILED" >> ${1}; return 1; }
156
157 echo "====NO SIMD support..." >> ${1}
158 export GF_COMPLETE_DISABLE_NEON=1
159 for i in 128 64 32 16 8 4; do
160 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
161 done
162
163 echo "====FULL SIMD support..." >> ${1}
164 unset GF_COMPLETE_DISABLE_NEON
165 for i in 128 64 32 16 8 4; do
166 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
167 done
168
169 return ${failed}
170 }
171
172 runtime_intel_flags() {
173 failed=0
174
175 echo "====NO SIMD support..." >> ${1}
176 { ./configure --disable-sse --enable-debug-func && make clean && make; } || { echo "FAIL" >> ${1}; ((++failed)); }
177 for i in 128 64 32 16 8 4; do
178 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
179 done
180
181 echo "====SSE2 support..." >> ${1}
182 export ax_cv_have_sse_ext=no
183 export ax_cv_have_sse2_ext=yes
184 export ax_cv_have_sse3_ext=no
185 export ax_cv_have_ssse3_ext=no
186 export ax_cv_have_sse41_ext=no
187 export ax_cv_have_sse42_ext=no
188 export ax_cv_have_pclmuldq_ext=no
189 { ./configure --enable-debug-func && make clean && make; } || { echo "FAIL" >> ${1}; ((++failed)); }
190 for i in 128 64 32 16 8 4; do
191 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
192 done
193
194 echo "====SSE2,SSE3 support..." >> ${1}
195 export ax_cv_have_sse_ext=no
196 export ax_cv_have_sse2_ext=yes
197 export ax_cv_have_sse3_ext=yes
198 export ax_cv_have_ssse3_ext=no
199 export ax_cv_have_sse41_ext=no
200 export ax_cv_have_sse42_ext=no
201 export ax_cv_have_pclmuldq_ext=no
202 { ./configure --enable-debug-func && make clean && make; } || { echo "FAIL" >> ${1}; ((++failed)); }
203 for i in 128 64 32 16 8 4; do
204 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
205 done
206
207 echo "====SSE2,SSE3,SSSE3 support..." >> ${1}
208 export ax_cv_have_sse_ext=no
209 export ax_cv_have_sse2_ext=yes
210 export ax_cv_have_sse3_ext=yes
211 export ax_cv_have_ssse3_ext=yes
212 export ax_cv_have_sse41_ext=no
213 export ax_cv_have_sse42_ext=no
214 export ax_cv_have_pclmuldq_ext=no
215 { ./configure --enable-debug-func && make clean && make; } || { echo "FAIL" >> ${1}; ((++failed)); }
216 for i in 128 64 32 16 8 4; do
217 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
218 done
219
220 echo "====SSE2,SSE3,SSSE3,SSE4_1 support..." >> ${1}
221 export ax_cv_have_sse_ext=no
222 export ax_cv_have_sse2_ext=yes
223 export ax_cv_have_sse3_ext=yes
224 export ax_cv_have_ssse3_ext=yes
225 export ax_cv_have_sse41_ext=yes
226 export ax_cv_have_sse42_ext=no
227 export ax_cv_have_pclmuldq_ext=no
228 { ./configure --enable-debug-func && make clean && make; } || { echo "FAIL" >> ${1}; ((++failed)); }
229 for i in 128 64 32 16 8 4; do
230 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
231 done
232
233 echo "====SSE2,SSE3,SSSE3,SSE4_2 support..." >> ${1}
234 export ax_cv_have_sse_ext=no
235 export ax_cv_have_sse2_ext=yes
236 export ax_cv_have_sse3_ext=yes
237 export ax_cv_have_ssse3_ext=yes
238 export ax_cv_have_sse41_ext=no
239 export ax_cv_have_sse42_ext=yes
240 export ax_cv_have_pclmuldq_ext=no
241 { ./configure --enable-debug-func && make clean && make; } || { echo "FAIL" >> ${1}; ((++failed)); }
242 for i in 128 64 32 16 8 4; do
243 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
244 done
245
246 echo "====FULL SIMD support..." >> ${1}
247 { ./configure --enable-debug-func && make clean && make; } || { echo "FAIL" >> ${1}; ((++failed)); }
248 for i in 128 64 32 16 8 4; do
249 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
250 done
251
252 return ${failed}
253 }
254
255 runtime_intel_env() {
256 failed=0
257
258 # compile a build with full SIMD support
259 { ./configure --enable-debug-func && make clean && make; } || { echo "Compile FAILED" >> ${1}; return 1; }
260
261 echo "====NO SIMD support..." >> ${1}
262 export GF_COMPLETE_DISABLE_SSE2=1
263 export GF_COMPLETE_DISABLE_SSE3=1
264 export GF_COMPLETE_DISABLE_SSSE3=1
265 export GF_COMPLETE_DISABLE_SSE4=1
266 export GF_COMPLETE_DISABLE_SSE4_PCLMUL=1
267 for i in 128 64 32 16 8 4; do
268 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
269 done
270
271 echo "====SSE2 support..." >> ${1}
272 unset GF_COMPLETE_DISABLE_SSE2
273 export GF_COMPLETE_DISABLE_SSE3=1
274 export GF_COMPLETE_DISABLE_SSSE3=1
275 export GF_COMPLETE_DISABLE_SSE4=1
276 export GF_COMPLETE_DISABLE_SSE4_PCLMUL=1
277 for i in 128 64 32 16 8 4; do
278 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
279 done
280
281 echo "====SSE2,SSE3 support..." >> ${1}
282 unset GF_COMPLETE_DISABLE_SSE2
283 unset GF_COMPLETE_DISABLE_SSE3
284 export GF_COMPLETE_DISABLE_SSSE3=1
285 export GF_COMPLETE_DISABLE_SSE4=1
286 export GF_COMPLETE_DISABLE_SSE4_PCLMUL=1
287 for i in 128 64 32 16 8 4; do
288 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
289 done
290
291 echo "====SSE2,SSE3,SSSE3 support..." >> ${1}
292 unset GF_COMPLETE_DISABLE_SSE2
293 unset GF_COMPLETE_DISABLE_SSE3
294 unset GF_COMPLETE_DISABLE_SSSE3
295 export GF_COMPLETE_DISABLE_SSE4=1
296 export GF_COMPLETE_DISABLE_SSE4_PCLMUL=1
297 for i in 128 64 32 16 8 4; do
298 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
299 done
300
301 echo "====SSE2,SSE3,SSSE3,SSE4_1 support..." >> ${1}
302 unset GF_COMPLETE_DISABLE_SSE2
303 unset GF_COMPLETE_DISABLE_SSE3
304 unset GF_COMPLETE_DISABLE_SSSE3
305 unset GF_COMPLETE_DISABLE_SSE4
306 export GF_COMPLETE_DISABLE_SSE4_PCLMUL=1
307 for i in 128 64 32 16 8 4; do
308 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
309 done
310
311 echo "====SSE2,SSE3,SSSE3,SSE4_2 support..." >> ${1}
312 unset GF_COMPLETE_DISABLE_SSE2
313 unset GF_COMPLETE_DISABLE_SSE3
314 unset GF_COMPLETE_DISABLE_SSSE3
315 unset GF_COMPLETE_DISABLE_SSE4
316 export GF_COMPLETE_DISABLE_SSE4_PCLMUL=1
317 for i in 128 64 32 16 8 4; do
318 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
319 done
320
321 echo "====FULL SIMD support..." >> ${1}
322 unset GF_COMPLETE_DISABLE_SSE2
323 unset GF_COMPLETE_DISABLE_SSE3
324 unset GF_COMPLETE_DISABLE_SSSE3
325 unset GF_COMPLETE_DISABLE_SSE4
326 unset GF_COMPLETE_DISABLE_SSE4_PCLMUL
327 for i in 128 64 32 16 8 4; do
328 { ${script_dir}/gf_methods $i -ACD -X >> ${1}; } || { echo "gf_methods $i FAILED" >> ${1}; ((++failed)); }
329 done
330
331 return ${failed}
332 }
333
334 test_runtime() {
335 rm -f ${results}.left
336 rm -f ${results}.right
337
338 case $host_cpu in
339 aarch64*|arm*)
340 runtime_arm_flags ${results}.left
341 runtime_arm_env ${results}.right
342 ;;
343 i[[3456]]86*|x86_64*|amd64*)
344 runtime_intel_flags ${results}.left
345 runtime_intel_env ${results}.right
346 ;;
347 esac
348
349 echo "======LEFT======" > ${results}
350 cat ${results}.left >> ${results}
351 echo "======RIGHT======" >> ${results}
352 cat ${results}.right >> ${results}
353 echo "======RESULT======" >> ${results}
354 if diff "${results}.left" "${results}.right"; then
355 echo SUCCESS >> ${results}
356 return 0
357 else
358 echo SUCCESS >> ${results}
359 return 1
360 fi
361 }
362
363 cd ${script_dir}/..
364 rm -f ${results}
365
366 test_$1
367 exit $?