From a80fd50deaceedf05e6f2556f0a11fc8a38797bf Mon Sep 17 00:00:00 2001 From: Marcel Keller Date: Wed, 3 Jan 2018 13:15:45 +0100 Subject: [PATCH] Support for processors without AVX. --- CONFIG | 4 ++-- README.md | 1 + Tools/avx_memcpy.h | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CONFIG b/CONFIG index 2687fd7d..2f644aa9 100644 --- a/CONFIG +++ b/CONFIG @@ -15,7 +15,7 @@ USE_GF2N_LONG = 0 # set to -march= for optimization # AVX2 support (Haswell or later) changes the bit matrix transpose -ARCH = -mtune=native +ARCH = -mtune=native -mavx #use CONFIG.mine to overwrite DIR settings -include CONFIG.mine @@ -40,7 +40,7 @@ LDLIBS += -lrt endif CXX = g++ -CFLAGS = $(ARCH) $(MY_CFLAGS) -g -Wextra -Wall $(OPTIM) -I$(ROOT) -pthread $(PROF) $(DEBUG) $(MOD) $(MEMPROTECT) $(GF2N_LONG) $(PREP_DIR) -maes -mpclmul -msse4.1 -mavx --std=c++11 -Werror +CFLAGS = $(ARCH) $(MY_CFLAGS) -g -Wextra -Wall $(OPTIM) -I$(ROOT) -pthread $(PROF) $(DEBUG) $(MOD) $(MEMPROTECT) $(GF2N_LONG) $(PREP_DIR) -maes -mpclmul -msse4.1 --std=c++11 -Werror CPPFLAGS = $(CFLAGS) LD = g++ diff --git a/README.md b/README.md index 288e3cd4..859f9f80 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ In particular, the online phase will discard preprocessed data and crash when it - To benchmark only the online phase (skipping the secure offline phase), add the following line at the top: `MY_CFLAGS = -DINSECURE` - `PREP_DIR` should point to should be a local, unversioned directory to store preprocessing data (default is `Player-Data` in the current directory). - For the SPDZ-2 offline phase, set `USE_NTL = 1` and `MOD = -DMAX_MOD_SZ=6`. + - For processors without AVX (e.g., Intel Atom) or for optimization, set `ARCH = -march=`. 2) Run make (use the flag -j for faster compilation multiple threads). Remember to run `make clean` first after changing `CONFIG` or `CONFIG.mine`. diff --git a/Tools/avx_memcpy.h b/Tools/avx_memcpy.h index 1317e190..e9a2f8ff 100644 --- a/Tools/avx_memcpy.h +++ b/Tools/avx_memcpy.h @@ -14,11 +14,13 @@ inline void avx_memcpy(void* dest, const void* source, size_t length) { __m256i* d = (__m256i*)dest, *s = (__m256i*)source; +#ifdef __AVX__ while (length >= 32) { _mm256_storeu_si256(d++, _mm256_loadu_si256(s++)); length -= 32; } +#endif __m128i* d2 = (__m128i*)d; __m128i* s2 = (__m128i*)s; while (length >= 16) @@ -33,12 +35,14 @@ inline void avx_memcpy(void* dest, const void* source, size_t length) inline void avx_memzero(void* dest, size_t length) { __m256i* d = (__m256i*)dest; +#ifdef __AVX__ __m256i s = _mm256_setzero_si256(); while (length >= 32) { _mm256_storeu_si256(d++, s); length -= 32; } +#endif if (length) memset(d, 0, length); }