mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-20 15:06:34 -05:00
Updates the coding style of the RAID engine.
This commit is contained in:
parent
abc05c612c
commit
684edf2173
13 changed files with 515 additions and 481 deletions
|
|
@ -180,6 +180,13 @@
|
|||
#define __always_inline inline __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Missing __aligned, like in user mode.
|
||||
*/
|
||||
#ifndef __aligned
|
||||
#define __aligned(a) __attribute__((aligned(a)))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Another name for link() to avoid confusion with local variables called "link".
|
||||
*/
|
||||
|
|
|
|||
12
raid/cpu.h
12
raid/cpu.h
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
static __always_inline void raid_cpuid(uint32_t func_eax, uint32_t sub_ecx, uint32_t* reg)
|
||||
static __always_inline void raid_cpuid(uint32_t func_eax, uint32_t sub_ecx, uint32_t *reg)
|
||||
{
|
||||
asm volatile(
|
||||
#if defined(__i386__) && defined(__PIC__)
|
||||
|
|
@ -40,16 +40,16 @@ static __always_inline void raid_cpuid(uint32_t func_eax, uint32_t sub_ecx, uint
|
|||
|
||||
#define CPU_VENDOR_MAX 13
|
||||
|
||||
static __always_inline void raid_cpu_info(char* vendor, unsigned* family, unsigned* model)
|
||||
static __always_inline void raid_cpu_info(char *vendor, unsigned *family, unsigned *model)
|
||||
{
|
||||
uint32_t reg[4];
|
||||
unsigned f, ef, m, em;
|
||||
|
||||
raid_cpuid(0, 0, reg);
|
||||
|
||||
((uint32_t*)vendor)[0] = reg[1];
|
||||
((uint32_t*)vendor)[1] = reg[3];
|
||||
((uint32_t*)vendor)[2] = reg[2];
|
||||
((uint32_t *)vendor)[0] = reg[1];
|
||||
((uint32_t *)vendor)[1] = reg[3];
|
||||
((uint32_t *)vendor)[2] = reg[2];
|
||||
vendor[12] = 0;
|
||||
|
||||
raid_cpuid(1, 0, reg);
|
||||
|
|
@ -185,7 +185,7 @@ static __always_inline int raid_cpu_has_slowpshufb(void)
|
|||
* CPU GenuineIntel, family 6, model 28, flags mmx sse2 ssse3 slowmult
|
||||
* Memory is little-endian 64-bit
|
||||
* Support nanosecond timestamps with futimens()
|
||||
*
|
||||
*
|
||||
* Speed test with 8 disk and 262144 buffer size, for a total of 2816 KiB...
|
||||
* memset0 1850 [MB/s]
|
||||
* CRC table 316 [MB/s]
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ static __always_inline uint8_t pow2(int v)
|
|||
/*
|
||||
* Gets the multiplication table for a specified value.
|
||||
*/
|
||||
static __always_inline const uint8_t* table(uint8_t v)
|
||||
static __always_inline const uint8_t *table(uint8_t v)
|
||||
{
|
||||
return gfmul[v];
|
||||
}
|
||||
|
|
@ -80,17 +80,17 @@ static __always_inline uint8_t A(int p, int d)
|
|||
/*
|
||||
* Dereference as uint8_t
|
||||
*/
|
||||
#define v_8(p) (*(uint8_t*)&(p))
|
||||
#define v_8(p) (*(uint8_t *)&(p))
|
||||
|
||||
/*
|
||||
* Dereference as uint32_t
|
||||
*/
|
||||
#define v_32(p) (*(uint32_t*)&(p))
|
||||
#define v_32(p) (*(uint32_t *)&(p))
|
||||
|
||||
/*
|
||||
* Dereference as uint64_t
|
||||
*/
|
||||
#define v_64(p) (*(uint64_t*)&(p))
|
||||
#define v_64(p) (*(uint64_t *)&(p))
|
||||
|
||||
/*
|
||||
* Multiply each byte of a uint32 by 2 in the GF(2^8).
|
||||
|
|
|
|||
212
raid/int.c
212
raid/int.c
|
|
@ -21,10 +21,10 @@
|
|||
/*
|
||||
* PAR1 (RAID5 with xor) 32bit C implementation
|
||||
*/
|
||||
void raid_par1_int32(int nd, size_t size, void** vv)
|
||||
void raid_par1_int32(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -34,12 +34,12 @@ void raid_par1_int32(int nd, size_t size, void** vv)
|
|||
l = nd - 1;
|
||||
p = v[nd];
|
||||
|
||||
for(i=0;i<size;i+=8) {
|
||||
for (i = 0; i < size; i += 8) {
|
||||
p0 = v_32(v[l][i]);
|
||||
p1 = v_32(v[l][i+4]);
|
||||
/* accessing disks in backward order because the buffers */
|
||||
/* are also in backward order */
|
||||
for(d=l-1;d>=0;--d) {
|
||||
for (d = l-1; d >= 0; --d) {
|
||||
p0 ^= v_32(v[d][i]);
|
||||
p1 ^= v_32(v[d][i+4]);
|
||||
}
|
||||
|
|
@ -51,10 +51,10 @@ void raid_par1_int32(int nd, size_t size, void** vv)
|
|||
/*
|
||||
* PAR1 (RAID5 with xor) 64bit C implementation
|
||||
*/
|
||||
void raid_par1_int64(int nd, size_t size, void** vv)
|
||||
void raid_par1_int64(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -64,12 +64,12 @@ void raid_par1_int64(int nd, size_t size, void** vv)
|
|||
l = nd - 1;
|
||||
p = v[nd];
|
||||
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
p0 = v_64(v[l][i]);
|
||||
p1 = v_64(v[l][i+8]);
|
||||
/* accessing disks in backward order because the buffers */
|
||||
/* are also in backward order */
|
||||
for(d=l-1;d>=0;--d) {
|
||||
for (d = l-1; d >= 0; --d) {
|
||||
p0 ^= v_64(v[d][i]);
|
||||
p1 ^= v_64(v[d][i+8]);
|
||||
}
|
||||
|
|
@ -81,11 +81,11 @@ void raid_par1_int64(int nd, size_t size, void** vv)
|
|||
/*
|
||||
* PAR2 (RAID6 with powers of 2) 32bit C implementation
|
||||
*/
|
||||
void raid_par2_int32(int nd, size_t size, void** vv)
|
||||
void raid_par2_int32(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -96,10 +96,10 @@ void raid_par2_int32(int nd, size_t size, void** vv)
|
|||
p = v[nd];
|
||||
q = v[nd+1];
|
||||
|
||||
for(i=0;i<size;i+=8) {
|
||||
for (i = 0; i < size; i += 8) {
|
||||
q0 = p0 = v_32(v[l][i]);
|
||||
q1 = p1 = v_32(v[l][i+4]);
|
||||
for(d=l-1;d>=0;--d) {
|
||||
for (d = l-1; d >= 0; --d) {
|
||||
d0 = v_32(v[d][i]);
|
||||
d1 = v_32(v[d][i+4]);
|
||||
|
||||
|
|
@ -122,11 +122,11 @@ void raid_par2_int32(int nd, size_t size, void** vv)
|
|||
/*
|
||||
* PAR2 (RAID6 with powers of 2) 64bit C implementation
|
||||
*/
|
||||
void raid_par2_int64(int nd, size_t size, void** vv)
|
||||
void raid_par2_int64(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -137,10 +137,10 @@ void raid_par2_int64(int nd, size_t size, void** vv)
|
|||
p = v[nd];
|
||||
q = v[nd+1];
|
||||
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
q0 = p0 = v_64(v[l][i]);
|
||||
q1 = p1 = v_64(v[l][i+8]);
|
||||
for(d=l-1;d>=0;--d) {
|
||||
for (d = l-1; d >= 0; --d) {
|
||||
d0 = v_64(v[d][i]);
|
||||
d1 = v_64(v[d][i+8]);
|
||||
|
||||
|
|
@ -162,18 +162,18 @@ void raid_par2_int64(int nd, size_t size, void** vv)
|
|||
|
||||
/*
|
||||
* PAR3 (triple parity with Cauchy matrix) 8bit C implementation
|
||||
*
|
||||
*
|
||||
* Note that instead of a generic multiplicationt table, likely resulting
|
||||
* in multiple cache misses, a precomputed table could be used.
|
||||
* in multiple cache misses, a precomputed table could be used.
|
||||
* But this is only a kind of reference function, and we are not really
|
||||
* interested in speed.
|
||||
*/
|
||||
void raid_par3_int8(int nd, size_t size, void** vv)
|
||||
void raid_par3_int8(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -184,9 +184,9 @@ void raid_par3_int8(int nd, size_t size, void** vv)
|
|||
q = v[nd+1];
|
||||
r = v[nd+2];
|
||||
|
||||
for(i=0;i<size;i+=1) {
|
||||
for (i = 0; i < size; i += 1) {
|
||||
p0 = q0 = r0 = 0;
|
||||
for(d=l;d>0;--d) {
|
||||
for (d = l; d > 0; --d) {
|
||||
d0 = v_8(v[d][i]);
|
||||
|
||||
p0 ^= d0;
|
||||
|
|
@ -209,19 +209,19 @@ void raid_par3_int8(int nd, size_t size, void** vv)
|
|||
|
||||
/*
|
||||
* PAR4 (quad parity with Cauchy matrix) 8bit C implementation
|
||||
*
|
||||
*
|
||||
* Note that instead of a generic multiplicationt table, likely resulting
|
||||
* in multiple cache misses, a precomputed table could be used.
|
||||
* in multiple cache misses, a precomputed table could be used.
|
||||
* But this is only a kind of reference function, and we are not really
|
||||
* interested in speed.
|
||||
*/
|
||||
void raid_par4_int8(int nd, size_t size, void** vv)
|
||||
void raid_par4_int8(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t* s;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
uint8_t *s;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -233,9 +233,9 @@ void raid_par4_int8(int nd, size_t size, void** vv)
|
|||
r = v[nd+2];
|
||||
s = v[nd+3];
|
||||
|
||||
for(i=0;i<size;i+=1) {
|
||||
for (i = 0; i < size; i += 1) {
|
||||
p0 = q0 = r0 = s0 = 0;
|
||||
for(d=l;d>0;--d) {
|
||||
for (d = l; d > 0; --d) {
|
||||
d0 = v_8(v[d][i]);
|
||||
|
||||
p0 ^= d0;
|
||||
|
|
@ -261,20 +261,20 @@ void raid_par4_int8(int nd, size_t size, void** vv)
|
|||
|
||||
/*
|
||||
* PAR5 (penta parity with Cauchy matrix) 8bit C implementation
|
||||
*
|
||||
*
|
||||
* Note that instead of a generic multiplicationt table, likely resulting
|
||||
* in multiple cache misses, a precomputed table could be used.
|
||||
* in multiple cache misses, a precomputed table could be used.
|
||||
* But this is only a kind of reference function, and we are not really
|
||||
* interested in speed.
|
||||
*/
|
||||
void raid_par5_int8(int nd, size_t size, void** vv)
|
||||
void raid_par5_int8(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t* s;
|
||||
uint8_t* t;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
uint8_t *s;
|
||||
uint8_t *t;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -287,9 +287,9 @@ void raid_par5_int8(int nd, size_t size, void** vv)
|
|||
s = v[nd+3];
|
||||
t = v[nd+4];
|
||||
|
||||
for(i=0;i<size;i+=1) {
|
||||
for (i = 0; i < size; i += 1) {
|
||||
p0 = q0 = r0 = s0 = t0 = 0;
|
||||
for(d=l;d>0;--d) {
|
||||
for (d = l; d > 0; --d) {
|
||||
d0 = v_8(v[d][i]);
|
||||
|
||||
p0 ^= d0;
|
||||
|
|
@ -318,21 +318,21 @@ void raid_par5_int8(int nd, size_t size, void** vv)
|
|||
|
||||
/*
|
||||
* PAR6 (hexa parity with Cauchy matrix) 8bit C implementation
|
||||
*
|
||||
*
|
||||
* Note that instead of a generic multiplicationt table, likely resulting
|
||||
* in multiple cache misses, a precomputed table could be used.
|
||||
* in multiple cache misses, a precomputed table could be used.
|
||||
* But this is only a kind of reference function, and we are not really
|
||||
* interested in speed.
|
||||
*/
|
||||
void raid_par6_int8(int nd, size_t size, void** vv)
|
||||
void raid_par6_int8(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t* s;
|
||||
uint8_t* t;
|
||||
uint8_t* u;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
uint8_t *s;
|
||||
uint8_t *t;
|
||||
uint8_t *u;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -346,9 +346,9 @@ void raid_par6_int8(int nd, size_t size, void** vv)
|
|||
t = v[nd+4];
|
||||
u = v[nd+5];
|
||||
|
||||
for(i=0;i<size;i+=1) {
|
||||
for (i = 0; i < size; i += 1) {
|
||||
p0 = q0 = r0 = s0 = t0 = u0 = 0;
|
||||
for(d=l;d>0;--d) {
|
||||
for (d = l; d > 0; --d) {
|
||||
d0 = v_8(v[d][i]);
|
||||
|
||||
p0 ^= d0;
|
||||
|
|
@ -390,12 +390,12 @@ void raid_par6_int8(int nd, size_t size, void** vv)
|
|||
*
|
||||
* Dx = A[ip[0],id[0]]^-1 * Pd
|
||||
*/
|
||||
void raid_rec1_int8(int nr, const int* id, const int* ip, int nd, size_t size, void** vv)
|
||||
void raid_rec1_int8(int nr, const int *id, const int *ip, int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* pa;
|
||||
const uint8_t* T;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *pa;
|
||||
const uint8_t *T;
|
||||
uint8_t G;
|
||||
uint8_t V;
|
||||
size_t i;
|
||||
|
|
@ -409,7 +409,7 @@ void raid_rec1_int8(int nr, const int* id, const int* ip, int nd, size_t size, v
|
|||
}
|
||||
|
||||
/* setup the coefficients matrix */
|
||||
G = A(ip[0],id[0]);
|
||||
G = A(ip[0], id[0]);
|
||||
|
||||
/* invert it to solve the system of linear equations */
|
||||
V = inv(G);
|
||||
|
|
@ -423,7 +423,7 @@ void raid_rec1_int8(int nr, const int* id, const int* ip, int nd, size_t size, v
|
|||
p = v[nd+ip[0]];
|
||||
pa = v[id[0]];
|
||||
|
||||
for(i=0;i<size;++i) {
|
||||
for (i = 0; i < size; ++i) {
|
||||
/* delta */
|
||||
uint8_t Pd = p[i] ^ pa[i];
|
||||
|
||||
|
|
@ -443,15 +443,15 @@ void raid_rec1_int8(int nr, const int* id, const int* ip, int nd, size_t size, v
|
|||
*
|
||||
* we solve inverting the coefficients matrix.
|
||||
*/
|
||||
void raid_rec2_int8(int nr, const int* id, const int* ip, int nd, size_t size, void** vv)
|
||||
void raid_rec2_int8(int nr, const int *id, const int *ip, int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* pa;
|
||||
uint8_t* q;
|
||||
uint8_t* qa;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *pa;
|
||||
uint8_t *q;
|
||||
uint8_t *qa;
|
||||
const int N = 2;
|
||||
const uint8_t* T[N][N];
|
||||
const uint8_t *T[N][N];
|
||||
uint8_t G[N*N];
|
||||
uint8_t V[N*N];
|
||||
size_t i;
|
||||
|
|
@ -459,28 +459,24 @@ void raid_rec2_int8(int nr, const int* id, const int* ip, int nd, size_t size, v
|
|||
|
||||
(void)nr; /* unused, it's always 2 */
|
||||
|
||||
/* if it's RAID6 uses the dedicated and faster function */
|
||||
/* if it's RAID6 recovering with P and Q uses the dedicated and faster function */
|
||||
if (ip[0] == 0 && ip[1] == 1) {
|
||||
raid_rec2_par2(id, ip, nd, size, vv);
|
||||
return;
|
||||
}
|
||||
|
||||
/* setup the coefficients matrix */
|
||||
for(j=0;j<N;++j) {
|
||||
for(k=0;k<N;++k) {
|
||||
G[j*N+k] = A(ip[j],id[k]);
|
||||
}
|
||||
}
|
||||
for (j = 0; j < N; ++j)
|
||||
for (k = 0; k < N; ++k)
|
||||
G[j*N+k] = A(ip[j], id[k]);
|
||||
|
||||
/* invert it to solve the system of linear equations */
|
||||
raid_invert(G, V, N);
|
||||
|
||||
/* get multiplication tables */
|
||||
for(j=0;j<N;++j) {
|
||||
for(k=0;k<N;++k) {
|
||||
T[j][k] = table( V[j*N+k] );
|
||||
}
|
||||
}
|
||||
for (j = 0; j < N; ++j)
|
||||
for (k = 0; k < N; ++k)
|
||||
T[j][k] = table(V[j*N+k]);
|
||||
|
||||
/* compute delta parity */
|
||||
raid_delta_gen(2, id, ip, nd, size, vv);
|
||||
|
|
@ -490,7 +486,7 @@ void raid_rec2_int8(int nr, const int* id, const int* ip, int nd, size_t size, v
|
|||
pa = v[id[0]];
|
||||
qa = v[id[1]];
|
||||
|
||||
for(i=0;i<size;++i) {
|
||||
for (i = 0; i < size; ++i) {
|
||||
/* delta */
|
||||
uint8_t Pd = p[i] ^ pa[i];
|
||||
uint8_t Qd = q[i] ^ qa[i];
|
||||
|
|
@ -515,53 +511,49 @@ void raid_rec2_int8(int nr, const int* id, const int* ip, int nd, size_t size, v
|
|||
* PD[0] = Pd, PD[1] = Qd, PD[2] = Rd, ...
|
||||
* D[0] = Dx, D[1] = Dy, D[2] = Dz, ...
|
||||
*/
|
||||
void raid_recX_int8(int nr, const int* id, const int* ip, int nd, size_t size, void** vv)
|
||||
void raid_recX_int8(int nr, const int *id, const int *ip, int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p[RAID_PARITY_MAX];
|
||||
uint8_t* pa[RAID_PARITY_MAX];
|
||||
const uint8_t* T[RAID_PARITY_MAX][RAID_PARITY_MAX];
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p[RAID_PARITY_MAX];
|
||||
uint8_t *pa[RAID_PARITY_MAX];
|
||||
const uint8_t *T[RAID_PARITY_MAX][RAID_PARITY_MAX];
|
||||
uint8_t G[RAID_PARITY_MAX*RAID_PARITY_MAX];
|
||||
uint8_t V[RAID_PARITY_MAX*RAID_PARITY_MAX];
|
||||
size_t i;
|
||||
int j, k;
|
||||
|
||||
/* setup the coefficients matrix */
|
||||
for(j=0;j<nr;++j) {
|
||||
for(k=0;k<nr;++k) {
|
||||
G[j*nr+k] = A(ip[j],id[k]);
|
||||
}
|
||||
}
|
||||
for (j = 0; j < nr; ++j)
|
||||
for (k = 0; k < nr; ++k)
|
||||
G[j*nr+k] = A(ip[j], id[k]);
|
||||
|
||||
/* invert it to solve the system of linear equations */
|
||||
raid_invert(G, V, nr);
|
||||
|
||||
/* get multiplication tables */
|
||||
for(j=0;j<nr;++j) {
|
||||
for(k=0;k<nr;++k) {
|
||||
T[j][k] = table( V[j*nr+k] );
|
||||
}
|
||||
}
|
||||
for (j = 0; j < nr; ++j)
|
||||
for (k = 0; k < nr; ++k)
|
||||
T[j][k] = table(V[j*nr+k]);
|
||||
|
||||
/* compute delta parity */
|
||||
raid_delta_gen(nr, id, ip, nd, size, vv);
|
||||
|
||||
for(j=0;j<nr;++j) {
|
||||
for (j = 0; j < nr; ++j) {
|
||||
p[j] = v[nd+ip[j]];
|
||||
pa[j] = v[id[j]];
|
||||
}
|
||||
|
||||
for(i=0;i<size;++i) {
|
||||
for (i = 0; i < size; ++i) {
|
||||
uint8_t PD[RAID_PARITY_MAX];
|
||||
|
||||
/* delta */
|
||||
for(j=0;j<nr;++j)
|
||||
for (j = 0; j < nr; ++j)
|
||||
PD[j] = p[j][i] ^ pa[j][i];
|
||||
|
||||
/* reconstruct */
|
||||
for(j=0;j<nr;++j) {
|
||||
for (j = 0; j < nr; ++j) {
|
||||
uint8_t b = 0;
|
||||
for(k=0;k<nr;++k)
|
||||
for (k = 0; k < nr; ++k)
|
||||
b ^= T[j][k][PD[k]];
|
||||
pa[j][i] = b;
|
||||
}
|
||||
|
|
|
|||
117
raid/internal.h
117
raid/internal.h
|
|
@ -27,74 +27,74 @@
|
|||
*
|
||||
* These are intented to provide access for testing.
|
||||
*/
|
||||
void raid_invert(uint8_t* M, uint8_t* V, int n);
|
||||
void raid_delta_gen(int nr, const int* id, const int* ip, int nd, size_t size, void** v);
|
||||
void raid_rec1_par1(const int* id, int nd, size_t size, void** v);
|
||||
void raid_rec2_par2(const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_par1_int32(int nd, size_t size, void** vv);
|
||||
void raid_par1_int64(int nd, size_t size, void** vv);
|
||||
void raid_par1_sse2(int nd, size_t size, void** vv);
|
||||
void raid_par2_int32(int nd, size_t size, void** vv);
|
||||
void raid_par2_int64(int nd, size_t size, void** vv);
|
||||
void raid_par2_sse2(int nd, size_t size, void** vv);
|
||||
void raid_par2_sse2ext(int nd, size_t size, void** vv);
|
||||
void raid_parz_int32(int nd, size_t size, void** vv);
|
||||
void raid_parz_int64(int nd, size_t size, void** vv);
|
||||
void raid_parz_sse2(int nd, size_t size, void** vv);
|
||||
void raid_parz_sse2ext(int nd, size_t size, void** vv);
|
||||
void raid_par3_int8(int nd, size_t size, void** vv);
|
||||
void raid_par3_ssse3(int nd, size_t size, void** vv);
|
||||
void raid_par3_ssse3ext(int nd, size_t size, void** vv);
|
||||
void raid_par4_int8(int nd, size_t size, void** vv);
|
||||
void raid_par4_ssse3(int nd, size_t size, void** vv);
|
||||
void raid_par4_ssse3ext(int nd, size_t size, void** vv);
|
||||
void raid_par5_int8(int nd, size_t size, void** vv);
|
||||
void raid_par5_ssse3(int nd, size_t size, void** vv);
|
||||
void raid_par5_ssse3ext(int nd, size_t size, void** vv);
|
||||
void raid_par6_int8(int nd, size_t size, void** vv);
|
||||
void raid_par6_ssse3(int nd, size_t size, void** vv);
|
||||
void raid_par6_ssse3ext(int nd, size_t size, void** vv);
|
||||
void raid_rec1_int8(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_rec2_int8(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_recX_int8(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_rec1_ssse3(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_rec2_ssse3(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_recX_ssse3(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_invert(uint8_t *M, uint8_t *V, int n);
|
||||
void raid_delta_gen(int nr, const int *id, const int *ip, int nd, size_t size, void **v);
|
||||
void raid_rec1_par1(const int *id, int nd, size_t size, void **v);
|
||||
void raid_rec2_par2(const int *id, const int *ip, int nd, size_t size, void **vv);
|
||||
void raid_par1_int32(int nd, size_t size, void **vv);
|
||||
void raid_par1_int64(int nd, size_t size, void **vv);
|
||||
void raid_par1_sse2(int nd, size_t size, void **vv);
|
||||
void raid_par2_int32(int nd, size_t size, void **vv);
|
||||
void raid_par2_int64(int nd, size_t size, void **vv);
|
||||
void raid_par2_sse2(int nd, size_t size, void **vv);
|
||||
void raid_par2_sse2ext(int nd, size_t size, void **vv);
|
||||
void raid_parz_int32(int nd, size_t size, void **vv);
|
||||
void raid_parz_int64(int nd, size_t size, void **vv);
|
||||
void raid_parz_sse2(int nd, size_t size, void **vv);
|
||||
void raid_parz_sse2ext(int nd, size_t size, void **vv);
|
||||
void raid_par3_int8(int nd, size_t size, void **vv);
|
||||
void raid_par3_ssse3(int nd, size_t size, void **vv);
|
||||
void raid_par3_ssse3ext(int nd, size_t size, void **vv);
|
||||
void raid_par4_int8(int nd, size_t size, void **vv);
|
||||
void raid_par4_ssse3(int nd, size_t size, void **vv);
|
||||
void raid_par4_ssse3ext(int nd, size_t size, void **vv);
|
||||
void raid_par5_int8(int nd, size_t size, void **vv);
|
||||
void raid_par5_ssse3(int nd, size_t size, void **vv);
|
||||
void raid_par5_ssse3ext(int nd, size_t size, void **vv);
|
||||
void raid_par6_int8(int nd, size_t size, void **vv);
|
||||
void raid_par6_ssse3(int nd, size_t size, void **vv);
|
||||
void raid_par6_ssse3ext(int nd, size_t size, void **vv);
|
||||
void raid_rec1_int8(int nr, const int *id, const int *ip, int nd, size_t size, void **vv);
|
||||
void raid_rec2_int8(int nr, const int *id, const int *ip, int nd, size_t size, void **vv);
|
||||
void raid_recX_int8(int nr, const int *id, const int *ip, int nd, size_t size, void **vv);
|
||||
void raid_rec1_ssse3(int nr, const int *id, const int *ip, int nd, size_t size, void **vv);
|
||||
void raid_rec2_ssse3(int nr, const int *id, const int *ip, int nd, size_t size, void **vv);
|
||||
void raid_recX_ssse3(int nr, const int *id, const int *ip, int nd, size_t size, void **vv);
|
||||
|
||||
/*
|
||||
* Internal naming.
|
||||
*
|
||||
* These are intented to provide access for testing.
|
||||
*/
|
||||
const char* raid_par1_tag(void);
|
||||
const char* raid_par2_tag(void);
|
||||
const char* raid_parz_tag(void);
|
||||
const char* raid_par3_tag(void);
|
||||
const char* raid_par4_tag(void);
|
||||
const char* raid_par5_tag(void);
|
||||
const char* raid_par6_tag(void);
|
||||
const char* raid_rec1_tag(void);
|
||||
const char* raid_rec2_tag(void);
|
||||
const char* raid_recX_tag(void);
|
||||
const char *raid_par1_tag(void);
|
||||
const char *raid_par2_tag(void);
|
||||
const char *raid_parz_tag(void);
|
||||
const char *raid_par3_tag(void);
|
||||
const char *raid_par4_tag(void);
|
||||
const char *raid_par5_tag(void);
|
||||
const char *raid_par6_tag(void);
|
||||
const char *raid_rec1_tag(void);
|
||||
const char *raid_rec2_tag(void);
|
||||
const char *raid_recX_tag(void);
|
||||
|
||||
/*
|
||||
* Internal forwarders.
|
||||
*/
|
||||
extern void (*raid_par_ptr[RAID_PARITY_MAX])(int nd, size_t size, void** vv);
|
||||
extern void (*raid_par3_ptr)(int nd, size_t size, void** vv);
|
||||
extern void (*raid_parz_ptr)(int nd, size_t size, void** vv);
|
||||
extern void (*raid_rec_ptr[RAID_PARITY_MAX])(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
extern void (*raid_par_ptr[RAID_PARITY_MAX])(int nd, size_t size, void **vv);
|
||||
extern void (*raid_par3_ptr)(int nd, size_t size, void **vv);
|
||||
extern void (*raid_parz_ptr)(int nd, size_t size, void **vv);
|
||||
extern void (*raid_rec_ptr[RAID_PARITY_MAX])(int nr, const int *id, const int *ip, int nd, size_t size, void **vv);
|
||||
|
||||
/*
|
||||
* Tables.
|
||||
*/
|
||||
extern const uint8_t raid_gfmul[256][256] __attribute__((aligned(256)));
|
||||
extern const uint8_t raid_gfexp[256] __attribute__((aligned(256)));
|
||||
extern const uint8_t raid_gfinv[256] __attribute__((aligned(256)));
|
||||
extern const uint8_t raid_gfvandermonde[3][256] __attribute__((aligned(256)));
|
||||
extern const uint8_t raid_gfcauchy[6][256] __attribute__((aligned(256)));
|
||||
extern const uint8_t raid_gfcauchypshufb[251][4][2][16] __attribute__((aligned(256)));
|
||||
extern const uint8_t raid_gfmulpshufb[256][2][16] __attribute__((aligned(256)));
|
||||
extern const uint8_t raid_gfmul[256][256] __aligned(256);
|
||||
extern const uint8_t raid_gfexp[256] __aligned(256);
|
||||
extern const uint8_t raid_gfinv[256] __aligned(256);
|
||||
extern const uint8_t raid_gfvandermonde[3][256] __aligned(256);
|
||||
extern const uint8_t raid_gfcauchy[6][256] __aligned(256);
|
||||
extern const uint8_t raid_gfcauchypshufb[251][4][2][16] __aligned(256);
|
||||
extern const uint8_t raid_gfmulpshufb[256][2][16] __aligned(256);
|
||||
#define gfmul raid_gfmul
|
||||
#define gfexp raid_gfexp
|
||||
#define gfinv raid_gfinv
|
||||
|
|
@ -103,5 +103,14 @@ extern const uint8_t raid_gfmulpshufb[256][2][16] __attribute__((aligned(256)));
|
|||
#define gfcauchypshufb raid_gfcauchypshufb
|
||||
#define gfmulpshufb raid_gfmulpshufb
|
||||
|
||||
/*
|
||||
* Assembler blocks.
|
||||
*/
|
||||
#define asm_begin() \
|
||||
do { } while (0)
|
||||
|
||||
#define asm_end() \
|
||||
asm volatile("sfence" : : : "memory")
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
28
raid/intz.c
28
raid/intz.c
|
|
@ -21,12 +21,12 @@
|
|||
/*
|
||||
* PARz (triple parity with powers of 2^-1) 32bit C implementation
|
||||
*/
|
||||
void raid_parz_int32(int nd, size_t size, void** vv)
|
||||
void raid_parz_int32(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -38,10 +38,10 @@ void raid_parz_int32(int nd, size_t size, void** vv)
|
|||
q = v[nd+1];
|
||||
r = v[nd+2];
|
||||
|
||||
for(i=0;i<size;i+=8) {
|
||||
for (i = 0; i < size; i += 8) {
|
||||
r0 = q0 = p0 = v_32(v[l][i]);
|
||||
r1 = q1 = p1 = v_32(v[l][i+4]);
|
||||
for(d=l-1;d>=0;--d) {
|
||||
for (d = l-1; d >= 0; --d) {
|
||||
d0 = v_32(v[d][i]);
|
||||
d1 = v_32(v[d][i+4]);
|
||||
|
||||
|
|
@ -72,12 +72,12 @@ void raid_parz_int32(int nd, size_t size, void** vv)
|
|||
/*
|
||||
* PARz (triple parity with powers of 2^-1) 64bit C implementation
|
||||
*/
|
||||
void raid_parz_int64(int nd, size_t size, void** vv)
|
||||
void raid_parz_int64(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -89,10 +89,10 @@ void raid_parz_int64(int nd, size_t size, void** vv)
|
|||
q = v[nd+1];
|
||||
r = v[nd+2];
|
||||
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
r0 = q0 = p0 = v_64(v[l][i]);
|
||||
r1 = q1 = p1 = v_64(v[l][i+8]);
|
||||
for(d=l-1;d>=0;--d) {
|
||||
for (d = l-1; d >= 0; --d) {
|
||||
d0 = v_64(v[d][i]);
|
||||
d1 = v_64(v[d][i+8]);
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ uint8_t gfinv[256];
|
|||
/**
|
||||
* Setup the Cauchy matrix used to generate the parity.
|
||||
*/
|
||||
static void set_cauchy(uint8_t* matrix)
|
||||
static void set_cauchy(uint8_t *matrix)
|
||||
{
|
||||
int i, j;
|
||||
uint8_t inv_x, y;
|
||||
|
|
@ -74,9 +74,8 @@ static void set_cauchy(uint8_t* matrix)
|
|||
* This is an Extended Cauchy matrix built from a Cauchy matrix
|
||||
* adding the first row of all 1.
|
||||
*/
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i)
|
||||
matrix[0*DISK+i] = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Second row is formed by power of 2^i.
|
||||
|
|
@ -93,7 +92,7 @@ static void set_cauchy(uint8_t* matrix)
|
|||
* with 2^-i != 0 for any i
|
||||
*/
|
||||
inv_x = 1;
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i) {
|
||||
matrix[1*DISK+i] = inv_x;
|
||||
inv_x = gfmul(2, inv_x);
|
||||
}
|
||||
|
|
@ -108,9 +107,9 @@ static void set_cauchy(uint8_t* matrix)
|
|||
* with xi != yj for any i,j with i>=0,j>=1,i+j<255
|
||||
*/
|
||||
y = 2;
|
||||
for(j=0;j<PARITY-2;++j) {
|
||||
for (j = 0; j < PARITY-2; ++j) {
|
||||
inv_x = 1;
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i) {
|
||||
uint8_t x = gfinv[inv_x];
|
||||
matrix[(j+2)*DISK+i] = gfinv[y ^ x];
|
||||
inv_x = gfmul(2, inv_x);
|
||||
|
|
@ -126,36 +125,34 @@ static void set_cauchy(uint8_t* matrix)
|
|||
* This operation doesn't invalidate the property that all the square
|
||||
* submatrices are not singular.
|
||||
*/
|
||||
for(j=0;j<PARITY-2;++j) {
|
||||
for (j = 0; j < PARITY-2; ++j) {
|
||||
uint8_t f = gfinv[matrix[(j+2)*DISK]];
|
||||
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i)
|
||||
matrix[(j+2)*DISK+i] = gfmul(matrix[(j+2)*DISK+i], f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the Power matrix used to generate the parity.
|
||||
*/
|
||||
static void set_power(uint8_t* matrix)
|
||||
static void set_power(uint8_t *matrix)
|
||||
{
|
||||
unsigned i;
|
||||
uint8_t v;
|
||||
|
||||
v = 1;
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i)
|
||||
matrix[0*DISK+i] = v;
|
||||
}
|
||||
|
||||
v = 1;
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i) {
|
||||
matrix[1*DISK+i] = v;
|
||||
v = gfmul(2, v);
|
||||
}
|
||||
|
||||
v = 1;
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i) {
|
||||
matrix[2*DISK+i] = v;
|
||||
v = gfmul(0x8e, v);
|
||||
}
|
||||
|
|
@ -205,11 +202,11 @@ int main(void)
|
|||
printf("\n");
|
||||
|
||||
/* a*b */
|
||||
printf("const uint8_t __attribute__((aligned(256))) raid_gfmul[256][256] =\n");
|
||||
printf("const uint8_t __aligned(256) raid_gfmul[256][256] =\n");
|
||||
printf("{\n");
|
||||
for(i=0;i<256;++i) {
|
||||
for (i = 0; i < 256; ++i) {
|
||||
printf("\t{\n");
|
||||
for(j=0;j<256;++j) {
|
||||
for (j = 0; j < 256; ++j) {
|
||||
if (j % 8 == 0)
|
||||
printf("\t\t");
|
||||
v = gfmul(i, j);
|
||||
|
|
@ -226,10 +223,10 @@ int main(void)
|
|||
printf("};\n\n");
|
||||
|
||||
/* 2^a */
|
||||
printf("const uint8_t __attribute__((aligned(256))) raid_gfexp[256] =\n");
|
||||
printf("const uint8_t __aligned(256) raid_gfexp[256] =\n");
|
||||
printf("{\n");
|
||||
v = 1;
|
||||
for(i=0;i<256;++i) {
|
||||
for (i = 0; i < 256; ++i) {
|
||||
if (i % 8 == 0)
|
||||
printf("\t");
|
||||
printf("0x%02x,", v);
|
||||
|
|
@ -242,10 +239,10 @@ int main(void)
|
|||
printf("};\n\n");
|
||||
|
||||
/* 1/a */
|
||||
printf("const uint8_t __attribute__((aligned(256))) raid_gfinv[256] =\n");
|
||||
printf("const uint8_t __aligned(256) raid_gfinv[256] =\n");
|
||||
printf("{\n");
|
||||
printf("\t/* note that the first element is not significative */\n");
|
||||
for(i=0;i<256;++i) {
|
||||
for (i = 0; i < 256; ++i) {
|
||||
if (i % 8 == 0)
|
||||
printf("\t");
|
||||
if (i == 0)
|
||||
|
|
@ -267,19 +264,18 @@ int main(void)
|
|||
printf(" * Power matrix used to generate parity.\n");
|
||||
printf(" * This matrix is valid for up to %u parity with %u data disks.\n", 3, DISK);
|
||||
printf(" *\n");
|
||||
for(p=0;p<3;++p) {
|
||||
for (p = 0; p < 3; ++p) {
|
||||
printf(" * ");
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i)
|
||||
printf("%02x ", matrix[p*DISK+i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf(" */\n");
|
||||
printf("const uint8_t __attribute__((aligned(256))) raid_gfvandermonde[%u][256] =\n", 3);
|
||||
printf("const uint8_t __aligned(256) raid_gfvandermonde[%u][256] =\n", 3);
|
||||
printf("{\n");
|
||||
for(p=0;p<3;++p) {
|
||||
for (p = 0; p < 3; ++p) {
|
||||
printf("\t{\n");
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i) {
|
||||
if (i % 8 == 0)
|
||||
printf("\t\t");
|
||||
printf("0x%02x,", matrix[p*DISK+i]);
|
||||
|
|
@ -299,19 +295,18 @@ int main(void)
|
|||
printf(" * Cauchy matrix used to generate parity.\n");
|
||||
printf(" * This matrix is valid for up to %u parity with %u data disks.\n", PARITY, DISK);
|
||||
printf(" *\n");
|
||||
for(p=0;p<PARITY;++p) {
|
||||
for (p = 0; p < PARITY; ++p) {
|
||||
printf(" * ");
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i)
|
||||
printf("%02x ", matrix[p*DISK+i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf(" */\n");
|
||||
printf("const uint8_t __attribute__((aligned(256))) raid_gfcauchy[%u][256] =\n", PARITY);
|
||||
printf("const uint8_t __aligned(256) raid_gfcauchy[%u][256] =\n", PARITY);
|
||||
printf("{\n");
|
||||
for(p=0;p<PARITY;++p) {
|
||||
for (p = 0; p < PARITY; ++p) {
|
||||
printf("\t{\n");
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i) {
|
||||
if (i % 8 == 0)
|
||||
printf("\t\t");
|
||||
printf("0x%02x,", matrix[p*DISK+i]);
|
||||
|
|
@ -331,15 +326,15 @@ int main(void)
|
|||
printf(" * Indexes are [DISK][PARITY - 2][LH].\n");
|
||||
printf(" * Where DISK is from 0 to %u, PARITY from 2 to %u, LH from 0 to 1.\n", DISK - 1, PARITY - 1);
|
||||
printf(" */\n");
|
||||
printf("const uint8_t __attribute__((aligned(256))) raid_gfcauchypshufb[%u][%u][2][16] =\n", DISK, np(PARITY - 2));
|
||||
printf("const uint8_t __aligned(256) raid_gfcauchypshufb[%u][%u][2][16] =\n", DISK, np(PARITY - 2));
|
||||
printf("{\n");
|
||||
for(i=0;i<DISK;++i) {
|
||||
for (i = 0; i < DISK; ++i) {
|
||||
printf("\t{\n");
|
||||
for(p=2;p<PARITY;++p) {
|
||||
for (p = 2; p < PARITY; ++p) {
|
||||
printf("\t\t{\n");
|
||||
for(j=0;j<2;++j) {
|
||||
for (j = 0; j < 2; ++j) {
|
||||
printf("\t\t\t{ ");
|
||||
for(k=0;k<16;++k) {
|
||||
for (k = 0; k < 16; ++k) {
|
||||
v = gfmul(matrix[p*DISK+i], k);
|
||||
if (j == 1)
|
||||
v = gfmul(v, 16);
|
||||
|
|
@ -363,13 +358,13 @@ int main(void)
|
|||
printf(" * Indexes are [MULTIPLER][LH].\n");
|
||||
printf(" * Where MULTIPLER is from 0 to 255, LH from 0 to 1.\n");
|
||||
printf(" */\n");
|
||||
printf("const uint8_t __attribute__((aligned(256))) raid_gfmulpshufb[256][2][16] =\n");
|
||||
printf("const uint8_t __aligned(256) raid_gfmulpshufb[256][2][16] =\n");
|
||||
printf("{\n");
|
||||
for(i=0;i<256;++i) {
|
||||
for (i = 0; i < 256; ++i) {
|
||||
printf("\t{\n");
|
||||
for(j=0;j<2;++j) {
|
||||
for (j = 0; j < 2; ++j) {
|
||||
printf("\t\t{ ");
|
||||
for(k=0;k<16;++k) {
|
||||
for (k = 0; k < 16; ++k) {
|
||||
v = gfmul(i, k);
|
||||
if (j == 1)
|
||||
v = gfmul(v, 16);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ void raid_init(void)
|
|||
raid_par_ptr[4] = raid_par5_int8;
|
||||
raid_par_ptr[5] = raid_par6_int8;
|
||||
|
||||
if (sizeof(void*) == 4) {
|
||||
if (sizeof(void *) == 4) {
|
||||
raid_par_ptr[0] = raid_par1_int32;
|
||||
raid_par_ptr[1] = raid_par2_int32;
|
||||
raid_parz_ptr = raid_parz_int32;
|
||||
|
|
@ -85,8 +85,8 @@ void raid_init(void)
|
|||
}
|
||||
|
||||
static struct raid_func {
|
||||
const char* name;
|
||||
void* p;
|
||||
const char *name;
|
||||
void *p;
|
||||
} RAID_FUNC[] = {
|
||||
{ "int8", raid_par3_int8 },
|
||||
{ "int8", raid_par4_int8 },
|
||||
|
|
@ -126,9 +126,9 @@ static struct raid_func {
|
|||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const char* raid_tag(void* func)
|
||||
static const char *raid_tag(void *func)
|
||||
{
|
||||
struct raid_func* i = RAID_FUNC;
|
||||
struct raid_func *i = RAID_FUNC;
|
||||
while (i->name != 0) {
|
||||
if (i->p == func)
|
||||
return i->name;
|
||||
|
|
@ -137,52 +137,52 @@ static const char* raid_tag(void* func)
|
|||
return "unknown";
|
||||
}
|
||||
|
||||
const char* raid_par1_tag(void)
|
||||
const char *raid_par1_tag(void)
|
||||
{
|
||||
return raid_tag(raid_par_ptr[0]);
|
||||
}
|
||||
|
||||
const char* raid_par2_tag(void)
|
||||
const char *raid_par2_tag(void)
|
||||
{
|
||||
return raid_tag(raid_par_ptr[1]);
|
||||
}
|
||||
|
||||
const char* raid_parz_tag(void)
|
||||
const char *raid_parz_tag(void)
|
||||
{
|
||||
return raid_tag(raid_parz_ptr);
|
||||
}
|
||||
|
||||
const char* raid_par3_tag(void)
|
||||
const char *raid_par3_tag(void)
|
||||
{
|
||||
return raid_tag(raid_par_ptr[2]);
|
||||
}
|
||||
|
||||
const char* raid_par4_tag(void)
|
||||
const char *raid_par4_tag(void)
|
||||
{
|
||||
return raid_tag(raid_par_ptr[3]);
|
||||
}
|
||||
|
||||
const char* raid_par5_tag(void)
|
||||
const char *raid_par5_tag(void)
|
||||
{
|
||||
return raid_tag(raid_par_ptr[4]);
|
||||
}
|
||||
|
||||
const char* raid_par6_tag(void)
|
||||
const char *raid_par6_tag(void)
|
||||
{
|
||||
return raid_tag(raid_par_ptr[5]);
|
||||
}
|
||||
|
||||
const char* raid_rec1_tag(void)
|
||||
const char *raid_rec1_tag(void)
|
||||
{
|
||||
return raid_tag(raid_rec_ptr[0]);
|
||||
}
|
||||
|
||||
const char* raid_rec2_tag(void)
|
||||
const char *raid_rec2_tag(void)
|
||||
{
|
||||
return raid_tag(raid_rec_ptr[1]);
|
||||
}
|
||||
|
||||
const char* raid_recX_tag(void)
|
||||
const char *raid_recX_tag(void)
|
||||
{
|
||||
return raid_tag(raid_rec_ptr[2]);
|
||||
}
|
||||
|
|
|
|||
114
raid/raid.c
114
raid/raid.c
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
/*
|
||||
* The RAID5 and RAID6 support is implemented using the Galois Field
|
||||
* GF(2^8) with the primitive polynomial x^8 + x^4 + x^3 + x^2 + 1
|
||||
* GF(2^8) with the primitive polynomial x^8 + x^4 + x^3 + x^2 + 1
|
||||
* (285 decimal).
|
||||
*
|
||||
* The parity P and Q of a set of N disk Di with 0<=i<N, is computed
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
* Q = sum(2^i * Di) with 0<=i<N
|
||||
*
|
||||
* This approach is the same used by the Linux Kernel RAID, and by ZFS
|
||||
* RAIDZ2, better described in the H. Peter Anvin paper "The mathematics
|
||||
* of RAID-6" [1].
|
||||
* RAIDZ2, better described in the H. Peter Anvin paper "The mathematics
|
||||
* of RAID-6" [1].
|
||||
*
|
||||
* To support triple parity, it was first evaluated and then dropped, an
|
||||
* extension of the same approach, with additional parity coefficients set
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
* because we can implement very fast parallel multiplications and
|
||||
* divisions by 2 in GF(2^8).
|
||||
*
|
||||
* It's also similar at the approach used by ZFS RAIDZ3, with the
|
||||
* It's also similar at the approach used by ZFS RAIDZ3, with the
|
||||
* difference that ZFS uses powers of 4 instead of 2^-1.
|
||||
*
|
||||
* Unfortunately it doesn't work beyond triple parity, because whatever
|
||||
|
|
@ -70,13 +70,13 @@
|
|||
* [2, Chap 11, Problem 7] and this is a requirement to have
|
||||
* a MDS (Maximum Distance Separable) code [2, Chap 11, Theorem 8].
|
||||
*
|
||||
* To overcome this limitation, we use a Cauchy matrix [3][4] to compute
|
||||
* To overcome this limitation, we use a Cauchy matrix [3][4] to compute
|
||||
* the parity. A Cauchy matrix has the property to have all the square
|
||||
* submatrices not singular, resulting in always solvable equations,
|
||||
* for any combination of missing disks.
|
||||
*
|
||||
* The problem of this approach is that it requires the use of
|
||||
* generic multiplications, and not only by 2 or 2^-1, potentially
|
||||
* generic multiplications, and not only by 2 or 2^-1, potentially
|
||||
* affecting badly the performance.
|
||||
*
|
||||
* Hopefully there is a method to implement parallel multiplications
|
||||
|
|
@ -87,13 +87,13 @@
|
|||
* the first two rows with coeffients equal at the RAID5 and RAID6 approach
|
||||
* decribed, resulting in a compatible extension, and requiring SSSE3
|
||||
* instructions only if triple parity or beyond is used.
|
||||
*
|
||||
*
|
||||
* The matrix is also adjusted, multipling each row by a constant factor
|
||||
* to make the first column of all 1, to optimize the computation for
|
||||
* the first disk.
|
||||
*
|
||||
* This results in the matrix A[row,col] defined as:
|
||||
*
|
||||
*
|
||||
* 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01...
|
||||
* 01 02 04 08 10 20 40 80 1d 3a 74 e8 cd 87 13 26 4c 98 2d 5a b4 75...
|
||||
* 01 f5 d2 c4 9a 71 f1 7f fc 87 c1 c6 19 2f 40 55 3d ba 53 04 9c 61...
|
||||
|
|
@ -105,11 +105,11 @@
|
|||
* This matrix supports 6 level of parity, one for each row, for up to 251
|
||||
* data disks, one for each column, with all the 377,342,351,231 square
|
||||
* submatrices not singular, verified also with brute-force.
|
||||
*
|
||||
* This matrix can be extended to support any number of parities, just
|
||||
*
|
||||
* This matrix can be extended to support any number of parities, just
|
||||
* adding additional rows, and removing one column for each new row.
|
||||
* (see mktables.c for more details in how the matrix is generated)
|
||||
*
|
||||
*
|
||||
* In details, parity is computed as:
|
||||
*
|
||||
* P = sum(Di)
|
||||
|
|
@ -120,7 +120,7 @@
|
|||
* U = sum(A[5,i] * Di) with 0<=i<N
|
||||
*
|
||||
* To recover from a failure of six disks at indexes x,y,z,h,v,w,
|
||||
* with 0<=x<y<z<h<v<w<N, we compute the parity of the available N-6
|
||||
* with 0<=x<y<z<h<v<w<N, we compute the parity of the available N-6
|
||||
* disks as:
|
||||
*
|
||||
* Pa = sum(Di)
|
||||
|
|
@ -153,7 +153,7 @@
|
|||
*
|
||||
* Resulting speed in x64, with 8 data disks, using a stripe of 256 KiB,
|
||||
* for a Core i7-3740QM CPU @ 2.7GHz is:
|
||||
*
|
||||
*
|
||||
* int8 int32 int64 sse2 sse2e ssse3 ssse3e
|
||||
* par1 11927 22075 36004
|
||||
* par2 3378 5874 18235 19164
|
||||
|
|
@ -176,10 +176,10 @@
|
|||
*
|
||||
*
|
||||
* In conclusion, the use of power coefficients, and specifically powers
|
||||
* of 1,2,2^-1, is the best option to implement triple parity in CPUs
|
||||
* of 1,2,2^-1, is the best option to implement triple parity in CPUs
|
||||
* without SSSE3.
|
||||
* But if a modern CPU with SSSE3 (or similar) is available, the Cauchy
|
||||
* matrix is the best option because it provides a fast and general
|
||||
* matrix is the best option because it provides a fast and general
|
||||
* approach working for any number of parities.
|
||||
*
|
||||
* References:
|
||||
|
|
@ -212,21 +212,22 @@ void raid_mode(int mode)
|
|||
/**
|
||||
* Buffer filled with 0 used in recovering.
|
||||
*/
|
||||
static void* raid_empty_zero_block;
|
||||
static void *raid_empty_zero_block;
|
||||
|
||||
void raid_zero(void* zero)
|
||||
void raid_zero(void *zero)
|
||||
{
|
||||
raid_empty_zero_block = zero;
|
||||
}
|
||||
|
||||
/* internal forwarder */
|
||||
void (*raid_par_ptr[RAID_PARITY_MAX])(int nd, size_t size, void** vv);
|
||||
void (*raid_par3_ptr)(int nd, size_t size, void** vv);
|
||||
void (*raid_parz_ptr)(int nd, size_t size, void** vv);
|
||||
void (*raid_par_ptr[RAID_PARITY_MAX])(int nd, size_t size, void **vv);
|
||||
void (*raid_par3_ptr)(int nd, size_t size, void **vv);
|
||||
void (*raid_parz_ptr)(int nd, size_t size, void **vv);
|
||||
|
||||
void raid_par(int np, int nd, size_t size, void** v)
|
||||
void raid_par(int np, int nd, size_t size, void **v)
|
||||
{
|
||||
BUG_ON(np < 1 || np > RAID_PARITY_MAX);
|
||||
BUG_ON(size % 64 != 0);
|
||||
|
||||
raid_par_ptr[np - 1](nd, size, v);
|
||||
}
|
||||
|
|
@ -235,19 +236,17 @@ void raid_par(int np, int nd, size_t size, void** v)
|
|||
* Inverts the square matrix M of size nxn into V.
|
||||
* We use Gauss elimination to invert.
|
||||
*/
|
||||
void raid_invert(uint8_t* M, uint8_t* V, int n)
|
||||
void raid_invert(uint8_t *M, uint8_t *V, int n)
|
||||
{
|
||||
int i,j,k;
|
||||
int i, j, k;
|
||||
|
||||
/* set the identity matrix in V */
|
||||
for(i=0;i<n;++i) {
|
||||
for(j=0;j<n;++j) {
|
||||
for (i = 0; i < n; ++i)
|
||||
for (j = 0; j < n; ++j)
|
||||
V[i*n+j] = i == j;
|
||||
}
|
||||
}
|
||||
|
||||
/* for each element in the diagonal */
|
||||
for(k=0;k<n;++k) {
|
||||
for (k = 0; k < n; ++k) {
|
||||
uint8_t f;
|
||||
|
||||
/* the diagonal element cannot be 0 because */
|
||||
|
|
@ -257,17 +256,17 @@ void raid_invert(uint8_t* M, uint8_t* V, int n)
|
|||
|
||||
/* make the diagonal element to be 1 */
|
||||
f = inv(M[k*n+k]);
|
||||
for(j=0;j<n;++j) {
|
||||
for (j = 0; j < n; ++j) {
|
||||
M[k*n+j] = mul(f, M[k*n+j]);
|
||||
V[k*n+j] = mul(f, V[k*n+j]);
|
||||
}
|
||||
|
||||
/* make all the elements over and under the diagonal to be 0 */
|
||||
for(i=0;i<n;++i) {
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (i == k)
|
||||
continue;
|
||||
f = M[i*n+k];
|
||||
for(j=0;j<n;++j) {
|
||||
for (j = 0; j < n; ++j) {
|
||||
M[i*n+j] ^= mul(f, M[k*n+j]);
|
||||
V[i*n+j] ^= mul(f, V[k*n+j]);
|
||||
}
|
||||
|
|
@ -285,13 +284,13 @@ void raid_invert(uint8_t* M, uint8_t* V, int n)
|
|||
* Note that all the other parities not in the ip[] vector
|
||||
* are destroyed.
|
||||
*/
|
||||
void raid_delta_gen(int nr, const int* id, const int* ip, int nd, size_t size, void** v)
|
||||
void raid_delta_gen(int nr, const int *id, const int *ip, int nd, size_t size, void **v)
|
||||
{
|
||||
void* p[RAID_PARITY_MAX];
|
||||
void* pa[RAID_PARITY_MAX];
|
||||
void *p[RAID_PARITY_MAX];
|
||||
void *pa[RAID_PARITY_MAX];
|
||||
int i;
|
||||
|
||||
for(i=0;i<nr;++i) {
|
||||
for (i = 0; i < nr; ++i) {
|
||||
/* keep a copy of the parity buffer */
|
||||
p[i] = v[nd+ip[i]];
|
||||
|
||||
|
|
@ -308,7 +307,7 @@ void raid_delta_gen(int nr, const int* id, const int* ip, int nd, size_t size, v
|
|||
/* recompute the minimal parity required */
|
||||
raid_par(ip[nr - 1] + 1, nd, size, v);
|
||||
|
||||
for(i=0;i<nr;++i) {
|
||||
for (i = 0; i < nr; ++i) {
|
||||
/* restore disk buffers as before */
|
||||
v[id[i]] = pa[i];
|
||||
|
||||
|
|
@ -328,10 +327,10 @@ void raid_delta_gen(int nr, const int* id, const int* ip, int nd, size_t size, v
|
|||
*
|
||||
* Dx = Pd
|
||||
*/
|
||||
void raid_rec1_par1(const int* id, int nd, size_t size, void** v)
|
||||
void raid_rec1_par1(const int *id, int nd, size_t size, void **v)
|
||||
{
|
||||
void* p;
|
||||
void* pa;
|
||||
void *p;
|
||||
void *pa;
|
||||
|
||||
/* for PAR1 we can directly compute the missing block */
|
||||
/* and we don't need to use the zero buffer */
|
||||
|
|
@ -375,19 +374,19 @@ void raid_rec1_par1(const int* id, int nd, size_t size, void** v)
|
|||
*
|
||||
* That are always satisfied for any 0<=id[0]<id[1]<255.
|
||||
*/
|
||||
void raid_rec2_par2(const int* id, const int* ip, int nd, size_t size, void** vv)
|
||||
void raid_rec2_par2(const int *id, const int *ip, int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
size_t i;
|
||||
uint8_t* p;
|
||||
uint8_t* pa;
|
||||
uint8_t* q;
|
||||
uint8_t* qa;
|
||||
const uint8_t* T[2];
|
||||
uint8_t *p;
|
||||
uint8_t *pa;
|
||||
uint8_t *q;
|
||||
uint8_t *qa;
|
||||
const uint8_t *T[2];
|
||||
|
||||
/* get multiplication tables */
|
||||
T[0] = table( inv(pow2(id[1]-id[0]) ^ 1) );
|
||||
T[1] = table( inv(pow2(id[0]) ^ pow2(id[1])) );
|
||||
T[0] = table(inv(pow2(id[1]-id[0]) ^ 1));
|
||||
T[1] = table(inv(pow2(id[0]) ^ pow2(id[1])));
|
||||
|
||||
/* compute delta parity */
|
||||
raid_delta_gen(2, id, ip, nd, size, vv);
|
||||
|
|
@ -397,7 +396,7 @@ void raid_rec2_par2(const int* id, const int* ip, int nd, size_t size, void** vv
|
|||
pa = v[id[0]];
|
||||
qa = v[id[1]];
|
||||
|
||||
for(i=0;i<size;++i) {
|
||||
for (i = 0; i < size; ++i) {
|
||||
/* delta */
|
||||
uint8_t Pd = p[i] ^ pa[i];
|
||||
uint8_t Qd = q[i] ^ qa[i];
|
||||
|
|
@ -413,22 +412,23 @@ void raid_rec2_par2(const int* id, const int* ip, int nd, size_t size, void** vv
|
|||
}
|
||||
|
||||
/* internal forwarder */
|
||||
void (*raid_rec_ptr[RAID_PARITY_MAX])(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void (*raid_rec_ptr[RAID_PARITY_MAX])(int nr, const int *id, const int *ip, int nd, size_t size, void **vv);
|
||||
|
||||
void raid_rec(int nr, const int* id, const int* ip, int nd, size_t size, void** v)
|
||||
void raid_rec(int nr, const int *id, const int *ip, int nd, size_t size, void **v)
|
||||
{
|
||||
BUG_ON(nr > nd);
|
||||
BUG_ON(size % 64 != 0);
|
||||
|
||||
/* if failed data is present */
|
||||
if (nr != 0) {
|
||||
if (nr != 0)
|
||||
raid_rec_ptr[nr - 1](nr, id, ip, nd, size, v);
|
||||
}
|
||||
}
|
||||
|
||||
void raid_recpar(int nrd, const int* id, int nrp, int* ip, int np, int nd, size_t size, void** v)
|
||||
void raid_recpar(int nrd, const int *id, int nrp, int *ip, int np, int nd, size_t size, void **v)
|
||||
{
|
||||
BUG_ON(nrd > nd);
|
||||
BUG_ON(nrd + nrp > np);
|
||||
BUG_ON(size % 64 != 0);
|
||||
|
||||
/* if failed data is present */
|
||||
if (nrd != 0) {
|
||||
|
|
@ -436,7 +436,7 @@ void raid_recpar(int nrd, const int* id, int nrp, int* ip, int np, int nd, size_
|
|||
int i, j, k;
|
||||
|
||||
/* setup the vector of parities to use */
|
||||
for(i=0,j=0,k=0;i<np;++i) {
|
||||
for (i = 0, j = 0, k = 0; i < np; ++i) {
|
||||
if (ip[j] == i) {
|
||||
++j;
|
||||
} else {
|
||||
|
|
@ -450,9 +450,7 @@ void raid_recpar(int nrd, const int* id, int nrp, int* ip, int np, int nd, size_
|
|||
}
|
||||
|
||||
/* recompute all the parities up to the last bad one */
|
||||
if (nrp != 0) {
|
||||
if (nrp != 0)
|
||||
raid_par(ip[nrp - 1] + 1, nd, size, v);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
23
raid/raid.h
23
raid/raid.h
|
|
@ -21,7 +21,7 @@
|
|||
/**
|
||||
* RAID mode supporting up to 6 parities.
|
||||
*
|
||||
* It requires SSSE3 to get good performance with triple or more
|
||||
* It requires SSSE3 to get good performance with triple or more
|
||||
* parities.
|
||||
*
|
||||
* This is the default mode used by SnapRAID.
|
||||
|
|
@ -70,7 +70,7 @@ void raid_mode(int mode);
|
|||
* Before calling raid_rec() and raid_recpar() you must provide a memory
|
||||
* buffer filled with zero with the same size of the blocks to recover.
|
||||
*/
|
||||
void raid_zero(void* zero);
|
||||
void raid_zero(void *zero);
|
||||
|
||||
/**
|
||||
* Computes the parity.
|
||||
|
|
@ -79,10 +79,11 @@ void raid_zero(void* zero);
|
|||
* \param nd Number of data disks.
|
||||
* \param size Size of the blocks pointed by vv. It must be a multipler of 64.
|
||||
* \param vv Vector of pointers to the blocks for disks and parities.
|
||||
* It has (::nd + ::np) elements.
|
||||
* Each element points to a buffer of ::size bytes.
|
||||
* It has (::nd + ::np) elements. The first elements are the blocks for
|
||||
* data, following with the parity blocks.
|
||||
* Each blocks has ::size bytes.
|
||||
*/
|
||||
void raid_par(int np, int nd, size_t size, void** vv);
|
||||
void raid_par(int np, int nd, size_t size, void **vv);
|
||||
|
||||
/**
|
||||
* Recovers failures of data disks using the specified parities.
|
||||
|
|
@ -98,10 +99,11 @@ void raid_par(int np, int nd, size_t size, void** vv);
|
|||
* \param nd Number of data disks.
|
||||
* \param size Size of the blocks pointed by vv. It must be a multipler of 64.
|
||||
* \param vv Vector of pointers to the blocks for disks and parities.
|
||||
* It has (::nd + ::ip[::nr - 1] + 1) elements. The first elements are the blocks
|
||||
* for data, following with the parity blocks. Each blocks has ::size bytes.
|
||||
* It has (::nd + ::ip[::nr - 1] + 1) elements. The first elements are the
|
||||
* blocks for data, following with the parity blocks.
|
||||
* Each blocks has ::size bytes.
|
||||
*/
|
||||
void raid_rec(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_rec(int nr, const int *id, const int *ip, int nd, size_t size, void **vv);
|
||||
|
||||
/**
|
||||
* Recovers failures of data and parity disks.
|
||||
|
|
@ -127,8 +129,9 @@ void raid_rec(int nr, const int* id, const int* ip, int nd, size_t size, void**
|
|||
* \param size Size of the blocks pointed by vv. It must be a multipler of 64.
|
||||
* \param vv Vector of pointers to the blocks for disks and parities.
|
||||
* It has (::nd + ::np) elements. The first elements are the blocks
|
||||
* for data, following with the parity blocks. Each blocks has ::size bytes.
|
||||
* for data, following with the parity blocks.
|
||||
* Each blocks has ::size bytes.
|
||||
*/
|
||||
void raid_recpar(int nrd, const int* id, int nrp, int* ip, int np, int nd, size_t size, void** vv);
|
||||
void raid_recpar(int nrd, const int *id, int nrp, int *ip, int np, int nd, size_t size, void **vv);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "internal.h"
|
||||
|
||||
const uint8_t __attribute__((aligned(256))) raid_gfmul[256][256] =
|
||||
const uint8_t __aligned(256) raid_gfmul[256][256] =
|
||||
{
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
|
@ -8725,7 +8725,7 @@ const uint8_t __attribute__((aligned(256))) raid_gfmul[256][256] =
|
|||
},
|
||||
};
|
||||
|
||||
const uint8_t __attribute__((aligned(256))) raid_gfexp[256] =
|
||||
const uint8_t __aligned(256) raid_gfexp[256] =
|
||||
{
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
|
||||
0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26,
|
||||
|
|
@ -8761,7 +8761,7 @@ const uint8_t __attribute__((aligned(256))) raid_gfexp[256] =
|
|||
0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x01,
|
||||
};
|
||||
|
||||
const uint8_t __attribute__((aligned(256))) raid_gfinv[256] =
|
||||
const uint8_t __aligned(256) raid_gfinv[256] =
|
||||
{
|
||||
/* note that the first element is not significative */
|
||||
0x00, 0x01, 0x8e, 0xf4, 0x47, 0xa7, 0x7a, 0xba,
|
||||
|
|
@ -8806,7 +8806,7 @@ const uint8_t __attribute__((aligned(256))) raid_gfinv[256] =
|
|||
* 01 02 04 08 10 20 40 80 1d 3a 74 e8 cd 87 13 26 4c 98 2d 5a b4 75 ea c9 8f 03 06 0c 18 30 60 c0 9d 27 4e 9c 25 4a 94 35 6a d4 b5 77 ee c1 9f 23 46 8c 05 0a 14 28 50 a0 5d ba 69 d2 b9 6f de a1 5f be 61 c2 99 2f 5e bc 65 ca 89 0f 1e 3c 78 f0 fd e7 d3 bb 6b d6 b1 7f fe e1 df a3 5b b6 71 e2 d9 af 43 86 11 22 44 88 0d 1a 34 68 d0 bd 67 ce 81 1f 3e 7c f8 ed c7 93 3b 76 ec c5 97 33 66 cc 85 17 2e 5c b8 6d da a9 4f 9e 21 42 84 15 2a 54 a8 4d 9a 29 52 a4 55 aa 49 92 39 72 e4 d5 b7 73 e6 d1 bf 63 c6 91 3f 7e fc e5 d7 b3 7b f6 f1 ff e3 db ab 4b 96 31 62 c4 95 37 6e dc a5 57 ae 41 82 19 32 64 c8 8d 07 0e 1c 38 70 e0 dd a7 53 a6 51 a2 59 b2 79 f2 f9 ef c3 9b 2b 56 ac 45 8a 09 12 24 48 90 3d 7a f4 f5 f7 f3 fb eb cb 8b 0b 16 2c 58 b0 7d fa e9 cf 83 1b 36 6c
|
||||
* 01 8e 47 ad d8 6c 36 1b 83 cf e9 fa 7d b0 58 2c 16 0b 8b cb eb fb f3 f7 f5 f4 7a 3d 90 48 24 12 09 8a 45 ac 56 2b 9b c3 ef f9 f2 79 b2 59 a2 51 a6 53 a7 dd e0 70 38 1c 0e 07 8d c8 64 32 19 82 41 ae 57 a5 dc 6e 37 95 c4 62 31 96 4b ab db e3 ff f1 f6 7b b3 d7 e5 fc 7e 3f 91 c6 63 bf d1 e6 73 b7 d5 e4 72 39 92 49 aa 55 a4 52 29 9a 4d a8 54 2a 15 84 42 21 9e 4f a9 da 6d b8 5c 2e 17 85 cc 66 33 97 c5 ec 76 3b 93 c7 ed f8 7c 3e 1f 81 ce 67 bd d0 68 34 1a 0d 88 44 22 11 86 43 af d9 e2 71 b6 5b a3 df e1 fe 7f b1 d6 6b bb d3 e7 fd f0 78 3c 1e 0f 89 ca 65 bc 5e 2f 99 c2 61 be 5f a1 de 6f b9 d2 69 ba 5d a0 50 28 14 0a 05 8c 46 23 9f c1 ee 77 b5 d4 6a 35 94 4a 25 9c 4e 27 9d c0 60 30 18 0c 06 03 8f c9 ea 75 b4 5a 2d 98 4c 26 13 87 cd e8 74 3a 1d 80 40 20
|
||||
*/
|
||||
const uint8_t __attribute__((aligned(256))) raid_gfvandermonde[3][256] =
|
||||
const uint8_t __aligned(256) raid_gfvandermonde[3][256] =
|
||||
{
|
||||
{
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
|
|
@ -8923,7 +8923,7 @@ const uint8_t __attribute__((aligned(256))) raid_gfvandermonde[3][256] =
|
|||
* 01 97 7f 9c 7c 18 bd a2 58 1a da 74 70 a3 e5 47 29 07 f5 80 23 e9 fa 46 54 a0 99 95 53 9b 0b c7 09 c0 78 89 92 e3 0d b0 2a 8c fb 17 3f 26 65 87 27 5c 66 61 79 4d 32 b3 8d 52 e2 82 3d f9 c5 02 bc 4c 73 48 62 af ba 41 d9 c4 2f b1 33 b8 15 7d cf 3a a9 5f 84 6d 34 1b 44 94 72 81 42 be cc 4b 0a 6f 5a 22 36 b5 3c 9d 13 7e 08 dd d6 5e 04 fc 5b ec ef f1 6e 1e 77 24 e6 c6 aa cb fd 51 67 06 6a 4a 88 db b2 c2 5d 43 40 f7 50 a8 f2 7a 71 a4 d2 bf 31 90 19 9a 8e f6 c3 a6 e7 60 12 ee 2d de 38 e8 b7 98 c1 28 f3 05 96 63 d1 b9 14 9f 1d 83 68 75 ed 16 03 ce e4 df e0 10 ae 69 55 91 2e 4e fe 21 1f 9e e1 d5 cd ca f0 8b 2b c9 8a 93 bb 57 20 86 1c a1 4f 3e 25 d4 6c a5 6b a7 37 ff 39 35 0c f8 ea 56 45 8f 2c 59 ab 85 eb 49 0f dc d8 76 b6 f4 0e 11 b4 d0 30 d3 3b ad d7
|
||||
* 01 2b 3f cf 73 2c d6 ed cb 74 15 78 8a c1 17 c9 89 68 21 ab 76 3b 4b 5a 6e 0e b9 d3 b6 3e 36 86 bf a2 a7 30 14 eb c7 2d 96 67 20 b5 9a e0 a8 c6 80 04 8d fe 75 5e 23 ca 8f 48 99 0d df 8e b8 70 29 9c 44 69 3d a5 c2 90 d2 1c 9b 02 1d 98 93 ec 84 e8 64 4c 3a 8b 97 f3 e5 c0 7d 26 c8 08 a0 62 82 55 f7 33 f6 51 63 4d 77 da fd c3 38 6d ee 09 47 a3 05 de a6 f1 22 25 6a 0c 81 b2 6b 58 d5 b3 fc fb 28 7f 07 dc 7a 9e d0 37 b4 e1 1a 24 03 ae 94 ba 88 2f ea 2e 8c 5b bb 79 d1 11 ff a4 19 3c 2a 4e 52 e3 95 bd 31 5d 35 4a 41 c4 db 42 c5 0b 49 1b 7c e4 b0 9d 45 f0 a9 61 57 06 d4 40 91 56 13 fa 87 ac 27 54 dd 59 1f 71 39 43 6c f9 be 4f f4 1e 32 cd e9 7e 7b 66 5f ef e7 6f 0a 60 d7 b7 83 92 e2 af 72 f8 b1 50 10 ce 18 53 a1 cc ad 12 34 0f f5 aa 16 e6 f2 d8 85 9f bc
|
||||
*/
|
||||
const uint8_t __attribute__((aligned(256))) raid_gfcauchy[6][256] =
|
||||
const uint8_t __aligned(256) raid_gfcauchy[6][256] =
|
||||
{
|
||||
{
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
|
|
@ -9138,7 +9138,7 @@ const uint8_t __attribute__((aligned(256))) raid_gfcauchy[6][256] =
|
|||
* Indexes are [DISK][PARITY - 2][LH].
|
||||
* Where DISK is from 0 to 250, PARITY from 2 to 5, LH from 0 to 1.
|
||||
*/
|
||||
const uint8_t __attribute__((aligned(256))) raid_gfcauchypshufb[251][4][2][16] =
|
||||
const uint8_t __aligned(256) raid_gfcauchypshufb[251][4][2][16] =
|
||||
{
|
||||
{
|
||||
{
|
||||
|
|
@ -13668,7 +13668,7 @@ const uint8_t __attribute__((aligned(256))) raid_gfcauchypshufb[251][4][2][16] =
|
|||
* Indexes are [MULTIPLER][LH].
|
||||
* Where MULTIPLER is from 0 to 255, LH from 0 to 1.
|
||||
*/
|
||||
const uint8_t __attribute__((aligned(256))) raid_gfmulpshufb[256][2][16] =
|
||||
const uint8_t __aligned(256) raid_gfmulpshufb[256][2][16] =
|
||||
{
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
|
|
|
|||
314
raid/x86.c
314
raid/x86.c
|
|
@ -27,24 +27,26 @@
|
|||
* the typical cache block, and processing 128 bytes doesn't increase
|
||||
* performance.
|
||||
*/
|
||||
void raid_par1_sse2(int nd, size_t size, void** vv)
|
||||
void raid_par1_sse2(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
l = nd - 1;
|
||||
p = v[nd];
|
||||
|
||||
for(i=0;i<size;i+=64) {
|
||||
asm_begin();
|
||||
|
||||
for (i = 0; i < size; i += 64) {
|
||||
asm volatile("movdqa %0,%%xmm0" : : "m" (v[l][i]));
|
||||
asm volatile("movdqa %0,%%xmm1" : : "m" (v[l][i+16]));
|
||||
asm volatile("movdqa %0,%%xmm2" : : "m" (v[l][i+32]));
|
||||
asm volatile("movdqa %0,%%xmm3" : : "m" (v[l][i+48]));
|
||||
/* accessing disks in backward order because the buffers */
|
||||
/* are also in backward order */
|
||||
for(d=l-1;d>=0;--d) {
|
||||
for (d = l-1; d >= 0; --d) {
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[d][i]));
|
||||
asm volatile("movdqa %0,%%xmm5" : : "m" (v[d][i+16]));
|
||||
asm volatile("movdqa %0,%%xmm6" : : "m" (v[d][i+32]));
|
||||
|
|
@ -60,7 +62,7 @@ void raid_par1_sse2(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm3,%0" : "=m" (p[i+48]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -68,19 +70,21 @@ void raid_par1_sse2(int nd, size_t size, void** vv)
|
|||
static const struct gfconst16 {
|
||||
uint8_t poly[16];
|
||||
uint8_t low4[16];
|
||||
} gfconst16 __attribute__((aligned(64))) = {
|
||||
} gfconst16 __aligned(32) = {
|
||||
{ 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d },
|
||||
{ 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f },
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
/*
|
||||
* PAR2 (RAID6 with powers of 2) SSE2 implementation
|
||||
*/
|
||||
void raid_par2_sse2(int nd, size_t size, void** vv)
|
||||
void raid_par2_sse2(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -88,14 +92,16 @@ void raid_par2_sse2(int nd, size_t size, void** vv)
|
|||
p = v[nd];
|
||||
q = v[nd+1];
|
||||
|
||||
asm_begin();
|
||||
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0]));
|
||||
|
||||
for(i=0;i<size;i+=32) {
|
||||
for (i = 0; i < size; i += 32) {
|
||||
asm volatile("movdqa %0,%%xmm0" : : "m" (v[l][i]));
|
||||
asm volatile("movdqa %0,%%xmm1" : : "m" (v[l][i+16]));
|
||||
asm volatile("movdqa %xmm0,%xmm2");
|
||||
asm volatile("movdqa %xmm1,%xmm3");
|
||||
for(d=l-1;d>=0;--d) {
|
||||
for (d = l-1; d >= 0; --d) {
|
||||
asm volatile("pxor %xmm4,%xmm4");
|
||||
asm volatile("pxor %xmm5,%xmm5");
|
||||
asm volatile("pcmpgtb %xmm2,%xmm4");
|
||||
|
|
@ -120,7 +126,7 @@ void raid_par2_sse2(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm3,%0" : "=m" (q[i+16]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -130,11 +136,11 @@ void raid_par2_sse2(int nd, size_t size, void** vv)
|
|||
*
|
||||
* Note that it uses 16 registers, meaning that x64 is required.
|
||||
*/
|
||||
void raid_par2_sse2ext(int nd, size_t size, void** vv)
|
||||
void raid_par2_sse2ext(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -142,9 +148,11 @@ void raid_par2_sse2ext(int nd, size_t size, void** vv)
|
|||
p = v[nd];
|
||||
q = v[nd+1];
|
||||
|
||||
asm_begin();
|
||||
|
||||
asm volatile("movdqa %0,%%xmm15" : : "m" (gfconst16.poly[0]));
|
||||
|
||||
for(i=0;i<size;i+=64) {
|
||||
for (i = 0; i < size; i += 64) {
|
||||
asm volatile("movdqa %0,%%xmm0" : : "m" (v[l][i]));
|
||||
asm volatile("movdqa %0,%%xmm1" : : "m" (v[l][i+16]));
|
||||
asm volatile("movdqa %0,%%xmm2" : : "m" (v[l][i+32]));
|
||||
|
|
@ -153,7 +161,7 @@ void raid_par2_sse2ext(int nd, size_t size, void** vv)
|
|||
asm volatile("movdqa %xmm1,%xmm5");
|
||||
asm volatile("movdqa %xmm2,%xmm6");
|
||||
asm volatile("movdqa %xmm3,%xmm7");
|
||||
for(d=l-1;d>=0;--d) {
|
||||
for (d = l-1; d >= 0; --d) {
|
||||
asm volatile("pxor %xmm8,%xmm8");
|
||||
asm volatile("pxor %xmm9,%xmm9");
|
||||
asm volatile("pxor %xmm10,%xmm10");
|
||||
|
|
@ -198,7 +206,7 @@ void raid_par2_sse2ext(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm7,%0" : "=m" (q[i+48]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -206,12 +214,12 @@ void raid_par2_sse2ext(int nd, size_t size, void** vv)
|
|||
/*
|
||||
* PAR3 (triple parity with Cauchy matrix) SSSE3 implementation
|
||||
*/
|
||||
void raid_par3_ssse3(int nd, size_t size, void** vv)
|
||||
void raid_par3_ssse3(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -222,16 +230,18 @@ void raid_par3_ssse3(int nd, size_t size, void** vv)
|
|||
|
||||
/* special case with only one data disk */
|
||||
if (l == 0) {
|
||||
for(i=0;i<3;++i)
|
||||
for (i = 0; i < 3; ++i)
|
||||
memcpy(v[1+i], v[0], size);
|
||||
return;
|
||||
}
|
||||
|
||||
asm_begin();
|
||||
|
||||
/* generic case with at least two data disks */
|
||||
asm volatile("movdqa %0,%%xmm3" : : "m" (gfconst16.poly[0]));
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0]));
|
||||
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
/* last disk without the by two multiplication */
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[l][i]));
|
||||
|
||||
|
|
@ -250,7 +260,7 @@ void raid_par3_ssse3(int nd, size_t size, void** vv)
|
|||
asm volatile("pxor %xmm6,%xmm2");
|
||||
|
||||
/* intermediate disks */
|
||||
for(d=l-1;d>0;--d) {
|
||||
for (d = l-1; d > 0; --d) {
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[d][i]));
|
||||
|
||||
asm volatile("pxor %xmm5,%xmm5");
|
||||
|
|
@ -287,13 +297,13 @@ void raid_par3_ssse3(int nd, size_t size, void** vv)
|
|||
asm volatile("pxor %xmm4,%xmm0");
|
||||
asm volatile("pxor %xmm4,%xmm1");
|
||||
asm volatile("pxor %xmm4,%xmm2");
|
||||
|
||||
|
||||
asm volatile("movntdq %%xmm0,%0" : "=m" (p[i]));
|
||||
asm volatile("movntdq %%xmm1,%0" : "=m" (q[i]));
|
||||
asm volatile("movntdq %%xmm2,%0" : "=m" (r[i]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -303,12 +313,12 @@ void raid_par3_ssse3(int nd, size_t size, void** vv)
|
|||
*
|
||||
* Note that it uses 16 registers, meaning that x64 is required.
|
||||
*/
|
||||
void raid_par3_ssse3ext(int nd, size_t size, void** vv)
|
||||
void raid_par3_ssse3ext(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -319,16 +329,18 @@ void raid_par3_ssse3ext(int nd, size_t size, void** vv)
|
|||
|
||||
/* special case with only one data disk */
|
||||
if (l == 0) {
|
||||
for(i=0;i<3;++i)
|
||||
for (i = 0; i < 3; ++i)
|
||||
memcpy(v[1+i], v[0], size);
|
||||
return;
|
||||
}
|
||||
|
||||
asm_begin();
|
||||
|
||||
/* generic case with at least two data disks */
|
||||
asm volatile("movdqa %0,%%xmm3" : : "m" (gfconst16.poly[0]));
|
||||
asm volatile("movdqa %0,%%xmm11" : : "m" (gfconst16.low4[0]));
|
||||
|
||||
for(i=0;i<size;i+=32) {
|
||||
for (i = 0; i < size; i += 32) {
|
||||
/* last disk without the by two multiplication */
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[l][i]));
|
||||
asm volatile("movdqa %0,%%xmm12" : : "m" (v[l][i+16]));
|
||||
|
|
@ -359,7 +371,7 @@ void raid_par3_ssse3ext(int nd, size_t size, void** vv)
|
|||
asm volatile("pxor %xmm15,%xmm10");
|
||||
|
||||
/* intermediate disks */
|
||||
for(d=l-1;d>0;--d) {
|
||||
for (d = l-1; d > 0; --d) {
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[d][i]));
|
||||
asm volatile("movdqa %0,%%xmm12" : : "m" (v[d][i+16]));
|
||||
|
||||
|
|
@ -432,7 +444,7 @@ void raid_par3_ssse3ext(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm10,%0" : "=m" (r[i+16]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -440,13 +452,13 @@ void raid_par3_ssse3ext(int nd, size_t size, void** vv)
|
|||
/*
|
||||
* PAR4 (quad parity with Cauchy matrix) SSSE3 implementation
|
||||
*/
|
||||
void raid_par4_ssse3(int nd, size_t size, void** vv)
|
||||
void raid_par4_ssse3(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t* s;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
uint8_t *s;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -458,13 +470,15 @@ void raid_par4_ssse3(int nd, size_t size, void** vv)
|
|||
|
||||
/* special case with only one data disk */
|
||||
if (l == 0) {
|
||||
for(i=0;i<4;++i)
|
||||
for (i = 0; i < 4; ++i)
|
||||
memcpy(v[1+i], v[0], size);
|
||||
return;
|
||||
}
|
||||
|
||||
asm_begin();
|
||||
|
||||
/* generic case with at least two data disks */
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
/* last disk without the by two multiplication */
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0]));
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[l][i]));
|
||||
|
|
@ -490,7 +504,7 @@ void raid_par4_ssse3(int nd, size_t size, void** vv)
|
|||
asm volatile("pxor %xmm7,%xmm3");
|
||||
|
||||
/* intermediate disks */
|
||||
for(d=l-1;d>0;--d) {
|
||||
for (d = l-1; d > 0; --d) {
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0]));
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[d][i]));
|
||||
|
||||
|
|
@ -546,7 +560,7 @@ void raid_par4_ssse3(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm3,%0" : "=m" (s[i]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -556,13 +570,13 @@ void raid_par4_ssse3(int nd, size_t size, void** vv)
|
|||
*
|
||||
* Note that it uses 16 registers, meaning that x64 is required.
|
||||
*/
|
||||
void raid_par4_ssse3ext(int nd, size_t size, void** vv)
|
||||
void raid_par4_ssse3ext(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t* s;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
uint8_t *s;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -574,13 +588,15 @@ void raid_par4_ssse3ext(int nd, size_t size, void** vv)
|
|||
|
||||
/* special case with only one data disk */
|
||||
if (l == 0) {
|
||||
for(i=0;i<4;++i)
|
||||
for (i = 0; i < 4; ++i)
|
||||
memcpy(v[1+i], v[0], size);
|
||||
return;
|
||||
}
|
||||
|
||||
asm_begin();
|
||||
|
||||
/* generic case with at least two data disks */
|
||||
for(i=0;i<size;i+=32) {
|
||||
for (i = 0; i < size; i += 32) {
|
||||
/* last disk without the by two multiplication */
|
||||
asm volatile("movdqa %0,%%xmm15" : : "m" (gfconst16.low4[0]));
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[l][i]));
|
||||
|
|
@ -623,7 +639,7 @@ void raid_par4_ssse3ext(int nd, size_t size, void** vv)
|
|||
asm volatile("pxor %xmm15,%xmm11");
|
||||
|
||||
/* intermediate disks */
|
||||
for(d=l-1;d>0;--d) {
|
||||
for (d = l-1; d > 0; --d) {
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0]));
|
||||
asm volatile("movdqa %0,%%xmm15" : : "m" (gfconst16.low4[0]));
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[d][i]));
|
||||
|
|
@ -717,7 +733,7 @@ void raid_par4_ssse3ext(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm11,%0" : "=m" (s[i+16]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -729,18 +745,18 @@ void raid_par4_ssse3ext(int nd, size_t size, void** vv)
|
|||
/* ensures that stack is aligned at 16 bytes because we allocate SSE registers in it */
|
||||
__attribute__((force_align_arg_pointer))
|
||||
#endif
|
||||
void raid_par5_ssse3(int nd, size_t size, void** vv)
|
||||
void raid_par5_ssse3(int nd, size_t size, void **vv)
|
||||
/* ensures that stack is aligned at 16 bytes because we allocate SSE registers in it */
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t* s;
|
||||
uint8_t* t;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
uint8_t *s;
|
||||
uint8_t *t;
|
||||
int d, l;
|
||||
size_t i;
|
||||
uint8_t p0[16] __attribute__((aligned(16)));
|
||||
uint8_t p0[16] __aligned(16);
|
||||
|
||||
l = nd - 1;
|
||||
p = v[nd];
|
||||
|
|
@ -751,13 +767,15 @@ void raid_par5_ssse3(int nd, size_t size, void** vv)
|
|||
|
||||
/* special case with only one data disk */
|
||||
if (l == 0) {
|
||||
for(i=0;i<5;++i)
|
||||
for (i = 0; i < 5; ++i)
|
||||
memcpy(v[1+i], v[0], size);
|
||||
return;
|
||||
}
|
||||
|
||||
asm_begin();
|
||||
|
||||
/* generic case with at least two data disks */
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
/* last disk without the by two multiplication */
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[l][i]));
|
||||
|
||||
|
|
@ -789,7 +807,7 @@ void raid_par5_ssse3(int nd, size_t size, void** vv)
|
|||
asm volatile("pxor %xmm7,%xmm3");
|
||||
|
||||
/* intermediate disks */
|
||||
for(d=l-1;d>0;--d) {
|
||||
for (d = l-1; d > 0; --d) {
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[d][i]));
|
||||
asm volatile("movdqa %0,%%xmm6" : : "m" (p0[0]));
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0]));
|
||||
|
|
@ -856,7 +874,7 @@ void raid_par5_ssse3(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm3,%0" : "=m" (t[i]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -866,14 +884,14 @@ void raid_par5_ssse3(int nd, size_t size, void** vv)
|
|||
*
|
||||
* Note that it uses 16 registers, meaning that x64 is required.
|
||||
*/
|
||||
void raid_par5_ssse3ext(int nd, size_t size, void** vv)
|
||||
void raid_par5_ssse3ext(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t* s;
|
||||
uint8_t* t;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
uint8_t *s;
|
||||
uint8_t *t;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -886,16 +904,18 @@ void raid_par5_ssse3ext(int nd, size_t size, void** vv)
|
|||
|
||||
/* special case with only one data disk */
|
||||
if (l == 0) {
|
||||
for(i=0;i<5;++i)
|
||||
for (i = 0; i < 5; ++i)
|
||||
memcpy(v[1+i], v[0], size);
|
||||
return;
|
||||
}
|
||||
|
||||
asm_begin();
|
||||
|
||||
/* generic case with at least two data disks */
|
||||
asm volatile("movdqa %0,%%xmm14" : : "m" (gfconst16.poly[0]));
|
||||
asm volatile("movdqa %0,%%xmm15" : : "m" (gfconst16.low4[0]));
|
||||
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
/* last disk without the by two multiplication */
|
||||
asm volatile("movdqa %0,%%xmm10" : : "m" (v[l][i]));
|
||||
|
||||
|
|
@ -926,7 +946,7 @@ void raid_par5_ssse3ext(int nd, size_t size, void** vv)
|
|||
asm volatile("pxor %xmm13,%xmm4");
|
||||
|
||||
/* intermediate disks */
|
||||
for(d=l-1;d>0;--d) {
|
||||
for (d = l-1; d > 0; --d) {
|
||||
asm volatile("movdqa %0,%%xmm10" : : "m" (v[d][i]));
|
||||
|
||||
asm volatile("pxor %xmm11,%xmm11");
|
||||
|
|
@ -987,7 +1007,7 @@ void raid_par5_ssse3ext(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm4,%0" : "=m" (t[i]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -999,19 +1019,19 @@ void raid_par5_ssse3ext(int nd, size_t size, void** vv)
|
|||
/* ensures that stack is aligned at 16 bytes because we allocate SSE registers in it */
|
||||
__attribute__((force_align_arg_pointer))
|
||||
#endif
|
||||
void raid_par6_ssse3(int nd, size_t size, void** vv)
|
||||
void raid_par6_ssse3(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t* s;
|
||||
uint8_t* t;
|
||||
uint8_t* u;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
uint8_t *s;
|
||||
uint8_t *t;
|
||||
uint8_t *u;
|
||||
int d, l;
|
||||
size_t i;
|
||||
uint8_t p0[16] __attribute__((aligned(16)));
|
||||
uint8_t q0[16] __attribute__((aligned(16)));
|
||||
uint8_t p0[16] __aligned(16);
|
||||
uint8_t q0[16] __aligned(16);
|
||||
|
||||
l = nd - 1;
|
||||
p = v[nd];
|
||||
|
|
@ -1023,13 +1043,15 @@ void raid_par6_ssse3(int nd, size_t size, void** vv)
|
|||
|
||||
/* special case with only one data disk */
|
||||
if (l == 0) {
|
||||
for(i=0;i<6;++i)
|
||||
for (i = 0; i < 6; ++i)
|
||||
memcpy(v[1+i], v[0], size);
|
||||
return;
|
||||
}
|
||||
|
||||
asm_begin();
|
||||
|
||||
/* generic case with at least two data disks */
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
/* last disk without the by two multiplication */
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (v[l][i]));
|
||||
|
||||
|
|
@ -1067,7 +1089,7 @@ void raid_par6_ssse3(int nd, size_t size, void** vv)
|
|||
asm volatile("pxor %xmm7,%xmm3");
|
||||
|
||||
/* intermediate disks */
|
||||
for(d=l-1;d>0;--d) {
|
||||
for (d = l-1; d > 0; --d) {
|
||||
asm volatile("movdqa %0,%%xmm5" : : "m" (p0[0]));
|
||||
asm volatile("movdqa %0,%%xmm6" : : "m" (q0[0]));
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.poly[0]));
|
||||
|
|
@ -1147,7 +1169,7 @@ void raid_par6_ssse3(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm3,%0" : "=m" (u[i]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1157,15 +1179,15 @@ void raid_par6_ssse3(int nd, size_t size, void** vv)
|
|||
*
|
||||
* Note that it uses 16 registers, meaning that x64 is required.
|
||||
*/
|
||||
void raid_par6_ssse3ext(int nd, size_t size, void** vv)
|
||||
void raid_par6_ssse3ext(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t* s;
|
||||
uint8_t* t;
|
||||
uint8_t* u;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
uint8_t *s;
|
||||
uint8_t *t;
|
||||
uint8_t *u;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -1179,16 +1201,18 @@ void raid_par6_ssse3ext(int nd, size_t size, void** vv)
|
|||
|
||||
/* special case with only one data disk */
|
||||
if (l == 0) {
|
||||
for(i=0;i<6;++i)
|
||||
for (i = 0; i < 6; ++i)
|
||||
memcpy(v[1+i], v[0], size);
|
||||
return;
|
||||
}
|
||||
|
||||
asm_begin();
|
||||
|
||||
/* generic case with at least two data disks */
|
||||
asm volatile("movdqa %0,%%xmm14" : : "m" (gfconst16.poly[0]));
|
||||
asm volatile("movdqa %0,%%xmm15" : : "m" (gfconst16.low4[0]));
|
||||
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
/* last disk without the by two multiplication */
|
||||
asm volatile("movdqa %0,%%xmm10" : : "m" (v[l][i]));
|
||||
|
||||
|
|
@ -1225,7 +1249,7 @@ void raid_par6_ssse3ext(int nd, size_t size, void** vv)
|
|||
asm volatile("pxor %xmm13,%xmm5");
|
||||
|
||||
/* intermediate disks */
|
||||
for(d=l-1;d>0;--d) {
|
||||
for (d = l-1; d > 0; --d) {
|
||||
asm volatile("movdqa %0,%%xmm10" : : "m" (v[d][i]));
|
||||
|
||||
asm volatile("pxor %xmm11,%xmm11");
|
||||
|
|
@ -1295,7 +1319,7 @@ void raid_par6_ssse3ext(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm5,%0" : "=m" (u[i]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1303,11 +1327,11 @@ void raid_par6_ssse3ext(int nd, size_t size, void** vv)
|
|||
/*
|
||||
* RAID recovering for one disk SSSE3 implementation
|
||||
*/
|
||||
void raid_rec1_ssse3(int nr, const int* id, const int* ip, int nd, size_t size, void** vv)
|
||||
void raid_rec1_ssse3(int nr, const int *id, const int *ip, int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* pa;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *pa;
|
||||
uint8_t G;
|
||||
uint8_t V;
|
||||
size_t i;
|
||||
|
|
@ -1321,7 +1345,7 @@ void raid_rec1_ssse3(int nr, const int* id, const int* ip, int nd, size_t size,
|
|||
}
|
||||
|
||||
/* setup the coefficients matrix */
|
||||
G = A(ip[0],id[0]);
|
||||
G = A(ip[0], id[0]);
|
||||
|
||||
/* invert it to solve the system of linear equations */
|
||||
V = inv(G);
|
||||
|
|
@ -1332,11 +1356,13 @@ void raid_rec1_ssse3(int nr, const int* id, const int* ip, int nd, size_t size,
|
|||
p = v[nd+ip[0]];
|
||||
pa = v[id[0]];
|
||||
|
||||
asm_begin();
|
||||
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0]));
|
||||
asm volatile("movdqa %0,%%xmm4" : : "m" (gfmulpshufb[V][0][0]));
|
||||
asm volatile("movdqa %0,%%xmm5" : : "m" (gfmulpshufb[V][1][0]));
|
||||
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
asm volatile("movdqa %0,%%xmm0" : : "m" (p[i]));
|
||||
asm volatile("movdqa %0,%%xmm1" : : "m" (pa[i]));
|
||||
asm volatile("movdqa %xmm4,%xmm2");
|
||||
|
|
@ -1352,7 +1378,7 @@ void raid_rec1_ssse3(int nr, const int* id, const int* ip, int nd, size_t size,
|
|||
asm volatile("movdqa %%xmm2,%0" : "=m" (pa[i]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1360,12 +1386,12 @@ void raid_rec1_ssse3(int nr, const int* id, const int* ip, int nd, size_t size,
|
|||
/*
|
||||
* RAID recovering for two disks SSSE3 implementation
|
||||
*/
|
||||
void raid_rec2_ssse3(int nr, const int* id, const int* ip, int nd, size_t size, void** vv)
|
||||
void raid_rec2_ssse3(int nr, const int *id, const int *ip, int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
const int N = 2;
|
||||
uint8_t* p[N];
|
||||
uint8_t* pa[N];
|
||||
uint8_t *p[N];
|
||||
uint8_t *pa[N];
|
||||
uint8_t G[N*N];
|
||||
uint8_t V[N*N];
|
||||
size_t i;
|
||||
|
|
@ -1374,11 +1400,9 @@ void raid_rec2_ssse3(int nr, const int* id, const int* ip, int nd, size_t size,
|
|||
(void)nr; /* unused, it's always 2 */
|
||||
|
||||
/* setup the coefficients matrix */
|
||||
for(j=0;j<N;++j) {
|
||||
for(k=0;k<N;++k) {
|
||||
G[j*N+k] = A(ip[j],id[k]);
|
||||
}
|
||||
}
|
||||
for (j = 0; j < N; ++j)
|
||||
for (k = 0; k < N; ++k)
|
||||
G[j*N+k] = A(ip[j], id[k]);
|
||||
|
||||
/* invert it to solve the system of linear equations */
|
||||
raid_invert(G, V, N);
|
||||
|
|
@ -1386,14 +1410,16 @@ void raid_rec2_ssse3(int nr, const int* id, const int* ip, int nd, size_t size,
|
|||
/* compute delta parity */
|
||||
raid_delta_gen(N, id, ip, nd, size, vv);
|
||||
|
||||
for(j=0;j<N;++j) {
|
||||
for (j = 0; j < N; ++j) {
|
||||
p[j] = v[nd+ip[j]];
|
||||
pa[j] = v[id[j]];
|
||||
}
|
||||
|
||||
asm_begin();
|
||||
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0]));
|
||||
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
asm volatile("movdqa %0,%%xmm0" : : "m" (p[0][i]));
|
||||
asm volatile("movdqa %0,%%xmm2" : : "m" (pa[0][i]));
|
||||
asm volatile("movdqa %0,%%xmm1" : : "m" (p[1][i]));
|
||||
|
|
@ -1458,7 +1484,7 @@ void raid_rec2_ssse3(int nr, const int* id, const int* ip, int nd, size_t size,
|
|||
asm volatile("movdqa %%xmm6,%0" : "=m" (pa[1][i]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1466,23 +1492,21 @@ void raid_rec2_ssse3(int nr, const int* id, const int* ip, int nd, size_t size,
|
|||
/*
|
||||
* RAID recovering SSSE3 implementation
|
||||
*/
|
||||
void raid_recX_ssse3(int nr, const int* id, const int* ip, int nd, size_t size, void** vv)
|
||||
void raid_recX_ssse3(int nr, const int *id, const int *ip, int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
int N = nr;
|
||||
uint8_t* p[RAID_PARITY_MAX];
|
||||
uint8_t* pa[RAID_PARITY_MAX];
|
||||
uint8_t *p[RAID_PARITY_MAX];
|
||||
uint8_t *pa[RAID_PARITY_MAX];
|
||||
uint8_t G[RAID_PARITY_MAX*RAID_PARITY_MAX];
|
||||
uint8_t V[RAID_PARITY_MAX*RAID_PARITY_MAX];
|
||||
size_t i;
|
||||
int j, k;
|
||||
|
||||
/* setup the coefficients matrix */
|
||||
for(j=0;j<N;++j) {
|
||||
for(k=0;k<N;++k) {
|
||||
G[j*N+k] = A(ip[j],id[k]);
|
||||
}
|
||||
}
|
||||
for (j = 0; j < N; ++j)
|
||||
for (k = 0; k < N; ++k)
|
||||
G[j*N+k] = A(ip[j], id[k]);
|
||||
|
||||
/* invert it to solve the system of linear equations */
|
||||
raid_invert(G, V, N);
|
||||
|
|
@ -1490,18 +1514,20 @@ void raid_recX_ssse3(int nr, const int* id, const int* ip, int nd, size_t size,
|
|||
/* compute delta parity */
|
||||
raid_delta_gen(N, id, ip, nd, size, vv);
|
||||
|
||||
for(j=0;j<N;++j) {
|
||||
for (j = 0; j < N; ++j) {
|
||||
p[j] = v[nd+ip[j]];
|
||||
pa[j] = v[id[j]];
|
||||
}
|
||||
|
||||
asm_begin();
|
||||
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0]));
|
||||
|
||||
for(i=0;i<size;i+=16) {
|
||||
uint8_t PD[RAID_PARITY_MAX][16] __attribute__((aligned(16)));
|
||||
for (i = 0; i < size; i += 16) {
|
||||
uint8_t PD[RAID_PARITY_MAX][16] __aligned(16);
|
||||
|
||||
/* delta */
|
||||
for(j=0;j<N;++j) {
|
||||
for (j = 0; j < N; ++j) {
|
||||
asm volatile("movdqa %0,%%xmm0" : : "m" (p[j][i]));
|
||||
asm volatile("movdqa %0,%%xmm1" : : "m" (pa[j][i]));
|
||||
asm volatile("pxor %xmm1,%xmm0");
|
||||
|
|
@ -1509,11 +1535,11 @@ void raid_recX_ssse3(int nr, const int* id, const int* ip, int nd, size_t size,
|
|||
}
|
||||
|
||||
/* reconstruct */
|
||||
for(j=0;j<N;++j) {
|
||||
for (j = 0; j < N; ++j) {
|
||||
asm volatile("pxor %xmm0,%xmm0");
|
||||
asm volatile("pxor %xmm1,%xmm1");
|
||||
|
||||
for(k=0;k<N;++k) {
|
||||
for (k = 0; k < N; ++k) {
|
||||
uint8_t m = V[j*N+k];
|
||||
|
||||
asm volatile("movdqa %0,%%xmm2" : : "m" (gfmulpshufb[m][0][0]));
|
||||
|
|
@ -1534,7 +1560,7 @@ void raid_recX_ssse3(int nr, const int* id, const int* ip, int nd, size_t size,
|
|||
}
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
38
raid/x86z.c
38
raid/x86z.c
|
|
@ -22,7 +22,7 @@ static const struct gfzconst16 {
|
|||
uint8_t poly[16];
|
||||
uint8_t half[16];
|
||||
uint8_t low7[16];
|
||||
} gfzconst16 __attribute__((aligned(64))) = {
|
||||
} gfzconst16 __aligned(64) = {
|
||||
{ 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d },
|
||||
{ 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e, 0x8e },
|
||||
{ 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f }
|
||||
|
|
@ -31,12 +31,12 @@ static const struct gfzconst16 {
|
|||
/*
|
||||
* PARz (triple parity with powers of 2^-1) SSE2 implementation
|
||||
*/
|
||||
void raid_parz_sse2(int nd, size_t size, void** vv)
|
||||
void raid_parz_sse2(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -45,15 +45,17 @@ void raid_parz_sse2(int nd, size_t size, void** vv)
|
|||
q = v[nd+1];
|
||||
r = v[nd+2];
|
||||
|
||||
asm_begin();
|
||||
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfzconst16.poly[0]));
|
||||
asm volatile("movdqa %0,%%xmm3" : : "m" (gfzconst16.half[0]));
|
||||
asm volatile("movdqa %0,%%xmm6" : : "m" (gfzconst16.low7[0]));
|
||||
|
||||
for(i=0;i<size;i+=16) {
|
||||
for (i = 0; i < size; i += 16) {
|
||||
asm volatile("movdqa %0,%%xmm0" : : "m" (v[l][i]));
|
||||
asm volatile("movdqa %xmm0,%xmm1");
|
||||
asm volatile("movdqa %xmm0,%xmm2");
|
||||
for(d=l-1;d>=0;--d) {
|
||||
for (d = l-1; d >= 0; --d) {
|
||||
asm volatile("pxor %xmm4,%xmm4");
|
||||
asm volatile("pcmpgtb %xmm1,%xmm4");
|
||||
asm volatile("paddb %xmm1,%xmm1");
|
||||
|
|
@ -79,7 +81,7 @@ void raid_parz_sse2(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm2,%0" : "=m" (r[i]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -89,12 +91,12 @@ void raid_parz_sse2(int nd, size_t size, void** vv)
|
|||
*
|
||||
* Note that it uses 16 registers, meaning that x64 is required.
|
||||
*/
|
||||
void raid_parz_sse2ext(int nd, size_t size, void** vv)
|
||||
void raid_parz_sse2ext(int nd, size_t size, void **vv)
|
||||
{
|
||||
uint8_t** v = (uint8_t**)vv;
|
||||
uint8_t* p;
|
||||
uint8_t* q;
|
||||
uint8_t* r;
|
||||
uint8_t **v = (uint8_t **)vv;
|
||||
uint8_t *p;
|
||||
uint8_t *q;
|
||||
uint8_t *r;
|
||||
int d, l;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -103,18 +105,20 @@ void raid_parz_sse2ext(int nd, size_t size, void** vv)
|
|||
q = v[nd+1];
|
||||
r = v[nd+2];
|
||||
|
||||
asm_begin();
|
||||
|
||||
asm volatile("movdqa %0,%%xmm7" : : "m" (gfzconst16.poly[0]));
|
||||
asm volatile("movdqa %0,%%xmm3" : : "m" (gfzconst16.half[0]));
|
||||
asm volatile("movdqa %0,%%xmm11" : : "m" (gfzconst16.low7[0]));
|
||||
|
||||
for(i=0;i<size;i+=32) {
|
||||
for (i = 0; i < size; i += 32) {
|
||||
asm volatile("movdqa %0,%%xmm0" : : "m" (v[l][i]));
|
||||
asm volatile("movdqa %0,%%xmm8" : : "m" (v[l][i+16]));
|
||||
asm volatile("movdqa %xmm0,%xmm1");
|
||||
asm volatile("movdqa %xmm8,%xmm9");
|
||||
asm volatile("movdqa %xmm0,%xmm2");
|
||||
asm volatile("movdqa %xmm8,%xmm10");
|
||||
for(d=l-1;d>=0;--d) {
|
||||
for (d = l-1; d >= 0; --d) {
|
||||
asm volatile("movdqa %xmm2,%xmm6");
|
||||
asm volatile("movdqa %xmm10,%xmm14");
|
||||
asm volatile("pxor %xmm4,%xmm4");
|
||||
|
|
@ -159,7 +163,7 @@ void raid_parz_sse2ext(int nd, size_t size, void** vv)
|
|||
asm volatile("movntdq %%xmm10,%0" : "=m" (r[i+16]));
|
||||
}
|
||||
|
||||
asm volatile("sfence" : : : "memory");
|
||||
asm_end();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue