erasure code arm 32 and 64 bit neon optimisations
Hi,
gf-complete has since last week optimisations using ARM's NEON SIMD instruction set. This patch set adds a jerasure erasure code plugin using the NEON optimisations.
Reed-Solomon-Vandermonde encoding for large block sizes (256k) is 2-8 times faster depending on the number of chunks and erasures (tested on cortex-a9, coretex-a53 and cortex-a57). For smaller block size (4k) the speed-up is smaller since the memory management overhead is larger than encoding workload.
cheers Janne
PATCH 1/5 erasure-code: conditionally build jerasure sse3/sse4 plugins
--- configure.ac | 2 ++ src/erasure-code/jerasure/Makefile.am | 4 ++++ src/test/erasure-code/Makefile.am | 4 ++++ 3 files changed, 10 insertions(+)
configure.ac +2 -0
@@ -539,6 +539,8 @@ AC_LANG_POP([C++]) # Find supported SIMD / SSE extensions supported by the compiler AX_INTEL_FEATURES() +AM_CONDITIONAL(HAVE_SSSE3, [ test "x$ax_cv_support_ssse3_ext" = "xyes"]) +AM_CONDITIONAL(HAVE_SSE4_PCLMUL, [ test "x$ax_cv_support_pclmuldq_ext" = "xyes"]) # kinetic osd backend? AC_ARG_WITH([kinetic],
src/erasure-code/jerasure/Makefile.am +4 -0
@@ -71,7 +71,9 @@ if LINUX libec_jerasure_sse3_la_LDFLAGS += -export-symbols-regex '.*__erasure_code_.*' endif +if HAVE_SSSE3 erasure_codelib_LTLIBRARIES += libec_jerasure_sse3.la +endif libec_jerasure_sse4_la_SOURCES = ${jerasure_sources} libec_jerasure_sse4_la_CFLAGS = ${AM_CFLAGS} \
@@ -98,7 +100,9 @@ if LINUX libec_jerasure_sse4_la_LDFLAGS += -export-symbols-regex '.*__erasure_code_.*' endif +if HAVE_SSE4_PCLMUL erasure_codelib_LTLIBRARIES += libec_jerasure_sse4.la +endif libec_jerasure_la_SOURCES = \ erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc
src/test/erasure-code/Makefile.am +4 -0
@@ -74,7 +74,9 @@ libec_test_jerasure_sse4_la_CFLAGS = ${AM_CFLAGS} libec_test_jerasure_sse4_la_CXXFLAGS= ${AM_CXXFLAGS} libec_test_jerasure_sse4_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS) libec_test_jerasure_sse4_la_LDFLAGS = ${AM_LDFLAGS} -export-symbols-regex '.*__erasure_code_.*' +if HAVE_SSE4_PCLMUL erasure_codelib_LTLIBRARIES += libec_test_jerasure_sse4.la +endif libec_test_jerasure_sse3_la_SOURCES = test/erasure-code/TestJerasurePluginSSE3.cc test/erasure-code/TestJerasurePluginSSE3.cc: ./ceph_ver.h
@@ -82,7 +84,9 @@ libec_test_jerasure_sse3_la_CFLAGS = ${AM_CFLAGS} libec_test_jerasure_sse3_la_CXXFLAGS= ${AM_CXXFLAGS} libec_test_jerasure_sse3_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS) libec_test_jerasure_sse3_la_LDFLAGS = ${AM_LDFLAGS} -export-symbols-regex '.*__erasure_code_.*' +if HAVE_SSSE3 erasure_codelib_LTLIBRARIES += libec_test_jerasure_sse3.la +endif libec_test_jerasure_generic_la_SOURCES = test/erasure-code/TestJerasurePluginGeneric.cc test/erasure-code/TestJerasurePluginGeneric.cc: ./ceph_ver.h
Signature · 1 line
2.1.2
Re: [PATCH 1/5] erasure-code: conditionally build jerasure sse3/sse4 plugins
Quoted 24 lines · Janne Grunau
--- configure.ac | 2 ++ src/erasure-code/jerasure/Makefile.am | 4 ++++ src/test/erasure-code/Makefile.am | 4 ++++ 3 files changed, 10 insertions(+)configure.ac +2
-0@@ -539,6 +539,8 @@ AC_LANG_POP([C++]) # Find supported SIMD / SSE extensions supported by the compiler AX_INTEL_FEATURES() +AM_CONDITIONAL(HAVE_SSSE3, [ test "x$ax_cv_support_ssse3_ext" = "xyes"]) +AM_CONDITIONAL(HAVE_SSE4_PCLMUL, [ test "x$ax_cv_support_pclmuldq_ext" = "xyes"]) # kinetic osd backend? AC_ARG_WITH([kinetic],src/erasure-code/jerasure/Makefile.am +0
-0
src/erasure-code/jerasure/Makefile.am if LINUX · line 76
Quoted 6 lines
src/erasure-code/jerasure/Makefile.am +2
-0@@ -71,7 +71,9 @@ if LINUX libec_jerasure_sse3_la_LDFLAGS += -export-symbols-regex '.*__erasure_code_.*' endif +if HAVE_SSSE3 erasure_codelib_LTLIBRARIES += libec_jerasure_sse3.la +endif
I just realised that this is not exactly safe. While libec_jerasure_sse3 won't have useful code if HAVE_SSSE3 is not defined, the runtime detection in ErasureCodePluginSelectJerasure.cc can still return "sse3". That would fail since the sse3 libec_jerasure plugin is not built.
I'll send an updated patch which avoids this problem later.
Janne
PATCH 2/5 autotools: ARM/AArch64 NEON detection similar to x86
In reply to Janne Grunau--- configure.ac | 7 +++---- m4/ax_arm.m4 | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 m4/ax_arm.m4
configure.ac +3 -4
@@ -141,9 +141,6 @@ AC_DEFUN([AC_CHECK_CC_FLAG], AC_CHECK_CC_FLAG([-Wtype-limits], [WARN_TYPE_LIMITS]) AC_CHECK_CC_FLAG([-Wignored-qualifiers], [WARN_IGNORED_QUALIFIERS]) -# Checks for architecture stuff -AM_CONDITIONAL([ENABLE_FPU_NEON], [case $target_cpu in arm*) true;; *) false;; esac]) - # Check for compiler VTA support AX_CHECK_COMPILE_FLAG([-fvar-tracking-assignments], [HAS_VTA_SUPPORT=1], [HAS_VTA_SUPPORT=0]) AM_CONDITIONAL(COMPILER_HAS_VTA, [test "$HAS_VTA_SUPPORT" = 1])
@@ -537,7 +534,9 @@ AC_LANG_PUSH([C++]) AC_CHECK_HEADER([leveldb/filter_policy.h], [AC_DEFINE([HAVE_LEVELDB_FILTER_POLICY], [1], [Defined if LevelDB supports bloom filters ])]) AC_LANG_POP([C++]) -# Find supported SIMD / SSE extensions supported by the compiler +# Find supported SIMD / NEON / SSE extensions supported by the compiler +AX_ARM_FEATURES() +AM_CONDITIONAL(HAVE_NEON, [ test "x$ax_cv_support_neon_ext" = "xyes"]) AX_INTEL_FEATURES() AM_CONDITIONAL(HAVE_SSSE3, [ test "x$ax_cv_support_ssse3_ext" = "xyes"]) AM_CONDITIONAL(HAVE_SSE4_PCLMUL, [ test "x$ax_cv_support_pclmuldq_ext" = "xyes"])
m4/ax_arm.m4 new file +27 -0
@@ -0,0 +1,27 @@ +AC_DEFUN([AX_ARM_FEATURES], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + + case $target_cpu in + arm*) + AX_CHECK_COMPILE_FLAG(-mfpu=neon, ax_cv_support_neon_ext=yes, []) + if test x"$ax_cv_support_neon_ext" = x"yes"; then + ARM_NEON_FLAGS="-mfpu=neon -DARM_NEON" + AC_SUBST(ARM_NEON_FLAGS) + ARM_FLAGS="$ARM_FLAGS $ARM_NEON_FLAGS" + AC_DEFINE(HAVE_NEON,,[Support NEON instructions]) + fi + ;; + aarch64*) + AX_CHECK_COMPILE_FLAG(-march=armv8-a+simd, ax_cv_support_neon_ext=yes, []) + if test x"$ax_cv_support_neon_ext" = x"yes"; then + ARM_NEON_FLAGS="-march=armv8-a+simd -DARCH_AARCH64 -DARM_NEON" + AC_SUBST(ARM_NEON_FLAGS) + ARM_FLAGS="$ARM_FLAGS $ARM_NEON_FLAGS" + AC_DEFINE(HAVE_NEON,,[Support NEON instructions]) + fi + ;; + esac + + AC_SUBST(ARM_FLAGS) +])
Signature · 1 line
2.1.2
Re: [PATCH 2/5] autotools: ARM/AArch64 NEON detection similar to x86
Quoted 11 lines · Janne Grunau
--- configure.ac | 7 +++---- m4/ax_arm.m4 | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 m4/ax_arm.m4configure.ac +0
-0
configure.ac AC_DEFUN([AC_CHECK_CC_FLAG], · line 146
Quoted 6 lines
configure.ac +0
-3@@ -141,9 +141,6 @@ AC_DEFUN([AC_CHECK_CC_FLAG], AC_CHECK_CC_FLAG([-Wtype-limits], [WARN_TYPE_LIMITS]) AC_CHECK_CC_FLAG([-Wignored-qualifiers], [WARN_IGNORED_QUALIFIERS]) -# Checks for architecture stuff -AM_CONDITIONAL([ENABLE_FPU_NEON], [case $target_cpu in arm*) true;; *) false;; esac]) -
This conflicts with the wip-neon-crc32c branch. I removed it since ENABLE_FPU_NEON is currently unused. I think that branch should be updated to use the defines/flags in this patch since this is more in line with behaviour for x86.
Janne
PATCH 3/5 aarch64: add support for HW_CAP based neon runtime detection
In reply to Janne Grunau--- src/arch/neon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
src/arch/neon.c +3 -1
@@ -10,7 +10,7 @@ int ceph_arch_neon = 0;#include <elf.h> #include <link.h> // ElfW macro -#if __arm__ +#if __arm__ || __aarch64__#include <asm/hwcap.h> #endif // __arm__
@@ -42,6 +42,8 @@ int ceph_arch_neon_probe(void) {#if __arm__ && __linux__ ceph_arch_neon = (get_hwcap () &HWCAP_NEON ) ==HWCAP_NEON ; +#elif __aarch64__ && __linux__ + ceph_arch_neon = (get_hwcap () &HWCAP_ASIMD ) ==HWCAP_ASIMD ;#else if (0 )get_hwcap ();// make compiler shut up
Signature · 1 line
2.1.2
PATCH 4/5 erasure-code: switch gf-complete's submodule branch to master
In reply to Janne GrunauThe master branch of gf-complete has NEON optimisations for ARMv7 and 64-bit ARMv8 the jerasure erasure code plugin can use.
--- .gitmodules | 2 +- src/erasure-code/jerasure/gf-complete | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
.gitmodules +1 -1
@@ -14,7 +14,7 @@ [submodule "src/erasure-code/jerasure/gf-complete"] path = src/erasure-code/jerasure/gf-complete url = https://github.com/ceph/gf-complete.git - branch = v1-ceph + branch = master [submodule "src/rocksdb"] path = src/rocksdb url = git://github.com/ceph/rocksdb
src/erasure-code/jerasure/gf-complete +1 -1
@@ -1 +1 @@ -Subproject commit 191e7105b2b75f7f48ef23dfab9ae72275363168 +Subproject commit 70dd94ae38f2d20dd78532a6dfd1310fdfb4a884
Signature · 1 line
2.1.2
PATCH 5/5 erasure-code: build and use a NEON jerasure variant
In reply to Janne Grunau--- .../jerasure/ErasureCodePluginSelectJerasure.cc | 3 +++ src/erasure-code/jerasure/Makefile.am | 24 +++++++++++++++++++++ src/test/erasure-code/Makefile.am | 10 +++++++++ src/test/erasure-code/TestJerasurePluginNEON.cc | 25 ++++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 src/test/erasure-code/TestJerasurePluginNEON.cc
src/erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc +3 -0
@@ -19,6 +19,7 @@ #include "common/debug.h" #include "arch/probe.h" #include "arch/intel.h" +#include "arch/neon.h" #include "erasure-code/ErasureCodePlugin.h" #define dout_subsys ceph_subsys_osd
@@ -44,6 +45,8 @@ static string get_variant() { ceph_arch_intel_sse3 && ceph_arch_intel_sse2) { return "sse3"; + } else if (ceph_arch_neon) { + return "neon"; } else { return "generic"; }
src/erasure-code/jerasure/Makefile.am +24 -0
@@ -50,6 +50,30 @@ endif erasure_codelib_LTLIBRARIES += libec_jerasure_generic.la +libec_jerasure_neon_la_SOURCES = ${jerasure_sources} \ + erasure-code/jerasure/gf-complete/src/neon/gf_w4_neon.c \ + erasure-code/jerasure/gf-complete/src/neon/gf_w8_neon.c \ + erasure-code/jerasure/gf-complete/src/neon/gf_w16_neon.c \ + erasure-code/jerasure/gf-complete/src/neon/gf_w32_neon.c \ + erasure-code/jerasure/gf-complete/src/neon/gf_w64_neon.c +libec_jerasure_neon_la_CFLAGS = ${AM_CFLAGS} \ + ${ARM_NEON_FLAGS} \ + -I$(srcdir)/erasure-code/jerasure/gf-complete/include \ + -I$(srcdir)/erasure-code/jerasure/jerasure/include +libec_jerasure_neon_la_CXXFLAGS= ${AM_CXXFLAGS} \ + ${ARM_NEON_FLAGS} \ + -I$(srcdir)/erasure-code/jerasure/gf-complete/include \ + -I$(srcdir)/erasure-code/jerasure/jerasure/include +libec_jerasure_neon_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS) +libec_jerasure_neon_la_LDFLAGS = ${AM_LDFLAGS} -version-info 2:0:0 +if LINUX +libec_jerasure_neon_la_LDFLAGS += -export-symbols-regex '.*__erasure_code_.*' +endif + +if HAVE_NEON +erasure_codelib_LTLIBRARIES += libec_jerasure_neon.la +endif + libec_jerasure_sse3_la_SOURCES = ${jerasure_sources} libec_jerasure_sse3_la_CFLAGS = ${AM_CFLAGS} \ ${INTEL_SSE_FLAGS} \
src/test/erasure-code/Makefile.am +10 -0
@@ -68,6 +68,16 @@ libec_fail_to_register_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS) libec_fail_to_register_la_LDFLAGS = ${AM_LDFLAGS} -export-symbols-regex '.*__erasure_code_.*' erasure_codelib_LTLIBRARIES += libec_fail_to_register.la +libec_test_jerasure_neon_la_SOURCES = test/erasure-code/TestJerasurePluginNEON.cc +test/erasure-code/TestJerasurePluginNEON.cc: ./ceph_ver.h +libec_test_jerasure_neon_la_CFLAGS = ${AM_CFLAGS} +libec_test_jerasure_neon_la_CXXFLAGS= ${AM_CXXFLAGS} +libec_test_jerasure_neon_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS) +libec_test_jerasure_neon_la_LDFLAGS = ${AM_LDFLAGS} -export-symbols-regex '.*__erasure_code_.*' +if HAVE_NEON +erasure_codelib_LTLIBRARIES += libec_test_jerasure_neon.la +endif + libec_test_jerasure_sse4_la_SOURCES = test/erasure-code/TestJerasurePluginSSE4.cc test/erasure-code/TestJerasurePluginSSE4.cc: ./ceph_ver.h libec_test_jerasure_sse4_la_CFLAGS = ${AM_CFLAGS}
src/test/erasure-code/TestJerasurePluginNEON.cc new file +25 -0
@@ -0,0 +1,25 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph distributed storage system + * + * Copyright (C) 2014 Cloudwatt <[email protected]> + * Copyright (C) 2014 Red Hat <[email protected]> + * + * Author: Loic Dachary <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + */ + +#include "ceph_ver.h" + +extern "C" const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; } + +extern "C" int __erasure_code_init(char *plugin_name, char *directory) +{ + return -444; +}
Signature · 1 line
2.1.2