3 # this scripts has a number of tests for SIMD. It can be invoked
4 # on the host or on a QEMU machine.
6 script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8 results=${script_dir}/test_simd.results
9 nprocs=$(grep -c ^processor /proc/cpuinfo)
11 # runs unit tests and save the results
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
18 # build with DEBUG_FUNCTIONS and save all methods selected
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)); }
31 # build with DEBUG_CPU_FUNCTIONS and print out CPU detection
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)); }
44 echo -n "Compiling with NO SIMD support..." >> ${results}
45 { ./configure --disable-neon && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
47 echo -n "Compiling with FULL SIMD support..." >> ${results}
48 { ./configure && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
56 echo -n "Compiling with NO SIMD support..." >> ${results}
57 { ./configure && make clean && make && echo "SUCCESS" >> ${results}; } || { echo "FAIL" >> ${results}; ((++failed)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
122 # test that we can compile the source code with different
123 # SIMD options. We assume that we are running on processor
127 aarch64*|arm*) compile_arm ;;
128 i[[3456]]86*|x86_64*|amd64*) compile_intel ;;
132 # disable through build flags
133 runtime_arm_flags() {
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)); }
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)); }
151 # build once with FULL SIMD and disable at runtime through environment
155 { ./configure --enable-debug-func && make clean && make; } || { echo "Compile FAILED" >> ${1}; return 1; }
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)); }
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)); }
172 runtime_intel_flags() {
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
255 runtime_intel_env() {
258 # compile a build with full SIMD support
259 { ./configure --enable-debug-func && make clean && make; } || { echo "Compile FAILED" >> ${1}; return 1; }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
335 rm -f ${results}.left
336 rm -f ${results}.right
340 runtime_arm_flags ${results}.left
341 runtime_arm_env ${results}.right
343 i[[3456]]86*|x86_64*|amd64*)
344 runtime_intel_flags ${results}.left
345 runtime_intel_env ${results}.right
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}
358 echo SUCCESS >> ${results}