From 161614ecc1c20d94a8599888524b1d1fd0eb2754 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Sat, 25 Feb 2023 10:21:57 +0200 Subject: sha2-ppc: better optimization for POWER9 * cipher/sha256-ppc.c: Change to use vector registers, generate POWER8 and POWER9 from same code with help of 'target' and 'optimize' attribute. * cipher/sha512-ppc.c: Likewise. * configure.ac (gcry_cv_gcc_attribute_optimize) (gcry_cv_gcc_attribute_ppc_target): New. -- Benchmark on POWER9: Before: | nanosecs/byte mebibytes/sec cycles/byte SHA256 | 5.22 ns/B 182.8 MiB/s 12.00 c/B SHA512 | 3.53 ns/B 269.9 MiB/s 8.13 c/B After (sha256 ~12% faster, sha512 ~19% faster): | nanosecs/byte mebibytes/sec cycles/byte SHA256 | 4.65 ns/B 204.9 MiB/s 10.71 c/B SHA512 | 2.97 ns/B 321.1 MiB/s 6.83 c/B Signed-off-by: Jussi Kivilinna --- configure.ac | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 75622e50..63f705ea 100644 --- a/configure.ac +++ b/configure.ac @@ -1363,6 +1363,21 @@ _gcc_cflags_save=$CFLAGS CFLAGS="$CFLAGS -Werror" +# +# Check whether compiler supports 'optimize' function attribute +# +AC_CACHE_CHECK([whether compiler supports 'optimize' function attribute], + [gcry_cv_gcc_attribute_optimize], + [gcry_cv_gcc_attribute_optimize=no + AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [[int __attribute__ ((optimize("-O2"))) fn(int i){return i;}]])], + [gcry_cv_gcc_attribute_optimize=yes])]) +if test "$gcry_cv_gcc_attribute_optimize" = "yes" ; then + AC_DEFINE(HAVE_GCC_ATTRIBUTE_OPTIMIZE,1, + [Defined if compiler supports "__attribute__ ((optimize))" function attribute]) +fi + + # # Check whether compiler supports 'ms_abi' function attribute. # @@ -2254,6 +2269,28 @@ if test "$gcry_cv_gcc_inline_asm_ppc_arch_3_00" = "yes" ; then fi +# +# Check whether compiler supports GCC PowerPC target attributes +# +AC_CACHE_CHECK([whether compiler supports GCC PowerPC target attributes], + [gcry_cv_gcc_attribute_ppc_target], + [if test "$mpi_cpu_arch" != "ppc" ; then + gcry_cv_gcc_attribute_ppc_target="n/a" + else + gcry_cv_gcc_attribute_ppc_target=no + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[void __attribute__((target("cpu=power8"))) testfn8(void) {} + void __attribute__((target("cpu=power9"))) testfn9(void) + { testfn8(); } + ]], [ testfn9(); ])], + [gcry_cv_gcc_attribute_ppc_target=yes]) + fi]) +if test "$gcry_cv_gcc_attribute_ppc_target" = "yes" ; then + AC_DEFINE(HAVE_GCC_ATTRIBUTE_PPC_TARGET,1, + [Defined if compiler supports GCC PowerPC target attributes]) +fi + + # # Check whether GCC inline assembler supports zSeries instructions # -- cgit v1.2.1