]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: SSE optimized jerasure plugins
authorLoic Dachary <loic@dachary.org>
Wed, 26 Mar 2014 10:16:01 +0000 (11:16 +0100)
committerLoic Dachary <loic@dachary.org>
Thu, 27 Mar 2014 13:27:23 +0000 (14:27 +0100)
The jerasure plugin is compiled with three sets of flags:

* jerasure_generic with no SSE optimization
* jerasure_sse3 with SSE2, SSE3 and SSSE3 optimizations
* jerasure_sse4 with SSE2, SSE3, SSSE3, SSE41, SSE42 and PCLMUL optimizations

The jerasure plugin loads the appropriate plugin depending on the CPU
features detected at runtime.

http://tracker.ceph.com/issues/7826 fixes #7826

Signed-off-by: Loic Dachary <loic@dachary.org>
src/erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc [new file with mode: 0644]
src/erasure-code/jerasure/Makefile.am
src/test/erasure-code/Makefile.am

diff --git a/src/erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc b/src/erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc
new file mode 100644 (file)
index 0000000..2d35e92
--- /dev/null
@@ -0,0 +1,66 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
+ *
+ * Author: Loic Dachary <loic@dachary.org>
+ *
+ *  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 "common/debug.h"
+#include "arch/probe.h"
+#include "arch/intel.h"
+#include "erasure-code/ErasureCodePlugin.h"
+
+#define dout_subsys ceph_subsys_osd
+#undef dout_prefix
+#define dout_prefix _prefix(_dout)
+
+static ostream& _prefix(std::ostream* _dout)
+{
+  return *_dout << "ErasureCodePluginSelectJerasure: ";
+}
+
+class ErasureCodePluginSelectJerasure : public ErasureCodePlugin {
+public:
+  virtual int factory(const map<std::string,std::string> &parameters,
+                     ErasureCodeInterfaceRef *erasure_code) {
+    ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
+    stringstream ss;
+    int ret;
+    ceph_arch_probe();
+    if (ceph_arch_intel_pclmul &&
+       ceph_arch_intel_sse42 &&
+       ceph_arch_intel_sse41 &&
+       ceph_arch_intel_ssse3 &&
+       ceph_arch_intel_sse3 &&
+       ceph_arch_intel_sse2) {
+      dout(10) << "SSE4 plugin" << dendl;
+      ret = instance.factory("jerasure_sse4", parameters, erasure_code, ss);
+    } else if (ceph_arch_intel_ssse3 &&
+              ceph_arch_intel_sse3 &&
+              ceph_arch_intel_sse2) {
+      dout(10) << "SSE3 plugin" << dendl;
+      ret = instance.factory("jerasure_sse3", parameters, erasure_code, ss);
+    } else {
+      dout(10) << "generic plugin" << dendl;
+      ret = instance.factory("jerasure_generic", parameters, erasure_code, ss);
+    }
+    if (ret)
+      derr << ss.str() << dendl;
+    return ret;
+  }
+};
+
+int __erasure_code_init(char *plugin_name)
+{
+  ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
+  return instance.add(plugin_name, new ErasureCodePluginSelectJerasure());
+}
index ff8114b8033413b7d82dfb901692c90e84e71d29..e16fe07af29d1f62f5b0d3c5ac920847b05c88ac 100644 (file)
@@ -1,5 +1,18 @@
 # jerasure plugin
-libec_jerasure_la_SOURCES = \
+noinst_HEADERS += \
+  erasure-code/jerasure/jerasure/include/cauchy.h \
+  erasure-code/jerasure/jerasure/include/galois.h \
+  erasure-code/jerasure/jerasure/include/jerasure.h \
+  erasure-code/jerasure/jerasure/include/liberation.h \
+  erasure-code/jerasure/jerasure/include/reed_sol.h \
+  erasure-code/jerasure/gf-complete/include/gf_int.h \
+  erasure-code/jerasure/gf-complete/include/gf_complete.h \
+  erasure-code/jerasure/gf-complete/include/gf_rand.h \
+  erasure-code/jerasure/gf-complete/include/gf_method.h \
+  erasure-code/jerasure/gf-complete/include/gf_general.h \
+  erasure-code/jerasure/ErasureCodeJerasure.h
+
+jerasure_sources = \
   erasure-code/jerasure/jerasure/src/cauchy.c \
   erasure-code/jerasure/jerasure/src/galois.c \
   erasure-code/jerasure/jerasure/src/jerasure.c \
@@ -19,27 +32,75 @@ libec_jerasure_la_SOURCES = \
   erasure-code/jerasure/ErasureCodePluginJerasure.cc \
   erasure-code/jerasure/ErasureCodeJerasure.cc
 
-noinst_HEADERS += \
-  erasure-code/jerasure/jerasure/include/cauchy.h \
-  erasure-code/jerasure/jerasure/include/galois.h \
-  erasure-code/jerasure/jerasure/include/jerasure.h \
-  erasure-code/jerasure/jerasure/include/liberation.h \
-  erasure-code/jerasure/jerasure/include/reed_sol.h \
-  erasure-code/jerasure/gf-complete/include/gf_int.h \
-  erasure-code/jerasure/gf-complete/include/gf_complete.h \
-  erasure-code/jerasure/gf-complete/include/gf_rand.h \
-  erasure-code/jerasure/gf-complete/include/gf_method.h \
-  erasure-code/jerasure/gf-complete/include/gf_general.h \
-  erasure-code/jerasure/ErasureCodeJerasure.h
+libec_jerasure_generic_la_SOURCES = ${jerasure_sources}
+libec_jerasure_generic_la_CFLAGS = ${AM_CFLAGS}  \
+       -Ierasure-code/jerasure/gf-complete/include \
+       -Ierasure-code/jerasure/jerasure/include
+libec_jerasure_generic_la_CXXFLAGS= ${AM_CXXFLAGS} \
+       -Ierasure-code/jerasure/gf-complete/include \
+       -Ierasure-code/jerasure/jerasure/include
+libec_jerasure_generic_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
+libec_jerasure_generic_la_LDFLAGS = ${AM_LDFLAGS} -version-info 2:0:0
+if LINUX
+libec_jerasure_generic_la_LDFLAGS += -export-symbols-regex '.*__erasure_code_.*'
+endif
 
-libec_jerasure_la_CFLAGS = ${AM_CFLAGS}  \
-       ${SIMD_FLAGS} \
+erasure_codelib_LTLIBRARIES += libec_jerasure_generic.la
+
+libec_jerasure_sse3_la_SOURCES = ${jerasure_sources}
+libec_jerasure_sse3_la_CFLAGS = ${AM_CFLAGS}  \
+       ${INTEL_SSE_FLAGS} \
+       ${INTEL_SSE2_FLAGS} \
+       ${INTEL_SSE3_FLAGS} \
+       ${INTEL_SSSE3_FLAGS} \
        -Ierasure-code/jerasure/gf-complete/include \
        -Ierasure-code/jerasure/jerasure/include
-libec_jerasure_la_CXXFLAGS= ${AM_CXXFLAGS} \
-       ${SIMD_FLAGS} \
+libec_jerasure_sse3_la_CXXFLAGS= ${AM_CXXFLAGS} \
+       ${INTEL_SSE_FLAGS} \
+       ${INTEL_SSE2_FLAGS} \
+       ${INTEL_SSE3_FLAGS} \
+       ${INTEL_SSSE3_FLAGS} \
        -Ierasure-code/jerasure/gf-complete/include \
        -Ierasure-code/jerasure/jerasure/include
+libec_jerasure_sse3_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
+libec_jerasure_sse3_la_LDFLAGS = ${AM_LDFLAGS} -version-info 2:0:0
+if LINUX
+libec_jerasure_sse3_la_LDFLAGS += -export-symbols-regex '.*__erasure_code_.*'
+endif
+
+erasure_codelib_LTLIBRARIES += libec_jerasure_sse3.la
+
+libec_jerasure_sse4_la_SOURCES = ${jerasure_sources}
+libec_jerasure_sse4_la_CFLAGS = ${AM_CFLAGS}  \
+       ${INTEL_SSE_FLAGS} \
+       ${INTEL_SSE2_FLAGS} \
+       ${INTEL_SSE3_FLAGS} \
+       ${INTEL_SSSE3_FLAGS} \
+       ${INTEL_SSE4_1_FLAGS} \
+       ${INTEL_SSE4_2_FLAGS} \
+       -Ierasure-code/jerasure/gf-complete/include \
+       -Ierasure-code/jerasure/jerasure/include
+libec_jerasure_sse4_la_CXXFLAGS= ${AM_CXXFLAGS} \
+       ${INTEL_SSE_FLAGS} \
+       ${INTEL_SSE2_FLAGS} \
+       ${INTEL_SSE3_FLAGS} \
+       ${INTEL_SSSE3_FLAGS} \
+       ${INTEL_SSE4_1_FLAGS} \
+       ${INTEL_SSE4_2_FLAGS} \
+       -Ierasure-code/jerasure/gf-complete/include \
+       -Ierasure-code/jerasure/jerasure/include
+libec_jerasure_sse4_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
+libec_jerasure_sse4_la_LDFLAGS = ${AM_LDFLAGS} -version-info 2:0:0
+if LINUX
+libec_jerasure_sse4_la_LDFLAGS += -export-symbols-regex '.*__erasure_code_.*'
+endif
+
+erasure_codelib_LTLIBRARIES += libec_jerasure_sse4.la
+
+libec_jerasure_la_SOURCES = \
+       erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc
+libec_jerasure_la_CFLAGS = ${AM_CFLAGS} 
+libec_jerasure_la_CXXFLAGS= ${AM_CXXFLAGS}
 libec_jerasure_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
 libec_jerasure_la_LDFLAGS = ${AM_LDFLAGS} -version-info 2:0:0
 if LINUX
index aa8fbbd5c9b84856c6a0fc723c4d63cb2da18019..95065cf343c50ec0f5c0ffd247fdc0a2324c1977 100644 (file)
@@ -62,13 +62,11 @@ check_PROGRAMS += unittest_erasure_code_plugin
 
 unittest_erasure_code_jerasure_SOURCES = \
        test/erasure-code/TestErasureCodeJerasure.cc \
-       $(libec_jerasure_la_SOURCES)
+       ${jerasure_sources}
 unittest_erasure_code_jerasure_CFLAGS = $(AM_CFLAGS) \
-       ${SIMD_FLAGS} \
        -Ierasure-code/jerasure/gf-complete/include \
        -Ierasure-code/jerasure/jerasure/include
 unittest_erasure_code_jerasure_CXXFLAGS = $(UNITTEST_CXXFLAGS) \
-       ${SIMD_FLAGS} \
        -Ierasure-code/jerasure/gf-complete/include \
        -Ierasure-code/jerasure/jerasure/include
 unittest_erasure_code_jerasure_LDADD = $(LIBOSD) $(LIBCOMMON) $(UNITTEST_LDADD) $(CEPH_GLOBAL)