Refactor and reorganize parity generation functions using inline templates

This commit is contained in:
Andrea Mazzoleni 2026-06-05 11:01:03 +02:00
parent 677aa0cc90
commit e0f7f9fa6f
16 changed files with 3629 additions and 4884 deletions

View file

@ -142,6 +142,108 @@ void raid_gen2_int64(int nd, size_t size, void **vv)
}
}
/*
* GENz (triple parity with powers of 2^-1) 32bit C implementation
*/
void raid_genz_int32(int nd, size_t size, void **vv)
{
uint8_t **v = (uint8_t**)vv;
uint8_t *p;
uint8_t *q;
uint8_t *r;
int d, l;
size_t i;
uint32_t d0, r0, q0, p0;
uint32_t d1, r1, q1, p1;
l = nd - 1;
p = v[nd];
q = v[nd + 1];
r = v[nd + 2];
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) {
d0 = v_32(v[d][i]);
d1 = v_32(v[d][i + 4]);
p0 ^= d0;
p1 ^= d1;
q0 = x2_32(q0);
q1 = x2_32(q1);
q0 ^= d0;
q1 ^= d1;
r0 = d2_32(r0);
r1 = d2_32(r1);
r0 ^= d0;
r1 ^= d1;
}
v_32(p[i]) = p0;
v_32(p[i + 4]) = p1;
v_32(q[i]) = q0;
v_32(q[i + 4]) = q1;
v_32(r[i]) = r0;
v_32(r[i + 4]) = r1;
}
}
/*
* GENz (triple parity with powers of 2^-1) 64bit C implementation
*/
void raid_genz_int64(int nd, size_t size, void **vv)
{
uint8_t **v = (uint8_t**)vv;
uint8_t *p;
uint8_t *q;
uint8_t *r;
int d, l;
size_t i;
uint64_t d0, r0, q0, p0;
uint64_t d1, r1, q1, p1;
l = nd - 1;
p = v[nd];
q = v[nd + 1];
r = v[nd + 2];
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) {
d0 = v_64(v[d][i]);
d1 = v_64(v[d][i + 8]);
p0 ^= d0;
p1 ^= d1;
q0 = x2_64(q0);
q1 = x2_64(q1);
q0 ^= d0;
q1 ^= d1;
r0 = d2_64(r0);
r1 = d2_64(r1);
r0 ^= d0;
r1 ^= d1;
}
v_64(p[i]) = p0;
v_64(p[i + 8]) = p1;
v_64(q[i]) = q0;
v_64(q[i + 8]) = q1;
v_64(r[i]) = r0;
v_64(r[i + 8]) = r1;
}
}
/*
* GEN3 (triple parity with Cauchy matrix) 8bit C implementation
*