btrfs-progs: hash-speedtest: benchmark the configured backend
Change what hash-speedtest benchmarks according to the --with-crypto=backend option. Until now it would run the same version under different names inherited from the builting. At configure time detect availability of all backends and define all macros. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
4fc291a465
commit
bbcd599062
17
configure.ac
17
configure.ac
|
@ -236,29 +236,38 @@ AC_ARG_WITH([crypto],
|
|||
cryptoprovider=
|
||||
cryptoproviderversion=
|
||||
CRYPTOPROVIDER_BUILTIN=0
|
||||
CRYPTOPROVIDER_LIBGCRYPT=0
|
||||
CRYPTOPROVIDER_LIBSODIUM=0
|
||||
CRYPTOPROVIDER_LIBKCAPI=0
|
||||
if test "$with_crypto" = "builtin"; then
|
||||
cryptoprovider="builtin"
|
||||
CRYPTOPROVIDER_BUILTIN=1
|
||||
AC_DEFINE([CRYPTOPROVIDER_BUILTIN],[1],[Use builtin implementation])
|
||||
elif test "$with_crypto" = "libgcrypt"; then
|
||||
cryptoprovider="libgcrypt"
|
||||
PKG_CHECK_MODULES(GCRYPT, [libgcrypt >= 1.8.0])
|
||||
AC_DEFINE([CRYPTOPROVIDER_LIBGCRYPT],[1],[Use libcrypt])
|
||||
CRYPTOPROVIDER_LIBGCRYPT=1
|
||||
cryptoproviderversion=`${PKG_CONFIG} libgcrypt --version`
|
||||
elif test "$with_crypto" = "libsodium"; then
|
||||
cryptoprovider="libsodium"
|
||||
PKG_CHECK_MODULES(SODIUM, [libsodium >= 1.0.4])
|
||||
AC_DEFINE([CRYPTOPROVIDER_LIBSODIUM],[1],[Use libsodium])
|
||||
CRYPTOPROVIDER_LIBSODIUM=1
|
||||
cryptoproviderversion=`${PKG_CONFIG} libsodium --version`
|
||||
elif test "$with_crypto" = "libkcapi"; then
|
||||
cryptoprovider="libkcapi"
|
||||
PKG_CHECK_MODULES(KCAPI, [libkcapi >= 1.0.0])
|
||||
AC_DEFINE([CRYPTOPROVIDER_LIBKCAPI],[1],[Use libkcapi])
|
||||
CRYPTOPROVIDER_LIBKCAPI=1
|
||||
cryptoproviderversion=`${PKG_CONFIG} libkcapi --version`
|
||||
else
|
||||
AC_MSG_ERROR([unrecognized crypto provider: $with_crypto])
|
||||
fi
|
||||
AC_SUBST([CRYPTOPROVIDER_BUILTIN])
|
||||
AC_DEFINE_UNQUOTED([CRYPTOPROVIDER_BUILTIN],[$CRYPTOPROVIDER_BUILTIN],[Use builtin implementation])
|
||||
AC_SUBST([CRYPTOPROVIDER_LIBGCRYPT])
|
||||
AC_DEFINE_UNQUOTED([CRYPTOPROVIDER_LIBGCRYPT],[$CRYPTOPROVIDER_LIBGCRYPT],[Use libcrypt])
|
||||
AC_SUBST([CRYPTOPROVIDER_LIBSODIUM])
|
||||
AC_DEFINE_UNQUOTED([CRYPTOPROVIDER_LIBSODIUM],[$CRYPTOPROVIDER_LIBSODIUM],[Use libsodium])
|
||||
AC_SUBST([CRYPTOPROVIDER_LIBKCAPI])
|
||||
AC_DEFINE_UNQUOTED([CRYPTOPROVIDER_LIBKCAPI],[$CRYPTOPROVIDER_LIBKCAPI],[Use libkcapi])
|
||||
AC_DEFINE_UNQUOTED([CRYPTOPROVIDER],["$cryptoprovider"],[Crypto implementation source name])
|
||||
|
||||
AX_CHECK_DEFINE([linux/fiemap.h], [FIEMAP_EXTENT_SHARED], [],
|
||||
|
|
|
@ -183,6 +183,7 @@ int main(int argc, char **argv) {
|
|||
u64 cycles;
|
||||
u64 time;
|
||||
unsigned long cpu_flag;
|
||||
int backend;
|
||||
} contestants[] = {
|
||||
{ .name = "NULL-NOP", .digest = hash_null_nop, .digest_size = 32 },
|
||||
{ .name = "NULL-MEMCPY", .digest = hash_null_memcpy, .digest_size = 32 },
|
||||
|
@ -192,17 +193,29 @@ int main(int argc, char **argv) {
|
|||
.cpu_flag = CPU_FLAG_SSE42 },
|
||||
{ .name = "XXHASH", .digest = hash_xxhash, .digest_size = 8 },
|
||||
{ .name = "SHA256-ref", .digest = hash_sha256, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_NONE },
|
||||
.cpu_flag = CPU_FLAG_NONE, .backend = CRYPTOPROVIDER_BUILTIN + 1 },
|
||||
{ .name = "SHA256-gcrypt", .digest = hash_sha256, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_NONE, .backend = CRYPTOPROVIDER_LIBGCRYPT + 1 },
|
||||
{ .name = "SHA256-sodium", .digest = hash_sha256, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_NONE, .backend = CRYPTOPROVIDER_LIBSODIUM + 1 },
|
||||
{ .name = "SHA256-kcapi", .digest = hash_sha256, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_NONE, .backend = CRYPTOPROVIDER_LIBKCAPI + 1 },
|
||||
{ .name = "SHA256-NI", .digest = hash_sha256, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_SHA },
|
||||
.cpu_flag = CPU_FLAG_SHA, .backend = CRYPTOPROVIDER_BUILTIN + 1 },
|
||||
{ .name = "BLAKE2-ref", .digest = hash_blake2b, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_NONE },
|
||||
.cpu_flag = CPU_FLAG_NONE, .backend = CRYPTOPROVIDER_BUILTIN + 1 },
|
||||
{ .name = "BLAKE2-gcrypt", .digest = hash_blake2b, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_NONE, .backend = CRYPTOPROVIDER_LIBGCRYPT + 1 },
|
||||
{ .name = "BLAKE2-sodium", .digest = hash_blake2b, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_NONE, .backend = CRYPTOPROVIDER_LIBSODIUM + 1 },
|
||||
{ .name = "BLAKE2-kcapi", .digest = hash_blake2b, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_NONE, .backend = CRYPTOPROVIDER_LIBKCAPI + 1 },
|
||||
{ .name = "BLAKE2-SSE2", .digest = hash_blake2b, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_SSE2 },
|
||||
.cpu_flag = CPU_FLAG_SSE2, .backend = CRYPTOPROVIDER_BUILTIN + 1 },
|
||||
{ .name = "BLAKE2-SSE41", .digest = hash_blake2b, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_SSE41 },
|
||||
.cpu_flag = CPU_FLAG_SSE41, .backend = CRYPTOPROVIDER_BUILTIN + 1 },
|
||||
{ .name = "BLAKE2-AVX2", .digest = hash_blake2b, .digest_size = 32,
|
||||
.cpu_flag = CPU_FLAG_AVX2 },
|
||||
.cpu_flag = CPU_FLAG_AVX2, .backend = CRYPTOPROVIDER_BUILTIN + 1 },
|
||||
};
|
||||
int units = UNITS_CYCLES;
|
||||
|
||||
|
@ -272,7 +285,10 @@ int main(int argc, char **argv) {
|
|||
printf("%12s: no CPU support\n", c->name);
|
||||
continue;
|
||||
}
|
||||
printf("%12s: ", c->name);
|
||||
/* Backend not compiled in */
|
||||
if (c->backend == 1)
|
||||
continue;
|
||||
printf("%14s: ", c->name);
|
||||
fflush(stdout);
|
||||
|
||||
if (c->cpu_flag) {
|
||||
|
|
Loading…
Reference in New Issue