ax_ext.m4 no longer performs any CPU checks. Instead it just checks
if the the compile supports SIMD flags.
Runtime detection will choose the right methods base on CPU
instructions available.
Intel AVX support is still done through the build since it would
require a major refactoring of the code base to support it at runtime.
For now I added a configuration flag --enable-avx that can be used
to compile with AVX support.
Also use cpu intrinsics instead of __asm__
This commits adds support for runtime detection of SIMD instructions. The idea is that you would build once with all supported SIMD functions and the same binaries could run on different machines with varying support for SIMD. At runtime gf-complete will select the right functions based on the processor.
gf_cpu.c has the logic to detect SIMD instructions. On Intel processors this is done through cpuid. For ARM on linux we use getauxv.
The logic in gf_w*.c has been changed to check for runtime SIMD support and fallback to generic code.
Also a new test has been added. It compares the functions selected by gf_init when we enable/disable SIMD support through build flags, with runtime enabling/disabling. The test checks if the results are identical.
This commit adds a couple of scripts that help test SIMD functionality
on different machines through QEMU.
tools/test_simd_qemu.sh will automatically start qemu, run tests
and stop it. it uses the Ubuntu cloud images which are built for
x86_64, arm and arm64.
tools/test_simd.sh run a number of tests including compiling
with different flags, unit tests, and gathering the functions
selected in gf_init (and when compiling with DEBUG_FUNCTIONS)
There is currently no way to figure out which functions were selected
during gf_init and as a result of SIMD options. This is not even possible
in gdb since most functions are static.
This commit adds a new macro SET_FUNCTION that records the name of the
function selected during init inside the gf_internal structure. This macro
only works when DEBUG_FUNCTIONS is defined during compile. Otherwise the
code works exactly as it did before this change.
The names of selected functions will be used during testing of SIMD
runtime detection.
All calls such as:
gf->multiply.w32 = gf_w16_shift_multiply;
need to be replaced with the following:
SET_FUNCTION(gf,multiply,w32,gf_w16_shift_multiply)
Also added a new flag to tools/gf_methods that will print the names of
functions selected during gf_init.
If --enable-valgrind is given to ./configure, all tests are run with
valgrind set to fail if an error is reported ( --error-exitcode=1 )
Signed-off-by: Loic Dachary <loic@dachary.org>
Due to man page of malloc the behaviour in case of allocation size of
0 bytes is undefined: "If size was equal to 0, either NULL or a
pointer suitable to be passed to free() is returned"
Fix for clang scan-build report:
Unix API Undefined allocation of 0 bytes (CERT MEM04-C; CWE-131)
210 poly = (gf_general_t *) malloc(sizeof(gf_general_t)*(n+1));
9 Call to 'malloc' has an allocation size of 0 bytes
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Free all with malloc allocated memory before exit. Change
if checks against 'w' to be a if-else check to prevent checking
after already matched.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
To conveniently run tests as
$ make check
============================================================================
Testsuite summary for gf-complete 1.0
============================================================================
# TOTAL: 1
# PASS: 1
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================
The run-tests.sh script loops over gf_methods and is introduced because
autotools does not allow tests to have parameters in the Makefile.am
Signed-off-by: Loic Dachary <loic@dachary.org>