The type of expression '1<<31' is signed int and this causes cppcheck to
issue the following warning.
src/gf_w32.c:681]: (error) Signed integer overflow for expression
'1<<31'.
Signed-off-by: Brad Hubbard <bhubbard@redhat.com>
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.
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.
Optimisations for the 4,4 split table region multiplication and carry
less multiplication using NEON's polynomial long multiplication.
arm: w8: NEON carry less multiplication
Selected time_tool.sh results for a 1.7GHz cortex-a9:
Region Best (MB/s): 375.86 W-Method: 8 -m CARRY_FREE -
Region Best (MB/s): 142.94 W-Method: 8 -m TABLE -
Region Best (MB/s): 225.01 W-Method: 8 -m TABLE -r DOUBLE -
Region Best (MB/s): 211.23 W-Method: 8 -m TABLE -r DOUBLE -r LAZY -
Region Best (MB/s): 160.09 W-Method: 8 -m LOG -
Region Best (MB/s): 123.61 W-Method: 8 -m LOG_ZERO -
Region Best (MB/s): 123.85 W-Method: 8 -m LOG_ZERO_EXT -
Region Best (MB/s): 1183.79 W-Method: 8 -m SPLIT 8 4 -r SIMD -
Region Best (MB/s): 177.68 W-Method: 8 -m SPLIT 8 4 -r NOSIMD -
Region Best (MB/s): 87.85 W-Method: 8 -m COMPOSITE 2 - -
Region Best (MB/s): 428.59 W-Method: 8 -m COMPOSITE 2 - -r ALTMAP -
Optimisations for the single table region multiplication and carry less
multiplication using NEON's polynomial multiplication of 8-bit values.
The single polynomial multiplication is not that useful but vector
version is for region multiplication.
Selected time_tool.sh results for a 1.7GHz cortex-a9:
Region Best (MB/s): 672.72 W-Method: 4 -m CARRY_FREE -
Region Best (MB/s): 265.84 W-Method: 4 -m BYTWO_p -
Region Best (MB/s): 329.41 W-Method: 4 -m TABLE -r DOUBLE -
Region Best (MB/s): 278.63 W-Method: 4 -m TABLE -r QUAD -
Region Best (MB/s): 329.81 W-Method: 4 -m TABLE -r QUAD -r LAZY -
Region Best (MB/s): 1318.03 W-Method: 4 -m TABLE -r SIMD -
Region Best (MB/s): 165.15 W-Method: 4 -m TABLE -r NOSIMD -
Region Best (MB/s): 99.73 W-Method: 4 -m LOG -