From 1eeb4562a72ab29345572609e1e4315ecd26c5a1 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Wed, 9 Dec 2015 15:34:16 -0800 Subject: Implementation of AVX2 optimized Fletcher-4 New functionality: - Preserves existing scalar implementation. - Adds AVX2 optimized Fletcher-4 computation. - Fastest routines selected on module load (benchmark). - Test case for Fletcher-4 added to ztest. New zcommon module parameters: - zfs_fletcher_4_impl (str): selects the implementation to use. "fastest" - use the fastest version available "cycle" - cycle trough all available impl for ztest "scalar" - use the original version "avx2" - new AVX2 implementation if available Performance comparison (Intel i7 CPU, 1MB data buffers): - Scalar: 4216 MB/s - AVX2: 14499 MB/s See contents of `/sys/module/zcommon/parameters/zfs_fletcher_4_impl` to get list of supported values. If an implementation is not supported on the system, it will not be shown. Currently selected option is enclosed in `[]`. Signed-off-by: Jinshan Xiong Signed-off-by: Andreas Dilger Signed-off-by: Brian Behlendorf Closes #4330 --- include/zfs_fletcher.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'include/zfs_fletcher.h') diff --git a/include/zfs_fletcher.h b/include/zfs_fletcher.h index b49df0cf4..4ccb4a2f4 100644 --- a/include/zfs_fletcher.h +++ b/include/zfs_fletcher.h @@ -27,7 +27,7 @@ #define _ZFS_FLETCHER_H #include -#include +#include #ifdef __cplusplus extern "C" { @@ -45,6 +45,25 @@ void fletcher_4_incremental_native(const void *, uint64_t, zio_cksum_t *); void fletcher_4_incremental_byteswap(const void *, uint64_t, zio_cksum_t *); +int fletcher_4_impl_set(const char *selector); +void fletcher_4_init(void); +void fletcher_4_fini(void); + +/* + * fletcher checksum struct + */ +typedef struct fletcher_4_func { + void (*init)(zio_cksum_t *); + void (*fini)(zio_cksum_t *); + void (*compute)(const void *, uint64_t, zio_cksum_t *); + void (*compute_byteswap)(const void *, uint64_t, zio_cksum_t *); + boolean_t (*valid)(void); + const char *name; +} fletcher_4_ops_t; + +#if defined(HAVE_AVX) && defined(HAVE_AVX2) +extern const fletcher_4_ops_t fletcher_4_avx2_ops; +#endif #ifdef __cplusplus } -- cgit v1.2.3