From: Bassam Tabbara Date: Thu, 22 Sep 2016 19:40:52 +0000 (-0700) Subject: erasure-code: Remove SIMD flavors for jerasure and shec X-Git-Tag: v11.0.1~44^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cc62c11a76d6d8a29b6894ce02e08458885e557b;p=ceph.git erasure-code: Remove SIMD flavors for jerasure and shec By switching to a new gf-complete with SIMD runtime detection, we can now remove all the different flavors of jerasure and shec. This simplifies deployment and configuration of erasure coding, enables hetergenous OSDs, and enables us to take advantage of new performance improvements in jerasure without config/build changes. This commit removes flavors from cmake, removes ErasureCodePluginSelect___, and fixes unit tests. There is now a single plugin for jerasure and a single plugin for shec. SIMDExt.cmake was changed so that its a little more generic, and is not polluted with gf-complete specific CFLAG defines. The #define for SIMD instruction were based on gf-complete. I also added a small init helper for jerasure that has code that was common between jerasure and shec. Signed-off-by: Bassam Tabbara --- diff --git a/cmake/modules/SIMDExt.cmake b/cmake/modules/SIMDExt.cmake index f556a71c9cc1..df3ad3b9ab36 100644 --- a/cmake/modules/SIMDExt.cmake +++ b/cmake/modules/SIMDExt.cmake @@ -1,66 +1,63 @@ # detect SIMD extentions # -# ARM_NEON_FLAGS -# # HAVE_ARMV8_CRC -# HAVE_NEON -# HAVE_SSE -# HAVE_SSE2 +# HAVE_ARMV8_SIMD +# HAVE_ARM_NEON +# HAVE_INTEL_SSE +# HAVE_INTEL_SSE2 +# HAVE_INTEL_SSE3 +# HAVE_INTEL_SSSE3 +# HAVE_INTEL_PCLMUL +# HAVE_INTEL_SSE4_1 +# HAVE_INTEL_SSE4_2 # # INTEL_SSE4_1 -# INTEL_SSE4_2 -# -# SSE3_FLAGS -# SSE4_FLAGS +# +# SIMD_COMPILE_FLAGS # if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64") CHECK_C_COMPILER_FLAG(-march=armv8-a+crc HAVE_ARMV8_CRC) if(HAVE_ARMV8_CRC) - set(ARM_CRC_FLAGS "-march=armv8-a+crc -DARCH_AARCH64") + set(ARM_CRC_FLAGS "-march=armv8-a+crc") endif() - CHECK_C_COMPILER_FLAG(-march=armv8-a+simd HAVE_NEON) - if(HAVE_NEON) - set(ARM_NEON_FLAGS "-march=armv8-a+simd -DARCH_AARCH64 -DARM_NEON") + CHECK_C_COMPILER_FLAG(-march=armv8-a+simd HAVE_ARMV8_SIMD) + if(HAVE_ARMV8_SIMD) + set(SIMD_COMPILE_FLAGS "${SIMD_COMPILE_FLAGS} -march=armv8-a+simd") endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM") - CHECK_C_COMPILER_FLAG(-mfpu=neon HAVE_NEON) - if(HAVE_NEON) - set(ARM_NEON_FLAGS "-mfpu=neon -DARM_NEON") + CHECK_C_COMPILER_FLAG(-mfpu=neon HAVE_ARM_NEON) + if(HAVE_ARM_NEON) + set(SIMD_COMPILE_FLAGS "${SIMD_COMPILE_FLAGS} -mfpu=neon") endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i686|amd64|x86_64|AMD64") - set(SSE3_FLAGS) - CHECK_C_COMPILER_FLAG(-msse HAVE_SSE) - if(HAVE_SSE) - set(SSE3_FLAGS "${SSE3_FLAGS} -msse -DINTEL_SSE") + CHECK_C_COMPILER_FLAG(-msse HAVE_INTEL_SSE) + if(HAVE_INTEL_SSE) + set(SIMD_COMPILE_FLAGS "${SIMD_COMPILE_FLAGS} -msse") endif() - - CHECK_C_COMPILER_FLAG(-msse2 HAVE_SSE2) - if(HAVE_SSE2) - set(SSE3_FLAGS "${SSE3_FLAGS} -msse2 -DINTEL_SSE2") + CHECK_C_COMPILER_FLAG(-msse2 HAVE_INTEL_SSE2) + if(HAVE_INTEL_SSE2) + set(SIMD_COMPILE_FLAGS "${SIMD_COMPILE_FLAGS} -msse2") endif() - - CHECK_C_COMPILER_FLAG(-msse3 HAVE_SSE3) - if(HAVE_SSE3) - set(SSE3_FLAGS "${SSE3_FLAGS} -msse3 -DINTEL_SSE3") + CHECK_C_COMPILER_FLAG(-msse3 HAVE_INTEL_SSE3) + if(HAVE_INTEL_SSE3) + set(SIMD_COMPILE_FLAGS "${SIMD_COMPILE_FLAGS} -msse3") endif() - - CHECK_C_COMPILER_FLAG(-mssse3 SUPPORTS_SSSE3) - if(SUPPORTS_SSSE3) - set(SSE3_FLAGS "${SSE3_FLAGS} -mssse3 -DINTEL_SSSE3") + CHECK_C_COMPILER_FLAG(-mssse3 HAVE_INTEL_SSSE3) + if(HAVE_INTEL_SSSE3) + set(SIMD_COMPILE_FLAGS "${SIMD_COMPILE_FLAGS} -mssse3") + endif() + CHECK_C_COMPILER_FLAG(-mpclmul HAVE_INTEL_PCLMUL) + if(HAVE_INTEL_PCLMUL) + set(SIMD_COMPILE_FLAGS "${SIMD_COMPILE_FLAGS} -mpclmul") endif() - - # pclmul is not enabled in SSE3, otherwise we need another - # flavor or an cmake option for enabling it - - set(SSE4_FLAGS ${SSE3_FLAGS}) CHECK_C_COMPILER_FLAG(-msse4.1 INTEL_SSE4_1) - if(SUPPORTS_SSE41) - set(SSE4_FLAGS "${SSE4_FLAGS} -msse41 -DINTEL_SSE4") + CHECK_C_COMPILER_FLAG(-msse4.1 HAVE_INTEL_SSE4_1) + if(HAVE_INTEL_SSE4_1) + set(SIMD_COMPILE_FLAGS "${SIMD_COMPILE_FLAGS} -msse4.1") endif() - - CHECK_C_COMPILER_FLAG(-msse4.2 INTEL_SSE4_2) - if(SUPPORTS_SSE42) - set(SSE4_FLAGS "${SSE4_FLAGS} -msse42 -DINTEL_SSE4") + CHECK_C_COMPILER_FLAG(-msse4.2 HAVE_INTEL_SSE4_2) + if(HAVE_INTEL_SSE4_2) + set(SIMD_COMPILE_FLAGS "${SIMD_COMPILE_FLAGS} -msse4.2") endif() endif() diff --git a/qa/workunits/erasure-code/bench.sh b/qa/workunits/erasure-code/bench.sh index 8e8671c49ccf..e2bec8edd272 100755 --- a/qa/workunits/erasure-code/bench.sh +++ b/qa/workunits/erasure-code/bench.sh @@ -49,7 +49,7 @@ export PATH=/sbin:$PATH : ${VERBOSE:=false} : ${CEPH_ERASURE_CODE_BENCHMARK:=ceph_erasure_code_benchmark} : ${PLUGIN_DIRECTORY:=/usr/lib/ceph/erasure-code} -: ${PLUGINS:=isa jerasure_generic jerasure_sse4} +: ${PLUGINS:=isa jerasure} : ${TECHNIQUES:=vandermonde cauchy} : ${TOTAL_SIZE:=$((1024 * 1024))} : ${SIZE:=4096} @@ -111,12 +111,6 @@ function bench_run() { k2ms[4]="2 3" k2ms[6]="2 3 4" k2ms[10]="3 4" - local isa2technique_vandermonde='reed_sol_van' - local isa2technique_cauchy='cauchy' - local jerasure_generic2technique_vandermonde='reed_sol_van' - local jerasure_generic2technique_cauchy='cauchy_good' - local jerasure_sse42technique_vandermonde='reed_sol_van' - local jerasure_sse42technique_cauchy='cauchy_good' for technique in ${TECHNIQUES} ; do for plugin in ${PLUGINS} ; do eval technique_parameter=\$${plugin}2technique_${technique} diff --git a/qa/workunits/erasure-code/plot.js b/qa/workunits/erasure-code/plot.js index 793ab1a7b1a7..bd2bba5bbada 100644 --- a/qa/workunits/erasure-code/plot.js +++ b/qa/workunits/erasure-code/plot.js @@ -8,22 +8,14 @@ $(function() { lines: { show: true }, }); } - if (typeof encode_vandermonde_jerasure_generic != 'undefined') { + if (typeof encode_vandermonde_jerasure != 'undefined') { encode.push({ - data: encode_vandermonde_jerasure_generic, + data: encode_vandermonde_jerasure, label: "Jerasure Generic, Vandermonde", points: { show: true }, lines: { show: true }, }); } - if (typeof encode_vandermonde_jerasure_sse4 != 'undefined') { - encode.push({ - data: encode_vandermonde_jerasure_sse4, - label: "Jerasure SIMD, Vandermonde", - points: { show: true }, - lines: { show: true }, - }); - } if (typeof encode_cauchy_isa != 'undefined') { encode.push({ data: encode_cauchy_isa, @@ -32,9 +24,9 @@ $(function() { lines: { show: true }, }); } - if (typeof encode_cauchy_jerasure_generic != 'undefined') { + if (typeof encode_cauchy_jerasure != 'undefined') { encode.push({ - data: encode_cauchy_jerasure_generic, + data: encode_cauchy_jerasure, label: "Jerasure, Cauchy", points: { show: true }, lines: { show: true }, @@ -56,22 +48,14 @@ $(function() { lines: { show: true }, }); } - if (typeof decode_vandermonde_jerasure_generic != 'undefined') { + if (typeof decode_vandermonde_jerasure != 'undefined') { decode.push({ - data: decode_vandermonde_jerasure_generic, + data: decode_vandermonde_jerasure, label: "Jerasure Generic, Vandermonde", points: { show: true }, lines: { show: true }, }); } - if (typeof decode_vandermonde_jerasure_sse4 != 'undefined') { - decode.push({ - data: decode_vandermonde_jerasure_sse4, - label: "Jerasure SIMD, Vandermonde", - points: { show: true }, - lines: { show: true }, - }); - } if (typeof decode_cauchy_isa != 'undefined') { decode.push({ data: decode_cauchy_isa, @@ -80,9 +64,9 @@ $(function() { lines: { show: true }, }); } - if (typeof decode_cauchy_jerasure_generic != 'undefined') { + if (typeof decode_cauchy_jerasure != 'undefined') { decode.push({ - data: decode_cauchy_jerasure_generic, + data: decode_cauchy_jerasure, label: "Jerasure, Cauchy", points: { show: true }, lines: { show: true }, diff --git a/src/erasure-code/CMakeLists.txt b/src/erasure-code/CMakeLists.txt index d0941c112311..943dea187f26 100644 --- a/src/erasure-code/CMakeLists.txt +++ b/src/erasure-code/CMakeLists.txt @@ -7,22 +7,6 @@ include_directories(jerasure/jerasure/include) include_directories(jerasure/gf-complete/include) include_directories(jerasure) -if(TRUE) - list(APPEND jerasure_flavors generic) -endif() - -if(HAVE_NEON) - list(APPEND jerasure_flavors neon) -endif() - -if(HAVE_SSE) - list(APPEND jerasure_flavors sse3) -endif() - -if(INTEL_SSE4_1) - list(APPEND jerasure_flavors sse4) -endif() - add_subdirectory(jerasure) add_subdirectory(lrc) add_subdirectory(shec) @@ -42,9 +26,3 @@ add_custom_target(erasure_code_plugins DEPENDS ${EC_ISA_LIB} ec_lrc ec_jerasure) -if(TARGET ec_jerasure_sse3) - add_dependencies(erasure_code_plugins ec_jerasure_sse3) -endif() -if(TARGET ec_jerasure_sse4) - add_dependencies(erasure_code_plugins ec_jerasure_sse4) -endif() diff --git a/src/erasure-code/jerasure/CMakeLists.txt b/src/erasure-code/jerasure/CMakeLists.txt index cf22a43d14d0..a17f5c392382 100644 --- a/src/erasure-code/jerasure/CMakeLists.txt +++ b/src/erasure-code/jerasure/CMakeLists.txt @@ -5,20 +5,39 @@ add_library(jerasure_utils OBJECT ErasureCodeJerasure.cc) add_dependencies(jerasure_utils ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) -add_library(ec_jerasure SHARED ErasureCodePluginSelectJerasure.cc) -add_dependencies(ec_jerasure ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) -target_link_libraries(ec_jerasure ${EXTRALIBS}) -install(TARGETS ec_jerasure DESTINATION ${erasure_plugin_dir}) +# Set the CFLAGS correctly for gf-complete based on SIMD compiler support +set(GF_COMPILE_FLAGS) +if(HAVE_ARMV8_SIMD) + list(APPEND GF_COMPILE_FLAGS ARM_NEON ARCH_AARCH64) +endif() +if(HAVE_ARM_NEON) + list(APPEND GF_COMPILE_FLAGS ARM_NEON) +endif() +if(HAVE_INTEL_SSE) + list(APPEND GF_COMPILE_FLAGS INTEL_SSE) +endif() +if(HAVE_INTEL_SSE2) + list(APPEND GF_COMPILE_FLAGS INTEL_SSE2) +endif() +if(HAVE_INTEL_SSE3) + list(APPEND GF_COMPILE_FLAGS INTEL_SSE3) +endif() +if(HAVE_INTEL_SSSE3) + list(APPEND GF_COMPILE_FLAGS INTEL_SSSE3) +endif() +if(HAVE_INTEL_PCLMUL) + list(APPEND GF_COMPILE_FLAGS INTEL_SSE4_PCLMUL) +endif() +if(HAVE_INTEL_SSE4_1) + list(APPEND GF_COMPILE_FLAGS INTEL_SSE4) +endif() +if(HAVE_INTEL_SSE4_2) + list(APPEND GF_COMPILE_FLAGS INTEL_SSE4) +endif() -set(jerasure_srcs - jerasure/src/cauchy.c - jerasure/src/galois.c - jerasure/src/jerasure.c - jerasure/src/liberation.c - jerasure/src/reed_sol.c +set(gf-complete_srcs gf-complete/src/gf_cpu.c gf-complete/src/gf_wgen.c - gf-complete/src/gf_method.c gf-complete/src/gf_w16.c gf-complete/src/gf.c gf-complete/src/gf_w32.c @@ -29,44 +48,34 @@ set(jerasure_srcs gf-complete/src/gf_rand.c gf-complete/src/gf_w8.c) -list(FIND jerasure_flavors generic found) -if(found GREATER -1) - add_library(jerasure_generic OBJECT ${jerasure_srcs}) -endif() - -list(FIND jerasure_flavors neon found) -if(found GREATER -1) - add_library(jerasure_neon OBJECT - ${jerasure_srcs} +if(HAVE_ARM_NEON OR HAVE_ARMV8_SIMD) + list(APPEND gf-complete_srcs gf-complete/src/neon/gf_w4_neon.c gf-complete/src/neon/gf_w8_neon.c gf-complete/src/neon/gf_w16_neon.c gf-complete/src/neon/gf_w32_neon.c gf-complete/src/neon/gf_w64_neon.c) - set_target_properties(jerasure_neon PROPERTIES - COMPILE_FLAGS ${ARM_NEON_FLAGS}) endif() -list(FIND jerasure_flavors sse3 found) -if(found GREATER -1) - add_library(jerasure_sse3 OBJECT ${jerasure_srcs}) - set_target_properties(jerasure_sse3 PROPERTIES - COMPILE_FLAGS ${SSE3_FLAGS}) -endif() +add_library(gf-complete_objs OBJECT ${gf-complete_srcs}) +set_target_properties(gf-complete_objs PROPERTIES + COMPILE_FLAGS ${SIMD_COMPILE_FLAGS}) +set_target_properties(gf-complete_objs PROPERTIES + COMPILE_DEFINITIONS "${GF_COMPILE_FLAGS}") -list(FIND jerasure_flavors sse4 found) -if(found GREATER -1) - add_library(jerasure_sse4 OBJECT ${jerasure_srcs}) - set_target_properties(jerasure_sse4 PROPERTIES - COMPILE_FLAGS ${SSE4_FLAGS}) -endif() +set(jerasure_srcs + jerasure/src/cauchy.c + jerasure/src/galois.c + jerasure/src/jerasure.c + jerasure/src/liberation.c + jerasure/src/reed_sol.c + jerasure_init.cc) +add_library(jerasure_objs OBJECT ${jerasure_srcs}) -foreach(flavor ${jerasure_flavors}) - set(plugin_name "ec_jerasure_${flavor}") - add_library(${plugin_name} SHARED - $ - $ - $) - target_link_libraries(${plugin_name} ${EXTRALIBS}) - install(TARGETS ${plugin_name} DESTINATION ${erasure_plugin_dir}) -endforeach() +add_library(ec_jerasure SHARED + $ + $ + $ + $) +target_link_libraries(ec_jerasure ${EXTRALIBS}) +install(TARGETS ec_jerasure DESTINATION ${erasure_plugin_dir}) diff --git a/src/erasure-code/jerasure/ErasureCodePluginJerasure.cc b/src/erasure-code/jerasure/ErasureCodePluginJerasure.cc index b3d03b56132a..3ae4366635b5 100644 --- a/src/erasure-code/jerasure/ErasureCodePluginJerasure.cc +++ b/src/erasure-code/jerasure/ErasureCodePluginJerasure.cc @@ -19,6 +19,7 @@ #include "common/debug.h" #include "erasure-code/ErasureCodePlugin.h" #include "ErasureCodeJerasure.h" +#include "jerasure_init.h" #define dout_subsys ceph_subsys_osd #undef dout_prefix @@ -72,25 +73,15 @@ public: } }; -extern "C" { -#include "galois.h" - -extern gf_t *gfp_array[]; -extern int gfp_is_composite[]; -} - const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; } int __erasure_code_init(char *plugin_name, char *directory) { ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); int w[] = { 4, 8, 16, 32 }; - for(int i = 0; i < 4; i++) { - int r = galois_init_default_field(w[i]); - if (r) { - derr << "failed to gf_init_easy(" << w[i] << ")" << dendl; - return -r; - } + int r = jerasure_init(4, w); + if (r) { + return -r; } return instance.add(plugin_name, new ErasureCodePluginJerasure()); } diff --git a/src/erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc b/src/erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc deleted file mode 100644 index 96c2280c539f..000000000000 --- a/src/erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc +++ /dev/null @@ -1,98 +0,0 @@ -// -*- 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 - * Copyright (C) 2014 Red Hat - * - * Author: Loic Dachary - * - * 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" -#include "common/debug.h" -#include "arch/probe.h" -#include "arch/intel.h" -#include "arch/arm.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: "; -} - -static string get_variant() { - 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) { - return "sse4"; - } else if (ceph_arch_intel_ssse3 && - ceph_arch_intel_sse3 && - ceph_arch_intel_sse2) { - return "sse3"; - } else if (ceph_arch_neon) { - return "neon"; - } else { - return "generic"; - } -} - -class ErasureCodePluginSelectJerasure : public ErasureCodePlugin { -public: - virtual int factory(const std::string &directory, - ErasureCodeProfile &profile, - ErasureCodeInterfaceRef *erasure_code, - ostream *ss) { - ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); - int ret; - string name = "jerasure"; - if (profile.count("jerasure-name")) - name = profile.find("jerasure-name")->second; - if (profile.count("jerasure-variant")) { - dout(10) << "jerasure-variant " - << profile.find("jerasure-variant")->second << dendl; - ret = instance.factory(name + "_" + profile.find("jerasure-variant")->second, - directory, - profile, erasure_code, ss); - } else { - string variant = get_variant(); - dout(10) << variant << " plugin" << dendl; - ret = instance.factory(name + "_" + variant, directory, - profile, erasure_code, ss); - } - return ret; - } -}; - -const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; } - -int __erasure_code_init(char *plugin_name, char *directory) -{ - ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); - string variant = get_variant(); - ErasureCodePlugin *plugin; - stringstream ss; - int r = instance.load(plugin_name + string("_") + variant, - directory, &plugin, &ss); - if (r) { - derr << ss.str() << dendl; - return r; - } - dout(10) << ss.str() << dendl; - return instance.add(plugin_name, new ErasureCodePluginSelectJerasure()); -} diff --git a/src/erasure-code/jerasure/jerasure_init.cc b/src/erasure-code/jerasure/jerasure_init.cc new file mode 100644 index 000000000000..d05c6ceab7ff --- /dev/null +++ b/src/erasure-code/jerasure/jerasure_init.cc @@ -0,0 +1,35 @@ +// -*- 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) 2013,2014 Cloudwatt + * Copyright (C) 2014 Red Hat + * + * Author: Loic Dachary + * + * 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 "jerasure_init.h" + +extern "C" { +#include "galois.h" +} + +extern "C" int jerasure_init(int count, int *words) +{ + for(int i = 0; i < count; i++) { + int r = galois_init_default_field(words[i]); + if (r) { + derr << "failed to galois_init_default_field(" << words[i] << ")" << dendl; + return -r; + } + } + return 0; +} diff --git a/src/erasure-code/jerasure/jerasure_init.h b/src/erasure-code/jerasure/jerasure_init.h new file mode 100644 index 000000000000..758287ae5783 --- /dev/null +++ b/src/erasure-code/jerasure/jerasure_init.h @@ -0,0 +1,24 @@ +// -*- 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) 2013, 2014 Cloudwatt + * Copyright (C) 2014 Red Hat + * + * Author: Loic Dachary + * + * 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. + * + */ + +#ifndef CEPH_JERASURE_INIT_H +#define CEPH_JERASURE_INIT_H + +extern "C" int jerasure_init(int count, int *words); + +#endif + diff --git a/src/erasure-code/shec/CMakeLists.txt b/src/erasure-code/shec/CMakeLists.txt index b49f75fc7208..4c5eaf408b85 100644 --- a/src/erasure-code/shec/CMakeLists.txt +++ b/src/erasure-code/shec/CMakeLists.txt @@ -10,16 +10,10 @@ add_library(shec_utils OBJECT determinant.c) add_dependencies(shec_utils ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) -add_library(ec_shec SHARED ErasureCodePluginSelectShec.cc) +add_library(ec_shec SHARED + $ + $ + $) add_dependencies(ec_shec ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) target_link_libraries(ec_shec ${EXTRALIBS}) install(TARGETS ec_shec DESTINATION ${erasure_plugin_dir}) - -foreach(flavor ${jerasure_flavors}) - set(plugin_name "ec_shec_${flavor}") - add_library(${plugin_name} SHARED - $ - $) - target_link_libraries(${plugin_name} ${EXTRALIBS}) - install(TARGETS ${plugin_name} DESTINATION ${erasure_plugin_dir}) -endforeach() diff --git a/src/erasure-code/shec/ErasureCodePluginSelectShec.cc b/src/erasure-code/shec/ErasureCodePluginSelectShec.cc deleted file mode 100644 index 3a4f74eb6a79..000000000000 --- a/src/erasure-code/shec/ErasureCodePluginSelectShec.cc +++ /dev/null @@ -1,102 +0,0 @@ -// -*- 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) 2013,2014 Cloudwatt - * Copyright (C) 2014 Red Hat - * Copyright (C) 2014,2015 FUJITSU LIMITED - * - * Author: Loic Dachary - * Author: Shotaro Kawaguchi - * Author: Takanori Nakao - * Author: Takeshi Miyamae - * - * 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" -#include "common/debug.h" -#include "arch/probe.h" -#include "arch/intel.h" -#include "arch/arm.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 << "ErasureCodePluginSelectShec: "; -} - -static string get_variant() { - 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) { - return "sse4"; - } else if (ceph_arch_intel_ssse3 && - ceph_arch_intel_sse3 && - ceph_arch_intel_sse2) { - return "sse3"; - } else if (ceph_arch_neon) { - return "neon"; - } else { - return "generic"; - } -} - -class ErasureCodePluginSelectShec : public ErasureCodePlugin { -public: - virtual int factory(const std::string &directory, - ErasureCodeProfile &profile, - ErasureCodeInterfaceRef *erasure_code, - ostream *ss) { - ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); - int ret; - string name = "shec"; - if (profile.count("shec-name")) - name = profile.find("shec-name")->second; - if (profile.count("shec-variant")) { - dout(10) << "shec-variant " - << profile.find("shec-variant")->second << dendl; - ret = instance.factory(name + "_" + profile.find("shec-variant")->second, - directory, - profile, erasure_code, ss); - } else { - string variant = get_variant(); - dout(10) << variant << " plugin" << dendl; - ret = instance.factory(name + "_" + variant, directory, - profile, erasure_code, ss); - } - return ret; - } -}; - -const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; } - -int __erasure_code_init(char *plugin_name, char *directory) -{ - ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); - string variant = get_variant(); - ErasureCodePlugin *plugin; - stringstream ss; - int r = instance.load(plugin_name + string("_") + variant, - directory, &plugin, &ss); - if (r) { - derr << ss.str() << dendl; - return r; - } - dout(10) << ss.str() << dendl; - return instance.add(plugin_name, new ErasureCodePluginSelectShec()); -} diff --git a/src/erasure-code/shec/ErasureCodePluginShec.cc b/src/erasure-code/shec/ErasureCodePluginShec.cc index d2b72f5d56fe..7d242b4f7e01 100644 --- a/src/erasure-code/shec/ErasureCodePluginShec.cc +++ b/src/erasure-code/shec/ErasureCodePluginShec.cc @@ -23,6 +23,7 @@ #include "erasure-code/ErasureCodePlugin.h" #include "ErasureCodeShecTableCache.h" #include "ErasureCodeShec.h" +#include "jerasure_init.h" #define dout_subsys ceph_subsys_osd #undef dout_prefix @@ -70,25 +71,15 @@ public: } }; -extern "C" { -#include "jerasure/include/galois.h" - -extern gf_t *gfp_array[]; -extern int gfp_is_composite[]; -} - const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; } int __erasure_code_init(char *plugin_name, char *directory = (char *)"") { ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); int w[] = { 8, 16, 32 }; - for(int i = 0; i < 3; i++) { - int r = galois_init_default_field(w[i]); - if (r) { - derr << "failed to gf_init_easy(" << w[i] << ")" << dendl; - return -r; - } + int r = jerasure_init(3, w); + if (r) { + return -r; } return instance.add(plugin_name, new ErasureCodePluginShec()); } diff --git a/src/test/erasure-code/CMakeLists.txt b/src/test/erasure-code/CMakeLists.txt index c9062e49acb7..4426d88710e8 100644 --- a/src/test/erasure-code/CMakeLists.txt +++ b/src/test/erasure-code/CMakeLists.txt @@ -73,22 +73,6 @@ target_link_libraries(unittest_erasure_code common ) -add_library(ec_test_jerasure_neon SHARED TestJerasurePluginNEON.cc) -add_dependencies(ec_test_jerasure_neon ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) -target_link_libraries(ec_test_jerasure_neon pthread ${EXTRALIBS}) - -add_library(ec_test_jerasure_sse4 SHARED TestJerasurePluginSSE4.cc) -add_dependencies(ec_test_jerasure_sse4 ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) -target_link_libraries(ec_test_jerasure_sse4 pthread ${EXTRALIBS}) - -add_library(ec_test_jerasure_sse3 SHARED TestJerasurePluginSSE3.cc) -add_dependencies(ec_test_jerasure_sse3 ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) -target_link_libraries(ec_test_jerasure_sse3 pthread ${EXTRALIBS}) - -add_library(ec_test_jerasure_generic SHARED TestJerasurePluginGeneric.cc) -add_dependencies(ec_test_jerasure_generic ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) -target_link_libraries(ec_test_jerasure_generic pthread ${EXTRALIBS}) - # unittest_erasure_code_plugin_jerasure add_executable(unittest_erasure_code_plugin_jerasure TestErasureCodePluginJerasure.cc @@ -97,16 +81,10 @@ add_ceph_unittest(unittest_erasure_code_plugin_jerasure ${CMAKE_RUNTIME_OUTPUT_D target_link_libraries(unittest_erasure_code_plugin_jerasure global osd - ec_jerasure_generic + ec_jerasure common) add_dependencies(unittest_erasure_code_plugin_jerasure - ec_jerasure - ec_jerasure_sse3 - ec_jerasure_sse4 - ec_test_jerasure_neon - ec_test_jerasure_sse4 - ec_test_jerasure_sse3 - ec_test_jerasure_generic) + ec_jerasure) if(HAVE_BETTER_YASM_ELF64) @@ -160,34 +138,15 @@ add_executable(unittest_erasure_code_plugin_lrc add_ceph_unittest(unittest_erasure_code_plugin_lrc ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest_erasure_code_plugin_lrc) add_dependencies(unittest_erasure_code_plugin_lrc ec_lrc - ec_jerasure - ec_jerasure_sse3 - ec_jerasure_sse4 - ec_jerasure_generic) + ec_jerasure) target_link_libraries(unittest_erasure_code_plugin_lrc global osd ${CMAKE_DL_LIBS} ec_lrc - ec_jerasure_generic + ec_jerasure common) -add_library(ec_test_shec_neon SHARED TestShecPluginNEON.cc) -add_dependencies(ec_test_shec_neon ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) -target_link_libraries(ec_test_shec_neon pthread ${EXTRALIBS}) - -add_library(ec_test_shec_sse4 SHARED TestShecPluginSSE4.cc) -add_dependencies(ec_test_shec_sse4 ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) -target_link_libraries(ec_test_shec_sse4 pthread ${EXTRALIBS}) - -add_library(ec_test_shec_sse3 SHARED TestShecPluginSSE3.cc) -add_dependencies(ec_test_shec_sse3 ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) -target_link_libraries(ec_test_shec_sse3 pthread ${EXTRALIBS}) - -add_library(ec_test_shec_generic SHARED TestShecPluginGeneric.cc) -add_dependencies(ec_test_shec_generic ${CMAKE_SOURCE_DIR}/src/ceph_ver.h) -target_link_libraries(ec_test_shec_generic pthread ${EXTRALIBS}) - # unittest_erasure_code_plugin_shec add_executable(unittest_erasure_code_plugin_shec TestErasureCodePluginShec.cc @@ -198,16 +157,9 @@ target_link_libraries(unittest_erasure_code_plugin_shec osd ${CMAKE_DL_LIBS} common - ec_shec_generic) + ec_shec) add_dependencies(unittest_erasure_code_plugin_shec - ec_shec - ec_shec_sse3 - ec_shec_sse4 - #ec_shec_neon - ec_test_shec_neon - ec_test_shec_sse3 - ec_test_shec_sse4 - ec_test_shec_generic) + ec_shec) # unittest_erasure_code_example add_executable(unittest_erasure_code_example @@ -237,7 +189,7 @@ target_link_libraries(unittest_erasure_code_jerasure global osd common - ec_jerasure_generic + ec_jerasure ) include_directories(${CMAKE_SOURCE_DIR}/src/erasure-code/jerasure) @@ -253,7 +205,7 @@ target_link_libraries(unittest_erasure_code_shec osd ${CMAKE_DL_LIBS} common - ec_shec_generic + ec_shec ) # unittest_erasure_code_shec_all @@ -266,7 +218,7 @@ target_link_libraries(unittest_erasure_code_shec_all osd ${CMAKE_DL_LIBS} common - ec_shec_generic + ec_shec ) # unittest_erasure_code_shec_thread @@ -279,7 +231,7 @@ target_link_libraries(unittest_erasure_code_shec_thread osd ${CMAKE_DL_LIBS} common - ec_shec_generic + ec_shec ) @@ -293,5 +245,5 @@ target_link_libraries(unittest_erasure_code_shec_arguments osd ${CMAKE_DL_LIBS} common - ec_shec_generic + ec_shec ) diff --git a/src/test/erasure-code/TestErasureCodePluginJerasure.cc b/src/test/erasure-code/TestErasureCodePluginJerasure.cc index 6c06ccfd75f9..9b1e1c7d3892 100644 --- a/src/test/erasure-code/TestErasureCodePluginJerasure.cc +++ b/src/test/erasure-code/TestErasureCodePluginJerasure.cc @@ -17,9 +17,6 @@ #include #include -#include "arch/probe.h" -#include "arch/intel.h" -#include "arch/arm.h" #include "global/global_init.h" #include "erasure-code/ErasureCodePlugin.h" #include "common/ceph_argparse.h" @@ -63,192 +60,6 @@ TEST(ErasureCodePlugin, factory) } } -TEST(ErasureCodePlugin, select) -{ - ceph_arch_probe(); - // save probe results - int arch_intel_pclmul = ceph_arch_intel_pclmul; - int arch_intel_sse42 = ceph_arch_intel_sse42; - int arch_intel_sse41 = ceph_arch_intel_sse41; - int arch_intel_ssse3 = ceph_arch_intel_ssse3; - int arch_intel_sse3 = ceph_arch_intel_sse3; - int arch_intel_sse2 = ceph_arch_intel_sse2; - int arch_neon = ceph_arch_neon; - - ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); - ErasureCodeProfile profile; - // load test plugins instead of actual plugins to assert the desired side effect - // happens - profile["jerasure-name"] = "test_jerasure"; - profile["technique"] = "reed_sol_van"; - - // all features are available, load the SSE4 plugin - { - ceph_arch_intel_pclmul = 1; - ceph_arch_intel_sse42 = 1; - ceph_arch_intel_sse41 = 1; - ceph_arch_intel_ssse3 = 1; - ceph_arch_intel_sse3 = 1; - ceph_arch_intel_sse2 = 1; - ceph_arch_neon = 0; - - ErasureCodeInterfaceRef erasure_code; - int sse4_side_effect = -444; - EXPECT_EQ(sse4_side_effect, instance.factory("jerasure", - g_conf->erasure_code_dir, - profile, - &erasure_code, &cerr)); - } - // pclmul is missing, load the SSE3 plugin - { - ceph_arch_intel_pclmul = 0; - ceph_arch_intel_sse42 = 1; - ceph_arch_intel_sse41 = 1; - ceph_arch_intel_ssse3 = 1; - ceph_arch_intel_sse3 = 1; - ceph_arch_intel_sse2 = 1; - ceph_arch_neon = 0; - - ErasureCodeInterfaceRef erasure_code; - int sse3_side_effect = -333; - EXPECT_EQ(sse3_side_effect, instance.factory("jerasure", - g_conf->erasure_code_dir, - profile, - &erasure_code, &cerr)); - } - // pclmul and sse3 are missing, load the generic plugin - { - ceph_arch_intel_pclmul = 0; - ceph_arch_intel_sse42 = 1; - ceph_arch_intel_sse41 = 1; - ceph_arch_intel_ssse3 = 1; - ceph_arch_intel_sse3 = 0; - ceph_arch_intel_sse2 = 1; - ceph_arch_neon = 0; - - ErasureCodeInterfaceRef erasure_code; - int generic_side_effect = -111; - EXPECT_EQ(generic_side_effect, instance.factory("jerasure", - g_conf->erasure_code_dir, - profile, - &erasure_code, &cerr)); - } - // neon is set, load the neon plugin - { - ceph_arch_intel_pclmul = 0; - ceph_arch_intel_sse42 = 0; - ceph_arch_intel_sse41 = 0; - ceph_arch_intel_ssse3 = 0; - ceph_arch_intel_sse3 = 0; - ceph_arch_intel_sse2 = 0; - ceph_arch_neon = 1; - - ErasureCodeInterfaceRef erasure_code; - int generic_side_effect = -555; - EXPECT_EQ(generic_side_effect, instance.factory("jerasure", - g_conf->erasure_code_dir, - profile, - &erasure_code, &cerr)); - } - - - // restore probe results - ceph_arch_intel_pclmul = arch_intel_pclmul; - ceph_arch_intel_sse42 = arch_intel_sse42; - ceph_arch_intel_sse41 = arch_intel_sse41; - ceph_arch_intel_ssse3 = arch_intel_ssse3; - ceph_arch_intel_sse3 = arch_intel_sse3; - ceph_arch_intel_sse2 = arch_intel_sse2; - ceph_arch_neon = arch_neon; -} - -TEST(ErasureCodePlugin, sse) -{ - ceph_arch_probe(); - bool sse4 = ceph_arch_intel_pclmul && - ceph_arch_intel_sse42 && ceph_arch_intel_sse41 && - ceph_arch_intel_ssse3 && ceph_arch_intel_sse3 && - ceph_arch_intel_sse2; - bool sse3 = ceph_arch_intel_ssse3 && ceph_arch_intel_sse3 && - ceph_arch_intel_sse2; - vector sse_variants; - sse_variants.push_back("generic"); - if (!sse3) - cerr << "SKIP sse3 plugin testing because CPU does not support it\n"; - else - sse_variants.push_back("sse3"); - if (!sse4) - cerr << "SKIP sse4 plugin testing because CPU does not support it\n"; - else - sse_variants.push_back("sse4"); - -#define LARGE_ENOUGH 2048 - bufferptr in_ptr(buffer::create_page_aligned(LARGE_ENOUGH)); - in_ptr.zero(); - in_ptr.set_length(0); - const char *payload = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - in_ptr.append(payload, strlen(payload)); - bufferlist in; - in.push_front(in_ptr); - - ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); - ErasureCodeProfile profile; - profile["technique"] = "reed_sol_van"; - profile["k"] = "2"; - profile["m"] = "1"; - for (vector::iterator sse_variant = sse_variants.begin(); - sse_variant != sse_variants.end(); - ++sse_variant) { - // - // load the plugin variant - // - ErasureCodeInterfaceRef erasure_code; - EXPECT_FALSE(erasure_code); - EXPECT_EQ(0, instance.factory("jerasure_" + *sse_variant, - g_conf->erasure_code_dir, - profile, - &erasure_code, &cerr)); - EXPECT_TRUE(erasure_code.get()); - - // - // encode - // - int want_to_encode[] = { 0, 1, 2 }; - map encoded; - EXPECT_EQ(0, erasure_code->encode(set(want_to_encode, want_to_encode+3), - in, - &encoded)); - EXPECT_EQ(3u, encoded.size()); - unsigned length = encoded[0].length(); - EXPECT_EQ(0, strncmp(encoded[0].c_str(), in.c_str(), length)); - EXPECT_EQ(0, strncmp(encoded[1].c_str(), in.c_str() + length, - in.length() - length)); - - // - // decode with reconstruction - // - map degraded = encoded; - degraded.erase(1); - EXPECT_EQ(2u, degraded.size()); - int want_to_decode[] = { 0, 1 }; - map decoded; - EXPECT_EQ(0, erasure_code->decode(set(want_to_decode, want_to_decode+2), - degraded, - &decoded)); - EXPECT_EQ(3u, decoded.size()); - EXPECT_EQ(length, decoded[0].length()); - EXPECT_EQ(0, strncmp(decoded[0].c_str(), in.c_str(), length)); - EXPECT_EQ(0, strncmp(decoded[1].c_str(), in.c_str() + length, - in.length() - length)); - - } -} - int main(int argc, char **argv) { vector args; diff --git a/src/test/erasure-code/TestErasureCodePluginShec.cc b/src/test/erasure-code/TestErasureCodePluginShec.cc index abd116ca7007..a6d95205e4d6 100644 --- a/src/test/erasure-code/TestErasureCodePluginShec.cc +++ b/src/test/erasure-code/TestErasureCodePluginShec.cc @@ -18,9 +18,6 @@ #include #include -#include "arch/probe.h" -#include "arch/intel.h" -#include "arch/arm.h" #include "global/global_init.h" #include "erasure-code/ErasureCodePlugin.h" #include "common/ceph_argparse.h" @@ -58,193 +55,6 @@ TEST(ErasureCodePlugin, factory) } } -TEST(ErasureCodePlugin, select) -{ - ceph_arch_probe(); - // save probe results - int arch_intel_pclmul = ceph_arch_intel_pclmul; - int arch_intel_sse42 = ceph_arch_intel_sse42; - int arch_intel_sse41 = ceph_arch_intel_sse41; - int arch_intel_ssse3 = ceph_arch_intel_ssse3; - int arch_intel_sse3 = ceph_arch_intel_sse3; - int arch_intel_sse2 = ceph_arch_intel_sse2; - int arch_neon = ceph_arch_neon; - - ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); - map profile; - // load test plugins instead of actual plugins to assert the desired side effect - // happens - profile["shec-name"] = "test_shec"; - profile["technique"] = "multiple"; - - // all features are available, load the SSE4 plugin - { - ceph_arch_intel_pclmul = 1; - ceph_arch_intel_sse42 = 1; - ceph_arch_intel_sse41 = 1; - ceph_arch_intel_ssse3 = 1; - ceph_arch_intel_sse3 = 1; - ceph_arch_intel_sse2 = 1; - ceph_arch_neon = 0; - - ErasureCodeInterfaceRef erasure_code; - int sse4_side_effect = -444; - EXPECT_EQ(sse4_side_effect, instance.factory("shec", - g_conf->erasure_code_dir, - profile, - &erasure_code, &cerr)); - } - // pclmul is missing, load the SSE3 plugin - { - ceph_arch_intel_pclmul = 0; - ceph_arch_intel_sse42 = 1; - ceph_arch_intel_sse41 = 1; - ceph_arch_intel_ssse3 = 1; - ceph_arch_intel_sse3 = 1; - ceph_arch_intel_sse2 = 1; - ceph_arch_neon = 0; - - ErasureCodeInterfaceRef erasure_code; - int sse3_side_effect = -333; - EXPECT_EQ(sse3_side_effect, instance.factory("shec", - g_conf->erasure_code_dir, - profile, - &erasure_code, &cerr)); - } - // pclmul and sse3 are missing, load the generic plugin - { - ceph_arch_intel_pclmul = 0; - ceph_arch_intel_sse42 = 1; - ceph_arch_intel_sse41 = 1; - ceph_arch_intel_ssse3 = 1; - ceph_arch_intel_sse3 = 0; - ceph_arch_intel_sse2 = 1; - ceph_arch_neon = 0; - - ErasureCodeInterfaceRef erasure_code; - int generic_side_effect = -111; - EXPECT_EQ(generic_side_effect, instance.factory("shec", - g_conf->erasure_code_dir, - profile, - &erasure_code, &cerr)); - } - // neon is set, load the neon plugin - { - ceph_arch_intel_pclmul = 0; - ceph_arch_intel_sse42 = 0; - ceph_arch_intel_sse41 = 0; - ceph_arch_intel_ssse3 = 0; - ceph_arch_intel_sse3 = 0; - ceph_arch_intel_sse2 = 0; - ceph_arch_neon = 1; - - ErasureCodeInterfaceRef erasure_code; - int generic_side_effect = -555; - EXPECT_EQ(generic_side_effect, instance.factory("shec", - g_conf->erasure_code_dir, - profile, - &erasure_code, &cerr)); - } - - - // restore probe results - ceph_arch_intel_pclmul = arch_intel_pclmul; - ceph_arch_intel_sse42 = arch_intel_sse42; - ceph_arch_intel_sse41 = arch_intel_sse41; - ceph_arch_intel_ssse3 = arch_intel_ssse3; - ceph_arch_intel_sse3 = arch_intel_sse3; - ceph_arch_intel_sse2 = arch_intel_sse2; - ceph_arch_neon = arch_neon; -} - -TEST(ErasureCodePlugin, sse) -{ - ceph_arch_probe(); - bool sse4 = ceph_arch_intel_pclmul && - ceph_arch_intel_sse42 && ceph_arch_intel_sse41 && - ceph_arch_intel_ssse3 && ceph_arch_intel_sse3 && - ceph_arch_intel_sse2; - bool sse3 = ceph_arch_intel_ssse3 && ceph_arch_intel_sse3 && - ceph_arch_intel_sse2; - vector sse_variants; - sse_variants.push_back("generic"); - if (!sse3) - cerr << "SKIP sse3 plugin testing because CPU does not support it\n"; - else - sse_variants.push_back("sse3"); - if (!sse4) - cerr << "SKIP sse4 plugin testing because CPU does not support it\n"; - else - sse_variants.push_back("sse4"); - -#define LARGE_ENOUGH 2048 - bufferptr in_ptr(buffer::create_page_aligned(LARGE_ENOUGH)); - in_ptr.zero(); - in_ptr.set_length(0); - const char *payload = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - in_ptr.append(payload, strlen(payload)); - bufferlist in; - in.push_front(in_ptr); - - ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); - map profile; - profile["technique"] = "multiple"; - profile["k"] = "2"; - profile["m"] = "1"; - profile["c"] = "1"; - for (vector::iterator sse_variant = sse_variants.begin(); - sse_variant != sse_variants.end(); - ++sse_variant) { - // - // load the plugin variant - // - ErasureCodeInterfaceRef erasure_code; - EXPECT_FALSE(erasure_code); - EXPECT_EQ(0, instance.factory("shec_" + *sse_variant, - g_conf->erasure_code_dir, - profile, - &erasure_code, &cerr)); - EXPECT_TRUE(erasure_code.get()); - - // - // encode - // - int want_to_encode[] = { 0, 1, 2 }; - map encoded; - EXPECT_EQ(0, erasure_code->encode(set(want_to_encode, want_to_encode+3), - in, - &encoded)); - EXPECT_EQ(3u, encoded.size()); - unsigned length = encoded[0].length(); - EXPECT_EQ(0, strncmp(encoded[0].c_str(), in.c_str(), length)); - EXPECT_EQ(0, strncmp(encoded[1].c_str(), in.c_str() + length, - in.length() - length)); - - // - // decode with reconstruction - // - map degraded = encoded; - degraded.erase(1); - EXPECT_EQ(2u, degraded.size()); - int want_to_decode[] = { 0, 1 }; - map decoded; - EXPECT_EQ(0, erasure_code->decode(set(want_to_decode, want_to_decode+2), - degraded, - &decoded)); - EXPECT_EQ(3u, decoded.size()); - EXPECT_EQ(length, decoded[0].length()); - EXPECT_EQ(0, strncmp(decoded[0].c_str(), in.c_str(), length)); - EXPECT_EQ(0, strncmp(decoded[1].c_str(), in.c_str() + length, - in.length() - length)); - - } -} - int main(int argc, char **argv) { vector args; diff --git a/src/test/erasure-code/TestJerasurePluginGeneric.cc b/src/test/erasure-code/TestJerasurePluginGeneric.cc deleted file mode 100644 index e7a759757a9f..000000000000 --- a/src/test/erasure-code/TestJerasurePluginGeneric.cc +++ /dev/null @@ -1,25 +0,0 @@ -// -*- 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 - * Copyright (C) 2014 Red Hat - * - * Author: Loic Dachary - * - * 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 -111; -} diff --git a/src/test/erasure-code/TestJerasurePluginNEON.cc b/src/test/erasure-code/TestJerasurePluginNEON.cc deleted file mode 100644 index cd38ccbd1e89..000000000000 --- a/src/test/erasure-code/TestJerasurePluginNEON.cc +++ /dev/null @@ -1,25 +0,0 @@ -// -*- 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 - * Copyright (C) 2014 Red Hat - * - * Author: Loic Dachary - * - * 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 -555; -} diff --git a/src/test/erasure-code/TestJerasurePluginSSE3.cc b/src/test/erasure-code/TestJerasurePluginSSE3.cc deleted file mode 100644 index 0c752b2dd7dd..000000000000 --- a/src/test/erasure-code/TestJerasurePluginSSE3.cc +++ /dev/null @@ -1,25 +0,0 @@ -// -*- 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 - * Copyright (C) 2014 Red Hat - * - * Author: Loic Dachary - * - * 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 -333; -} diff --git a/src/test/erasure-code/TestJerasurePluginSSE4.cc b/src/test/erasure-code/TestJerasurePluginSSE4.cc deleted file mode 100644 index a39a9b41150a..000000000000 --- a/src/test/erasure-code/TestJerasurePluginSSE4.cc +++ /dev/null @@ -1,25 +0,0 @@ -// -*- 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 - * Copyright (C) 2014 Red Hat - * - * Author: Loic Dachary - * - * 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; -} diff --git a/src/test/erasure-code/TestShecPluginGeneric.cc b/src/test/erasure-code/TestShecPluginGeneric.cc deleted file mode 100644 index 0bd063b094cf..000000000000 --- a/src/test/erasure-code/TestShecPluginGeneric.cc +++ /dev/null @@ -1,29 +0,0 @@ -// -*- 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 - * Copyright (C) 2014 Red Hat - * Copyright (C) 2015 FUJITSU LIMITED - * - * Author: Loic Dachary - * Author: Shotaro Kawaguchi - * Author: Takanori Nakao - * Author: Takeshi Miyamae - * - * 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 -111; -} diff --git a/src/test/erasure-code/TestShecPluginNEON.cc b/src/test/erasure-code/TestShecPluginNEON.cc deleted file mode 100644 index 373f5eb4b47c..000000000000 --- a/src/test/erasure-code/TestShecPluginNEON.cc +++ /dev/null @@ -1,29 +0,0 @@ -// -*- 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 - * Copyright (C) 2014 Red Hat - * Copyright (C) 2015 FUJITSU LIMITED - * - * Author: Loic Dachary - * Author: Shotaro Kawaguchi - * Author: Takanori Nakao - * Author: Takeshi Miyamae - * - * 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 -555; -} diff --git a/src/test/erasure-code/TestShecPluginSSE3.cc b/src/test/erasure-code/TestShecPluginSSE3.cc deleted file mode 100644 index 220ea7b63974..000000000000 --- a/src/test/erasure-code/TestShecPluginSSE3.cc +++ /dev/null @@ -1,29 +0,0 @@ -// -*- 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 - * Copyright (C) 2014 Red Hat - * Copyright (C) 2015 FUJITSU LIMITED - * - * Author: Loic Dachary - * Author: Shotaro Kawaguchi - * Author: Takanori Nakao - * Author: Takeshi Miyamae - * - * 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 -333; -} diff --git a/src/test/erasure-code/TestShecPluginSSE4.cc b/src/test/erasure-code/TestShecPluginSSE4.cc deleted file mode 100644 index ef8e8410c617..000000000000 --- a/src/test/erasure-code/TestShecPluginSSE4.cc +++ /dev/null @@ -1,29 +0,0 @@ -// -*- 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 - * Copyright (C) 2014 Red Hat - * Copyright (C) 2015 FUJITSU LIMITED - * - * Author: Loic Dachary - * Author: Shotaro Kawaguchi - * Author: Takanori Nakao - * Author: Takeshi Miyamae - * - * 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; -}