From 7dae118b0aacd90c829272d9862e219922013622 Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Fri, 1 Oct 2021 16:11:24 +0200 Subject: [PATCH] build: experimental ci build with AVX2 --- .github/workflows/ci.yml | 13 +++++++++++-- configure.ac | 19 ++++++++++++++----- src/crypto/sha1.cpp | 5 +++-- src/crypto/sha256.cpp | 5 +++-- src/crypto/sha512.cpp | 5 +++-- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d6f99224..2700eec9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,7 @@ jobs: - x86_64-linux-nowallet - x86_64-macos - x86_64-win + - x86_64-linux-experimental include: - name: i686-linux host: i686-pc-linux-gnu @@ -92,7 +93,7 @@ jobs: sudo update-binfmts --import /usr/share/binfmts/wine run-tests: true dep-opts: "" - config-opts: "CC=x86_64-w64-mingw32-gcc LIBS=-lIPSec_MB --enable-reduce-exports --enable-gui=qt5" + config-opts: "--enable-reduce-exports --enable-gui=qt5" goal: install - name: x86_64-macos host: x86_64-apple-darwin11 @@ -103,6 +104,14 @@ jobs: config-opts: "--enable-gui=qt5 --enable-reduce-exports" goal: deploy sdk: 10.11 + - name: x86_64-linux-experimental + host: x86_64-unknown-linux-gnu + os: ubuntu-20.04 + packages: bc python3-zmq + run-tests: true + dep-opts: "AVX2=1" + config-opts: "--with-intel-avx2 --enable-gui=qt5 --enable-zmq --enable-glibc-back-compat --enable-reduce-exports" + goal: install runs-on: ${{ matrix.os }} @@ -115,7 +124,7 @@ jobs: - name: Install packages run: | sudo apt-get update - sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl ca-certificates ccache python3 rsync git procps bison nasm + sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl ca-certificates ccache python3 rsync git procps bison sudo apt-get install ${{ matrix.packages }} - name: Post install diff --git a/configure.ac b/configure.ac index 474db9f8d..cb1ef0f50 100644 --- a/configure.ac +++ b/configure.ac @@ -177,6 +177,12 @@ AC_ARG_ENABLE([zmq], [use_zmq=$enableval], [use_zmq=yes]) +AC_ARG_WITH([intel-avx2], + [AS_HELP_STRING([--with-intel-avx2], + [Build with intel avx2 (default is no)])], + [intel_avx2=$withval], + [intel_avx2=no]) + AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], []) AC_ARG_ENABLE(man, @@ -785,12 +791,15 @@ fi fi -case $host in - x86_64-*-linux*) - AC_CHECK_LIB([IPSec_MB],[sha1_one_block_avx2],LIBS=-lIPSec_MB, AC_MSG_ERROR(IPSec_MB missing)) - AC_CHECK_LIB([IPSec_MB],[sha256_one_block_avx2],LIBS=-lIPSec_MB, AC_MSG_ERROR(IPSec_MB missing)) - AC_CHECK_LIB([IPSec_MB],[sha512_one_block_avx2],LIBS=-lIPSec_MB, AC_MSG_ERROR(IPSec_MB missing)) +if test x$intel_avx2 = xyes; then + case $host in + x86_64-*-linux*) + AC_CHECK_LIB([IPSec_MB],[sha1_one_block_avx2],LIBS=-lIPSec_MB, AC_MSG_ERROR(IPSec_MB missing)) + AC_CHECK_LIB([IPSec_MB],[sha256_one_block_avx2],LIBS=-lIPSec_MB, AC_MSG_ERROR(IPSec_MB missing)) + AC_CHECK_LIB([IPSec_MB],[sha512_one_block_avx2],LIBS=-lIPSec_MB, AC_MSG_ERROR(IPSec_MB missing)) + AC_DEFINE(USE_AVX2, 1, [Define this symbol if intel axv2 works]) esac +fi if test x$use_pkgconfig = xyes; then : dnl diff --git a/src/crypto/sha1.cpp b/src/crypto/sha1.cpp index 0b767e530..a5736edda 100644 --- a/src/crypto/sha1.cpp +++ b/src/crypto/sha1.cpp @@ -8,8 +8,9 @@ #include -#if defined(__x86_64__) -#define USE_AVX2 +#if (defined(__ia64__) || defined(__x86_64__)) && \ + (defined(__linux__) && !defined(__APPLE__)) && \ + (defined(USE_AVX2)) #include #endif diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp index 2e85a98d0..7543468dc 100644 --- a/src/crypto/sha256.cpp +++ b/src/crypto/sha256.cpp @@ -8,8 +8,9 @@ #include -#if defined(__x86_64__) -#define USE_AVX2 +#if (defined(__ia64__) || defined(__x86_64__)) && \ + (defined(__linux__) && !defined(__APPLE__)) && \ + (defined(USE_AVX2)) #include #endif diff --git a/src/crypto/sha512.cpp b/src/crypto/sha512.cpp index 6b02d6d67..052250394 100644 --- a/src/crypto/sha512.cpp +++ b/src/crypto/sha512.cpp @@ -8,8 +8,9 @@ #include -#if defined(__x86_64__) -#define USE_AVX2 +#if (defined(__ia64__) || defined(__x86_64__)) && \ + (defined(__linux__) && !defined(__APPLE__)) && \ + (defined(USE_AVX2)) #include #endif