Commit Graph

84 Commits (master)

Author SHA1 Message Date
Brad Hubbard 2700e1b9ae Resolve cppcheck Signed integer overflow errors
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>
2017-04-10 17:21:30 +10:00
John Coyle 7c2fcc5bd0 gf_cpu.c: fix pclmul detection and add portable cpuid feature bit defs
Correct invalid check for pclmul support. Was checking SSE3 (1 << 0) vs. PCLMUL (1 << 1).

Fixes: http://tracker.ceph.com/issues/18092
Signed-off-by: John Coyle <dx9err@gmail.com>
2016-12-07 21:50:17 -05:00
Kefu Chai 9fbc442593 gf_w32.c: silence the -Wmaybe-uninitialized warning
in gf_w32_cfmgk_multiply_region_from_single(), follow warning is
reported by gcc:

gf-complete/src/gf_w32.c:410:5: warning: ‘a’ may be used uninitialized
in this function [-Wmaybe-uninitialized]
   g = _mm_insert_epi64 (a, g_star, 0);
     ^

actually, we are using `a` as a dummy parameter for initializing `g` and
`q`. and only the lower lower 64 bits of them are used when doing
calculation. but their lower 64 bits are always initialized using
_mm_insert_epi64(). so this is a false alarm.

but we can silence this warning by moving the statement initializing `a`
up before passing it to  _mm_insert_epi64(). this change does not hurt
the performance.

Signed-off-by: Kefu Chai <kchai@redhat.com>
2016-11-18 03:53:50 +00:00
Bassam Tabbara 0e5c920fb6 gf_multby_one now checks runtime SIMD support 2016-09-13 12:25:00 -07:00
Bassam Tabbara ad11042132 Simplify SIMD make scripts
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__
2016-09-13 12:25:00 -07:00
Bassam Tabbara 4339569f14 Support for runtime SIMD detection
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.
2016-09-13 12:24:25 -07:00
Bassam Tabbara 87f0d4395d Add support for printing functions selected in gf_init
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.
2016-09-13 12:24:25 -07:00
Loic Dachary 185295f247 Merge branch 'wip-valgrind' into 'master'
enable valgrind for tests

See merge request !9
2016-09-13 19:23:39 +00:00
Loic Dachary 62b702d568 do not memcpy if src and dst are the same
This is harmless really but triggers a valgrind error.

Signed-off-by: Loic Dachary <loic@dachary.org>
2016-09-13 09:48:18 +02:00
animetosho 643743d048 Move conditional outside loop for NEON SPLIT4 implementation
Seems to improve performance a fair bit
2015-11-14 16:32:25 +10:00
animetosho 05057e5635 Eliminate unnecessary VTRNs in SPLIT(16,4) NEON implementation
Also makes the ARMv8 version consistent with the older one, in terms of processing width
2015-11-12 22:17:53 +10:00
animetosho 438283c12d Use similar strategy for SPLIT(16,4) ALTMAP NEON implementation as SPLIT(32,4) 2015-11-12 21:17:13 +10:00
animetosho f373b138aa Initial fix for SPLIT(16,4) ALTMAP NEON (non ARMv8) 2015-11-12 21:09:44 +10:00
animetosho 7a9a09f32c CARRY_FREE is currently only available for w=4 and w=8 on NEON 2015-11-12 21:06:34 +10:00
Loic Dachary d1b6bbf706 add -Wsign-compare and address the warnings
* (1 << w) are changed into ((uint32_t)1 << w)
* int are changed into uint32_t

gf.c: gf_composite_get_default_poly:

   a larger unsigned were assigned to unsigned integers in which case
   the type of the assigned variable is changed to be the same as the
   value assigned to it.

gf_w16.c: GF_MULTBY_TWO

   setting the parameter to a variable instead of passing the expression
   resolves the warning for some reason.

Signed-off-by: Loic Dachary <loic@dachary.org>
2015-09-02 19:20:33 +02:00
Danny Al-Gaaf 2f6db512fb gf_w64.c: fix integer overflow
Fix for Coverity issue (from Ceph):

CID 1193089 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
 overflow_before_widen: Potentially overflowing expression 1 << g_r with type
 int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in
 a context that expects an expression of type uint64_t (64 bits, unsigned).

CID 1193090 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
 overflow_before_widen: Potentially overflowing expression 1 << g_s with type
 int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in
 a context that expects an expression of type uint64_t (64 bits, unsigned).

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2015-06-18 09:01:37 +02:00
Danny Al-Gaaf 1aef8694bc gf_w64.c: fix integer overflow
Fix for Coverity issue (from Ceph):

CID 1193088 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
 overflow_before_widen: Potentially overflowing expression 1 << g_s with type
 int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in
 a context that expects an expression of type uint64_t (64 bits, unsigned).

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2015-06-18 09:00:03 +02:00
Danny Al-Gaaf e127bb1fb9 gf_w64.c: fix integer overflow
Fix for Coverity issue (from Ceph):

CID 1193087 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
 overflow_before_widen: Potentially overflowing expression 1 << g_r with type
  int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used
  in a context that expects an expression of type uint64_t (64 bits, unsigned).

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2015-06-18 08:58:20 +02:00
Danny Al-Gaaf 98e5e37159 gf_w64.c: fix integer overflow
Fix for Coverity issue (from Ceph):

CID 1193086 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
 overflow_before_widen: Potentially overflowing expression 1 << g_r with type
  int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in
  a context that expects an expression of type uint64_t (64 bits, unsigned).

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2015-06-18 08:55:49 +02:00
Danny Al-Gaaf 7972291e1f src/gf_w128.c: remove dead code and unused variable
Fix for Coverity issue:

CID 1297812 (#1 of 1): Constant variable guards dead code (DEADCODE)
 dead_error_begin: Execution cannot reach this statement: fprintf(stderr,
  "Code conta....
 Local variable no_default_flag is assigned only once, to a constant
  value, making it effectively constant throughout its scope. If this
  is not the intent, examine the logic to see if there is a missing
  assignment that would make no_default_flag not remain constant.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2015-06-17 10:46:44 +02:00
Danny Al-Gaaf da671b4908 src/gf_w64.c: remove dead code
Fix for Coverity issue:

CID 1297852 (#1 of 1): 'Constant'; variable guards dead code (DEADCODE)
 dead_error_begin: Execution cannot reach this statement:
  fprintf(stderr, "Code conta....
 Local variable no_default_flag is assigned only once, to a constant value,
  making it effectively constant throughout its scope. If this is not the
  intent, examine the logic to see if there is a missing assignment that
  would make no_default_flag not remain constant.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2015-06-17 10:46:21 +02:00
Loic Dachary 29427efac2 use assert(0) instead of exit(1)
When a fatal error (unaligned memory etc.) is detected, gf-complete should
assert(3) instead of exit(3) to give a chance to the calling program to
catch the exception and display a stack trace. Although it is possible
for gdb to display the stack trace and break on exit, libraries are not
usually expected to terminate the calling program in this way.

Signed-off-by: Loic Dachary <loic@dachary.org>
2014-12-02 00:27:27 +01:00
Janne Grunau 6fdd8bc3d3 arm: NEON optimisations for gf_w64
Optimisations for 4,64 split table region multiplications. Only used on
ARMv8-A since it is not faster on ARMv7-A.
2014-10-24 14:54:55 +02:00
Janne Grunau 370c88b901 arm: NEON optimisations for gf_w32
Optimisations for 4,32 split table multiplications.

Selected time_tool.sh results on a 1.7 GHz cortex-a9:
Region Best (MB/s):   346.67   W-Method: 32 -m SPLIT 32 4 -r SIMD -
Region Best (MB/s):    92.89   W-Method: 32 -m SPLIT 32 4 -r NOSIMD -
Region Best (MB/s):   258.17   W-Method: 32 -m SPLIT 32 4 -r SIMD -r ALTMAP -
Region Best (MB/s):   162.00   W-Method: 32 -m SPLIT 32 8 -
Region Best (MB/s):   160.53   W-Method: 32 -m SPLIT 8 8 -
Region Best (MB/s):    32.74   W-Method: 32 -m COMPOSITE 2 - -
Region Best (MB/s):   199.79   W-Method: 32 -m COMPOSITE 2 - -r ALTMAP -
2014-10-24 14:54:27 +02:00
Janne Grunau 474010a91d arm: NEON optimisations for gf_w16
Optimisations for the 4,16 split table region multiplications.

Selected time_tool.sh 16 -A -B results for a 1.7 GHz cortex-a9:
Region Best (MB/s):   532.14   W-Method: 16 -m SPLIT 16 4 -r SIMD -
Region Best (MB/s):   212.34   W-Method: 16 -m SPLIT 16 4 -r NOSIMD -
Region Best (MB/s):   801.36   W-Method: 16 -m SPLIT 16 4 -r SIMD -r ALTMAP -
Region Best (MB/s):    93.20   W-Method: 16 -m SPLIT 16 4 -r NOSIMD -r ALTMAP -
Region Best (MB/s):   273.99   W-Method: 16 -m SPLIT 16 8 -
Region Best (MB/s):   270.81   W-Method: 16 -m SPLIT 8 8 -
Region Best (MB/s):    70.42   W-Method: 16 -m COMPOSITE 2 - -
Region Best (MB/s):   393.54   W-Method: 16 -m COMPOSITE 2 - -r ALTMAP -
2014-10-24 14:53:57 +02:00
Janne Grunau bec15359de arm: NEON optimisations for gf_w8
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 -
2014-10-24 14:53:35 +02:00
Janne Grunau 1311a44f7a arm: NEON optimisations for gf_w4
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 -
2014-10-24 14:53:12 +02:00
Janne Grunau 3a1be40ea8 arm: NEON optimisations for XOR in gf_multby_one 2014-10-09 23:25:36 +02:00
Janne Grunau 568df90edc simd: rename the region flags from SSE to SIMD
SSE is not the only supported SIMD instruction set. Keep the old names
for backward compatibility.
2014-10-09 23:22:32 +02:00
Janne Grunau f6828cfbc1 build: fix out of source tree build 2014-10-09 23:22:28 +02:00
Loic Dachary dfffff2740 remove dead code in create_gf_from_argv
Since there can only be one -m, base cannot be set by -m COMPOSITE and
then deallocated on the second -m if it is bugous. The second -m will
exit on error at _gf_errno = GF_E_TWOMULT;.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
2014-09-17 10:08:37 +02:00
Loic Dachary 7c06749ab8 disable gf_error_check test that requires >> 64
Because >> 64 does not have a defined behavior.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
2014-09-17 10:08:37 +02:00
Adam Disney c25310f215 Removed comments marking CARRY_FREE_GK additions. 2014-06-16 13:04:15 -04:00
Adam Disney f48f2d38af Merge remote-tracking branch 'dalgaaf/wip-da-sca-20140513' 2014-06-16 12:44:45 -04:00
Adam Disney 5be1fecbcb Fixed a few minor warnings when running autogen.sh. 2014-06-16 12:27:19 -04:00
Adam Disney d08de3bdcb Merge remote-tracking branch 'jayrde/wip-autoconf-cleanup'
Conflicts:
	.gitignore
	INSTALL
	Makefile.in
	aclocal.m4
	config.guess
	config.sub
	configure
	examples/Makefile.in
	include/config.h.in
	include/config.h.in~
	install-sh
	ltmain.sh
	m4/libtool.m4
	m4/ltversion.m4
	missing
	src/Makefile.in
	test/Makefile.in
	tools/Makefile.in
2014-06-16 12:24:06 -04:00
Adam Disney 6bb1ebb9f4 Implemented CARRY_FREE_GK. Sections added are tagged with a comment //ADAM
for easy navigation.
2014-06-06 13:09:04 -04:00
Danny Al-Gaaf 5832024d68 gf_w32.c: remove dead assignment with no effect
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-05-14 16:15:52 +02:00
Danny Al-Gaaf 83f1eee1c2 gf_w32.c: fix/remove some dead assignments
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-05-14 16:10:49 +02:00
Danny Al-Gaaf bfa6671fa9 gf_w16.c: fix/remove some dead assignments
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-05-14 16:09:55 +02:00
Danny Al-Gaaf eb3bb91d84 gf_w128.c: remove some dead assignments
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-05-14 16:00:05 +02:00
Danny Al-Gaaf 925802a06a gf_w8.c: fix dead assignment report from scan-build
Fix dead assignment in case of INTEL_SSSE3 defined.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-05-14 15:44:06 +02:00
Danny Al-Gaaf c0dd8e0fe2 gf_w64.c: remove dead assignments and unused variable 'm2'
The 'm2' variable in gf_w64_clm_multiply_region_from_single_2() isn't
used except for calculations on 'm2' which are not used later in the code.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-05-14 10:49:20 +02:00
Danny Al-Gaaf 277819a972 gf_w64.c: remove dead assigments in gf_w64_shift_multiply()
These assigments are never used and directly overwritten later
in the function.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-05-14 10:46:05 +02:00
Danny Al-Gaaf f6936562b2 gf_w32.c: fix dereference of undefined pointer value
Check for array boundaries of 't' in while loop header.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-05-13 19:29:32 +02:00
Danny Al-Gaaf df2c84d232 gf_w4.c: remove some dead code
Fix for coverity issue from Ceph project:

CID 1193093 (#1 of 1): Structurally dead code (UNREACHABLE)
 unreachable: This code cannot be reached: "return gf_w4_double_table_i...".

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-04-22 20:08:27 +02:00
Danny Al-Gaaf 0c04d6e3db gf.c: fix pointless expression
Remove identical expression, reorganize code in gf_error_check()
to be identical handled trough all checks. Removed (raltmap && arg1 != 4)
check - this is dead code (arg1 is always 4 in this code path).

Fix for coverity issue from Ceph project:

CID 1193071 (#1 of 1): Same on both sides (CONSTANT_EXPRESSION_RESULT)
 pointless_expression: The expression (arg1 == 4 && arg2 == 32) ||
 (arg1 == 4 && arg2 == 32) does not accomplish anything because it
 evaluates to either of its identical operands, arg1 == 4 && arg2 == 32.
 Did you intend the operands to be different?

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-04-22 20:08:27 +02:00
Danny Al-Gaaf 13f0e8888f fix comment/message on GF_E_SP128_A/GF_E_SP128_S
Swap comments/messages on GF_E_SP128_A/GF_E_SP128_S.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-04-22 20:08:26 +02:00
Danny Al-Gaaf fa5ec8112b gf_w8.c: add missing breaks
Since there is no comment indicating fallthrough on purpose added a
break in switch value 5 and 6.

Fix for coverity issue from Ceph project:

CID 1193084 (#1 of 1): Missing break in switch (MISSING_BREAK)
 unterminated_case: This case (value 5) is not terminated by a 'break'
 statement.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-04-22 20:08:26 +02:00
Danny Al-Gaaf 3b6364e5f2 gf_w4.c: add missing breaks
Since there is no comment indicating fallthrough on purpose added a
break in switch value 5 and 6.

Fix for coverity issue from Ceph project:

CID 1193082 (#1 of 1): Missing break in switch (MISSING_BREAK)
 unterminated_case: This case (value 5) is not terminated by a 'break'
 statement.

CID 1193083 (#1 of 1): Missing break in switch (MISSING_BREAK)
 unterminated_case: This case (value 6) is not terminated by a 'break'
 statement.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2014-04-22 20:08:26 +02:00