From 3dd6e50c4eeeab52dd780094b3be7fc65dffd779 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 3 Nov 2013 17:50:09 +0100 Subject: [PATCH] Adds optimized SSSE3 functions for recovering. --- mktables.c | 28 ++ raid.c | 327 +++++++++++++++-- raid.h | 9 + selftest.c | 86 +++-- speed.c | 101 +++-- tables.h | 1036 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 1512 insertions(+), 75 deletions(-) diff --git a/mktables.c b/mktables.c index 528d9aa7..479dbaaf 100644 --- a/mktables.c +++ b/mktables.c @@ -294,6 +294,34 @@ int main(void) printf("};\n"); printf("#endif\n\n"); + printf("#if defined(__i386__) || defined(__x86_64__)\n"); + printf("/**\n"); + printf(" * PSHUFB tables for generic multiplication.\n"); + printf(" *\n"); + printf(" * Indexes are [MULTIPLER][LH].\n"); + printf(" * Where MULTIPLER is from 0 to 255, LH from 0 to 1.\n"); + printf(" */\n"); + printf("const unsigned char __attribute__((aligned(256))) gfmulpshufb[256][2][16] =\n"); + printf("{\n"); + for(i=0;i<256;++i) { + printf("\t{\n"); + for(j=0;j<2;++j) { + printf("\t\t{ "); + for(k=0;k<16;++k) { + v = gfmul(i, k); + if (j == 1) + v = gfmul(v, 16); + printf("0x%02x", (unsigned)v); + if (k != 15) + printf(", "); + } + printf(" },\n"); + } + printf("\t},\n"); + } + printf("};\n"); + printf("#endif\n\n"); + return 0; } diff --git a/raid.c b/raid.c index 0f9cf9f1..7f779122 100644 --- a/raid.c +++ b/raid.c @@ -1228,7 +1228,7 @@ void raidPP_ssse3(unsigned char** vbuf, unsigned data, unsigned size) asm volatile("movdqa %0,%%xmm4" : : "m" (vbuf[l][i])); asm volatile("movdqa %xmm4,%xmm0"); - asm volatile("movdqa %%xmm4,%0" : "=m" (p0)); + asm volatile("movdqa %%xmm4,%0" : "=m" (p0[0])); asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.mask[0])); asm volatile("movdqa %xmm4,%xmm5"); @@ -1268,7 +1268,7 @@ void raidPP_ssse3(unsigned char** vbuf, unsigned data, unsigned size) asm volatile("pxor %xmm4,%xmm0"); asm volatile("pxor %xmm4,%xmm6"); - asm volatile("movdqa %%xmm6,%0" : "=m" (p0)); + asm volatile("movdqa %%xmm6,%0" : "=m" (p0[0])); asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.mask[0])); asm volatile("movdqa %xmm4,%xmm5"); @@ -1542,8 +1542,8 @@ void raidHP_ssse3(unsigned char** vbuf, unsigned data, unsigned size) /* last disk without the by two multiplication */ asm volatile("movdqa %0,%%xmm4" : : "m" (vbuf[l][i])); - asm volatile("movdqa %%xmm4,%0" : "=m" (p0)); - asm volatile("movdqa %%xmm4,%0" : "=m" (q0)); + asm volatile("movdqa %%xmm4,%0" : "=m" (p0[0])); + asm volatile("movdqa %%xmm4,%0" : "=m" (q0[0])); asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.mask[0])); asm volatile("movdqa %xmm4,%xmm5"); @@ -1591,8 +1591,8 @@ void raidHP_ssse3(unsigned char** vbuf, unsigned data, unsigned size) asm volatile("pxor %xmm4,%xmm5"); asm volatile("pxor %xmm4,%xmm6"); - asm volatile("movdqa %%xmm5,%0" : "=m" (p0)); - asm volatile("movdqa %%xmm6,%0" : "=m" (q0)); + asm volatile("movdqa %%xmm5,%0" : "=m" (p0[0])); + asm volatile("movdqa %%xmm6,%0" : "=m" (q0[0])); asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.mask[0])); asm volatile("movdqa %xmm4,%xmm5"); @@ -1933,9 +1933,9 @@ static inline void raid_delta_gen(unsigned level, const int* d, const int* c, un * * and solving we get: * - * Dx = Pd (this one is easy :D) + * Dx = Pd */ -static void raid5_recov_data(const int* d, unsigned char** vbuf, unsigned data, unsigned size) +static void raid5_recov1(const int* d, unsigned char** vbuf, unsigned data, unsigned size) { unsigned char* p; unsigned char* pa; @@ -1982,7 +1982,7 @@ static void raid5_recov_data(const int* d, unsigned char** vbuf, unsigned data, * * That are always satisfied for any 0<=d[0]