erasure_code: reformat using new code style

Signed-off-by: Marcel Cornu <marcel.d.cornu@intel.com>
This commit is contained in:
Marcel Cornu 2024-04-19 17:08:53 +01:00 committed by Pablo de Lara
parent 671e67b62d
commit 300260a4d9
37 changed files with 10984 additions and 13068 deletions

View File

@ -43,7 +43,6 @@ DEFINE_INTERFACE_DISPATCHER(gf_vect_dot_prod)
return PROVIDER_INFO(gf_vect_dot_prod_neon); return PROVIDER_INFO(gf_vect_dot_prod_neon);
#endif #endif
return PROVIDER_BASIC(gf_vect_dot_prod); return PROVIDER_BASIC(gf_vect_dot_prod);
} }
DEFINE_INTERFACE_DISPATCHER(gf_vect_mad) DEFINE_INTERFACE_DISPATCHER(gf_vect_mad)
@ -61,7 +60,6 @@ DEFINE_INTERFACE_DISPATCHER(gf_vect_mad)
return PROVIDER_INFO(gf_vect_mad_neon); return PROVIDER_INFO(gf_vect_mad_neon);
#endif #endif
return PROVIDER_BASIC(gf_vect_mad); return PROVIDER_BASIC(gf_vect_mad);
} }
DEFINE_INTERFACE_DISPATCHER(ec_encode_data) DEFINE_INTERFACE_DISPATCHER(ec_encode_data)
@ -79,7 +77,6 @@ DEFINE_INTERFACE_DISPATCHER(ec_encode_data)
return PROVIDER_INFO(ec_encode_data_neon); return PROVIDER_INFO(ec_encode_data_neon);
#endif #endif
return PROVIDER_BASIC(ec_encode_data); return PROVIDER_BASIC(ec_encode_data);
} }
DEFINE_INTERFACE_DISPATCHER(ec_encode_data_update) DEFINE_INTERFACE_DISPATCHER(ec_encode_data_update)
@ -97,7 +94,6 @@ DEFINE_INTERFACE_DISPATCHER(ec_encode_data_update)
return PROVIDER_INFO(ec_encode_data_update_neon); return PROVIDER_INFO(ec_encode_data_update_neon);
#endif #endif
return PROVIDER_BASIC(ec_encode_data_update); return PROVIDER_BASIC(ec_encode_data_update);
} }
DEFINE_INTERFACE_DISPATCHER(gf_vect_mul) DEFINE_INTERFACE_DISPATCHER(gf_vect_mul)
@ -115,10 +111,6 @@ DEFINE_INTERFACE_DISPATCHER(gf_vect_mul)
return PROVIDER_INFO(gf_vect_mul_neon); return PROVIDER_INFO(gf_vect_mul_neon);
#endif #endif
return PROVIDER_BASIC(gf_vect_mul); return PROVIDER_BASIC(gf_vect_mul);
} }
DEFINE_INTERFACE_DISPATCHER(ec_init_tables) DEFINE_INTERFACE_DISPATCHER(ec_init_tables) { return PROVIDER_BASIC(ec_init_tables); }
{
return PROVIDER_BASIC(ec_init_tables);
}

View File

@ -29,30 +29,42 @@
#include "erasure_code.h" #include "erasure_code.h"
/*external function*/ /*external function*/
extern void gf_vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, extern void
unsigned char **src, unsigned char *dest); gf_vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char **src,
extern void gf_2vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char *dest);
unsigned char **src, unsigned char **dest); extern void
extern void gf_3vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, gf_2vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **src, unsigned char **dest); unsigned char **dest);
extern void gf_4vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, extern void
unsigned char **src, unsigned char **dest); gf_3vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char **src,
extern void gf_5vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char **dest);
unsigned char **src, unsigned char **dest); extern void
extern void gf_vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, gf_4vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char *src, unsigned char *dest); unsigned char **dest);
extern void gf_2vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, extern void
unsigned char *src, unsigned char **dest); gf_5vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char **src,
extern void gf_3vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char **dest);
unsigned char *src, unsigned char **dest); extern void
extern void gf_4vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, gf_vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *src, unsigned char **dest); unsigned char *dest);
extern void gf_5vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, extern void
unsigned char *src, unsigned char **dest); gf_2vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
extern void gf_6vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char **dest);
unsigned char *src, unsigned char **dest); extern void
gf_3vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_4vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_5vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_6vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
void ec_encode_data_neon(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data, void
ec_encode_data_neon(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding) unsigned char **coding)
{ {
if (len < 16) { if (len < 16) {
@ -89,7 +101,8 @@ void ec_encode_data_neon(int len, int k, int rows, unsigned char *g_tbls, unsign
} }
} }
void ec_encode_data_update_neon(int len, int k, int rows, int vec_i, unsigned char *g_tbls, void
ec_encode_data_update_neon(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
unsigned char *data, unsigned char **coding) unsigned char *data, unsigned char **coding)
{ {
if (len < 16) { if (len < 16) {
@ -127,36 +140,51 @@ void ec_encode_data_update_neon(int len, int k, int rows, int vec_i, unsigned ch
} }
/* SVE */ /* SVE */
extern void gf_vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, extern void
unsigned char **src, unsigned char *dest); gf_vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
extern void gf_2vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char *dest);
unsigned char **src, unsigned char **dest); extern void
extern void gf_3vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, gf_2vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **src, unsigned char **dest); unsigned char **dest);
extern void gf_4vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, extern void
unsigned char **src, unsigned char **dest); gf_3vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
extern void gf_5vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **dest);
unsigned char **src, unsigned char **dest); extern void
extern void gf_6vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, gf_4vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **src, unsigned char **dest); unsigned char **dest);
extern void gf_7vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, extern void
unsigned char **src, unsigned char **dest); gf_5vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
extern void gf_8vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **dest);
unsigned char **src, unsigned char **dest); extern void
extern void gf_vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, gf_6vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char *src, unsigned char *dest); unsigned char **dest);
extern void gf_2vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, extern void
unsigned char *src, unsigned char **dest); gf_7vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
extern void gf_3vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char **dest);
unsigned char *src, unsigned char **dest); extern void
extern void gf_4vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, gf_8vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char *src, unsigned char **dest); unsigned char **dest);
extern void gf_5vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, extern void
unsigned char *src, unsigned char **dest); gf_vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
extern void gf_6vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *dest);
unsigned char *src, unsigned char **dest); extern void
gf_2vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_3vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_4vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_5vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_6vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
void ec_encode_data_sve(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data, void
ec_encode_data_sve(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding) unsigned char **coding)
{ {
if (len < 16) { if (len < 16) {
@ -226,7 +254,8 @@ void ec_encode_data_sve(int len, int k, int rows, unsigned char *g_tbls, unsigne
} }
} }
void ec_encode_data_update_sve(int len, int k, int rows, int vec_i, unsigned char *g_tbls, void
ec_encode_data_update_sve(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
unsigned char *data, unsigned char **coding) unsigned char *data, unsigned char **coding)
{ {
if (len < 16) { if (len < 16) {

View File

@ -34,7 +34,8 @@
#include "erasure_code.h" #include "erasure_code.h"
#include "ec_base.h" // for GF tables #include "ec_base.h" // for GF tables
void ec_init_tables_base(int k, int rows, unsigned char *a, unsigned char *g_tbls) void
ec_init_tables_base(int k, int rows, unsigned char *a, unsigned char *g_tbls)
{ {
int i, j; int i, j;
@ -46,7 +47,8 @@ void ec_init_tables_base(int k, int rows, unsigned char *a, unsigned char *g_tbl
} }
} }
unsigned char gf_mul(unsigned char a, unsigned char b) unsigned char
gf_mul(unsigned char a, unsigned char b)
{ {
#ifndef GF_LARGE_TABLES #ifndef GF_LARGE_TABLES
int i; int i;
@ -60,7 +62,8 @@ unsigned char gf_mul(unsigned char a, unsigned char b)
#endif #endif
} }
unsigned char gf_inv(unsigned char a) unsigned char
gf_inv(unsigned char a)
{ {
#ifndef GF_LARGE_TABLES #ifndef GF_LARGE_TABLES
if (a == 0) if (a == 0)
@ -72,7 +75,8 @@ unsigned char gf_inv(unsigned char a)
#endif #endif
} }
void gf_gen_rs_matrix(unsigned char *a, int m, int k) void
gf_gen_rs_matrix(unsigned char *a, int m, int k)
{ {
int i, j; int i, j;
unsigned char p, gen = 1; unsigned char p, gen = 1;
@ -91,7 +95,8 @@ void gf_gen_rs_matrix(unsigned char *a, int m, int k)
} }
} }
void gf_gen_cauchy1_matrix(unsigned char *a, int m, int k) void
gf_gen_cauchy1_matrix(unsigned char *a, int m, int k)
{ {
int i, j; int i, j;
unsigned char *p; unsigned char *p;
@ -106,10 +111,10 @@ void gf_gen_cauchy1_matrix(unsigned char *a, int m, int k)
for (i = k; i < m; i++) for (i = k; i < m; i++)
for (j = 0; j < k; j++) for (j = 0; j < k; j++)
*p++ = gf_inv(i ^ j); *p++ = gf_inv(i ^ j);
} }
int gf_invert_matrix(unsigned char *in_mat, unsigned char *out_mat, const int n) int
gf_invert_matrix(unsigned char *in_mat, unsigned char *out_mat, const int n)
{ {
int i, j, k; int i, j, k;
unsigned char temp; unsigned char temp;
@ -167,7 +172,8 @@ int gf_invert_matrix(unsigned char *in_mat, unsigned char *out_mat, const int n)
// Calculates const table gftbl in GF(2^8) from single input A // Calculates const table gftbl in GF(2^8) from single input A
// gftbl(A) = {A{00}, A{01}, A{02}, ... , A{0f} }, {A{00}, A{10}, A{20}, ... , A{f0} } // gftbl(A) = {A{00}, A{01}, A{02}, ... , A{0f} }, {A{00}, A{10}, A{20}, ... , A{f0} }
void gf_vect_mul_init(unsigned char c, unsigned char *tbl) void
gf_vect_mul_init(unsigned char c, unsigned char *tbl)
{ {
unsigned char c2 = (c << 1) ^ ((c & 0x80) ? 0x1d : 0); // Mult by GF{2} unsigned char c2 = (c << 1) ^ ((c & 0x80) ? 0x1d : 0); // Mult by GF{2}
unsigned char c4 = (c2 << 1) ^ ((c2 & 0x80) ? 0x1d : 0); // Mult by GF{2} unsigned char c4 = (c2 << 1) ^ ((c2 & 0x80) ? 0x1d : 0); // Mult by GF{2}
@ -205,8 +211,7 @@ void gf_vect_mul_init(unsigned char c, unsigned char *tbl)
#else // 32-bit or other #else // 32-bit or other
unsigned char c3, c5, c6, c7, c9, c10, c11, c12, c13, c14, c15; unsigned char c3, c5, c6, c7, c9, c10, c11, c12, c13, c14, c15;
unsigned char c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, unsigned char c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31;
c31;
c3 = c2 ^ c; c3 = c2 ^ c;
c5 = c4 ^ c; c5 = c4 ^ c;
@ -274,8 +279,8 @@ void gf_vect_mul_init(unsigned char c, unsigned char *tbl)
#endif //__WORDSIZE == 64 || _WIN64 || __x86_64__ #endif //__WORDSIZE == 64 || _WIN64 || __x86_64__
} }
void gf_vect_dot_prod_base(int len, int vlen, unsigned char *v, void
unsigned char **src, unsigned char *dest) gf_vect_dot_prod_base(int len, int vlen, unsigned char *v, unsigned char **src, unsigned char *dest)
{ {
int i, j; int i, j;
unsigned char s; unsigned char s;
@ -288,8 +293,9 @@ void gf_vect_dot_prod_base(int len, int vlen, unsigned char *v,
} }
} }
void gf_vect_mad_base(int len, int vec, int vec_i, void
unsigned char *v, unsigned char *src, unsigned char *dest) gf_vect_mad_base(int len, int vec, int vec_i, unsigned char *v, unsigned char *src,
unsigned char *dest)
{ {
int i; int i;
unsigned char s; unsigned char s;
@ -300,8 +306,9 @@ void gf_vect_mad_base(int len, int vec, int vec_i,
} }
} }
void ec_encode_data_base(int len, int srcs, int dests, unsigned char *v, void
unsigned char **src, unsigned char **dest) ec_encode_data_base(int len, int srcs, int dests, unsigned char *v, unsigned char **src,
unsigned char **dest)
{ {
int i, j, l; int i, j, l;
unsigned char s; unsigned char s;
@ -317,7 +324,8 @@ void ec_encode_data_base(int len, int srcs, int dests, unsigned char *v,
} }
} }
void ec_encode_data_update_base(int len, int k, int rows, int vec_i, unsigned char *v, void
ec_encode_data_update_base(int len, int k, int rows, int vec_i, unsigned char *v,
unsigned char *data, unsigned char **dest) unsigned char *data, unsigned char **dest)
{ {
int i, l; int i, l;
@ -333,7 +341,8 @@ void ec_encode_data_update_base(int len, int k, int rows, int vec_i, unsigned ch
} }
} }
int gf_vect_mul_base(int len, unsigned char *a, unsigned char *src, unsigned char *dest) int
gf_vect_mul_base(int len, unsigned char *a, unsigned char *src, unsigned char *dest)
{ {
// 2nd element of table array is ref value used to fill it in // 2nd element of table array is ref value used to fill it in
unsigned char c = a[1]; unsigned char c = a[1];

File diff suppressed because it is too large Load Diff

View File

@ -29,37 +29,40 @@
#include "erasure_code.h" #include "erasure_code.h"
void gf_vect_dot_prod(int len, int vlen, unsigned char *v, void
unsigned char **src, unsigned char *dest) gf_vect_dot_prod(int len, int vlen, unsigned char *v, unsigned char **src, unsigned char *dest)
{ {
gf_vect_dot_prod_base(len, vlen, v, src, dest); gf_vect_dot_prod_base(len, vlen, v, src, dest);
} }
void gf_vect_mad(int len, int vec, int vec_i, void
unsigned char *v, unsigned char *src, unsigned char *dest) gf_vect_mad(int len, int vec, int vec_i, unsigned char *v, unsigned char *src, unsigned char *dest)
{ {
gf_vect_mad_base(len, vec, vec_i, v, src, dest); gf_vect_mad_base(len, vec, vec_i, v, src, dest);
} }
void ec_encode_data(int len, int srcs, int dests, unsigned char *v, void
unsigned char **src, unsigned char **dest) ec_encode_data(int len, int srcs, int dests, unsigned char *v, unsigned char **src,
unsigned char **dest)
{ {
ec_encode_data_base(len, srcs, dests, v, src, dest); ec_encode_data_base(len, srcs, dests, v, src, dest);
} }
void ec_encode_data_update(int len, int k, int rows, int vec_i, unsigned char *v, void
unsigned char *data, unsigned char **dest) ec_encode_data_update(int len, int k, int rows, int vec_i, unsigned char *v, unsigned char *data,
unsigned char **dest)
{ {
ec_encode_data_update_base(len, k, rows, vec_i, v, data, dest); ec_encode_data_update_base(len, k, rows, vec_i, v, data, dest);
} }
int gf_vect_mul(int len, unsigned char *a, void *src, void *dest) int
gf_vect_mul(int len, unsigned char *a, void *src, void *dest)
{ {
return gf_vect_mul_base(len, a, (unsigned char *) src, (unsigned char *) dest); return gf_vect_mul_base(len, a, (unsigned char *) src, (unsigned char *) dest);
} }
void ec_init_tables(int k, int rows, unsigned char *a, unsigned char *g_tbls) void
ec_init_tables(int k, int rows, unsigned char *a, unsigned char *g_tbls)
{ {
return ec_init_tables_base(k, rows, a, g_tbls); return ec_init_tables_base(k, rows, a, g_tbls);
} }

View File

@ -31,7 +31,8 @@
#include "ec_base.h" /* for GF tables */ #include "ec_base.h" /* for GF tables */
#if __x86_64__ || __i386__ || _M_X64 || _M_IX86 #if __x86_64__ || __i386__ || _M_X64 || _M_IX86
void ec_encode_data_sse(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data, void
ec_encode_data_sse(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding) unsigned char **coding)
{ {
@ -65,10 +66,10 @@ void ec_encode_data_sse(int len, int k, int rows, unsigned char *g_tbls, unsigne
case 0: case 0:
break; break;
} }
} }
void ec_encode_data_avx(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data, void
ec_encode_data_avx(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding) unsigned char **coding)
{ {
if (len < 16) { if (len < 16) {
@ -101,10 +102,10 @@ void ec_encode_data_avx(int len, int k, int rows, unsigned char *g_tbls, unsigne
case 0: case 0:
break; break;
} }
} }
void ec_encode_data_avx2(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data, void
ec_encode_data_avx2(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding) unsigned char **coding)
{ {
@ -138,38 +139,50 @@ void ec_encode_data_avx2(int len, int k, int rows, unsigned char *g_tbls, unsign
case 0: case 0:
break; break;
} }
} }
#ifdef HAVE_AS_KNOWS_AVX512 #ifdef HAVE_AS_KNOWS_AVX512
extern int gf_vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data, extern int
gf_vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char *dest); unsigned char *dest);
extern int gf_2vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, extern int
unsigned char **data, unsigned char **coding); gf_2vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data,
extern int gf_3vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **coding);
unsigned char **data, unsigned char **coding); extern int
extern int gf_4vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, gf_3vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **data, unsigned char **coding); unsigned char **coding);
extern int gf_5vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, extern int
unsigned char **data, unsigned char **coding); gf_4vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data,
extern int gf_6vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **coding);
unsigned char **data, unsigned char **coding); extern int
extern void gf_vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, gf_5vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char *src, unsigned char *dest); unsigned char **coding);
extern void gf_2vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, extern int
unsigned char *src, unsigned char **dest); gf_6vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data,
extern void gf_3vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char **coding);
unsigned char *src, unsigned char **dest); extern void
extern void gf_4vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, gf_vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *src, unsigned char **dest); unsigned char *dest);
extern void gf_5vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, extern void
unsigned char *src, unsigned char **dest); gf_2vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
extern void gf_6vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char **dest);
unsigned char *src, unsigned char **dest); extern void
gf_3vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_4vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_5vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_6vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
void ec_encode_data_avx512(int len, int k, int rows, unsigned char *g_tbls, void
unsigned char **data, unsigned char **coding) ec_encode_data_avx512(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding)
{ {
if (len < 64) { if (len < 64) {
@ -204,7 +217,8 @@ void ec_encode_data_avx512(int len, int k, int rows, unsigned char *g_tbls,
} }
} }
void ec_encode_data_update_avx512(int len, int k, int rows, int vec_i, unsigned char *g_tbls, void
ec_encode_data_update_avx512(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
unsigned char *data, unsigned char **coding) unsigned char *data, unsigned char **coding)
{ {
if (len < 64) { if (len < 64) {
@ -241,50 +255,71 @@ void ec_encode_data_update_avx512(int len, int k, int rows, int vec_i, unsigned
#if AS_FEATURE_LEVEL >= 10 #if AS_FEATURE_LEVEL >= 10
extern void gf_vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, extern void
unsigned char **data, unsigned char *dest); gf_vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
extern void gf_2vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char *dest);
unsigned char **data, unsigned char **coding); extern void
extern void gf_3vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, gf_2vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **data, unsigned char **coding); unsigned char **coding);
extern void gf_4vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, extern void
unsigned char **data, unsigned char **coding); gf_3vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
extern void gf_5vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char **coding);
unsigned char **data, unsigned char **coding); extern void
extern void gf_6vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, gf_4vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **data, unsigned char **coding); unsigned char **coding);
extern void
gf_5vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding);
extern void
gf_6vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding);
extern void gf_vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, extern void
unsigned char *src, unsigned char *dest); gf_vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
extern void gf_2vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *dest);
unsigned char *src, unsigned char **dest); extern void
extern void gf_3vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, gf_2vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *src, unsigned char **dest); unsigned char **dest);
extern void gf_4vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, extern void
unsigned char *src, unsigned char **dest); gf_3vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
extern void gf_5vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char **dest);
unsigned char *src, unsigned char **dest); extern void
extern void gf_6vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, gf_4vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *src, unsigned char **dest); unsigned char **dest);
extern void
gf_5vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_6vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void gf_vect_dot_prod_avx2_gfni(int len, int k, unsigned char *g_tbls, extern void
unsigned char **data, unsigned char *dest); gf_vect_dot_prod_avx2_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
extern void gf_2vect_dot_prod_avx2_gfni(int len, int k, unsigned char *g_tbls, unsigned char *dest);
unsigned char **data, unsigned char **coding); extern void
extern void gf_3vect_dot_prod_avx2_gfni(int len, int k, unsigned char *g_tbls, gf_2vect_dot_prod_avx2_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **data, unsigned char **coding); unsigned char **coding);
extern void gf_vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, extern void
unsigned char *src, unsigned char *dest); gf_3vect_dot_prod_avx2_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
extern void gf_2vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char **coding);
unsigned char *src, unsigned char **dest); extern void
extern void gf_3vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, gf_vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *src, unsigned char **dest); unsigned char *dest);
extern void gf_4vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, extern void
unsigned char *src, unsigned char **dest); gf_2vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
extern void gf_5vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char **dest);
unsigned char *src, unsigned char **dest); extern void
gf_3vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_4vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_5vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
void ec_init_tables_gfni(int k, int rows, unsigned char *a, unsigned char *g_tbls) void
ec_init_tables_gfni(int k, int rows, unsigned char *a, unsigned char *g_tbls)
{ {
int i, j; int i, j;
@ -293,11 +328,11 @@ void ec_init_tables_gfni(int k, int rows, unsigned char *a, unsigned char *g_tbl
for (i = 0; i < rows; i++) for (i = 0; i < rows; i++)
for (j = 0; j < k; j++) for (j = 0; j < k; j++)
*(g64++) = gf_table_gfni[*a++]; *(g64++) = gf_table_gfni[*a++];
} }
void ec_encode_data_avx512_gfni(int len, int k, int rows, unsigned char *g_tbls, void
unsigned char **data, unsigned char **coding) ec_encode_data_avx512_gfni(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding)
{ {
while (rows >= 6) { while (rows >= 6) {
@ -328,8 +363,9 @@ void ec_encode_data_avx512_gfni(int len, int k, int rows, unsigned char *g_tbls,
} }
} }
void ec_encode_data_avx2_gfni(int len, int k, int rows, unsigned char *g_tbls, void
unsigned char **data, unsigned char **coding) ec_encode_data_avx2_gfni(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding)
{ {
while (rows >= 3) { while (rows >= 3) {
gf_3vect_dot_prod_avx2_gfni(len, k, g_tbls, data, coding); gf_3vect_dot_prod_avx2_gfni(len, k, g_tbls, data, coding);
@ -350,9 +386,9 @@ void ec_encode_data_avx2_gfni(int len, int k, int rows, unsigned char *g_tbls,
} }
} }
void ec_encode_data_update_avx512_gfni(int len, int k, int rows, int vec_i, void
unsigned char *g_tbls, unsigned char *data, ec_encode_data_update_avx512_gfni(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
unsigned char **coding) unsigned char *data, unsigned char **coding)
{ {
while (rows >= 6) { while (rows >= 6) {
gf_6vect_mad_avx512_gfni(len, k, vec_i, g_tbls, data, coding); gf_6vect_mad_avx512_gfni(len, k, vec_i, g_tbls, data, coding);
@ -382,9 +418,9 @@ void ec_encode_data_update_avx512_gfni(int len, int k, int rows, int vec_i,
} }
} }
void ec_encode_data_update_avx2_gfni(int len, int k, int rows, int vec_i, void
unsigned char *g_tbls, unsigned char *data, ec_encode_data_update_avx2_gfni(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
unsigned char **coding) unsigned char *data, unsigned char **coding)
{ {
while (rows >= 5) { while (rows >= 5) {
gf_5vect_mad_avx2_gfni(len, k, vec_i, g_tbls, data, coding); gf_5vect_mad_avx2_gfni(len, k, vec_i, g_tbls, data, coding);
@ -416,7 +452,8 @@ void ec_encode_data_update_avx2_gfni(int len, int k, int rows, int vec_i,
#if __WORDSIZE == 64 || _WIN64 || __x86_64__ #if __WORDSIZE == 64 || _WIN64 || __x86_64__
void ec_encode_data_update_sse(int len, int k, int rows, int vec_i, unsigned char *g_tbls, void
ec_encode_data_update_sse(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
unsigned char *data, unsigned char **coding) unsigned char *data, unsigned char **coding)
{ {
if (len < 16) { if (len < 16) {
@ -452,10 +489,10 @@ void ec_encode_data_update_sse(int len, int k, int rows, int vec_i, unsigned cha
case 0: case 0:
break; break;
} }
} }
void ec_encode_data_update_avx(int len, int k, int rows, int vec_i, unsigned char *g_tbls, void
ec_encode_data_update_avx(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
unsigned char *data, unsigned char **coding) unsigned char *data, unsigned char **coding)
{ {
if (len < 16) { if (len < 16) {
@ -490,10 +527,10 @@ void ec_encode_data_update_avx(int len, int k, int rows, int vec_i, unsigned cha
case 0: case 0:
break; break;
} }
} }
void ec_encode_data_update_avx2(int len, int k, int rows, int vec_i, unsigned char *g_tbls, void
ec_encode_data_update_avx2(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
unsigned char *data, unsigned char **coding) unsigned char *data, unsigned char **coding)
{ {
if (len < 32) { if (len < 32) {
@ -528,7 +565,6 @@ void ec_encode_data_update_avx2(int len, int k, int rows, int vec_i, unsigned ch
case 0: case 0:
break; break;
} }
} }
#endif //__WORDSIZE == 64 || _WIN64 || __x86_64__ #endif //__WORDSIZE == 64 || _WIN64 || __x86_64__

View File

@ -59,14 +59,16 @@
typedef unsigned char u8; typedef unsigned char u8;
void ec_encode_perf(int m, int k, u8 * a, u8 * g_tbls, u8 ** buffs) void
ec_encode_perf(int m, int k, u8 *a, u8 *g_tbls, u8 **buffs)
{ {
ec_init_tables_base(k, m - k, &a[k * k], g_tbls); ec_init_tables_base(k, m - k, &a[k * k], g_tbls);
ec_encode_data_base(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); ec_encode_data_base(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]);
} }
int ec_decode_perf(int m, int k, u8 * a, u8 * g_tbls, u8 ** buffs, u8 * src_in_err, int
u8 * src_err_list, int nerrs, u8 ** temp_buffs) ec_decode_perf(int m, int k, u8 *a, u8 *g_tbls, u8 **buffs, u8 *src_in_err, u8 *src_err_list,
int nerrs, u8 **temp_buffs)
{ {
int i, j, r; int i, j, r;
u8 b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; u8 b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX];
@ -95,7 +97,8 @@ int ec_decode_perf(int m, int k, u8 * a, u8 * g_tbls, u8 ** buffs, u8 * src_in_e
return 0; return 0;
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int i, j, m, k, nerrs, check; int i, j, m, k, nerrs, check;
void *buf; void *buf;
@ -151,8 +154,8 @@ int main(int argc, char *argv[])
perf_print(start, (long long) (TEST_LEN(m)) * (m)); perf_print(start, (long long) (TEST_LEN(m)) * (m));
// Start decode test // Start decode test
BENCHMARK(&start, BENCHMARK_TIME, check = BENCHMARK(&start, BENCHMARK_TIME,
ec_decode_perf(m, k, a, g_tbls, buffs, src_in_err, src_err_list, nerrs, check = ec_decode_perf(m, k, a, g_tbls, buffs, src_in_err, src_err_list, nerrs,
temp_buffs)); temp_buffs));
if (check == BAD_MATRIX) { if (check == BAD_MATRIX) {

View File

@ -65,7 +65,8 @@
typedef unsigned char u8; typedef unsigned char u8;
void dump(unsigned char *buf, int len) void
dump(unsigned char *buf, int len)
{ {
int i; int i;
for (i = 0; i < len;) { for (i = 0; i < len;) {
@ -76,7 +77,8 @@ void dump(unsigned char *buf, int len)
printf("\n"); printf("\n");
} }
void dump_matrix(unsigned char **s, int k, int m) void
dump_matrix(unsigned char **s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -88,7 +90,8 @@ void dump_matrix(unsigned char **s, int k, int m)
printf("\n"); printf("\n");
} }
void dump_u8xu8(unsigned char *s, int k, int m) void
dump_u8xu8(unsigned char *s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -101,8 +104,9 @@ void dump_u8xu8(unsigned char *s, int k, int m)
} }
// Generate Random errors // Generate Random errors
static void gen_err_list(unsigned char *src_err_list, static void
unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs, int k, int m) gen_err_list(unsigned char *src_err_list, unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs,
int k, int m)
{ {
int i, err; int i, err;
int nerrs = 0, nsrcerrs = 0; int nerrs = 0, nsrcerrs = 0;
@ -118,7 +122,8 @@ static void gen_err_list(unsigned char *src_err_list,
} }
} }
if (nerrs == 0) { // should have at least one error if (nerrs == 0) { // should have at least one error
while ((err = (rand() % KMAX)) >= m) ; while ((err = (rand() % KMAX)) >= m)
;
src_err_list[nerrs++] = err; src_err_list[nerrs++] = err;
src_in_err[err] = 1; src_in_err[err] = 1;
if (err < k) if (err < k)
@ -131,13 +136,11 @@ static void gen_err_list(unsigned char *src_err_list,
#define NO_INVERT_MATRIX -2 #define NO_INVERT_MATRIX -2
// Generate decode matrix from encode matrix // Generate decode matrix from encode matrix
static int gf_gen_decode_matrix(unsigned char *encode_matrix, static int
unsigned char *decode_matrix, gf_gen_decode_matrix(unsigned char *encode_matrix, unsigned char *decode_matrix,
unsigned char *invert_matrix, unsigned char *invert_matrix, unsigned int *decode_index,
unsigned int *decode_index, unsigned char *src_err_list, unsigned char *src_in_err, int nerrs,
unsigned char *src_err_list, int nsrcerrs, int k, int m)
unsigned char *src_in_err,
int nerrs, int nsrcerrs, int k, int m)
{ {
int i, j, p; int i, j, p;
int r; int r;
@ -189,7 +192,6 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
decode_index[k - 1] += incr; decode_index[k - 1] += incr;
for (j = 0; j < k; j++) for (j = 0; j < k; j++)
b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j]; b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j];
}; };
for (i = 0; i < nsrcerrs; i++) { for (i = 0; i < nsrcerrs; i++) {
@ -213,7 +215,8 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
return 0; return 0;
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int re = 0; int re = 0;
int i, j, p, rtest, m, k; int i, j, p, rtest, m, k;
@ -257,8 +260,8 @@ int main(int argc, char *argv[])
decode_matrix = malloc(MMAX * KMAX); decode_matrix = malloc(MMAX * KMAX);
invert_matrix = malloc(MMAX * KMAX); invert_matrix = malloc(MMAX * KMAX);
g_tbls = malloc(KMAX * TEST_SOURCES * 32); g_tbls = malloc(KMAX * TEST_SOURCES * 32);
if (encode_matrix == NULL || decode_matrix == NULL if (encode_matrix == NULL || decode_matrix == NULL || invert_matrix == NULL ||
|| invert_matrix == NULL || g_tbls == NULL) { g_tbls == NULL) {
printf("Test failure! Error with malloc\n"); printf("Test failure! Error with malloc\n");
return -1; return -1;
} }
@ -289,9 +292,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_in_err, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
return -1; return -1;
@ -357,9 +359,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_in_err, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
return -1; return -1;
@ -400,8 +401,10 @@ int main(int argc, char *argv[])
// Do more random tests // Do more random tests
for (rtest = 0; rtest < RANDOMS; rtest++) { for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ; while ((m = (rand() % MMAX)) < 2)
while ((k = (rand() % KMAX)) >= m || k < 1) ; ;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX) if (m > MMAX || k > KMAX)
continue; continue;
@ -427,9 +430,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
return -1; return -1;
@ -505,17 +507,16 @@ int main(int argc, char *argv[])
ec_init_tables_base(k, m - k, &encode_matrix[k * k], g_tbls); ec_init_tables_base(k, m - k, &encode_matrix[k * k], g_tbls);
// Perform matrix dot_prod for EC encoding // Perform matrix dot_prod for EC encoding
// using g_tbls from encode matrix a // using g_tbls from encode matrix a
ec_encode_data_base(size, k, m - k, g_tbls, efence_buffs, ec_encode_data_base(size, k, m - k, g_tbls, efence_buffs, &efence_buffs[k]);
&efence_buffs[k]);
// Random errors // Random errors
memset(src_in_err, 0, TEST_SOURCES); memset(src_in_err, 0, TEST_SOURCES);
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix,
invert_matrix, decode_index, src_err_list, decode_index, src_err_list, src_in_err, nerrs,
src_in_err, nerrs, nsrcerrs, k, m); nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
return -1; return -1;
@ -533,11 +534,10 @@ int main(int argc, char *argv[])
for (i = 0; i < nerrs; i++) { for (i = 0; i < nerrs; i++) {
if (0 != if (0 != memcmp(temp_buffs[k + i], efence_buffs[src_err_list[i]],
memcmp(temp_buffs[k + i], efence_buffs[src_err_list[i]],
size)) { size)) {
printf("Efence: Fail error recovery (%d, %d, %d)\n", m, printf("Efence: Fail error recovery (%d, %d, %d)\n", m, k,
k, nerrs); nerrs);
printf("size = %d\n", size); printf("size = %d\n", size);
@ -562,14 +562,15 @@ int main(int argc, char *argv[])
} }
} }
} }
} }
// Test rand ptr alignment if available // Test rand ptr alignment if available
for (rtest = 0; rtest < RANDOMS; rtest++) { for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ; while ((m = (rand() % MMAX)) < 2)
while ((k = (rand() % KMAX)) >= m || k < 1) ; ;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX) if (m > MMAX || k > KMAX)
continue; continue;
@ -605,9 +606,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
return -1; return -1;
@ -660,8 +660,7 @@ int main(int argc, char *argv[])
printf("Fail rand ualign encode pad start\n"); printf("Fail rand ualign encode pad start\n");
return -1; return -1;
} }
if (memcmp if (memcmp(buffs[i] + offset + size, temp_buffs[0],
(buffs[i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) { PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign encode pad end\n"); printf("Fail rand ualign encode pad end\n");
return -1; return -1;
@ -675,8 +674,7 @@ int main(int argc, char *argv[])
printf("Fail rand ualign decode pad start\n"); printf("Fail rand ualign decode pad start\n");
return -1; return -1;
} }
if (memcmp if (memcmp(temp_buffs[k + i] + offset + size, temp_buffs[0],
(temp_buffs[k + i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) { PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign decode pad end\n"); printf("Fail rand ualign decode pad end\n");
return -1; return -1;
@ -693,8 +691,10 @@ int main(int argc, char *argv[])
align = (LEN_ALIGN_CHK_B != 0) ? 13 : 16; align = (LEN_ALIGN_CHK_B != 0) ? 13 : 16;
for (size = TEST_LEN; size > 0; size -= align) { for (size = TEST_LEN; size > 0; size -= align) {
while ((m = (rand() % MMAX)) < 2) ; while ((m = (rand() % MMAX)) < 2)
while ((k = (rand() % KMAX)) >= m || k < 1) ; ;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX) if (m > MMAX || k > KMAX)
continue; continue;
@ -718,9 +718,8 @@ int main(int argc, char *argv[])
memset(src_in_err, 0, TEST_SOURCES); memset(src_in_err, 0, TEST_SOURCES);
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
return -1; return -1;

View File

@ -61,26 +61,30 @@
typedef unsigned char u8; typedef unsigned char u8;
void usage(const char *app_name) void
usage(const char *app_name)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: %s [options]\n" "Usage: %s [options]\n"
" -h Help\n" " -h Help\n"
" -k <val> Number of source buffers\n" " -k <val> Number of source buffers\n"
" -p <val> Number of parity buffers\n" " -p <val> Number of parity buffers\n"
" -e <val> Number of simulated buffers with errors (cannot be higher than p or k)\n", " -e <val> Number of simulated buffers with errors (cannot be higher than p or "
"k)\n",
app_name); app_name);
} }
void ec_encode_perf(int m, int k, u8 * a, u8 * g_tbls, u8 ** buffs, struct perf *start) void
ec_encode_perf(int m, int k, u8 *a, u8 *g_tbls, u8 **buffs, struct perf *start)
{ {
ec_init_tables(k, m - k, &a[k * k], g_tbls); ec_init_tables(k, m - k, &a[k * k], g_tbls);
BENCHMARK(start, BENCHMARK_TIME, BENCHMARK(start, BENCHMARK_TIME,
ec_encode_data(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k])); ec_encode_data(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]));
} }
int ec_decode_perf(int m, int k, u8 * a, u8 * g_tbls, u8 ** buffs, u8 * src_in_err, int
u8 * src_err_list, int nerrs, u8 ** temp_buffs, struct perf *start) ec_decode_perf(int m, int k, u8 *a, u8 *g_tbls, u8 **buffs, u8 *src_in_err, u8 *src_err_list,
int nerrs, u8 **temp_buffs, struct perf *start)
{ {
int i, j, r; int i, j, r;
u8 b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; u8 b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX];
@ -110,7 +114,8 @@ int ec_decode_perf(int m, int k, u8 * a, u8 * g_tbls, u8 ** buffs, u8 * src_in_e
return 0; return 0;
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int i, j, m, k, p, nerrs, check, ret = -1; int i, j, m, k, p, nerrs, check, ret = -1;
void *buf; void *buf;
@ -144,8 +149,7 @@ int main(int argc, char *argv[])
} }
if (nerrs > k) { if (nerrs > k) {
printf printf("Number of errors (%d) cannot be higher than number of data buffers (%d)\n",
("Number of errors (%d) cannot be higher than number of data buffers (%d)\n",
nerrs, k); nerrs, k);
return -1; return -1;
} }
@ -166,8 +170,8 @@ int main(int argc, char *argv[])
} }
if (nerrs > p) { if (nerrs > p) {
printf printf("Number of errors (%d) cannot be higher than number of parity buffers "
("Number of errors (%d) cannot be higher than number of parity buffers (%d)\n", "(%d)\n",
nerrs, p); nerrs, p);
return -1; return -1;
} }
@ -198,8 +202,8 @@ int main(int argc, char *argv[])
err_list[i++] = next_err; err_list[i++] = next_err;
} }
printf("Testing with %u data buffers and %u parity buffers (num errors = %u, in [ ", k, printf("Testing with %u data buffers and %u parity buffers (num errors = %u, in [ ", k, p,
p, nerrs); nerrs);
for (i = 0; i < nerrs; i++) for (i = 0; i < nerrs; i++)
printf("%d ", (int) err_list[i]); printf("%d ", (int) err_list[i]);
@ -242,8 +246,8 @@ int main(int argc, char *argv[])
perf_print(start, (long long) (TEST_LEN(m)) * (m)); perf_print(start, (long long) (TEST_LEN(m)) * (m));
// Start decode test // Start decode test
check = ec_decode_perf(m, k, a, g_tbls, buffs, src_in_err, src_err_list, nerrs, check = ec_decode_perf(m, k, a, g_tbls, buffs, src_in_err, src_err_list, nerrs, temp_buffs,
temp_buffs, &start); &start);
if (check == BAD_MATRIX) { if (check == BAD_MATRIX) {
printf("BAD MATRIX\n"); printf("BAD MATRIX\n");

View File

@ -66,7 +66,8 @@
typedef unsigned char u8; typedef unsigned char u8;
void dump(unsigned char *buf, int len) void
dump(unsigned char *buf, int len)
{ {
int i; int i;
for (i = 0; i < len;) { for (i = 0; i < len;) {
@ -77,7 +78,8 @@ void dump(unsigned char *buf, int len)
printf("\n"); printf("\n");
} }
void dump_matrix(unsigned char **s, int k, int m) void
dump_matrix(unsigned char **s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -89,7 +91,8 @@ void dump_matrix(unsigned char **s, int k, int m)
printf("\n"); printf("\n");
} }
void dump_u8xu8(unsigned char *s, int k, int m) void
dump_u8xu8(unsigned char *s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -102,8 +105,9 @@ void dump_u8xu8(unsigned char *s, int k, int m)
} }
// Generate Random errors // Generate Random errors
static void gen_err_list(unsigned char *src_err_list, static void
unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs, int k, int m) gen_err_list(unsigned char *src_err_list, unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs,
int k, int m)
{ {
int i, err; int i, err;
int nerrs = 0, nsrcerrs = 0; int nerrs = 0, nsrcerrs = 0;
@ -119,7 +123,8 @@ static void gen_err_list(unsigned char *src_err_list,
} }
} }
if (nerrs == 0) { // should have at least one error if (nerrs == 0) { // should have at least one error
while ((err = (rand() % KMAX)) >= m) ; while ((err = (rand() % KMAX)) >= m)
;
src_err_list[nerrs++] = err; src_err_list[nerrs++] = err;
src_in_err[err] = 1; src_in_err[err] = 1;
if (err < k) if (err < k)
@ -132,13 +137,11 @@ static void gen_err_list(unsigned char *src_err_list,
#define NO_INVERT_MATRIX -2 #define NO_INVERT_MATRIX -2
// Generate decode matrix from encode matrix // Generate decode matrix from encode matrix
static int gf_gen_decode_matrix(unsigned char *encode_matrix, static int
unsigned char *decode_matrix, gf_gen_decode_matrix(unsigned char *encode_matrix, unsigned char *decode_matrix,
unsigned char *invert_matrix, unsigned char *invert_matrix, unsigned int *decode_index,
unsigned int *decode_index, unsigned char *src_err_list, unsigned char *src_in_err, int nerrs,
unsigned char *src_err_list, int nsrcerrs, int k, int m)
unsigned char *src_in_err,
int nerrs, int nsrcerrs, int k, int m)
{ {
int i, j, p; int i, j, p;
int r; int r;
@ -190,7 +193,6 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
decode_index[k - 1] += incr; decode_index[k - 1] += incr;
for (j = 0; j < k; j++) for (j = 0; j < k; j++)
b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j]; b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j];
}; };
for (i = 0; i < nsrcerrs; i++) { for (i = 0; i < nsrcerrs; i++) {
@ -214,7 +216,8 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
return 0; return 0;
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int re = -1; int re = -1;
int i, j, p, rtest, m, k; int i, j, p, rtest, m, k;
@ -222,8 +225,8 @@ int main(int argc, char *argv[])
void *buf; void *buf;
unsigned int decode_index[MMAX]; unsigned int decode_index[MMAX];
unsigned char *temp_buffs[TEST_SOURCES] = { NULL }, *buffs[TEST_SOURCES] = { NULL }; unsigned char *temp_buffs[TEST_SOURCES] = { NULL }, *buffs[TEST_SOURCES] = { NULL };
unsigned char *encode_matrix = NULL, *decode_matrix = NULL, *invert_matrix = unsigned char *encode_matrix = NULL, *decode_matrix = NULL, *invert_matrix = NULL,
NULL, *g_tbls = NULL; *g_tbls = NULL;
unsigned char src_in_err[TEST_SOURCES], src_err_list[TEST_SOURCES]; unsigned char src_in_err[TEST_SOURCES], src_err_list[TEST_SOURCES];
unsigned char *recov[TEST_SOURCES]; unsigned char *recov[TEST_SOURCES];
@ -259,8 +262,8 @@ int main(int argc, char *argv[])
decode_matrix = malloc(MMAX * KMAX); decode_matrix = malloc(MMAX * KMAX);
invert_matrix = malloc(MMAX * KMAX); invert_matrix = malloc(MMAX * KMAX);
g_tbls = malloc(KMAX * TEST_SOURCES * 32); g_tbls = malloc(KMAX * TEST_SOURCES * 32);
if (encode_matrix == NULL || decode_matrix == NULL if (encode_matrix == NULL || decode_matrix == NULL || invert_matrix == NULL ||
|| invert_matrix == NULL || g_tbls == NULL) { g_tbls == NULL) {
printf("Test failure! Error with malloc\n"); printf("Test failure! Error with malloc\n");
goto exit; goto exit;
} }
@ -291,9 +294,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_in_err, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;
@ -362,9 +364,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_in_err, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;
@ -406,8 +407,10 @@ int main(int argc, char *argv[])
// Do more random tests // Do more random tests
for (rtest = 0; rtest < RANDOMS; rtest++) { for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ; while ((m = (rand() % MMAX)) < 2)
while ((k = (rand() % KMAX)) >= m || k < 1) ; ;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX) if (m > MMAX || k > KMAX)
continue; continue;
@ -433,9 +436,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;
@ -523,9 +525,9 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix,
invert_matrix, decode_index, src_err_list, decode_index, src_err_list, src_in_err, nerrs,
src_in_err, nerrs, nsrcerrs, k, m); nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;
@ -543,11 +545,10 @@ int main(int argc, char *argv[])
for (i = 0; i < nerrs; i++) { for (i = 0; i < nerrs; i++) {
if (0 != if (0 != memcmp(temp_buffs[k + i], efence_buffs[src_err_list[i]],
memcmp(temp_buffs[k + i], efence_buffs[src_err_list[i]],
size)) { size)) {
printf("Efence: Fail error recovery (%d, %d, %d)\n", m, printf("Efence: Fail error recovery (%d, %d, %d)\n", m, k,
k, nerrs); nerrs);
printf("size = %d\n", size); printf("size = %d\n", size);
@ -573,14 +574,15 @@ int main(int argc, char *argv[])
} }
} }
} }
} }
// Test rand ptr alignment if available // Test rand ptr alignment if available
for (rtest = 0; rtest < RANDOMS; rtest++) { for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ; while ((m = (rand() % MMAX)) < 2)
while ((k = (rand() % KMAX)) >= m || k < 1) ; ;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX) if (m > MMAX || k > KMAX)
continue; continue;
@ -616,9 +618,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;
@ -673,8 +674,7 @@ int main(int argc, char *argv[])
re = -1; re = -1;
goto exit; goto exit;
} }
if (memcmp if (memcmp(buffs[i] + offset + size, temp_buffs[0],
(buffs[i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) { PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign encode pad end\n"); printf("Fail rand ualign encode pad end\n");
re = -1; re = -1;
@ -690,8 +690,7 @@ int main(int argc, char *argv[])
re = -1; re = -1;
goto exit; goto exit;
} }
if (memcmp if (memcmp(temp_buffs[k + i] + offset + size, temp_buffs[0],
(temp_buffs[k + i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) { PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign decode pad end\n"); printf("Fail rand ualign decode pad end\n");
re = -1; re = -1;
@ -709,8 +708,10 @@ int main(int argc, char *argv[])
align = (LEN_ALIGN_CHK_B != 0) ? 13 : 16; align = (LEN_ALIGN_CHK_B != 0) ? 13 : 16;
for (size = TEST_LEN; size > 0; size -= align) { for (size = TEST_LEN; size > 0; size -= align) {
while ((m = (rand() % MMAX)) < 2) ; while ((m = (rand() % MMAX)) < 2)
while ((k = (rand() % KMAX)) >= m || k < 1) ; ;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX) if (m > MMAX || k > KMAX)
continue; continue;
@ -734,9 +735,8 @@ int main(int argc, char *argv[])
memset(src_in_err, 0, TEST_SOURCES); memset(src_in_err, 0, TEST_SOURCES);
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;

View File

@ -73,18 +73,21 @@
typedef unsigned char u8; typedef unsigned char u8;
void usage(const char *app_name) void
usage(const char *app_name)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: %s [options]\n" "Usage: %s [options]\n"
" -h Help\n" " -h Help\n"
" -k <val> Number of source buffers\n" " -k <val> Number of source buffers\n"
" -p <val> Number of parity buffers\n" " -p <val> Number of parity buffers\n"
" -e <val> Number of simulated buffers with errors (cannot be higher than p or k)\n", " -e <val> Number of simulated buffers with errors (cannot be higher than p or "
"k)\n",
app_name); app_name);
} }
void dump(unsigned char *buf, int len) void
dump(unsigned char *buf, int len)
{ {
int i; int i;
for (i = 0; i < len;) { for (i = 0; i < len;) {
@ -95,26 +98,29 @@ void dump(unsigned char *buf, int len)
printf("\n"); printf("\n");
} }
void encode_update_test_ref(int m, int k, u8 * g_tbls, u8 ** buffs, u8 * a) void
encode_update_test_ref(int m, int k, u8 *g_tbls, u8 **buffs, u8 *a)
{ {
ec_init_tables(k, m - k, &a[k * k], g_tbls); ec_init_tables(k, m - k, &a[k * k], g_tbls);
REF_FUNCTION(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]); REF_FUNCTION(TEST_LEN(m), k, m - k, g_tbls, buffs, &buffs[k]);
} }
void encode_update_test(int m, int k, u8 * g_tbls, u8 ** perf_update_buffs, u8 * a) void
encode_update_test(int m, int k, u8 *g_tbls, u8 **perf_update_buffs, u8 *a)
{ {
int i; int i;
// Make parity vects // Make parity vects
ec_init_tables(k, m - k, &a[k * k], g_tbls); ec_init_tables(k, m - k, &a[k * k], g_tbls);
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls, FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls, perf_update_buffs[i],
perf_update_buffs[i], &perf_update_buffs[k]); &perf_update_buffs[k]);
} }
} }
int decode_test(int m, int k, u8 ** update_buffs, u8 ** recov, u8 * a, u8 * src_in_err, int
u8 * src_err_list, int nerrs, u8 * g_tbls, u8 ** perf_update_buffs) decode_test(int m, int k, u8 **update_buffs, u8 **recov, u8 *a, u8 *src_in_err, u8 *src_err_list,
int nerrs, u8 *g_tbls, u8 **perf_update_buffs)
{ {
int i, j, r; int i, j, r;
u8 b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX]; u8 b[MMAX * KMAX], c[MMAX * KMAX], d[MMAX * KMAX];
@ -139,13 +145,13 @@ int decode_test(int m, int k, u8 ** update_buffs, u8 ** recov, u8 * a, u8 * src_
// Recover data // Recover data
ec_init_tables(k, nerrs, c, g_tbls); ec_init_tables(k, nerrs, c, g_tbls);
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
FUNCTION_UNDER_TEST(TEST_LEN(m), k, nerrs, i, g_tbls, recov[i], FUNCTION_UNDER_TEST(TEST_LEN(m), k, nerrs, i, g_tbls, recov[i], perf_update_buffs);
perf_update_buffs);
} }
return 0; return 0;
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int i, j, check, m, k, p, nerrs, ret = -1; int i, j, check, m, k, p, nerrs, ret = -1;
void *buf; void *buf;
@ -181,8 +187,7 @@ int main(int argc, char *argv[])
} }
if (nerrs > k) { if (nerrs > k) {
printf printf("Number of errors (%d) cannot be higher than number of data buffers (%d)\n",
("Number of errors (%d) cannot be higher than number of data buffers (%d)\n",
nerrs, k); nerrs, k);
return -1; return -1;
} }
@ -198,8 +203,8 @@ int main(int argc, char *argv[])
} }
if (nerrs > p) { if (nerrs > p) {
printf printf("Number of errors (%d) cannot be higher than number of parity buffers "
("Number of errors (%d) cannot be higher than number of parity buffers (%d)\n", "(%d)\n",
nerrs, p); nerrs, p);
return -1; return -1;
} }
@ -235,8 +240,8 @@ int main(int argc, char *argv[])
err_list[i++] = next_err; err_list[i++] = next_err;
} }
printf("Testing with %u data buffers and %u parity buffers (num errors = %u, in [ ", k, printf("Testing with %u data buffers and %u parity buffers (num errors = %u, in [ ", k, p,
p, nerrs); nerrs);
for (i = 0; i < nerrs; i++) for (i = 0; i < nerrs; i++)
printf("%d ", err_list[i]); printf("%d ", err_list[i]);
@ -264,7 +269,8 @@ int main(int argc, char *argv[])
goto exit; goto exit;
} }
temp_buffs[i] = buf; temp_buffs[i] = buf;
memset(temp_buffs[i], 0, TEST_LEN(m)); // initialize the destination buffer to be zero for update function memset(temp_buffs[i], 0, TEST_LEN(m)); // initialize the destination buffer to be
// zero for update function
} }
for (i = 0; i < TEST_SOURCES; i++) { for (i = 0; i < TEST_SOURCES; i++) {
@ -273,7 +279,8 @@ int main(int argc, char *argv[])
goto exit; goto exit;
} }
update_buffs[i] = buf; update_buffs[i] = buf;
memset(update_buffs[i], 0, TEST_LEN(m)); // initialize the destination buffer to be zero for update function memset(update_buffs[i], 0, TEST_LEN(m)); // initialize the destination buffer to be
// zero for update function
} }
for (i = 0; i < TEST_SOURCES; i++) { for (i = 0; i < TEST_SOURCES; i++) {
if (posix_memalign(&buf, 64, TEST_LEN(m))) { if (posix_memalign(&buf, 64, TEST_LEN(m))) {
@ -281,7 +288,8 @@ int main(int argc, char *argv[])
goto exit; goto exit;
} }
perf_update_buffs[i] = buf; perf_update_buffs[i] = buf;
memset(perf_update_buffs[i], 0, TEST_LEN(m)); // initialize the destination buffer to be zero for update function memset(perf_update_buffs[i], 0, TEST_LEN(m)); // initialize the destination buffer
// to be zero for update function
} }
// Make random data // Make random data
@ -313,8 +321,7 @@ int main(int argc, char *argv[])
#endif #endif
// Start encode test // Start encode test
BENCHMARK(&start, BENCHMARK_TIME, BENCHMARK(&start, BENCHMARK_TIME, encode_update_test(m, k, g_tbls, perf_update_buffs, a));
encode_update_test(m, k, g_tbls, perf_update_buffs, a));
printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": "); printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": ");
perf_print(start, (long long) (TEST_LEN(m)) * (m)); perf_print(start, (long long) (TEST_LEN(m)) * (m));
@ -336,18 +343,19 @@ int main(int argc, char *argv[])
perf_print(start, (long long) (TEST_LEN(m)) * (m - k + 1)); perf_print(start, (long long) (TEST_LEN(m)) * (m - k + 1));
for (i = k; i < m; i++) { for (i = k; i < m; i++) {
memset(update_buffs[i], 0, TEST_LEN(m)); // initialize the destination buffer to be zero for update function memset(update_buffs[i], 0, TEST_LEN(m)); // initialize the destination buffer to be
// zero for update function
} }
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls, update_buffs[i], FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls, update_buffs[i],
&update_buffs[k]); &update_buffs[k]);
} }
decode_test(m, k, update_buffs, recov, a, src_in_err, src_err_list, decode_test(m, k, update_buffs, recov, a, src_in_err, src_err_list, nerrs, g_tbls,
nerrs, g_tbls, temp_buffs); temp_buffs);
BENCHMARK(&start, BENCHMARK_TIME, check = BENCHMARK(&start, BENCHMARK_TIME,
decode_test(m, k, update_buffs, recov, a, src_in_err, src_err_list, check = decode_test(m, k, update_buffs, recov, a, src_in_err, src_err_list, nerrs,
nerrs, g_tbls, perf_update_buffs)); g_tbls, perf_update_buffs));
if (check) { if (check) {
printf("BAD_MATRIX\n"); printf("BAD_MATRIX\n");
ret = check; ret = check;

View File

@ -78,7 +78,8 @@
typedef unsigned char u8; typedef unsigned char u8;
void dump(unsigned char *buf, int len) void
dump(unsigned char *buf, int len)
{ {
int i; int i;
for (i = 0; i < len;) { for (i = 0; i < len;) {
@ -89,7 +90,8 @@ void dump(unsigned char *buf, int len)
printf("\n"); printf("\n");
} }
void dump_matrix(unsigned char **s, int k, int m) void
dump_matrix(unsigned char **s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -101,7 +103,8 @@ void dump_matrix(unsigned char **s, int k, int m)
printf("\n"); printf("\n");
} }
void dump_u8xu8(unsigned char *s, int k, int m) void
dump_u8xu8(unsigned char *s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -114,8 +117,9 @@ void dump_u8xu8(unsigned char *s, int k, int m)
} }
// Generate Random errors // Generate Random errors
static void gen_err_list(unsigned char *src_err_list, static void
unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs, int k, int m) gen_err_list(unsigned char *src_err_list, unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs,
int k, int m)
{ {
int i, err; int i, err;
int nerrs = 0, nsrcerrs = 0; int nerrs = 0, nsrcerrs = 0;
@ -131,7 +135,8 @@ static void gen_err_list(unsigned char *src_err_list,
} }
} }
if (nerrs == 0) { // should have at least one error if (nerrs == 0) { // should have at least one error
while ((err = (rand() % KMAX)) >= m) ; while ((err = (rand() % KMAX)) >= m)
;
src_err_list[nerrs++] = err; src_err_list[nerrs++] = err;
src_in_err[err] = 1; src_in_err[err] = 1;
if (err < k) if (err < k)
@ -144,13 +149,11 @@ static void gen_err_list(unsigned char *src_err_list,
#define NO_INVERT_MATRIX -2 #define NO_INVERT_MATRIX -2
// Generate decode matrix from encode matrix // Generate decode matrix from encode matrix
static int gf_gen_decode_matrix(unsigned char *encode_matrix, static int
unsigned char *decode_matrix, gf_gen_decode_matrix(unsigned char *encode_matrix, unsigned char *decode_matrix,
unsigned char *invert_matrix, unsigned char *invert_matrix, unsigned int *decode_index,
unsigned int *decode_index, unsigned char *src_err_list, unsigned char *src_in_err, int nerrs,
unsigned char *src_err_list, int nsrcerrs, int k, int m)
unsigned char *src_in_err,
int nerrs, int nsrcerrs, int k, int m)
{ {
int i, j, p; int i, j, p;
int r; int r;
@ -202,7 +205,6 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
decode_index[k - 1] += incr; decode_index[k - 1] += incr;
for (j = 0; j < k; j++) for (j = 0; j < k; j++)
b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j]; b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j];
}; };
for (i = 0; i < nsrcerrs; i++) { for (i = 0; i < nsrcerrs; i++) {
@ -226,7 +228,8 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
return 0; return 0;
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int re = -1; int re = -1;
int i, j, p, rtest, m, k; int i, j, p, rtest, m, k;
@ -235,8 +238,8 @@ int main(int argc, char *argv[])
unsigned int decode_index[MMAX]; unsigned int decode_index[MMAX];
unsigned char *temp_buffs[TEST_SOURCES] = { NULL }, *buffs[TEST_SOURCES] = { NULL }; unsigned char *temp_buffs[TEST_SOURCES] = { NULL }, *buffs[TEST_SOURCES] = { NULL };
unsigned char *update_buffs[TEST_SOURCES] = { NULL }; unsigned char *update_buffs[TEST_SOURCES] = { NULL };
unsigned char *encode_matrix = NULL, *decode_matrix = NULL, *invert_matrix = unsigned char *encode_matrix = NULL, *decode_matrix = NULL, *invert_matrix = NULL,
NULL, *g_tbls = NULL; *g_tbls = NULL;
unsigned char src_in_err[TEST_SOURCES], src_err_list[TEST_SOURCES]; unsigned char src_in_err[TEST_SOURCES], src_err_list[TEST_SOURCES];
unsigned char *recov[TEST_SOURCES]; unsigned char *recov[TEST_SOURCES];
@ -266,7 +269,8 @@ int main(int argc, char *argv[])
goto exit; goto exit;
} }
temp_buffs[i] = buf; temp_buffs[i] = buf;
memset(temp_buffs[i], 0, TEST_LEN); // initialize the destination buffer to be zero for update function memset(temp_buffs[i], 0, TEST_LEN); // initialize the destination buffer to be zero
// for update function
} }
for (i = 0; i < TEST_SOURCES; i++) { for (i = 0; i < TEST_SOURCES; i++) {
@ -275,7 +279,8 @@ int main(int argc, char *argv[])
goto exit; goto exit;
} }
update_buffs[i] = buf; update_buffs[i] = buf;
memset(update_buffs[i], 0, TEST_LEN); // initialize the destination buffer to be zero for update function memset(update_buffs[i], 0, TEST_LEN); // initialize the destination buffer to be
// zero for update function
} }
// Test erasure code by encode and recovery // Test erasure code by encode and recovery
@ -283,8 +288,8 @@ int main(int argc, char *argv[])
decode_matrix = malloc(MMAX * KMAX); decode_matrix = malloc(MMAX * KMAX);
invert_matrix = malloc(MMAX * KMAX); invert_matrix = malloc(MMAX * KMAX);
g_tbls = malloc(KMAX * TEST_SOURCES * 32); g_tbls = malloc(KMAX * TEST_SOURCES * 32);
if (encode_matrix == NULL || decode_matrix == NULL if (encode_matrix == NULL || decode_matrix == NULL || invert_matrix == NULL ||
|| invert_matrix == NULL || g_tbls == NULL) { g_tbls == NULL) {
printf("Test failure! Error with malloc\n"); printf("Test failure! Error with malloc\n");
goto exit; goto exit;
} }
@ -331,9 +336,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_in_err, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;
@ -427,9 +431,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_in_err, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;
@ -479,8 +482,10 @@ int main(int argc, char *argv[])
// Do more random tests // Do more random tests
for (rtest = 0; rtest < RANDOMS; rtest++) { for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ; while ((m = (rand() % MMAX)) < 2)
while ((k = (rand() % KMAX)) >= m || k < 1) ; ;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX) if (m > MMAX || k > KMAX)
continue; continue;
@ -528,9 +533,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;
@ -555,8 +559,7 @@ int main(int argc, char *argv[])
for (i = 0; i < nerrs; i++) { for (i = 0; i < nerrs; i++) {
if (0 != if (0 !=
memcmp(temp_buffs[k + i], update_buffs[src_err_list[i]], memcmp(temp_buffs[k + i], update_buffs[src_err_list[i]], TEST_LEN)) {
TEST_LEN)) {
printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs);
printf(" - erase list = "); printf(" - erase list = ");
for (j = 0; j < nerrs; j++) for (j = 0; j < nerrs; j++)
@ -640,8 +643,7 @@ int main(int argc, char *argv[])
} }
for (i = 0; i < m - k; i++) { for (i = 0; i < m - k; i++) {
if (0 != if (0 !=
memcmp(efence_update_buffs[k + i], efence_buffs[k + i], memcmp(efence_update_buffs[k + i], efence_buffs[k + i], size)) {
size)) {
printf("\nefence_update_buffs%d :", i); printf("\nefence_update_buffs%d :", i);
dump(efence_update_buffs[k + i], 25); dump(efence_update_buffs[k + i], 25);
printf("efence_buffs%d :", i); printf("efence_buffs%d :", i);
@ -656,9 +658,9 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix,
invert_matrix, decode_index, src_err_list, decode_index, src_err_list, src_in_err, nerrs,
src_in_err, nerrs, nsrcerrs, k, m); nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;
@ -682,11 +684,10 @@ int main(int argc, char *argv[])
for (i = 0; i < nerrs; i++) { for (i = 0; i < nerrs; i++) {
if (0 != if (0 != memcmp(temp_buffs[k + i],
memcmp(temp_buffs[k + i],
efence_update_buffs[src_err_list[i]], size)) { efence_update_buffs[src_err_list[i]], size)) {
printf("Efence: Fail error recovery (%d, %d, %d)\n", m, printf("Efence: Fail error recovery (%d, %d, %d)\n", m, k,
k, nerrs); nerrs);
printf("size = %d\n", size); printf("size = %d\n", size);
@ -715,14 +716,15 @@ int main(int argc, char *argv[])
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
putchar('.'); putchar('.');
#endif #endif
} }
// Test rand ptr alignment if available // Test rand ptr alignment if available
for (rtest = 0; rtest < RANDOMS; rtest++) { for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ; while ((m = (rand() % MMAX)) < 2)
while ((k = (rand() % KMAX)) >= m || k < 1) ; ;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX) if (m > MMAX || k > KMAX)
continue; continue;
@ -736,8 +738,7 @@ int main(int argc, char *argv[])
memset(update_buffs[i], 0, TEST_LEN); // zero pad to check write-over memset(update_buffs[i], 0, TEST_LEN); // zero pad to check write-over
memset(temp_buffs[i], 0, TEST_LEN); // zero pad to check write-over memset(temp_buffs[i], 0, TEST_LEN); // zero pad to check write-over
ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset));
update_ubuffs[i] = update_ubuffs[i] = update_buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset));
update_buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset));
temp_ubuffs[i] = temp_buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset)); temp_ubuffs[i] = temp_buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset));
} }
@ -784,9 +785,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;
@ -804,14 +804,12 @@ int main(int argc, char *argv[])
} }
ec_init_tables(k, nerrs, decode_matrix, g_tbls); ec_init_tables(k, nerrs, decode_matrix, g_tbls);
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
FUNCTION_UNDER_TEST(size, k, nerrs, i, g_tbls, recov[i], FUNCTION_UNDER_TEST(size, k, nerrs, i, g_tbls, recov[i], &temp_ubuffs[k]);
&temp_ubuffs[k]);
} }
for (i = 0; i < nerrs; i++) { for (i = 0; i < nerrs; i++) {
if (0 != if (0 != memcmp(temp_ubuffs[k + i], update_ubuffs[src_err_list[i]], size)) {
memcmp(temp_ubuffs[k + i], update_ubuffs[src_err_list[i]], size)) {
printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs);
printf(" - erase list = "); printf(" - erase list = ");
for (j = 0; j < nerrs; j++) for (j = 0; j < nerrs; j++)
@ -848,8 +846,7 @@ int main(int argc, char *argv[])
re = -1; re = -1;
goto exit; goto exit;
} }
if (memcmp if (memcmp(update_buffs[i] + offset + size, temp_buffs[0],
(update_buffs[i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) { PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign encode pad end\n"); printf("Fail rand ualign encode pad end\n");
re = -1; re = -1;
@ -865,8 +862,7 @@ int main(int argc, char *argv[])
re = -1; re = -1;
goto exit; goto exit;
} }
if (memcmp if (memcmp(temp_buffs[k + i] + offset + size, temp_buffs[0],
(temp_buffs[k + i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) { PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign decode pad end\n"); printf("Fail rand ualign decode pad end\n");
re = -1; re = -1;
@ -884,8 +880,10 @@ int main(int argc, char *argv[])
align = (LEN_ALIGN_CHK_B != 0) ? 13 : ALIGN_SIZE; align = (LEN_ALIGN_CHK_B != 0) ? 13 : ALIGN_SIZE;
for (size = TEST_LEN; size >= 0; size -= align) { for (size = TEST_LEN; size >= 0; size -= align) {
while ((m = (rand() % MMAX)) < 2) ; while ((m = (rand() % MMAX)) < 2)
while ((k = (rand() % KMAX)) >= m || k < 1) ; ;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX) if (m > MMAX || k > KMAX)
continue; continue;
@ -932,9 +930,8 @@ int main(int argc, char *argv[])
memset(src_in_err, 0, TEST_SOURCES); memset(src_in_err, 0, TEST_SOURCES);
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m); gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix // Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
invert_matrix, decode_index, src_err_list, src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) { if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n"); printf("Fail to gf_gen_decode_matrix\n");
goto exit; goto exit;
@ -952,14 +949,12 @@ int main(int argc, char *argv[])
} }
ec_init_tables(k, nerrs, decode_matrix, g_tbls); ec_init_tables(k, nerrs, decode_matrix, g_tbls);
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
FUNCTION_UNDER_TEST(size, k, nerrs, i, g_tbls, recov[i], FUNCTION_UNDER_TEST(size, k, nerrs, i, g_tbls, recov[i], &temp_buffs[k]);
&temp_buffs[k]);
} }
for (i = 0; i < nerrs; i++) { for (i = 0; i < nerrs; i++) {
if (0 != if (0 != memcmp(temp_buffs[k + i], update_buffs[src_err_list[i]], size)) {
memcmp(temp_buffs[k + i], update_buffs[src_err_list[i]], size)) {
printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs); printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs);
printf(" - erase list = "); printf(" - erase list = ");
for (j = 0; j < nerrs; j++) for (j = 0; j < nerrs; j++)

View File

@ -9,7 +9,8 @@
#define ROWS M_MAX #define ROWS M_MAX
#define COLS K_MAX #define COLS K_MAX
static inline uint64_t min(const uint64_t a, const uint64_t b) static inline uint64_t
min(const uint64_t a, const uint64_t b)
{ {
if (a <= b) if (a <= b)
return a; return a;
@ -17,7 +18,8 @@ static inline uint64_t min(const uint64_t a, const uint64_t b)
return b; return b;
} }
void gen_sub_matrix(unsigned char *out_matrix, const uint64_t dim, unsigned char *in_matrix, void
gen_sub_matrix(unsigned char *out_matrix, const uint64_t dim, unsigned char *in_matrix,
const uint64_t rows, const uint64_t cols, const uint64_t row_indicator, const uint64_t rows, const uint64_t cols, const uint64_t row_indicator,
const uint64_t col_indicator) const uint64_t col_indicator)
{ {
@ -38,7 +40,8 @@ void gen_sub_matrix(unsigned char *out_matrix, const uint64_t dim, unsigned char
} }
/* Gosper's Hack */ /* Gosper's Hack */
uint64_t next_subset(uint64_t * subset, uint64_t element_count, uint64_t subsize) uint64_t
next_subset(uint64_t *subset, uint64_t element_count, uint64_t subsize)
{ {
uint64_t tmp1 = *subset & -*subset; uint64_t tmp1 = *subset & -*subset;
uint64_t tmp2 = *subset + tmp1; uint64_t tmp2 = *subset + tmp1;
@ -52,7 +55,8 @@ uint64_t next_subset(uint64_t * subset, uint64_t element_count, uint64_t subsize
return 0; return 0;
} }
int are_submatrices_singular(unsigned char *vmatrix, const uint64_t rows, const uint64_t cols) int
are_submatrices_singular(unsigned char *vmatrix, const uint64_t rows, const uint64_t cols)
{ {
unsigned char matrix[COLS * COLS]; unsigned char matrix[COLS * COLS];
unsigned char invert_matrix[COLS * COLS]; unsigned char invert_matrix[COLS * COLS];
@ -66,8 +70,8 @@ int are_submatrices_singular(unsigned char *vmatrix, const uint64_t rows, const
do { do {
uint64_t row_indicator = subset_init; uint64_t row_indicator = subset_init;
do { do {
gen_sub_matrix(matrix, subsize, vmatrix, rows, gen_sub_matrix(matrix, subsize, vmatrix, rows, cols, row_indicator,
cols, row_indicator, col_indicator); col_indicator);
if (gf_invert_matrix(matrix, invert_matrix, (int) subsize)) if (gf_invert_matrix(matrix, invert_matrix, (int) subsize))
return 1; return 1;
@ -78,7 +82,8 @@ int are_submatrices_singular(unsigned char *vmatrix, const uint64_t rows, const
return 0; return 0;
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
unsigned char vmatrix[(ROWS + COLS) * COLS]; unsigned char vmatrix[(ROWS + COLS) * COLS];
uint64_t rows, cols; uint64_t rows, cols;
@ -107,10 +112,8 @@ int main(int argc, char **argv)
* singular submatrix */ * singular submatrix */
if (are_submatrices_singular(&vmatrix[cols * cols], rows, cols)) if (are_submatrices_singular(&vmatrix[cols * cols], rows, cols))
break; break;
} }
printf(" k = %2u, m <= %2u \n", (unsigned) cols, (unsigned) (rows + cols - 1)); printf(" k = %2u, m <= %2u \n", (unsigned) cols, (unsigned) (rows + cols - 1));
} }
return 0; return 0;
} }

View File

@ -47,7 +47,8 @@
typedef unsigned char u8; typedef unsigned char u8;
void matrix_mult(u8 * a, u8 * b, u8 * c, int n) void
matrix_mult(u8 *a, u8 *b, u8 *c, int n)
{ {
int i, j, k; int i, j, k;
u8 d; u8 d;
@ -63,7 +64,8 @@ void matrix_mult(u8 * a, u8 * b, u8 * c, int n)
} }
} }
void print_matrix(u8 * a, int n) void
print_matrix(u8 *a, int n)
{ {
int i, j; int i, j;
@ -76,7 +78,8 @@ void print_matrix(u8 * a, int n)
printf("\n"); printf("\n");
} }
int is_ident(u8 * a, const int n) int
is_ident(u8 *a, const int n)
{ {
int i, j; int i, j;
u8 c; u8 c;
@ -92,7 +95,8 @@ int is_ident(u8 * a, const int n)
return 0; return 0;
} }
int inv_test(u8 * in, u8 * inv, u8 * sav, int n) int
inv_test(u8 *in, u8 *inv, u8 *sav, int n)
{ {
memcpy(sav, in, n * n); memcpy(sav, in, n * n);
@ -118,32 +122,20 @@ int inv_test(u8 * in, u8 * inv, u8 * sav, int n)
return 0; return 0;
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int i, k, t; int i, k, t;
u8 *test_mat = NULL, *save_mat = NULL, *invr_mat = NULL; u8 *test_mat = NULL, *save_mat = NULL, *invr_mat = NULL;
int ret = -1; int ret = -1;
u8 test1[] = { 1, 1, 6, u8 test1[] = { 1, 1, 6, 1, 1, 1, 7, 1, 9 };
1, 1, 1,
7, 1, 9
};
u8 test2[] = { 0, 1, 6, u8 test2[] = { 0, 1, 6, 1, 0, 1, 0, 1, 9 };
1, 0, 1,
0, 1, 9
};
u8 test3[] = { 0, 0, 1, u8 test3[] = { 0, 0, 1, 1, 0, 0, 0, 1, 1 };
1, 0, 0,
0, 1, 1
};
u8 test4[] = { 0, 1, 6, 7, u8 test4[] = { 0, 1, 6, 7, 1, 1, 0, 0, 0, 1, 2, 3, 3, 2, 2, 3 }; // = row3+3*row2
1, 1, 0, 0,
0, 1, 2, 3,
3, 2, 2, 3
}; // = row3+3*row2
printf("gf_inverse_test: max=%d ", KMAX); printf("gf_inverse_test: max=%d ", KMAX);

View File

@ -58,7 +58,8 @@ u8 gff[256];
u8 gflog[256]; u8 gflog[256];
u8 gf_mul_table[256 * 256]; u8 gf_mul_table[256 * 256];
void mk_gf_field(void) void
mk_gf_field(void)
{ {
int i; int i;
u8 s = 1; u8 s = 1;
@ -71,7 +72,8 @@ void mk_gf_field(void)
} }
} }
void mk_gf_mul_table(u8 * table) void
mk_gf_mul_table(u8 *table)
{ {
// Populate a single table with all multiply combinations for a fast, // Populate a single table with all multiply combinations for a fast,
// single-table lookup of GF(2^8) multiply at the expense of memory. // single-table lookup of GF(2^8) multiply at the expense of memory.
@ -81,7 +83,8 @@ void mk_gf_mul_table(u8 * table)
table[i * 256 + j] = gf_mul(i, j); table[i * 256 + j] = gf_mul(i, j);
} }
void gf_vect_dot_prod_ref(int len, int vlen, u8 * v, u8 ** src, u8 * dest) void
gf_vect_dot_prod_ref(int len, int vlen, u8 *v, u8 **src, u8 *dest)
{ {
int i, j; int i, j;
u8 s; u8 s;
@ -94,7 +97,8 @@ void gf_vect_dot_prod_ref(int len, int vlen, u8 * v, u8 ** src, u8 * dest)
} }
} }
void gf_vect_dot_prod_mult(int len, int vlen, u8 * v, u8 ** src, u8 * dest) void
gf_vect_dot_prod_mult(int len, int vlen, u8 *v, u8 **src, u8 *dest)
{ {
int i, j; int i, j;
u8 s; u8 s;
@ -105,10 +109,10 @@ void gf_vect_dot_prod_mult(int len, int vlen, u8 * v, u8 ** src, u8 * dest)
} }
dest[i] = s; dest[i] = s;
} }
} }
int main(void) int
main(void)
{ {
int i, j; int i, j;
u8 vec[TEST_SOURCES], *dest1, *dest2; u8 vec[TEST_SOURCES], *dest1, *dest2;
@ -138,7 +142,6 @@ int main(void)
} }
for (j = 0; j < TEST_LEN; j++) for (j = 0; j < TEST_LEN; j++)
matrix[i][j] = rand(); matrix[i][j] = rand();
} }
BENCHMARK(&start, BENCHMARK_TIME, BENCHMARK(&start, BENCHMARK_TIME,

View File

@ -49,7 +49,8 @@
typedef unsigned char u8; typedef unsigned char u8;
void dump(unsigned char *buf, int len) void
dump(unsigned char *buf, int len)
{ {
int i; int i;
for (i = 0; i < len;) { for (i = 0; i < len;) {
@ -60,7 +61,8 @@ void dump(unsigned char *buf, int len)
printf("\n"); printf("\n");
} }
void dump_matrix(unsigned char **s, int k, int m) void
dump_matrix(unsigned char **s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -72,7 +74,8 @@ void dump_matrix(unsigned char **s, int k, int m)
printf("\n"); printf("\n");
} }
void dump_u8xu8(unsigned char *s, int k, int m) void
dump_u8xu8(unsigned char *s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -84,7 +87,8 @@ void dump_u8xu8(unsigned char *s, int k, int m)
printf("\n"); printf("\n");
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int i, j, rtest, m, k, nerrs, r, err; int i, j, rtest, m, k, nerrs, r, err;
void *buf; void *buf;
@ -202,8 +206,10 @@ int main(int argc, char *argv[])
// Do more random tests // Do more random tests
for (rtest = 0; rtest < RANDOMS; rtest++) { for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ; while ((m = (rand() % MMAX)) < 2)
while ((k = (rand() % KMAX)) >= m || k < 1) ; ;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX) if (m > MMAX || k > KMAX)
continue; continue;
@ -232,7 +238,8 @@ int main(int argc, char *argv[])
src_err_list[nerrs++] = i; src_err_list[nerrs++] = i;
} }
if (nerrs == 0) { // should have at least one error if (nerrs == 0) { // should have at least one error
while ((err = (rand() % KMAX)) >= k) ; while ((err = (rand() % KMAX)) >= k)
;
src_err_list[nerrs++] = err; src_err_list[nerrs++] = err;
src_in_err[err] = 1; src_in_err[err] = 1;
} }

View File

@ -60,7 +60,8 @@
typedef unsigned char u8; typedef unsigned char u8;
void dump(unsigned char *buf, int len) void
dump(unsigned char *buf, int len)
{ {
int i; int i;
for (i = 0; i < len;) { for (i = 0; i < len;) {
@ -71,7 +72,8 @@ void dump(unsigned char *buf, int len)
printf("\n"); printf("\n");
} }
void dump_matrix(unsigned char **s, int k, int m) void
dump_matrix(unsigned char **s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -83,8 +85,8 @@ void dump_matrix(unsigned char **s, int k, int m)
printf("\n"); printf("\n");
} }
void vect_dot_prod_perf(void (*fun_ptr) void
(int, int, unsigned char *, unsigned char **, unsigned char *), vect_dot_prod_perf(void (*fun_ptr)(int, int, unsigned char *, unsigned char **, unsigned char *),
u8 *g, u8 *g_tbls, u8 **buffs, u8 *dest_ref) u8 *g, u8 *g_tbls, u8 **buffs, u8 *dest_ref)
{ {
int j; int j;
@ -94,7 +96,8 @@ void vect_dot_prod_perf(void (*fun_ptr)
(*fun_ptr)(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref); (*fun_ptr)(TEST_LEN, TEST_SOURCES, &g_tbls[0], buffs, dest_ref);
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int i, j; int i, j;
void *buf; void *buf;
@ -146,8 +149,7 @@ int main(int argc, char *argv[])
#ifdef DO_REF_PERF #ifdef DO_REF_PERF
BENCHMARK(&start, BENCHMARK_TIME, BENCHMARK(&start, BENCHMARK_TIME,
vect_dot_prod_perf(&gf_vect_dot_prod_base, g, g_tbls, buffs, dest_ref) vect_dot_prod_perf(&gf_vect_dot_prod_base, g, g_tbls, buffs, dest_ref));
);
printf("gf_vect_dot_prod_base" TEST_TYPE_STR ": "); printf("gf_vect_dot_prod_base" TEST_TYPE_STR ": ");
perf_print(start, (long long) TEST_LEN * (TEST_SOURCES + 1)); perf_print(start, (long long) TEST_LEN * (TEST_SOURCES + 1));
#else #else

View File

@ -68,7 +68,8 @@
typedef unsigned char u8; typedef unsigned char u8;
void dump(unsigned char *buf, int len) void
dump(unsigned char *buf, int len)
{ {
int i; int i;
for (i = 0; i < len;) { for (i = 0; i < len;) {
@ -79,7 +80,8 @@ void dump(unsigned char *buf, int len)
printf("\n"); printf("\n");
} }
void dump_matrix(unsigned char **s, int k, int m) void
dump_matrix(unsigned char **s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -91,7 +93,8 @@ void dump_matrix(unsigned char **s, int k, int m)
printf("\n"); printf("\n");
} }
void dump_u8xu8(unsigned char *s, int k, int m) void
dump_u8xu8(unsigned char *s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -103,7 +106,8 @@ void dump_u8xu8(unsigned char *s, int k, int m)
printf("\n"); printf("\n");
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int i, j, rtest, srcs, m, k, nerrs, r, err; int i, j, rtest, srcs, m, k, nerrs, r, err;
void *buf; void *buf;
@ -318,8 +322,10 @@ int main(int argc, char *argv[])
// Do more random tests // Do more random tests
for (rtest = 0; rtest < RANDOMS; rtest++) { for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ; while ((m = (rand() % MMAX)) < 2)
while ((k = (rand() % KMAX)) >= m || k < 1) ; ;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX) if (m > MMAX || k > KMAX)
continue; continue;
@ -351,7 +357,8 @@ int main(int argc, char *argv[])
src_err_list[nerrs++] = i; src_err_list[nerrs++] = i;
} }
if (nerrs == 0) { // should have at least one error if (nerrs == 0) { // should have at least one error
while ((err = (rand() % KMAX)) >= k) ; while ((err = (rand() % KMAX)) >= k)
;
src_err_list[nerrs++] = err; src_err_list[nerrs++] = err;
src_in_err[err] = 1; src_in_err[err] = 1;
} }
@ -474,8 +481,7 @@ int main(int argc, char *argv[])
FUNCTION_UNDER_TEST(size, srcs, g_tbls, ubuffs, udest_ptr); FUNCTION_UNDER_TEST(size, srcs, g_tbls, ubuffs, udest_ptr);
if (memcmp(dest_ref, udest_ptr, size)) { if (memcmp(dest_ref, udest_ptr, size)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign srcs=%d\n", printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign srcs=%d\n", srcs);
srcs);
dump_matrix(ubuffs, 5, TEST_SOURCES); dump_matrix(ubuffs, 5, TEST_SOURCES);
printf("dprod_base:"); printf("dprod_base:");
dump(dest_ref, 25); dump(dest_ref, 25);
@ -522,8 +528,7 @@ int main(int argc, char *argv[])
FUNCTION_UNDER_TEST(size, srcs, g_tbls, buffs, dest); FUNCTION_UNDER_TEST(size, srcs, g_tbls, buffs, dest);
if (memcmp(dest_ref, dest, size)) { if (memcmp(dest_ref, dest, size)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign len=%d\n", printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign len=%d\n", size);
size);
dump_matrix(buffs, 5, TEST_SOURCES); dump_matrix(buffs, 5, TEST_SOURCES);
printf("dprod_base:"); printf("dprod_base:");
dump(dest_ref, 25); dump(dest_ref, 25);

View File

@ -85,12 +85,14 @@ typedef unsigned char u8;
#define LAST_ARG **dest #define LAST_ARG **dest
#endif #endif
extern void FUNCTION_UNDER_TEST(int len, int vec, int vec_i, unsigned char *gftbls, extern void
unsigned char *src, unsigned char LAST_ARG); FUNCTION_UNDER_TEST(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
extern void REF_FUNCTION(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char LAST_ARG); unsigned char LAST_ARG);
extern void
REF_FUNCTION(int len, int vlen, unsigned char *gftbls, unsigned char **src, unsigned char LAST_ARG);
void dump(unsigned char *buf, int len) void
dump(unsigned char *buf, int len)
{ {
int i; int i;
for (i = 0; i < len;) { for (i = 0; i < len;) {
@ -101,7 +103,8 @@ void dump(unsigned char *buf, int len)
printf("\n"); printf("\n");
} }
void dump_matrix(unsigned char **s, int k, int m) void
dump_matrix(unsigned char **s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -113,7 +116,8 @@ void dump_matrix(unsigned char **s, int k, int m)
printf("\n"); printf("\n");
} }
void dump_u8xu8(unsigned char *s, int k, int m) void
dump_u8xu8(unsigned char *s, int k, int m)
{ {
int i, j; int i, j;
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
@ -125,7 +129,8 @@ void dump_u8xu8(unsigned char *s, int k, int m)
printf("\n"); printf("\n");
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int i, j, rtest, srcs; int i, j, rtest, srcs;
void *buf; void *buf;
@ -208,8 +213,8 @@ int main(int argc, char *argv[])
} }
for (i = 0; i < vector; i++) for (i = 0; i < vector; i++)
gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[i * 32 * TEST_SOURCES], gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[i * 32 * TEST_SOURCES], buffs,
buffs, dest_ref[i]); dest_ref[i]);
for (i = 0; i < vector; i++) for (i = 0; i < vector; i++)
memset(dest_ptrs[i], 0, TEST_LEN); memset(dest_ptrs[i], 0, TEST_LEN);
@ -269,8 +274,7 @@ int main(int argc, char *argv[])
for (i = 0; i < vector; i++) for (i = 0; i < vector; i++)
gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES,
&g_tbls[i * 32 * TEST_SOURCES], buffs, &g_tbls[i * 32 * TEST_SOURCES], buffs, dest_ref[i]);
dest_ref[i]);
for (i = 0; i < vector; i++) for (i = 0; i < vector; i++)
memset(dest_ptrs[i], 0, TEST_LEN); memset(dest_ptrs[i], 0, TEST_LEN);
@ -279,14 +283,13 @@ int main(int argc, char *argv[])
FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, i, g_tbls, buffs[i], FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, i, g_tbls, buffs[i],
*dest_ptrs); *dest_ptrs);
#else #else
FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, i, g_tbls, buffs[i], FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, i, g_tbls, buffs[i], dest_ptrs);
dest_ptrs);
#endif #endif
} }
for (i = 0; i < vector; i++) { for (i = 0; i < vector; i++) {
if (0 != memcmp(dest_ref[i], dest_ptrs[i], TEST_LEN)) { if (0 != memcmp(dest_ref[i], dest_ptrs[i], TEST_LEN)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test%d %d\n", printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test%d %d\n", i,
i, rtest); rtest);
dump_matrix(buffs, vector, TEST_SOURCES); dump_matrix(buffs, vector, TEST_SOURCES);
printf("dprod_base:"); printf("dprod_base:");
dump(dest_ref[i], 25); dump(dest_ref[i], 25);
@ -316,8 +319,8 @@ int main(int argc, char *argv[])
} }
for (i = 0; i < vector; i++) for (i = 0; i < vector; i++)
gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[i * 32 * srcs], gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[i * 32 * srcs], buffs,
buffs, dest_ref[i]); dest_ref[i]);
for (i = 0; i < vector; i++) for (i = 0; i < vector; i++)
memset(dest_ptrs[i], 0, TEST_LEN); memset(dest_ptrs[i], 0, TEST_LEN);
@ -326,15 +329,14 @@ int main(int argc, char *argv[])
FUNCTION_UNDER_TEST(TEST_LEN, srcs, i, g_tbls, buffs[i], FUNCTION_UNDER_TEST(TEST_LEN, srcs, i, g_tbls, buffs[i],
*dest_ptrs); *dest_ptrs);
#else #else
FUNCTION_UNDER_TEST(TEST_LEN, srcs, i, g_tbls, buffs[i], FUNCTION_UNDER_TEST(TEST_LEN, srcs, i, g_tbls, buffs[i], dest_ptrs);
dest_ptrs);
#endif #endif
} }
for (i = 0; i < vector; i++) { for (i = 0; i < vector; i++) {
if (0 != memcmp(dest_ref[i], dest_ptrs[i], TEST_LEN)) { if (0 != memcmp(dest_ref[i], dest_ptrs[i], TEST_LEN)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) printf("Fail rand " xstr(
" test%d srcs=%d\n", i, srcs); FUNCTION_UNDER_TEST) " test%d srcs=%d\n",
i, srcs);
dump_matrix(buffs, vector, TEST_SOURCES); dump_matrix(buffs, vector, TEST_SOURCES);
printf("dprod_base:"); printf("dprod_base:");
dump(dest_ref[i], 25); dump(dest_ref[i], 25);
@ -368,9 +370,8 @@ int main(int argc, char *argv[])
} }
for (i = 0; i < vector; i++) for (i = 0; i < vector; i++)
gf_vect_dot_prod_base(size, TEST_SOURCES, gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[i * 32 * TEST_SOURCES],
&g_tbls[i * 32 * TEST_SOURCES], efence_buffs, efence_buffs, dest_ref[i]);
dest_ref[i]);
for (i = 0; i < vector; i++) for (i = 0; i < vector; i++)
memset(dest_ptrs[i], 0, size); memset(dest_ptrs[i], 0, size);
@ -385,8 +386,8 @@ int main(int argc, char *argv[])
} }
for (i = 0; i < vector; i++) { for (i = 0; i < vector; i++) {
if (0 != memcmp(dest_ref[i], dest_ptrs[i], size)) { if (0 != memcmp(dest_ref[i], dest_ptrs[i], size)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test%d size=%d\n",
" test%d size=%d\n", i, size); i, size);
dump_matrix(buffs, vector, TEST_SOURCES); dump_matrix(buffs, vector, TEST_SOURCES);
printf("dprod_base:"); printf("dprod_base:");
dump(dest_ref[i], TEST_MIN_SIZE + align); dump(dest_ref[i], TEST_MIN_SIZE + align);
@ -442,8 +443,9 @@ int main(int argc, char *argv[])
} }
for (i = 0; i < vector; i++) { for (i = 0; i < vector; i++) {
if (0 != memcmp(dest_ref[i], udest_ptrs[i], size)) { if (0 != memcmp(dest_ref[i], udest_ptrs[i], size)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) printf("Fail rand " xstr(
" test%d ualign srcs=%d\n", i, srcs); FUNCTION_UNDER_TEST) " test%d ualign srcs=%d\n",
i, srcs);
dump_matrix(buffs, vector, TEST_SOURCES); dump_matrix(buffs, vector, TEST_SOURCES);
printf("dprod_base:"); printf("dprod_base:");
dump(dest_ref[i], 25); dump(dest_ref[i], 25);
@ -462,8 +464,7 @@ int main(int argc, char *argv[])
printf("Fail rand ualign pad1 start\n"); printf("Fail rand ualign pad1 start\n");
return -1; return -1;
} }
if (memcmp if (memcmp(dest_ptrs[i] + offset + size, dest_ref[0],
(dest_ptrs[i] + offset + size, dest_ref[0],
PTR_ALIGN_CHK_B - offset)) { PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign pad1 end\n"); printf("Fail rand ualign pad1 end\n");
return -1; return -1;
@ -493,23 +494,21 @@ int main(int argc, char *argv[])
} }
for (i = 0; i < vector; i++) for (i = 0; i < vector; i++)
gf_vect_dot_prod_base(size, TEST_SOURCES, gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[i * 32 * TEST_SOURCES],
&g_tbls[i * 32 * TEST_SOURCES], buffs, buffs, dest_ref[i]);
dest_ref[i]);
for (i = 0; i < TEST_SOURCES; i++) { for (i = 0; i < TEST_SOURCES; i++) {
#if (VECT == 1) #if (VECT == 1)
FUNCTION_UNDER_TEST(size, TEST_SOURCES, i, g_tbls, buffs[i], FUNCTION_UNDER_TEST(size, TEST_SOURCES, i, g_tbls, buffs[i], *dest_ptrs);
*dest_ptrs);
#else #else
FUNCTION_UNDER_TEST(size, TEST_SOURCES, i, g_tbls, buffs[i], FUNCTION_UNDER_TEST(size, TEST_SOURCES, i, g_tbls, buffs[i], dest_ptrs);
dest_ptrs);
#endif #endif
} }
for (i = 0; i < vector; i++) { for (i = 0; i < vector; i++) {
if (0 != memcmp(dest_ref[i], dest_ptrs[i], size)) { if (0 != memcmp(dest_ref[i], dest_ptrs[i], size)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) printf("Fail rand " xstr(
" test%d ualign len=%d\n", i, size); FUNCTION_UNDER_TEST) " test%d ualign len=%d\n",
i, size);
dump_matrix(buffs, vector, TEST_SOURCES); dump_matrix(buffs, vector, TEST_SOURCES);
printf("dprod_base:"); printf("dprod_base:");
dump(dest_ref[i], 25); dump(dest_ref[i], 25);
@ -522,10 +521,8 @@ int main(int argc, char *argv[])
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
putchar('.'); putchar('.');
#endif #endif
} }
printf("Pass\n"); printf("Pass\n");
return 0; return 0;
} }

View File

@ -39,7 +39,8 @@
typedef unsigned char u8; typedef unsigned char u8;
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int i; int i;
u8 *buff1, *buff2, *buff3, gf_const_tbl[64], a = 2; u8 *buff1, *buff2, *buff3, gf_const_tbl[64], a = 2;
@ -82,8 +83,8 @@ int main(int argc, char *argv[])
// Check reference function // Check reference function
for (i = 0; i < TEST_SIZE; i++) for (i = 0; i < TEST_SIZE; i++)
if (buff2[i] != buff3[i]) { if (buff2[i] != buff3[i]) {
printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", i, a, buff1[i], buff2[i],
i, a, buff1[i], buff2[i], gf_mul(a, buff1[i])); gf_mul(a, buff1[i]));
return 1; return 1;
} }
@ -101,8 +102,8 @@ int main(int argc, char *argv[])
for (i = 0; i < TEST_SIZE; i++) for (i = 0; i < TEST_SIZE; i++)
if (gf_mul(a, buff1[i]) != buff2[i]) { if (gf_mul(a, buff1[i]) != buff2[i]) {
printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", i, a, buff1[i],
i, a, buff1[i], buff2[i], gf_mul(2, buff1[i])); buff2[i], gf_mul(2, buff1[i]));
return 1; return 1;
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
@ -120,18 +121,16 @@ int main(int argc, char *argv[])
efence_buff1 = buff1 + size; efence_buff1 = buff1 + size;
efence_buff2 = buff2 + size; efence_buff2 = buff2 + size;
if (gf_vect_mul_base if (gf_vect_mul_base(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff2) !=
(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff2) != 0) { 0) {
printf("fail tests at end of buffer\n"); printf("fail tests at end of buffer\n");
return -1; return -1;
} }
for (i = 0; i < TEST_SIZE - size; i++) for (i = 0; i < TEST_SIZE - size; i++)
if (gf_mul(a, efence_buff1[i]) != efence_buff2[i]) { if (gf_mul(a, efence_buff1[i]) != efence_buff2[i]) {
printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, efence_buff1[i],
i, efence_buff1[i], efence_buff2[i], gf_mul(2, efence_buff2[i], gf_mul(2, efence_buff1[i]));
efence_buff1
[i]));
return 1; return 1;
} }

View File

@ -55,13 +55,15 @@
typedef unsigned char u8; typedef unsigned char u8;
void gf_vect_mul_perf(u8 a, u8 * gf_const_tbl, u8 * buff1, u8 * buff2) void
gf_vect_mul_perf(u8 a, u8 *gf_const_tbl, u8 *buff1, u8 *buff2)
{ {
gf_vect_mul_init(a, gf_const_tbl); gf_vect_mul_init(a, gf_const_tbl);
gf_vect_mul(TEST_LEN, gf_const_tbl, buff1, buff2); gf_vect_mul(TEST_LEN, gf_const_tbl, buff1, buff2);
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
u8 *buff1, *buff2, gf_const_tbl[64], a = 2; u8 *buff1, *buff2, gf_const_tbl[64], a = 2;
struct perf start; struct perf start;

View File

@ -35,7 +35,8 @@
typedef unsigned char u8; typedef unsigned char u8;
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int i, ret = -1; int i, ret = -1;
u8 *buff1 = NULL, *buff2 = NULL, *buff3 = NULL, gf_const_tbl[64], a = 2; u8 *buff1 = NULL, *buff2 = NULL, *buff3 = NULL, gf_const_tbl[64], a = 2;
@ -68,8 +69,8 @@ int main(int argc, char *argv[])
for (i = 0; i < TEST_SIZE; i++) { for (i = 0; i < TEST_SIZE; i++) {
if (gf_mul(a, buff1[i]) != buff2[i]) { if (gf_mul(a, buff1[i]) != buff2[i]) {
printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, buff1[i], buff2[i],
buff1[i], buff2[i], gf_mul(2, buff1[i])); gf_mul(2, buff1[i]));
goto exit; goto exit;
} }
} }
@ -81,8 +82,8 @@ int main(int argc, char *argv[])
// Check reference function // Check reference function
for (i = 0; i < TEST_SIZE; i++) { for (i = 0; i < TEST_SIZE; i++) {
if (buff2[i] != buff3[i]) { if (buff2[i] != buff3[i]) {
printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", i, a, buff1[i], buff2[i],
i, a, buff1[i], buff2[i], gf_mul(a, buff1[i])); gf_mul(a, buff1[i]));
goto exit; goto exit;
} }
} }
@ -100,8 +101,8 @@ int main(int argc, char *argv[])
for (i = 0; i < TEST_SIZE; i++) for (i = 0; i < TEST_SIZE; i++)
if (gf_mul(a, buff1[i]) != buff2[i]) { if (gf_mul(a, buff1[i]) != buff2[i]) {
printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", i, a, buff1[i],
i, a, buff1[i], buff2[i], gf_mul(2, buff1[i])); buff2[i], gf_mul(2, buff1[i]));
goto exit; goto exit;
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
@ -120,8 +121,8 @@ int main(int argc, char *argv[])
for (i = 0; i < tsize; i++) for (i = 0; i < tsize; i++)
if (gf_mul(a, buff1[i]) != buff2[i]) { if (gf_mul(a, buff1[i]) != buff2[i]) {
printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", i, a, buff1[i],
i, a, buff1[i], buff2[i], gf_mul(2, buff1[i])); buff2[i], gf_mul(2, buff1[i]));
goto exit; goto exit;
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
@ -147,22 +148,21 @@ int main(int argc, char *argv[])
for (i = 0; i < TEST_SIZE - size; i++) for (i = 0; i < TEST_SIZE - size; i++)
if (gf_mul(a, efence_buff1[i]) != efence_buff2[i]) { if (gf_mul(a, efence_buff1[i]) != efence_buff2[i]) {
printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, efence_buff1[i],
i, efence_buff1[i], efence_buff2[i], efence_buff2[i], gf_mul(2, efence_buff1[i]));
gf_mul(2, efence_buff1[i]));
goto exit; goto exit;
} }
if (gf_vect_mul_base if (gf_vect_mul_base(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff3) !=
(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff3) != 0) { 0) {
printf("fail line up TEST_SIZE from end\n"); printf("fail line up TEST_SIZE from end\n");
goto exit; goto exit;
} }
// Check reference function // Check reference function
for (i = 0; i < TEST_SIZE - size; i++) for (i = 0; i < TEST_SIZE - size; i++)
if (efence_buff2[i] != efence_buff3[i]) { if (efence_buff2[i] != efence_buff3[i]) {
printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", i, a,
i, a, efence_buff2[i], efence_buff3[i], efence_buff2[i], efence_buff3[i],
gf_mul(2, efence_buff1[i])); gf_mul(2, efence_buff1[i]));
goto exit; goto exit;
} }
@ -174,8 +174,7 @@ int main(int argc, char *argv[])
// Test all unsupported sizes up to TEST_SIZE // Test all unsupported sizes up to TEST_SIZE
for (size = 0; size < TEST_SIZE; size++) { for (size = 0; size < TEST_SIZE; size++) {
if (size % align != 0 && gf_vect_mul(size, gf_const_tbl, buff1, buff2) == 0) { if (size % align != 0 && gf_vect_mul(size, gf_const_tbl, buff1, buff2) == 0) {
printf printf("fail expecting nonzero return code for unaligned size param (%d)\n",
("fail expecting nonzero return code for unaligned size param (%d)\n",
size); size);
goto exit; goto exit;
} }

View File

@ -1,21 +1,21 @@
#include "erasure_code.h" #include "erasure_code.h"
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_vect_dot_prod(int len, int vlen, unsigned char *v, void
unsigned char **src, unsigned char *dest) gf_vect_dot_prod(int len, int vlen, unsigned char *v, unsigned char **src, unsigned char *dest)
{ {
gf_vect_dot_prod_vsx(len, vlen, v, src, dest); gf_vect_dot_prod_vsx(len, vlen, v, src, dest);
} }
void gf_vect_mad(int len, int vec, int vec_i, unsigned char *v, void
unsigned char *src, unsigned char *dest) gf_vect_mad(int len, int vec, int vec_i, unsigned char *v, unsigned char *src, unsigned char *dest)
{ {
gf_vect_mad_vsx(len, vec, vec_i, v, src, dest); gf_vect_mad_vsx(len, vec, vec_i, v, src, dest);
} }
void ec_encode_data(int len, int srcs, int dests, unsigned char *v, void
unsigned char **src, unsigned char **dest) ec_encode_data(int len, int srcs, int dests, unsigned char *v, unsigned char **src,
unsigned char **dest)
{ {
if (len < 64) { if (len < 64) {
ec_encode_data_base(len, srcs, dests, v, src, dest); ec_encode_data_base(len, srcs, dests, v, src, dest);
@ -52,8 +52,9 @@ void ec_encode_data(int len, int srcs, int dests, unsigned char *v,
} }
} }
void ec_encode_data_update(int len, int k, int rows, int vec_i, unsigned char *v, void
unsigned char *data, unsigned char **dest) ec_encode_data_update(int len, int k, int rows, int vec_i, unsigned char *v, unsigned char *data,
unsigned char **dest)
{ {
if (len < 64) { if (len < 64) {
ec_encode_data_update_base(len, k, rows, vec_i, v, data, dest); ec_encode_data_update_base(len, k, rows, vec_i, v, data, dest);
@ -90,7 +91,8 @@ void ec_encode_data_update(int len, int k, int rows, int vec_i, unsigned char *v
} }
} }
int gf_vect_mul(int len, unsigned char *a, void *src, void *dest) int
gf_vect_mul(int len, unsigned char *a, void *src, void *dest)
{ {
/* Size must be aligned to 32 bytes */ /* Size must be aligned to 32 bytes */
if ((len % 32) != 0) if ((len % 32) != 0)
@ -100,7 +102,8 @@ int gf_vect_mul(int len, unsigned char *a, void *src, void *dest)
return 0; return 0;
} }
void ec_init_tables(int k, int rows, unsigned char *a, unsigned char *g_tbls) void
ec_init_tables(int k, int rows, unsigned char *a, unsigned char *g_tbls)
{ {
return ec_init_tables_base(k, rows, a, g_tbls); return ec_init_tables_base(k, rows, a, g_tbls);
} }

View File

@ -19,18 +19,26 @@ extern "C" {
#define EC_vec_xl(a, b) vec_vsx_ld(a, b) #define EC_vec_xl(a, b) vec_vsx_ld(a, b)
#define EC_vec_permxor(va, vb, vc) __builtin_crypto_vpermxor(va, vb, vec_nor(vc, vc)) #define EC_vec_permxor(va, vb, vc) __builtin_crypto_vpermxor(va, vb, vec_nor(vc, vc))
#else #else
inline vector unsigned char EC_vec_xl(int off, unsigned char *ptr) { inline vector unsigned char
EC_vec_xl(int off, unsigned char *ptr)
{
vector unsigned char vc; vector unsigned char vc;
__asm__ __volatile__("lxvd2x %x0, %1, %2; xxswapd %x0, %x0" : "=wa" (vc) : "r" (off), "r" (ptr)); __asm__ __volatile__("lxvd2x %x0, %1, %2; xxswapd %x0, %x0"
: "=wa"(vc)
: "r"(off), "r"(ptr));
return vc; return vc;
} }
#define EC_vec_permxor(va, vb, vc) __builtin_crypto_vpermxor(va, vb, vec_nor(vc, vc)) #define EC_vec_permxor(va, vb, vc) __builtin_crypto_vpermxor(va, vb, vec_nor(vc, vc))
#endif #endif
#else #else
#if defined _ARCH_PWR8 #if defined _ARCH_PWR8
inline vector unsigned char EC_vec_xl(int off, unsigned char *ptr) { inline vector unsigned char
EC_vec_xl(int off, unsigned char *ptr)
{
vector unsigned char vc; vector unsigned char vc;
__asm__ __volatile__("lxvd2x %x0, %1, %2; xxswapd %x0, %x0" : "=wa" (vc) : "r" (off), "r" (ptr)); __asm__ __volatile__("lxvd2x %x0, %1, %2; xxswapd %x0, %x0"
: "=wa"(vc)
: "r"(off), "r"(ptr));
return vc; return vc;
} }
#define EC_vec_permxor(va, vb, vc) __builtin_crypto_vpermxor(va, vb, vec_nor(vc, vc)) #define EC_vec_permxor(va, vb, vc) __builtin_crypto_vpermxor(va, vb, vec_nor(vc, vc))
@ -57,7 +65,8 @@ inline vector unsigned char EC_vec_xl(int off, unsigned char *ptr) {
* @returns none * @returns none
*/ */
void gf_vect_mul_vsx(int len, unsigned char *gftbls, unsigned char *src, unsigned char *dest); void
gf_vect_mul_vsx(int len, unsigned char *gftbls, unsigned char *src, unsigned char *dest);
/** /**
* @brief GF(2^8) vector dot product. VSX version. * @brief GF(2^8) vector dot product. VSX version.
@ -77,8 +86,9 @@ void gf_vect_mul_vsx(int len, unsigned char *gftbls, unsigned char *src, unsigne
* @returns none * @returns none
*/ */
void gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char *dest); gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char *dest);
/** /**
* @brief GF(2^8) vector dot product with two outputs. VSX version. * @brief GF(2^8) vector dot product with two outputs. VSX version.
@ -99,8 +109,9 @@ void gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @returns none * @returns none
*/ */
void gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char **dest); gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
/** /**
* @brief GF(2^8) vector dot product with three outputs. VSX version. * @brief GF(2^8) vector dot product with three outputs. VSX version.
@ -121,8 +132,9 @@ void gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @returns none * @returns none
*/ */
void gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char **dest); gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
/** /**
* @brief GF(2^8) vector dot product with four outputs. VSX version. * @brief GF(2^8) vector dot product with four outputs. VSX version.
@ -143,8 +155,9 @@ void gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @returns none * @returns none
*/ */
void gf_4vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char **dest); gf_4vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
/** /**
* @brief GF(2^8) vector dot product with five outputs. VSX version. * @brief GF(2^8) vector dot product with five outputs. VSX version.
@ -165,8 +178,9 @@ void gf_4vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @returns none * @returns none
*/ */
void gf_5vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char **dest); gf_5vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
/** /**
* @brief GF(2^8) vector dot product with six outputs. VSX version. * @brief GF(2^8) vector dot product with six outputs. VSX version.
@ -187,8 +201,9 @@ void gf_5vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @returns none * @returns none
*/ */
void gf_6vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char **dest); gf_6vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
/** /**
* @brief GF(2^8) vector multiply accumulate. VSX version. * @brief GF(2^8) vector multiply accumulate. VSX version.
@ -211,7 +226,8 @@ void gf_6vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @returns none * @returns none
*/ */
void gf_vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src, void
gf_vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *dest); unsigned char *dest);
/** /**
* @brief GF(2^8) vector multiply with 2 accumulate. VSX version. * @brief GF(2^8) vector multiply with 2 accumulate. VSX version.
@ -234,7 +250,8 @@ void gf_vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigne
* @returns none * @returns none
*/ */
void gf_2vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src, void
gf_2vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest); unsigned char **dest);
/** /**
@ -258,7 +275,8 @@ void gf_2vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsign
* @returns none * @returns none
*/ */
void gf_3vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src, void
gf_3vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest); unsigned char **dest);
/** /**
@ -282,7 +300,8 @@ void gf_3vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsign
* @returns none * @returns none
*/ */
void gf_4vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src, void
gf_4vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest); unsigned char **dest);
/** /**
@ -305,7 +324,8 @@ void gf_4vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsign
* @param dest Array of pointers to destination input/outputs. * @param dest Array of pointers to destination input/outputs.
* @returns none * @returns none
*/ */
void gf_5vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src, void
gf_5vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest); unsigned char **dest);
/** /**
@ -328,7 +348,8 @@ void gf_5vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsign
* @param dest Array of pointers to destination input/outputs. * @param dest Array of pointers to destination input/outputs.
* @returns none * @returns none
*/ */
void gf_6vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src, void
gf_6vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest); unsigned char **dest);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char **dest) gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest)
{ {
unsigned char *s, *t0, *t1; unsigned char *s, *t0, *t1;
vector unsigned char vX1, vX2, vX3, vX4; vector unsigned char vX1, vX2, vX3, vX4;

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_2vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, void
unsigned char *src, unsigned char **dest) gf_2vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest)
{ {
unsigned char *s, *t0, *t1; unsigned char *s, *t0, *t1;
vector unsigned char vX1, vX2, vX3, vX4; vector unsigned char vX1, vX2, vX3, vX4;

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char **dest) gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest)
{ {
unsigned char *s, *t0, *t1, *t2; unsigned char *s, *t0, *t1, *t2;
vector unsigned char vX1, vX2, vX3, vX4; vector unsigned char vX1, vX2, vX3, vX4;

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_3vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, void
unsigned char *src, unsigned char **dest) gf_3vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest)
{ {
unsigned char *s, *t0, *t1, *t2; unsigned char *s, *t0, *t1, *t2;
vector unsigned char vX1, vX2, vX3, vX4; vector unsigned char vX1, vX2, vX3, vX4;

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_4vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char **dest) gf_4vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest)
{ {
unsigned char *s, *t0, *t1, *t2, *t3; unsigned char *s, *t0, *t1, *t2, *t3;
vector unsigned char vX1, vX2, vX3, vX4; vector unsigned char vX1, vX2, vX3, vX4;

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_4vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, void
unsigned char *src, unsigned char **dest) gf_4vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest)
{ {
unsigned char *s, *t0, *t1, *t2, *t3; unsigned char *s, *t0, *t1, *t2, *t3;
vector unsigned char vX1, vX2, vX3, vX4; vector unsigned char vX1, vX2, vX3, vX4;

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_5vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char **dest) gf_5vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest)
{ {
unsigned char *s, *t0, *t1, *t2, *t3, *t4; unsigned char *s, *t0, *t1, *t2, *t3, *t4;
vector unsigned char vX1, vX2, vX3, vX4; vector unsigned char vX1, vX2, vX3, vX4;

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_5vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, void
unsigned char *src, unsigned char **dest) gf_5vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest)
{ {
unsigned char *s, *t0, *t1, *t2, *t3, *t4; unsigned char *s, *t0, *t1, *t2, *t3, *t4;
vector unsigned char vX1, vX2, vX3, vX4; vector unsigned char vX1, vX2, vX3, vX4;

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_6vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char **dest) gf_6vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest)
{ {
unsigned char *s, *t0, *t1, *t2, *t3, *t4, *t5; unsigned char *s, *t0, *t1, *t2, *t3, *t4, *t5;
vector unsigned char vX1, vX2, vX3, vX4; vector unsigned char vX1, vX2, vX3, vX4;

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_6vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, void
unsigned char *src, unsigned char **dest) gf_6vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest)
{ {
unsigned char *s, *t0, *t1, *t2, *t3, *t4, *t5; unsigned char *s, *t0, *t1, *t2, *t3, *t4, *t5;
vector unsigned char vX1, vX2, vX3, vX4; vector unsigned char vX1, vX2, vX3, vX4;

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, void
unsigned char **src, unsigned char *dest) gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char *dest)
{ {
unsigned char *s, *t0; unsigned char *s, *t0;
vector unsigned char vX1, vY1; vector unsigned char vX1, vY1;

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h" #include "ec_base_vsx.h"
void gf_vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, void
unsigned char *src, unsigned char *dest) gf_vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *dest)
{ {
unsigned char *s, *t0; unsigned char *s, *t0;
vector unsigned char vX1, vY1; vector unsigned char vX1, vY1;

View File

@ -3,8 +3,8 @@
/* /*
* Same as gf_vect_mul_base in "ec_base.h" but without the size restriction. * Same as gf_vect_mul_base in "ec_base.h" but without the size restriction.
*/ */
static void _gf_vect_mul_base(int len, unsigned char *a, unsigned char *src, static void
unsigned char *dest) _gf_vect_mul_base(int len, unsigned char *a, unsigned char *src, unsigned char *dest)
{ {
// 2nd element of table array is ref value used to fill it in // 2nd element of table array is ref value used to fill it in
unsigned char c = a[1]; unsigned char c = a[1];
@ -14,7 +14,8 @@ static void _gf_vect_mul_base(int len, unsigned char *a, unsigned char *src,
return; return;
} }
void gf_vect_mul_vsx(int len, unsigned char *gftbl, unsigned char *src, unsigned char *dest) void
gf_vect_mul_vsx(int len, unsigned char *gftbl, unsigned char *src, unsigned char *dest)
{ {
unsigned char *s, *t0; unsigned char *s, *t0;
vector unsigned char vX1, vY1; vector unsigned char vX1, vY1;