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);
#endif
return PROVIDER_BASIC(gf_vect_dot_prod);
}
DEFINE_INTERFACE_DISPATCHER(gf_vect_mad)
@ -61,7 +60,6 @@ DEFINE_INTERFACE_DISPATCHER(gf_vect_mad)
return PROVIDER_INFO(gf_vect_mad_neon);
#endif
return PROVIDER_BASIC(gf_vect_mad);
}
DEFINE_INTERFACE_DISPATCHER(ec_encode_data)
@ -79,7 +77,6 @@ DEFINE_INTERFACE_DISPATCHER(ec_encode_data)
return PROVIDER_INFO(ec_encode_data_neon);
#endif
return PROVIDER_BASIC(ec_encode_data);
}
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);
#endif
return PROVIDER_BASIC(ec_encode_data_update);
}
DEFINE_INTERFACE_DISPATCHER(gf_vect_mul)
@ -115,10 +111,6 @@ DEFINE_INTERFACE_DISPATCHER(gf_vect_mul)
return PROVIDER_INFO(gf_vect_mul_neon);
#endif
return PROVIDER_BASIC(gf_vect_mul);
}
DEFINE_INTERFACE_DISPATCHER(ec_init_tables)
{
return PROVIDER_BASIC(ec_init_tables);
}
DEFINE_INTERFACE_DISPATCHER(ec_init_tables) { return PROVIDER_BASIC(ec_init_tables); }

View File

@ -29,30 +29,42 @@
#include "erasure_code.h"
/*external function*/
extern void gf_vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char *dest);
extern void gf_2vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
extern void gf_3vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
extern void gf_4vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
extern void gf_5vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
extern void gf_vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char *dest);
extern void gf_2vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls,
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);
extern void
gf_vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char *dest);
extern void
gf_2vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
extern void
gf_3vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
extern void
gf_4vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
extern void
gf_5vect_dot_prod_neon(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
extern void
gf_vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *dest);
extern void
gf_2vect_mad_neon(int len, int vec, int vec_i, unsigned char *gftbls, 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)
{
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)
{
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 */
extern void gf_vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char *dest);
extern void gf_2vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
extern void gf_3vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
extern void gf_4vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
extern void gf_5vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
extern void gf_6vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
extern void gf_7vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
extern void gf_8vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
extern void gf_vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls,
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);
extern void
gf_vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char *dest);
extern void
gf_2vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
extern void
gf_3vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
extern void
gf_4vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
extern void
gf_5vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
extern void
gf_6vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
extern void
gf_7vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
extern void
gf_8vect_dot_prod_sve(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest);
extern void
gf_vect_mad_sve(int len, int vec, int vec_i, unsigned char *gftbls, 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)
{
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)
{
if (len < 16) {

View File

@ -34,7 +34,8 @@
#include "erasure_code.h"
#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;
@ -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
int i;
@ -60,7 +62,8 @@ unsigned char gf_mul(unsigned char a, unsigned char b)
#endif
}
unsigned char gf_inv(unsigned char a)
unsigned char
gf_inv(unsigned char a)
{
#ifndef GF_LARGE_TABLES
if (a == 0)
@ -72,7 +75,8 @@ unsigned char gf_inv(unsigned char a)
#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;
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;
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 (j = 0; j < k; 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;
unsigned char temp;
@ -167,18 +172,19 @@ 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
// 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 c4 = (c2 << 1) ^ ((c2 & 0x80) ? 0x1d : 0); //Mult by GF{2}
unsigned char c8 = (c4 << 1) ^ ((c4 & 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 c8 = (c4 << 1) ^ ((c4 & 0x80) ? 0x1d : 0); // Mult by GF{2}
#if (__WORDSIZE == 64 || _WIN64 || __x86_64__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
unsigned long long v1, v2, v4, v8, *t;
unsigned long long v10, v20, v40, v80;
unsigned char c17, c18, c20, c24;
t = (unsigned long long *)tbl;
t = (unsigned long long *) tbl;
v1 = c * 0x0100010001000100ull;
v2 = c2 * 0x0101000001010000ull;
@ -189,10 +195,10 @@ void gf_vect_mul_init(unsigned char c, unsigned char *tbl)
t[0] = v4;
t[1] = v8 ^ v4;
c17 = (c8 << 1) ^ ((c8 & 0x80) ? 0x1d : 0); //Mult by GF{2}
c18 = (c17 << 1) ^ ((c17 & 0x80) ? 0x1d : 0); //Mult by GF{2}
c20 = (c18 << 1) ^ ((c18 & 0x80) ? 0x1d : 0); //Mult by GF{2}
c24 = (c20 << 1) ^ ((c20 & 0x80) ? 0x1d : 0); //Mult by GF{2}
c17 = (c8 << 1) ^ ((c8 & 0x80) ? 0x1d : 0); // Mult by GF{2}
c18 = (c17 << 1) ^ ((c17 & 0x80) ? 0x1d : 0); // Mult by GF{2}
c20 = (c18 << 1) ^ ((c18 & 0x80) ? 0x1d : 0); // Mult by GF{2}
c24 = (c20 << 1) ^ ((c20 & 0x80) ? 0x1d : 0); // Mult by GF{2}
v10 = c17 * 0x0100010001000100ull;
v20 = c18 * 0x0101000001010000ull;
@ -205,8 +211,7 @@ void gf_vect_mul_init(unsigned char c, unsigned char *tbl)
#else // 32-bit or other
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,
c31;
unsigned char c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31;
c3 = c2 ^ c;
c5 = c4 ^ c;
@ -238,14 +243,14 @@ void gf_vect_mul_init(unsigned char c, unsigned char *tbl)
tbl[14] = c14;
tbl[15] = c15;
c17 = (c8 << 1) ^ ((c8 & 0x80) ? 0x1d : 0); //Mult by GF{2}
c18 = (c17 << 1) ^ ((c17 & 0x80) ? 0x1d : 0); //Mult by GF{2}
c17 = (c8 << 1) ^ ((c8 & 0x80) ? 0x1d : 0); // Mult by GF{2}
c18 = (c17 << 1) ^ ((c17 & 0x80) ? 0x1d : 0); // Mult by GF{2}
c19 = c18 ^ c17;
c20 = (c18 << 1) ^ ((c18 & 0x80) ? 0x1d : 0); //Mult by GF{2}
c20 = (c18 << 1) ^ ((c18 & 0x80) ? 0x1d : 0); // Mult by GF{2}
c21 = c20 ^ c17;
c22 = c20 ^ c18;
c23 = c20 ^ c19;
c24 = (c20 << 1) ^ ((c20 & 0x80) ? 0x1d : 0); //Mult by GF{2}
c24 = (c20 << 1) ^ ((c20 & 0x80) ? 0x1d : 0); // Mult by GF{2}
c25 = c24 ^ c17;
c26 = c24 ^ c18;
c27 = c24 ^ c19;
@ -274,8 +279,8 @@ void gf_vect_mul_init(unsigned char c, unsigned char *tbl)
#endif //__WORDSIZE == 64 || _WIN64 || __x86_64__
}
void gf_vect_dot_prod_base(int len, int vlen, unsigned char *v,
unsigned char **src, unsigned char *dest)
void
gf_vect_dot_prod_base(int len, int vlen, unsigned char *v, unsigned char **src, unsigned char *dest)
{
int i, j;
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,
unsigned char *v, unsigned char *src, unsigned char *dest)
void
gf_vect_mad_base(int len, int vec, int vec_i, unsigned char *v, unsigned char *src,
unsigned char *dest)
{
int i;
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,
unsigned char **src, unsigned char **dest)
void
ec_encode_data_base(int len, int srcs, int dests, unsigned char *v, unsigned char **src,
unsigned char **dest)
{
int i, j, l;
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)
{
int i, l;
@ -333,9 +341,10 @@ 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];
// Len must be aligned to 32B

File diff suppressed because it is too large Load Diff

View File

@ -29,37 +29,40 @@
#include "erasure_code.h"
void gf_vect_dot_prod(int len, int vlen, unsigned char *v,
unsigned char **src, unsigned char *dest)
void
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);
}
void gf_vect_mad(int len, int vec, int vec_i,
unsigned char *v, unsigned char *src, unsigned char *dest)
void
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);
}
void ec_encode_data(int len, int srcs, int dests, unsigned char *v,
unsigned char **src, unsigned char **dest)
void
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);
}
void ec_encode_data_update(int len, int k, int rows, int vec_i, unsigned char *v,
unsigned char *data, unsigned char **dest)
void
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);
}
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);
}

View File

@ -31,7 +31,8 @@
#include "ec_base.h" /* for GF tables */
#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)
{
@ -65,10 +66,10 @@ void ec_encode_data_sse(int len, int k, int rows, unsigned char *g_tbls, unsigne
case 0:
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)
{
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:
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)
{
@ -138,38 +139,50 @@ void ec_encode_data_avx2(int len, int k, int rows, unsigned char *g_tbls, unsign
case 0:
break;
}
}
#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);
extern int gf_2vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls,
unsigned char **data, unsigned char **coding);
extern int gf_3vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls,
unsigned char **data, unsigned char **coding);
extern int gf_4vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls,
unsigned char **data, unsigned char **coding);
extern int gf_5vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls,
unsigned char **data, unsigned char **coding);
extern int gf_6vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls,
unsigned char **data, unsigned char **coding);
extern void gf_vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char *dest);
extern void gf_2vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls,
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);
extern int
gf_2vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding);
extern int
gf_3vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding);
extern int
gf_4vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding);
extern int
gf_5vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding);
extern int
gf_6vect_dot_prod_avx512(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding);
extern void
gf_vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *dest);
extern void
gf_2vect_mad_avx512(int len, int vec, int vec_i, unsigned char *gftbls, 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,
unsigned char **data, unsigned char **coding)
void
ec_encode_data_avx512(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding)
{
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)
{
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
extern void gf_vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls,
unsigned char **data, unsigned char *dest);
extern void gf_2vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls,
unsigned char **data, unsigned char **coding);
extern void gf_3vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls,
unsigned char **data, unsigned char **coding);
extern void gf_4vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls,
unsigned char **data, 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_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char *dest);
extern void
gf_2vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding);
extern void
gf_3vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding);
extern void
gf_4vect_dot_prod_avx512_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
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,
unsigned char *src, unsigned char *dest);
extern void gf_2vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char **dest);
extern void gf_3vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char **dest);
extern void gf_4vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, 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_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *dest);
extern void
gf_2vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_3vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char **dest);
extern void
gf_4vect_mad_avx512_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
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,
unsigned char **data, unsigned char *dest);
extern void gf_2vect_dot_prod_avx2_gfni(int len, int k, unsigned char *g_tbls,
unsigned char **data, unsigned char **coding);
extern void gf_3vect_dot_prod_avx2_gfni(int len, int k, unsigned char *g_tbls,
unsigned char **data, unsigned char **coding);
extern void gf_vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char *dest);
extern void gf_2vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls,
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);
extern void
gf_vect_dot_prod_avx2_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char *dest);
extern void
gf_2vect_dot_prod_avx2_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding);
extern void
gf_3vect_dot_prod_avx2_gfni(int len, int k, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding);
extern void
gf_vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *dest);
extern void
gf_2vect_mad_avx2_gfni(int len, int vec, int vec_i, unsigned char *gftbls, 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;
@ -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 (j = 0; j < k; j++)
*(g64++) = gf_table_gfni[*a++];
}
void ec_encode_data_avx512_gfni(int len, int k, int rows, unsigned char *g_tbls,
unsigned char **data, unsigned char **coding)
void
ec_encode_data_avx512_gfni(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding)
{
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,
unsigned char **data, unsigned char **coding)
void
ec_encode_data_avx2_gfni(int len, int k, int rows, unsigned char *g_tbls, unsigned char **data,
unsigned char **coding)
{
while (rows >= 3) {
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,
unsigned char *g_tbls, unsigned char *data,
unsigned char **coding)
void
ec_encode_data_update_avx512_gfni(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
unsigned char *data, unsigned char **coding)
{
while (rows >= 6) {
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,
unsigned char *g_tbls, unsigned char *data,
unsigned char **coding)
void
ec_encode_data_update_avx2_gfni(int len, int k, int rows, int vec_i, unsigned char *g_tbls,
unsigned char *data, unsigned char **coding)
{
while (rows >= 5) {
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__
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)
{
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:
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)
{
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:
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)
{
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:
break;
}
}
#endif //__WORDSIZE == 64 || _WIN64 || __x86_64__

View File

@ -35,21 +35,21 @@
#include "test.h"
#ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */
#define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset
# define TEST_SOURCES 32
# define TEST_LEN(m) ((128*1024 / m) & ~(64-1))
# define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST)
#define TEST_SOURCES 32
#define TEST_LEN(m) ((128 * 1024 / m) & ~(64 - 1))
#define TEST_TYPE_STR "_warm"
#elif defined(COLD_TEST)
// Uncached test. Pull from large mem base.
# define TEST_SOURCES 32
# define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64-1))
# define TEST_TYPE_STR "_cold"
#elif defined (TEST_CUSTOM)
# define TEST_TYPE_STR "_cus"
#define TEST_SOURCES 32
#define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64 - 1))
#define TEST_TYPE_STR "_cold"
#elif defined(TEST_CUSTOM)
#define TEST_TYPE_STR "_cus"
#endif
#define MMAX TEST_SOURCES
@ -59,14 +59,16 @@
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_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,
u8 * src_err_list, int nerrs, u8 ** temp_buffs)
int
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;
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;
}
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int i, j, m, k, nerrs, check;
void *buf;
@ -148,11 +151,11 @@ int main(int argc, char *argv[])
// Start encode test
BENCHMARK(&start, BENCHMARK_TIME, ec_encode_perf(m, k, a, g_tbls, buffs));
printf("erasure_code_base_encode" TEST_TYPE_STR ": ");
perf_print(start, (long long)(TEST_LEN(m)) * (m));
perf_print(start, (long long) (TEST_LEN(m)) * (m));
// Start decode test
BENCHMARK(&start, BENCHMARK_TIME, check =
ec_decode_perf(m, k, a, g_tbls, buffs, src_in_err, src_err_list, nerrs,
BENCHMARK(&start, BENCHMARK_TIME,
check = ec_decode_perf(m, k, a, g_tbls, buffs, src_in_err, src_err_list, nerrs,
temp_buffs));
if (check == BAD_MATRIX) {
@ -168,7 +171,7 @@ int main(int argc, char *argv[])
}
printf("erasure_code_base_decode" TEST_TYPE_STR ": ");
perf_print(start, (long long)(TEST_LEN(m)) * (k + nerrs));
perf_print(start, (long long) (TEST_LEN(m)) * (k + nerrs));
printf("done all: Pass\n");
return 0;

View File

@ -35,13 +35,13 @@
#include "test.h"
#define TEST_LEN 8192
#define TEST_SIZE (TEST_LEN/2)
#define TEST_SIZE (TEST_LEN / 2)
#ifndef TEST_SOURCES
# define TEST_SOURCES 127
#define TEST_SOURCES 127
#endif
#ifndef RANDOMS
# define RANDOMS 50
#define RANDOMS 50
#endif
#define MMAX TEST_SOURCES
@ -51,12 +51,12 @@
#ifdef EC_ALIGNED_ADDR
// Define power of 2 range to check ptr, len alignment
# define PTR_ALIGN_CHK_B 0
# define LEN_ALIGN_CHK_B 0 // 0 for aligned only
#define PTR_ALIGN_CHK_B 0
#define LEN_ALIGN_CHK_B 0 // 0 for aligned only
#else
// Define power of 2 range to check ptr, len alignment
# define PTR_ALIGN_CHK_B 32
# define LEN_ALIGN_CHK_B 32 // 0 for aligned only
#define PTR_ALIGN_CHK_B 32
#define LEN_ALIGN_CHK_B 32 // 0 for aligned only
#endif
#ifndef TEST_SEED
@ -65,7 +65,8 @@
typedef unsigned char u8;
void dump(unsigned char *buf, int len)
void
dump(unsigned char *buf, int len)
{
int i;
for (i = 0; i < len;) {
@ -76,7 +77,8 @@ void dump(unsigned char *buf, int len)
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;
for (i = 0; i < k; i++) {
@ -88,7 +90,8 @@ void dump_matrix(unsigned char **s, int k, int m)
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;
for (i = 0; i < k; i++) {
@ -101,8 +104,9 @@ void dump_u8xu8(unsigned char *s, int k, int m)
}
// Generate Random errors
static void gen_err_list(unsigned char *src_err_list,
unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs, int k, int m)
static void
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 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
while ((err = (rand() % KMAX)) >= m) ;
while ((err = (rand() % KMAX)) >= m)
;
src_err_list[nerrs++] = err;
src_in_err[err] = 1;
if (err < k)
@ -131,13 +136,11 @@ static void gen_err_list(unsigned char *src_err_list,
#define NO_INVERT_MATRIX -2
// Generate decode matrix from encode matrix
static int gf_gen_decode_matrix(unsigned char *encode_matrix,
unsigned char *decode_matrix,
unsigned char *invert_matrix,
unsigned int *decode_index,
unsigned char *src_err_list,
unsigned char *src_in_err,
int nerrs, int nsrcerrs, int k, int m)
static int
gf_gen_decode_matrix(unsigned char *encode_matrix, unsigned char *decode_matrix,
unsigned char *invert_matrix, unsigned int *decode_index,
unsigned char *src_err_list, unsigned char *src_in_err, int nerrs,
int nsrcerrs, int k, int m)
{
int i, j, p;
int r;
@ -189,7 +192,6 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
decode_index[k - 1] += incr;
for (j = 0; j < k; j++)
b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j];
};
for (i = 0; i < nsrcerrs; i++) {
@ -213,7 +215,8 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
return 0;
}
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int re = 0;
int i, j, p, rtest, m, k;
@ -257,8 +260,8 @@ int main(int argc, char *argv[])
decode_matrix = malloc(MMAX * KMAX);
invert_matrix = malloc(MMAX * KMAX);
g_tbls = malloc(KMAX * TEST_SOURCES * 32);
if (encode_matrix == NULL || decode_matrix == NULL
|| invert_matrix == NULL || g_tbls == NULL) {
if (encode_matrix == NULL || decode_matrix == NULL || invert_matrix == NULL ||
g_tbls == NULL) {
printf("Test failure! Error with malloc\n");
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);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list, src_in_err,
nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
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);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list, src_in_err,
nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
return -1;
@ -400,8 +401,10 @@ int main(int argc, char *argv[])
// Do more random tests
for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ;
while ((k = (rand() % KMAX)) >= m || k < 1) ;
while ((m = (rand() % MMAX)) < 2)
;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX)
continue;
@ -427,9 +430,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
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);
// Perform matrix dot_prod for EC encoding
// using g_tbls from encode matrix a
ec_encode_data_base(size, k, m - k, g_tbls, efence_buffs,
&efence_buffs[k]);
ec_encode_data_base(size, k, m - k, g_tbls, efence_buffs, &efence_buffs[k]);
// Random errors
memset(src_in_err, 0, TEST_SOURCES);
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix,
decode_index, src_err_list, src_in_err, nerrs,
nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
return -1;
@ -533,11 +534,10 @@ int main(int argc, char *argv[])
for (i = 0; i < nerrs; i++) {
if (0 !=
memcmp(temp_buffs[k + i], efence_buffs[src_err_list[i]],
if (0 != memcmp(temp_buffs[k + i], efence_buffs[src_err_list[i]],
size)) {
printf("Efence: Fail error recovery (%d, %d, %d)\n", m,
k, nerrs);
printf("Efence: Fail error recovery (%d, %d, %d)\n", m, k,
nerrs);
printf("size = %d\n", size);
@ -562,14 +562,15 @@ int main(int argc, char *argv[])
}
}
}
}
// Test rand ptr alignment if available
for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ;
while ((k = (rand() % KMAX)) >= m || k < 1) ;
while ((m = (rand() % MMAX)) < 2)
;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX)
continue;
@ -605,9 +606,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
return -1;
@ -634,11 +634,11 @@ int main(int argc, char *argv[])
for (p = 0; p < k; p++)
printf(" %d", decode_index[p]);
printf("\nencode_matrix:\n");
dump_u8xu8((unsigned char *)encode_matrix, m, k);
dump_u8xu8((unsigned char *) encode_matrix, m, k);
printf("inv b:\n");
dump_u8xu8((unsigned char *)invert_matrix, k, k);
dump_u8xu8((unsigned char *) invert_matrix, k, k);
printf("\ndecode_matrix:\n");
dump_u8xu8((unsigned char *)decode_matrix, m, k);
dump_u8xu8((unsigned char *) decode_matrix, m, k);
printf("orig data:\n");
dump_matrix(ubuffs, m, 25);
printf("orig :");
@ -660,8 +660,7 @@ int main(int argc, char *argv[])
printf("Fail rand ualign encode pad start\n");
return -1;
}
if (memcmp
(buffs[i] + offset + size, temp_buffs[0],
if (memcmp(buffs[i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign encode pad end\n");
return -1;
@ -675,8 +674,7 @@ int main(int argc, char *argv[])
printf("Fail rand ualign decode pad start\n");
return -1;
}
if (memcmp
(temp_buffs[k + i] + offset + size, temp_buffs[0],
if (memcmp(temp_buffs[k + i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign decode pad end\n");
return -1;
@ -693,8 +691,10 @@ int main(int argc, char *argv[])
align = (LEN_ALIGN_CHK_B != 0) ? 13 : 16;
for (size = TEST_LEN; size > 0; size -= align) {
while ((m = (rand() % MMAX)) < 2) ;
while ((k = (rand() % KMAX)) >= m || k < 1) ;
while ((m = (rand() % MMAX)) < 2)
;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX)
continue;
@ -718,9 +718,8 @@ int main(int argc, char *argv[])
memset(src_in_err, 0, TEST_SOURCES);
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
return -1;
@ -747,11 +746,11 @@ int main(int argc, char *argv[])
for (p = 0; p < k; p++)
printf(" %d", decode_index[p]);
printf("\nencode_matrix:\n");
dump_u8xu8((unsigned char *)encode_matrix, m, k);
dump_u8xu8((unsigned char *) encode_matrix, m, k);
printf("inv b:\n");
dump_u8xu8((unsigned char *)invert_matrix, k, k);
dump_u8xu8((unsigned char *) invert_matrix, k, k);
printf("\ndecode_matrix:\n");
dump_u8xu8((unsigned char *)decode_matrix, m, k);
dump_u8xu8((unsigned char *) decode_matrix, m, k);
printf("orig data:\n");
dump_matrix(buffs, m, 25);
printf("orig :");

View File

@ -34,24 +34,24 @@
#include "test.h"
#ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */
#define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset
# define TEST_SOURCES 32
# define TEST_LEN(m) ((128*1024 / m) & ~(64-1))
# define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST)
#define TEST_SOURCES 32
#define TEST_LEN(m) ((128 * 1024 / m) & ~(64 - 1))
#define TEST_TYPE_STR "_warm"
#elif defined(COLD_TEST)
// Uncached test. Pull from large mem base.
# define TEST_SOURCES 32
# define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64-1))
# define TEST_TYPE_STR "_cold"
#elif defined (TEST_CUSTOM)
# define TEST_TYPE_STR "_cus"
#define TEST_SOURCES 32
#define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64 - 1))
#define TEST_TYPE_STR "_cold"
#elif defined(TEST_CUSTOM)
#define TEST_TYPE_STR "_cus"
#endif
#ifndef TEST_SEED
# define TEST_SEED 0x1234
#define TEST_SEED 0x1234
#endif
#define MMAX TEST_SOURCES
@ -61,26 +61,30 @@
typedef unsigned char u8;
void usage(const char *app_name)
void
usage(const char *app_name)
{
fprintf(stderr,
"Usage: %s [options]\n"
" -h Help\n"
" -k <val> Number of source 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);
}
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);
BENCHMARK(start, BENCHMARK_TIME,
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,
u8 * src_err_list, int nerrs, u8 ** temp_buffs, struct perf *start)
int
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;
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;
}
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int i, j, m, k, p, nerrs, check, ret = -1;
void *buf;
@ -144,8 +149,7 @@ int main(int argc, char *argv[])
}
if (nerrs > k) {
printf
("Number of errors (%d) cannot be higher than number of data buffers (%d)\n",
printf("Number of errors (%d) cannot be higher than number of data buffers (%d)\n",
nerrs, k);
return -1;
}
@ -166,8 +170,8 @@ int main(int argc, char *argv[])
}
if (nerrs > p) {
printf
("Number of errors (%d) cannot be higher than number of parity buffers (%d)\n",
printf("Number of errors (%d) cannot be higher than number of parity buffers "
"(%d)\n",
nerrs, p);
return -1;
}
@ -180,7 +184,7 @@ int main(int argc, char *argv[])
return -1;
}
u8 *err_list = malloc((size_t)nerrs);
u8 *err_list = malloc((size_t) nerrs);
if (err_list == NULL) {
printf("Error allocating list of array of error indices\n");
return -1;
@ -198,10 +202,10 @@ int main(int argc, char *argv[])
err_list[i++] = next_err;
}
printf("Testing with %u data buffers and %u parity buffers (num errors = %u, in [ ", k,
p, nerrs);
printf("Testing with %u data buffers and %u parity buffers (num errors = %u, in [ ", k, p,
nerrs);
for (i = 0; i < nerrs; i++)
printf("%d ", (int)err_list[i]);
printf("%d ", (int) err_list[i]);
printf("])\n");
@ -239,11 +243,11 @@ int main(int argc, char *argv[])
// Start encode test
ec_encode_perf(m, k, a, g_tbls, buffs, &start);
printf("erasure_code_encode" TEST_TYPE_STR ": ");
perf_print(start, (long long)(TEST_LEN(m)) * (m));
perf_print(start, (long long) (TEST_LEN(m)) * (m));
// Start decode test
check = ec_decode_perf(m, k, a, g_tbls, buffs, src_in_err, src_err_list, nerrs,
temp_buffs, &start);
check = ec_decode_perf(m, k, a, g_tbls, buffs, src_in_err, src_err_list, nerrs, temp_buffs,
&start);
if (check == BAD_MATRIX) {
printf("BAD MATRIX\n");
@ -259,13 +263,13 @@ int main(int argc, char *argv[])
}
printf("erasure_code_decode" TEST_TYPE_STR ": ");
perf_print(start, (long long)(TEST_LEN(m)) * (k + nerrs));
perf_print(start, (long long) (TEST_LEN(m)) * (k + nerrs));
printf("done all: Pass\n");
ret = 0;
exit:
exit:
free(err_list);
for (i = 0; i < TEST_SOURCES; i++) {
free(buffs[i]);

View File

@ -35,13 +35,13 @@
#include "test.h"
#define TEST_LEN 8192
#define TEST_SIZE (TEST_LEN/2)
#define TEST_SIZE (TEST_LEN / 2)
#ifndef TEST_SOURCES
# define TEST_SOURCES 127
#define TEST_SOURCES 127
#endif
#ifndef RANDOMS
# define RANDOMS 200
#define RANDOMS 200
#endif
#define MMAX TEST_SOURCES
@ -52,12 +52,12 @@
#ifdef EC_ALIGNED_ADDR
// Define power of 2 range to check ptr, len alignment
# define PTR_ALIGN_CHK_B 0
# define LEN_ALIGN_CHK_B 0 // 0 for aligned only
#define PTR_ALIGN_CHK_B 0
#define LEN_ALIGN_CHK_B 0 // 0 for aligned only
#else
// Define power of 2 range to check ptr, len alignment
# define PTR_ALIGN_CHK_B 32
# define LEN_ALIGN_CHK_B 32 // 0 for aligned only
#define PTR_ALIGN_CHK_B 32
#define LEN_ALIGN_CHK_B 32 // 0 for aligned only
#endif
#ifndef TEST_SEED
@ -66,7 +66,8 @@
typedef unsigned char u8;
void dump(unsigned char *buf, int len)
void
dump(unsigned char *buf, int len)
{
int i;
for (i = 0; i < len;) {
@ -77,7 +78,8 @@ void dump(unsigned char *buf, int len)
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;
for (i = 0; i < k; i++) {
@ -89,7 +91,8 @@ void dump_matrix(unsigned char **s, int k, int m)
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;
for (i = 0; i < k; i++) {
@ -102,8 +105,9 @@ void dump_u8xu8(unsigned char *s, int k, int m)
}
// Generate Random errors
static void gen_err_list(unsigned char *src_err_list,
unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs, int k, int m)
static void
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 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
while ((err = (rand() % KMAX)) >= m) ;
while ((err = (rand() % KMAX)) >= m)
;
src_err_list[nerrs++] = err;
src_in_err[err] = 1;
if (err < k)
@ -132,13 +137,11 @@ static void gen_err_list(unsigned char *src_err_list,
#define NO_INVERT_MATRIX -2
// Generate decode matrix from encode matrix
static int gf_gen_decode_matrix(unsigned char *encode_matrix,
unsigned char *decode_matrix,
unsigned char *invert_matrix,
unsigned int *decode_index,
unsigned char *src_err_list,
unsigned char *src_in_err,
int nerrs, int nsrcerrs, int k, int m)
static int
gf_gen_decode_matrix(unsigned char *encode_matrix, unsigned char *decode_matrix,
unsigned char *invert_matrix, unsigned int *decode_index,
unsigned char *src_err_list, unsigned char *src_in_err, int nerrs,
int nsrcerrs, int k, int m)
{
int i, j, p;
int r;
@ -190,7 +193,6 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
decode_index[k - 1] += incr;
for (j = 0; j < k; j++)
b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j];
};
for (i = 0; i < nsrcerrs; i++) {
@ -214,7 +216,8 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
return 0;
}
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int re = -1;
int i, j, p, rtest, m, k;
@ -222,8 +225,8 @@ int main(int argc, char *argv[])
void *buf;
unsigned int decode_index[MMAX];
unsigned char *temp_buffs[TEST_SOURCES] = { NULL }, *buffs[TEST_SOURCES] = { NULL };
unsigned char *encode_matrix = NULL, *decode_matrix = NULL, *invert_matrix =
NULL, *g_tbls = NULL;
unsigned char *encode_matrix = NULL, *decode_matrix = NULL, *invert_matrix = NULL,
*g_tbls = NULL;
unsigned char src_in_err[TEST_SOURCES], src_err_list[TEST_SOURCES];
unsigned char *recov[TEST_SOURCES];
@ -259,8 +262,8 @@ int main(int argc, char *argv[])
decode_matrix = malloc(MMAX * KMAX);
invert_matrix = malloc(MMAX * KMAX);
g_tbls = malloc(KMAX * TEST_SOURCES * 32);
if (encode_matrix == NULL || decode_matrix == NULL
|| invert_matrix == NULL || g_tbls == NULL) {
if (encode_matrix == NULL || decode_matrix == NULL || invert_matrix == NULL ||
g_tbls == NULL) {
printf("Test failure! Error with malloc\n");
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);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list, src_in_err,
nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
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);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list, src_in_err,
nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
goto exit;
@ -406,8 +407,10 @@ int main(int argc, char *argv[])
// Do more random tests
for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ;
while ((k = (rand() % KMAX)) >= m || k < 1) ;
while ((m = (rand() % MMAX)) < 2)
;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX)
continue;
@ -433,9 +436,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
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);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix,
decode_index, src_err_list, src_in_err, nerrs,
nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
goto exit;
@ -543,11 +545,10 @@ int main(int argc, char *argv[])
for (i = 0; i < nerrs; i++) {
if (0 !=
memcmp(temp_buffs[k + i], efence_buffs[src_err_list[i]],
if (0 != memcmp(temp_buffs[k + i], efence_buffs[src_err_list[i]],
size)) {
printf("Efence: Fail error recovery (%d, %d, %d)\n", m,
k, nerrs);
printf("Efence: Fail error recovery (%d, %d, %d)\n", m, k,
nerrs);
printf("size = %d\n", size);
@ -573,14 +574,15 @@ int main(int argc, char *argv[])
}
}
}
}
// Test rand ptr alignment if available
for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ;
while ((k = (rand() % KMAX)) >= m || k < 1) ;
while ((m = (rand() % MMAX)) < 2)
;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX)
continue;
@ -616,9 +618,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
goto exit;
@ -645,11 +646,11 @@ int main(int argc, char *argv[])
for (p = 0; p < k; p++)
printf(" %d", decode_index[p]);
printf("\nencode_matrix:\n");
dump_u8xu8((unsigned char *)encode_matrix, m, k);
dump_u8xu8((unsigned char *) encode_matrix, m, k);
printf("inv b:\n");
dump_u8xu8((unsigned char *)invert_matrix, k, k);
dump_u8xu8((unsigned char *) invert_matrix, k, k);
printf("\ndecode_matrix:\n");
dump_u8xu8((unsigned char *)decode_matrix, m, k);
dump_u8xu8((unsigned char *) decode_matrix, m, k);
printf("orig data:\n");
dump_matrix(ubuffs, m, 25);
printf("orig :");
@ -673,8 +674,7 @@ int main(int argc, char *argv[])
re = -1;
goto exit;
}
if (memcmp
(buffs[i] + offset + size, temp_buffs[0],
if (memcmp(buffs[i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign encode pad end\n");
re = -1;
@ -690,8 +690,7 @@ int main(int argc, char *argv[])
re = -1;
goto exit;
}
if (memcmp
(temp_buffs[k + i] + offset + size, temp_buffs[0],
if (memcmp(temp_buffs[k + i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign decode pad end\n");
re = -1;
@ -709,8 +708,10 @@ int main(int argc, char *argv[])
align = (LEN_ALIGN_CHK_B != 0) ? 13 : 16;
for (size = TEST_LEN; size > 0; size -= align) {
while ((m = (rand() % MMAX)) < 2) ;
while ((k = (rand() % KMAX)) >= m || k < 1) ;
while ((m = (rand() % MMAX)) < 2)
;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX)
continue;
@ -734,9 +735,8 @@ int main(int argc, char *argv[])
memset(src_in_err, 0, TEST_SOURCES);
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
goto exit;
@ -763,11 +763,11 @@ int main(int argc, char *argv[])
for (p = 0; p < k; p++)
printf(" %d", decode_index[p]);
printf("\nencode_matrix:\n");
dump_u8xu8((unsigned char *)encode_matrix, m, k);
dump_u8xu8((unsigned char *) encode_matrix, m, k);
printf("inv b:\n");
dump_u8xu8((unsigned char *)invert_matrix, k, k);
dump_u8xu8((unsigned char *) invert_matrix, k, k);
printf("\ndecode_matrix:\n");
dump_u8xu8((unsigned char *)decode_matrix, m, k);
dump_u8xu8((unsigned char *) decode_matrix, m, k);
printf("orig data:\n");
dump_matrix(buffs, m, 25);
printf("orig :");
@ -783,7 +783,7 @@ int main(int argc, char *argv[])
printf("done EC tests: Pass\n");
re = 0;
exit:
exit:
for (i = 0; i < TEST_SOURCES; i++) {
if (buffs[i])
aligned_free(buffs[i]);

View File

@ -33,39 +33,39 @@
#include "erasure_code.h"
#include "test.h"
//By default, test multibinary version
// By default, test multibinary version
#ifndef FUNCTION_UNDER_TEST
# define FUNCTION_UNDER_TEST ec_encode_data_update
# define REF_FUNCTION ec_encode_data
#define FUNCTION_UNDER_TEST ec_encode_data_update
#define REF_FUNCTION ec_encode_data
#endif
//By default, test EC(8+4)
// By default, test EC(8+4)
#if (!defined(VECT))
# define VECT 4
#define VECT 4
#endif
#define str(s) #s
#define xstr(s) str(s)
#ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */
#define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset
# define TEST_SOURCES 32
# define TEST_LEN(m) ((128*1024 / m) & ~(64-1))
# define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST)
#define TEST_SOURCES 32
#define TEST_LEN(m) ((128 * 1024 / m) & ~(64 - 1))
#define TEST_TYPE_STR "_warm"
#elif defined(COLD_TEST)
// Uncached test. Pull from large mem base.
# define TEST_SOURCES 32
# define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64-1))
# define TEST_TYPE_STR "_cold"
#elif defined (TEST_CUSTOM)
# define TEST_TYPE_STR "_cus"
#define TEST_SOURCES 32
#define TEST_LEN(m) ((GT_L3_CACHE / m) & ~(64 - 1))
#define TEST_TYPE_STR "_cold"
#elif defined(TEST_CUSTOM)
#define TEST_TYPE_STR "_cus"
#endif
#ifndef TEST_SEED
# define TEST_SEED 0x1234
#define TEST_SEED 0x1234
#endif
#define MMAX TEST_SOURCES
@ -73,18 +73,21 @@
typedef unsigned char u8;
void usage(const char *app_name)
void
usage(const char *app_name)
{
fprintf(stderr,
"Usage: %s [options]\n"
" -h Help\n"
" -k <val> Number of source 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);
}
void dump(unsigned char *buf, int len)
void
dump(unsigned char *buf, int len)
{
int i;
for (i = 0; i < len;) {
@ -95,26 +98,29 @@ void dump(unsigned char *buf, int len)
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);
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;
// Make parity vects
ec_init_tables(k, m - k, &a[k * k], g_tbls);
for (i = 0; i < k; i++) {
FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls,
perf_update_buffs[i], &perf_update_buffs[k]);
FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls, perf_update_buffs[i],
&perf_update_buffs[k]);
}
}
int 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
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;
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
ec_init_tables(k, nerrs, c, g_tbls);
for (i = 0; i < k; i++) {
FUNCTION_UNDER_TEST(TEST_LEN(m), k, nerrs, i, g_tbls, recov[i],
perf_update_buffs);
FUNCTION_UNDER_TEST(TEST_LEN(m), k, nerrs, i, g_tbls, recov[i], perf_update_buffs);
}
return 0;
}
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int i, j, check, m, k, p, nerrs, ret = -1;
void *buf;
@ -181,8 +187,7 @@ int main(int argc, char *argv[])
}
if (nerrs > k) {
printf
("Number of errors (%d) cannot be higher than number of data buffers (%d)\n",
printf("Number of errors (%d) cannot be higher than number of data buffers (%d)\n",
nerrs, k);
return -1;
}
@ -198,8 +203,8 @@ int main(int argc, char *argv[])
}
if (nerrs > p) {
printf
("Number of errors (%d) cannot be higher than number of parity buffers (%d)\n",
printf("Number of errors (%d) cannot be higher than number of parity buffers "
"(%d)\n",
nerrs, p);
return -1;
}
@ -217,7 +222,7 @@ int main(int argc, char *argv[])
return -1;
}
u8 *err_list = malloc((size_t)nerrs);
u8 *err_list = malloc((size_t) nerrs);
if (err_list == NULL) {
printf("Error allocating list of array of error indices\n");
return -1;
@ -235,8 +240,8 @@ int main(int argc, char *argv[])
err_list[i++] = next_err;
}
printf("Testing with %u data buffers and %u parity buffers (num errors = %u, in [ ", k,
p, nerrs);
printf("Testing with %u data buffers and %u parity buffers (num errors = %u, in [ ", k, p,
nerrs);
for (i = 0; i < nerrs; i++)
printf("%d ", err_list[i]);
@ -264,7 +269,8 @@ int main(int argc, char *argv[])
goto exit;
}
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++) {
@ -273,7 +279,8 @@ int main(int argc, char *argv[])
goto exit;
}
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++) {
if (posix_memalign(&buf, 64, TEST_LEN(m))) {
@ -281,7 +288,8 @@ int main(int argc, char *argv[])
goto exit;
}
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
@ -309,14 +317,13 @@ int main(int argc, char *argv[])
// Start encode test
BENCHMARK(&start, BENCHMARK_TIME, encode_update_test_ref(m, k, g_tbls, buffs, a));
printf(xstr(REF_FUNCTION) TEST_TYPE_STR ": ");
perf_print(start, (long long)(TEST_LEN(m)) * (m));
perf_print(start, (long long) (TEST_LEN(m)) * (m));
#endif
// Start encode test
BENCHMARK(&start, BENCHMARK_TIME,
encode_update_test(m, k, g_tbls, perf_update_buffs, a));
BENCHMARK(&start, BENCHMARK_TIME, encode_update_test(m, k, g_tbls, perf_update_buffs, a));
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));
// Start encode test
BENCHMARK(&start, BENCHMARK_TIME,
@ -325,7 +332,7 @@ int main(int argc, char *argv[])
FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, 0, g_tbls, perf_update_buffs[0],
&perf_update_buffs[k]));
printf(xstr(FUNCTION_UNDER_TEST) "_single_src" TEST_TYPE_STR ": ");
perf_print(start, (long long)(TEST_LEN(m)) * (m - k + 1));
perf_print(start, (long long) (TEST_LEN(m)) * (m - k + 1));
// Start encode test
BENCHMARK(&start, BENCHMARK_TIME,
@ -333,21 +340,22 @@ int main(int argc, char *argv[])
FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, 0, g_tbls, perf_update_buffs[0],
&perf_update_buffs[k]));
printf(xstr(FUNCTION_UNDER_TEST) "_single_src_simple" TEST_TYPE_STR ": ");
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++) {
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++) {
FUNCTION_UNDER_TEST(TEST_LEN(m), k, m - k, i, g_tbls, update_buffs[i],
&update_buffs[k]);
}
decode_test(m, k, update_buffs, recov, a, src_in_err, src_err_list,
nerrs, g_tbls, temp_buffs);
BENCHMARK(&start, BENCHMARK_TIME, check =
decode_test(m, k, update_buffs, recov, a, src_in_err, src_err_list,
nerrs, g_tbls, perf_update_buffs));
decode_test(m, k, update_buffs, recov, a, src_in_err, src_err_list, nerrs, g_tbls,
temp_buffs);
BENCHMARK(&start, BENCHMARK_TIME,
check = decode_test(m, k, update_buffs, recov, a, src_in_err, src_err_list, nerrs,
g_tbls, perf_update_buffs));
if (check) {
printf("BAD_MATRIX\n");
ret = check;
@ -362,13 +370,13 @@ int main(int argc, char *argv[])
}
printf(xstr(FUNCTION_UNDER_TEST) "_decode" TEST_TYPE_STR ": ");
perf_print(start, (long long)(TEST_LEN(m)) * (k + nerrs));
perf_print(start, (long long) (TEST_LEN(m)) * (k + nerrs));
printf("done all: Pass\n");
ret = 0;
exit:
exit:
free(err_list);
for (i = 0; i < TEST_SOURCES; i++) {
free(buffs[i]);

View File

@ -35,23 +35,23 @@
#include "test.h"
#ifndef ALIGN_SIZE
# define ALIGN_SIZE 16
#define ALIGN_SIZE 16
#endif
//By default, test multibinary version
// By default, test multibinary version
#ifndef FUNCTION_UNDER_TEST
# define FUNCTION_UNDER_TEST ec_encode_data_update
# define REF_FUNCTION ec_encode_data
#define FUNCTION_UNDER_TEST ec_encode_data_update
#define REF_FUNCTION ec_encode_data
#endif
#define TEST_LEN 8192
#define TEST_SIZE (TEST_LEN/2)
#define TEST_SIZE (TEST_LEN / 2)
#ifndef TEST_SOURCES
# define TEST_SOURCES 127
#define TEST_SOURCES 127
#endif
#ifndef RANDOMS
# define RANDOMS 200
#define RANDOMS 200
#endif
#define MMAX TEST_SOURCES
@ -61,12 +61,12 @@
#ifdef EC_ALIGNED_ADDR
// Define power of 2 range to check ptr, len alignment
# define PTR_ALIGN_CHK_B 0
# define LEN_ALIGN_CHK_B 0 // 0 for aligned only
#define PTR_ALIGN_CHK_B 0
#define LEN_ALIGN_CHK_B 0 // 0 for aligned only
#else
// Define power of 2 range to check ptr, len alignment
# define PTR_ALIGN_CHK_B ALIGN_SIZE
# define LEN_ALIGN_CHK_B ALIGN_SIZE // 0 for aligned only
#define PTR_ALIGN_CHK_B ALIGN_SIZE
#define LEN_ALIGN_CHK_B ALIGN_SIZE // 0 for aligned only
#endif
#ifndef TEST_SEED
@ -78,7 +78,8 @@
typedef unsigned char u8;
void dump(unsigned char *buf, int len)
void
dump(unsigned char *buf, int len)
{
int i;
for (i = 0; i < len;) {
@ -89,7 +90,8 @@ void dump(unsigned char *buf, int len)
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;
for (i = 0; i < k; i++) {
@ -101,7 +103,8 @@ void dump_matrix(unsigned char **s, int k, int m)
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;
for (i = 0; i < k; i++) {
@ -114,8 +117,9 @@ void dump_u8xu8(unsigned char *s, int k, int m)
}
// Generate Random errors
static void gen_err_list(unsigned char *src_err_list,
unsigned char *src_in_err, int *pnerrs, int *pnsrcerrs, int k, int m)
static void
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 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
while ((err = (rand() % KMAX)) >= m) ;
while ((err = (rand() % KMAX)) >= m)
;
src_err_list[nerrs++] = err;
src_in_err[err] = 1;
if (err < k)
@ -144,13 +149,11 @@ static void gen_err_list(unsigned char *src_err_list,
#define NO_INVERT_MATRIX -2
// Generate decode matrix from encode matrix
static int gf_gen_decode_matrix(unsigned char *encode_matrix,
unsigned char *decode_matrix,
unsigned char *invert_matrix,
unsigned int *decode_index,
unsigned char *src_err_list,
unsigned char *src_in_err,
int nerrs, int nsrcerrs, int k, int m)
static int
gf_gen_decode_matrix(unsigned char *encode_matrix, unsigned char *decode_matrix,
unsigned char *invert_matrix, unsigned int *decode_index,
unsigned char *src_err_list, unsigned char *src_in_err, int nerrs,
int nsrcerrs, int k, int m)
{
int i, j, p;
int r;
@ -202,7 +205,6 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
decode_index[k - 1] += incr;
for (j = 0; j < k; j++)
b[k * (k - 1) + j] = encode_matrix[k * decode_index[k - 1] + j];
};
for (i = 0; i < nsrcerrs; i++) {
@ -226,7 +228,8 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix,
return 0;
}
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int re = -1;
int i, j, p, rtest, m, k;
@ -235,8 +238,8 @@ int main(int argc, char *argv[])
unsigned int decode_index[MMAX];
unsigned char *temp_buffs[TEST_SOURCES] = { NULL }, *buffs[TEST_SOURCES] = { NULL };
unsigned char *update_buffs[TEST_SOURCES] = { NULL };
unsigned char *encode_matrix = NULL, *decode_matrix = NULL, *invert_matrix =
NULL, *g_tbls = NULL;
unsigned char *encode_matrix = NULL, *decode_matrix = NULL, *invert_matrix = NULL,
*g_tbls = NULL;
unsigned char src_in_err[TEST_SOURCES], src_err_list[TEST_SOURCES];
unsigned char *recov[TEST_SOURCES];
@ -266,7 +269,8 @@ int main(int argc, char *argv[])
goto exit;
}
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++) {
@ -275,7 +279,8 @@ int main(int argc, char *argv[])
goto exit;
}
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
@ -283,8 +288,8 @@ int main(int argc, char *argv[])
decode_matrix = malloc(MMAX * KMAX);
invert_matrix = malloc(MMAX * KMAX);
g_tbls = malloc(KMAX * TEST_SOURCES * 32);
if (encode_matrix == NULL || decode_matrix == NULL
|| invert_matrix == NULL || g_tbls == NULL) {
if (encode_matrix == NULL || decode_matrix == NULL || invert_matrix == NULL ||
g_tbls == NULL) {
printf("Test failure! Error with malloc\n");
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);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list, src_in_err,
nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
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);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list, src_in_err,
nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
goto exit;
@ -479,8 +482,10 @@ int main(int argc, char *argv[])
// Do more random tests
for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ;
while ((k = (rand() % KMAX)) >= m || k < 1) ;
while ((m = (rand() % MMAX)) < 2)
;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX)
continue;
@ -528,9 +533,8 @@ int main(int argc, char *argv[])
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
goto exit;
@ -555,8 +559,7 @@ int main(int argc, char *argv[])
for (i = 0; i < nerrs; i++) {
if (0 !=
memcmp(temp_buffs[k + i], update_buffs[src_err_list[i]],
TEST_LEN)) {
memcmp(temp_buffs[k + i], update_buffs[src_err_list[i]], TEST_LEN)) {
printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs);
printf(" - erase list = ");
for (j = 0; j < nerrs; j++)
@ -640,8 +643,7 @@ int main(int argc, char *argv[])
}
for (i = 0; i < m - k; i++) {
if (0 !=
memcmp(efence_update_buffs[k + i], efence_buffs[k + i],
size)) {
memcmp(efence_update_buffs[k + i], efence_buffs[k + i], size)) {
printf("\nefence_update_buffs%d :", i);
dump(efence_update_buffs[k + i], 25);
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);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix,
decode_index, src_err_list, src_in_err, nerrs,
nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
goto exit;
@ -682,11 +684,10 @@ int main(int argc, char *argv[])
for (i = 0; i < nerrs; i++) {
if (0 !=
memcmp(temp_buffs[k + i],
if (0 != memcmp(temp_buffs[k + i],
efence_update_buffs[src_err_list[i]], size)) {
printf("Efence: Fail error recovery (%d, %d, %d)\n", m,
k, nerrs);
printf("Efence: Fail error recovery (%d, %d, %d)\n", m, k,
nerrs);
printf("size = %d\n", size);
@ -715,14 +716,15 @@ int main(int argc, char *argv[])
#ifdef TEST_VERBOSE
putchar('.');
#endif
}
// Test rand ptr alignment if available
for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ;
while ((k = (rand() % KMAX)) >= m || k < 1) ;
while ((m = (rand() % MMAX)) < 2)
;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX)
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(temp_buffs[i], 0, TEST_LEN); // zero pad to check write-over
ubuffs[i] = buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset));
update_ubuffs[i] =
update_buffs[i] + (rand() & (PTR_ALIGN_CHK_B - offset));
update_ubuffs[i] = update_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);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
goto exit;
@ -804,14 +804,12 @@ int main(int argc, char *argv[])
}
ec_init_tables(k, nerrs, decode_matrix, g_tbls);
for (i = 0; i < k; i++) {
FUNCTION_UNDER_TEST(size, k, nerrs, i, g_tbls, recov[i],
&temp_ubuffs[k]);
FUNCTION_UNDER_TEST(size, k, nerrs, i, g_tbls, recov[i], &temp_ubuffs[k]);
}
for (i = 0; i < nerrs; i++) {
if (0 !=
memcmp(temp_ubuffs[k + i], update_ubuffs[src_err_list[i]], size)) {
if (0 != memcmp(temp_ubuffs[k + i], update_ubuffs[src_err_list[i]], size)) {
printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs);
printf(" - erase list = ");
for (j = 0; j < nerrs; j++)
@ -820,11 +818,11 @@ int main(int argc, char *argv[])
for (p = 0; p < k; p++)
printf(" %d", decode_index[p]);
printf("\nencode_matrix:\n");
dump_u8xu8((unsigned char *)encode_matrix, m, k);
dump_u8xu8((unsigned char *) encode_matrix, m, k);
printf("inv b:\n");
dump_u8xu8((unsigned char *)invert_matrix, k, k);
dump_u8xu8((unsigned char *) invert_matrix, k, k);
printf("\ndecode_matrix:\n");
dump_u8xu8((unsigned char *)decode_matrix, m, k);
dump_u8xu8((unsigned char *) decode_matrix, m, k);
printf("orig data:\n");
dump_matrix(update_ubuffs, m, 25);
printf("orig :");
@ -848,8 +846,7 @@ int main(int argc, char *argv[])
re = -1;
goto exit;
}
if (memcmp
(update_buffs[i] + offset + size, temp_buffs[0],
if (memcmp(update_buffs[i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign encode pad end\n");
re = -1;
@ -865,8 +862,7 @@ int main(int argc, char *argv[])
re = -1;
goto exit;
}
if (memcmp
(temp_buffs[k + i] + offset + size, temp_buffs[0],
if (memcmp(temp_buffs[k + i] + offset + size, temp_buffs[0],
PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign decode pad end\n");
re = -1;
@ -884,8 +880,10 @@ int main(int argc, char *argv[])
align = (LEN_ALIGN_CHK_B != 0) ? 13 : ALIGN_SIZE;
for (size = TEST_LEN; size >= 0; size -= align) {
while ((m = (rand() % MMAX)) < 2) ;
while ((k = (rand() % KMAX)) >= m || k < 1) ;
while ((m = (rand() % MMAX)) < 2)
;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX)
continue;
@ -932,9 +930,8 @@ int main(int argc, char *argv[])
memset(src_in_err, 0, TEST_SOURCES);
gen_err_list(src_err_list, src_in_err, &nerrs, &nsrcerrs, k, m);
// Generate decode matrix
re = gf_gen_decode_matrix(encode_matrix, decode_matrix,
invert_matrix, decode_index, src_err_list,
src_in_err, nerrs, nsrcerrs, k, m);
re = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, decode_index,
src_err_list, src_in_err, nerrs, nsrcerrs, k, m);
if (re != 0) {
printf("Fail to gf_gen_decode_matrix\n");
goto exit;
@ -952,14 +949,12 @@ int main(int argc, char *argv[])
}
ec_init_tables(k, nerrs, decode_matrix, g_tbls);
for (i = 0; i < k; i++) {
FUNCTION_UNDER_TEST(size, k, nerrs, i, g_tbls, recov[i],
&temp_buffs[k]);
FUNCTION_UNDER_TEST(size, k, nerrs, i, g_tbls, recov[i], &temp_buffs[k]);
}
for (i = 0; i < nerrs; i++) {
if (0 !=
memcmp(temp_buffs[k + i], update_buffs[src_err_list[i]], size)) {
if (0 != memcmp(temp_buffs[k + i], update_buffs[src_err_list[i]], size)) {
printf("Fail error recovery (%d, %d, %d) - ", m, k, nerrs);
printf(" - erase list = ");
for (j = 0; j < nerrs; j++)
@ -968,11 +963,11 @@ int main(int argc, char *argv[])
for (p = 0; p < k; p++)
printf(" %d", decode_index[p]);
printf("\nencode_matrix:\n");
dump_u8xu8((unsigned char *)encode_matrix, m, k);
dump_u8xu8((unsigned char *) encode_matrix, m, k);
printf("inv b:\n");
dump_u8xu8((unsigned char *)invert_matrix, k, k);
dump_u8xu8((unsigned char *) invert_matrix, k, k);
printf("\ndecode_matrix:\n");
dump_u8xu8((unsigned char *)decode_matrix, m, k);
dump_u8xu8((unsigned char *) decode_matrix, m, k);
printf("orig data:\n");
dump_matrix(update_buffs, m, 25);
printf("orig :");
@ -991,7 +986,7 @@ int main(int argc, char *argv[])
printf("done EC tests: Pass\n");
re = 0;
exit:
exit:
for (i = 0; i < TEST_SOURCES; i++) {
if (buffs[i])
aligned_free(buffs[i]);

View File

@ -9,7 +9,8 @@
#define ROWS M_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)
return a;
@ -17,7 +18,8 @@ static inline uint64_t min(const uint64_t a, const uint64_t 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 col_indicator)
{
@ -38,7 +40,8 @@ void gen_sub_matrix(unsigned char *out_matrix, const uint64_t dim, unsigned char
}
/* 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 tmp2 = *subset + tmp1;
@ -52,7 +55,8 @@ uint64_t next_subset(uint64_t * subset, uint64_t element_count, uint64_t subsize
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 invert_matrix[COLS * COLS];
@ -66,9 +70,9 @@ int are_submatrices_singular(unsigned char *vmatrix, const uint64_t rows, const
do {
uint64_t row_indicator = subset_init;
do {
gen_sub_matrix(matrix, subsize, vmatrix, rows,
cols, row_indicator, col_indicator);
if (gf_invert_matrix(matrix, invert_matrix, (int)subsize))
gen_sub_matrix(matrix, subsize, vmatrix, rows, cols, row_indicator,
col_indicator);
if (gf_invert_matrix(matrix, invert_matrix, (int) subsize))
return 1;
} while (next_subset(&row_indicator, rows, subsize) == 0);
@ -78,7 +82,8 @@ int are_submatrices_singular(unsigned char *vmatrix, const uint64_t rows, const
return 0;
}
int main(int argc, char **argv)
int
main(int argc, char **argv)
{
unsigned char vmatrix[(ROWS + COLS) * COLS];
uint64_t rows, cols;
@ -107,10 +112,8 @@ int main(int argc, char **argv)
* singular submatrix */
if (are_submatrices_singular(&vmatrix[cols * cols], rows, cols))
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;
}

View File

@ -37,17 +37,18 @@
#define TEST_LEN 8192
#ifndef TEST_SOURCES
# define TEST_SOURCES 128
#define TEST_SOURCES 128
#endif
#ifndef RANDOMS
# define RANDOMS 200
#define RANDOMS 200
#endif
#define KMAX TEST_SOURCES
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;
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;
@ -76,7 +78,8 @@ void print_matrix(u8 * a, int n)
printf("\n");
}
int is_ident(u8 * a, const int n)
int
is_ident(u8 *a, const int n)
{
int i, j;
u8 c;
@ -92,7 +95,8 @@ int is_ident(u8 * a, const int n)
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);
@ -118,32 +122,20 @@ int inv_test(u8 * in, u8 * inv, u8 * sav, int n)
return 0;
}
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int i, k, t;
u8 *test_mat = NULL, *save_mat = NULL, *invr_mat = NULL;
int ret = -1;
u8 test1[] = { 1, 1, 6,
1, 1, 1,
7, 1, 9
};
u8 test1[] = { 1, 1, 6, 1, 1, 1, 7, 1, 9 };
u8 test2[] = { 0, 1, 6,
1, 0, 1,
0, 1, 9
};
u8 test2[] = { 0, 1, 6, 1, 0, 1, 0, 1, 9 };
u8 test3[] = { 0, 0, 1,
1, 0, 0,
0, 1, 1
};
u8 test3[] = { 0, 0, 1, 1, 0, 0, 0, 1, 1 };
u8 test4[] = { 0, 1, 6, 7,
1, 1, 0, 0,
0, 1, 2, 3,
3, 2, 2, 3
}; // = row3+3*row2
u8 test4[] = { 0, 1, 6, 7, 1, 1, 0, 0, 0, 1, 2, 3, 3, 2, 2, 3 }; // = row3+3*row2
printf("gf_inverse_test: max=%d ", KMAX);
@ -229,7 +221,7 @@ int main(int argc, char *argv[])
ret = 0;
exit:
exit:
free(test_mat);
free(save_mat);
free(invr_mat);

View File

@ -34,21 +34,21 @@
#include "erasure_code.h"
#ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */
#define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset
# define TEST_SOURCES 10
# define TEST_LEN 8*1024
# define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST)
#define TEST_SOURCES 10
#define TEST_LEN 8 * 1024
#define TEST_TYPE_STR "_warm"
#elif defined(COLD_TEST)
// Uncached test. Pull from large mem base.
# define TEST_SOURCES 10
# define TEST_LEN (GT_L3_CACHE / TEST_SOURCES)
# define TEST_TYPE_STR "_cold"
#elif defined (TEST_CUSTOM)
# define TEST_TYPE_STR "_cus"
#define TEST_SOURCES 10
#define TEST_LEN (GT_L3_CACHE / TEST_SOURCES)
#define TEST_TYPE_STR "_cold"
#elif defined(TEST_CUSTOM)
#define TEST_TYPE_STR "_cus"
#endif
typedef unsigned char u8;
@ -58,7 +58,8 @@ u8 gff[256];
u8 gflog[256];
u8 gf_mul_table[256 * 256];
void mk_gf_field(void)
void
mk_gf_field(void)
{
int i;
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,
// 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);
}
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;
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;
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;
}
}
int main(void)
int
main(void)
{
int i, j;
u8 vec[TEST_SOURCES], *dest1, *dest2;
@ -128,7 +132,7 @@ int main(void)
mk_gf_field();
mk_gf_mul_table(gf_mul_table);
//generate random vector and matrix/data
// generate random vector and matrix/data
for (i = 0; i < TEST_SOURCES; i++) {
vec[i] = rand();
@ -138,18 +142,17 @@ int main(void)
}
for (j = 0; j < TEST_LEN; j++)
matrix[i][j] = rand();
}
BENCHMARK(&start, BENCHMARK_TIME,
gf_vect_dot_prod_ref(TEST_LEN, TEST_SOURCES, vec, matrix, dest1));
printf("gf_vect_dot_prod_2tbl" TEST_TYPE_STR ": ");
perf_print(start, (long long)TEST_LEN * (TEST_SOURCES + 1));
perf_print(start, (long long) TEST_LEN * (TEST_SOURCES + 1));
BENCHMARK(&start, BENCHMARK_TIME,
gf_vect_dot_prod_mult(TEST_LEN, TEST_SOURCES, vec, matrix, dest2));
printf("gf_vect_dot_prod_1tbl" TEST_TYPE_STR ": ");
perf_print(start, (long long)TEST_LEN * (TEST_SOURCES + 1));
perf_print(start, (long long) TEST_LEN * (TEST_SOURCES + 1));
// Compare with reference function
if (0 != memcmp(dest1, dest2, TEST_LEN)) {

View File

@ -35,13 +35,13 @@
#include "test.h"
#define TEST_LEN 8192
#define TEST_SIZE (TEST_LEN/2)
#define TEST_SIZE (TEST_LEN / 2)
#ifndef TEST_SOURCES
# define TEST_SOURCES 250
#define TEST_SOURCES 250
#endif
#ifndef RANDOMS
# define RANDOMS 20
#define RANDOMS 20
#endif
#define MMAX TEST_SOURCES
@ -49,7 +49,8 @@
typedef unsigned char u8;
void dump(unsigned char *buf, int len)
void
dump(unsigned char *buf, int len)
{
int i;
for (i = 0; i < len;) {
@ -60,7 +61,8 @@ void dump(unsigned char *buf, int len)
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;
for (i = 0; i < k; i++) {
@ -72,7 +74,8 @@ void dump_matrix(unsigned char **s, int k, int m)
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;
for (i = 0; i < k; i++) {
@ -84,7 +87,8 @@ void dump_u8xu8(unsigned char *s, int k, int m)
printf("\n");
}
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int i, j, rtest, m, k, nerrs, r, err;
void *buf;
@ -202,8 +206,10 @@ int main(int argc, char *argv[])
// Do more random tests
for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ;
while ((k = (rand() % KMAX)) >= m || k < 1) ;
while ((m = (rand() % MMAX)) < 2)
;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX)
continue;
@ -232,7 +238,8 @@ int main(int argc, char *argv[])
src_err_list[nerrs++] = i;
}
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_in_err[err] = 1;
}

View File

@ -34,33 +34,34 @@
#include "test.h"
#ifndef FUNCTION_UNDER_TEST
# define FUNCTION_UNDER_TEST gf_vect_dot_prod
#define FUNCTION_UNDER_TEST gf_vect_dot_prod
#endif
#define str(s) #s
#define xstr(s) str(s)
#ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */
#define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset
# define TEST_SOURCES 10
# define TEST_LEN 8*1024
# define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST)
#define TEST_SOURCES 10
#define TEST_LEN 8 * 1024
#define TEST_TYPE_STR "_warm"
#elif defined(COLD_TEST)
// Uncached test. Pull from large mem base.
# define TEST_SOURCES 10
# define TEST_LEN ((GT_L3_CACHE / TEST_SOURCES) & ~(64-1))
# define TEST_TYPE_STR "_cold"
#elif defined (TEST_CUSTOM)
# define TEST_TYPE_STR "_cus"
#define TEST_SOURCES 10
#define TEST_LEN ((GT_L3_CACHE / TEST_SOURCES) & ~(64 - 1))
#define TEST_TYPE_STR "_cold"
#elif defined(TEST_CUSTOM)
#define TEST_TYPE_STR "_cus"
#endif
typedef unsigned char u8;
void dump(unsigned char *buf, int len)
void
dump(unsigned char *buf, int len)
{
int i;
for (i = 0; i < len;) {
@ -71,7 +72,8 @@ void dump(unsigned char *buf, int len)
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;
for (i = 0; i < k; i++) {
@ -83,18 +85,19 @@ void dump_matrix(unsigned char **s, int k, int m)
printf("\n");
}
void 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)
void
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)
{
int j;
for (j = 0; j < TEST_SOURCES; j++)
gf_vect_mul_init(g[j], &g_tbls[j * 32]);
(*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;
void *buf;
@ -146,10 +149,9 @@ int main(int argc, char *argv[])
#ifdef DO_REF_PERF
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 ": ");
perf_print(start, (long long)TEST_LEN * (TEST_SOURCES + 1));
perf_print(start, (long long) TEST_LEN * (TEST_SOURCES + 1));
#else
vect_dot_prod_perf(&gf_vect_dot_prod_base, g, g_tbls, buffs, dest_ref);
#endif
@ -157,7 +159,7 @@ int main(int argc, char *argv[])
BENCHMARK(&start, BENCHMARK_TIME,
vect_dot_prod_perf(&FUNCTION_UNDER_TEST, g, g_tbls, buffs, dest));
printf(xstr(FUNCTION_UNDER_TEST) TEST_TYPE_STR ": ");
perf_print(start, (long long)TEST_LEN * (TEST_SOURCES + 1));
perf_print(start, (long long) TEST_LEN * (TEST_SOURCES + 1));
if (0 != memcmp(dest_ref, dest, TEST_LEN)) {
printf("Fail zero " xstr(FUNCTION_UNDER_TEST) " test\n");

View File

@ -34,23 +34,23 @@
#include "test.h"
#ifndef FUNCTION_UNDER_TEST
# define FUNCTION_UNDER_TEST gf_vect_dot_prod
#define FUNCTION_UNDER_TEST gf_vect_dot_prod
#endif
#ifndef TEST_MIN_SIZE
# define TEST_MIN_SIZE 32
#define TEST_MIN_SIZE 32
#endif
#define str(s) #s
#define xstr(s) str(s)
#define TEST_LEN 8192
#define TEST_SIZE (TEST_LEN/2)
#define TEST_SIZE (TEST_LEN / 2)
#ifndef TEST_SOURCES
# define TEST_SOURCES 16
#define TEST_SOURCES 16
#endif
#ifndef RANDOMS
# define RANDOMS 20
#define RANDOMS 20
#endif
#define MMAX TEST_SOURCES
@ -58,17 +58,18 @@
#ifdef EC_ALIGNED_ADDR
// Define power of 2 range to check ptr, len alignment
# define PTR_ALIGN_CHK_B 0
# define LEN_ALIGN_CHK_B 0 // 0 for aligned only
#define PTR_ALIGN_CHK_B 0
#define LEN_ALIGN_CHK_B 0 // 0 for aligned only
#else
// Define power of 2 range to check ptr, len alignment
# define PTR_ALIGN_CHK_B 32
# define LEN_ALIGN_CHK_B 32 // 0 for aligned only
#define PTR_ALIGN_CHK_B 32
#define LEN_ALIGN_CHK_B 32 // 0 for aligned only
#endif
typedef unsigned char u8;
void dump(unsigned char *buf, int len)
void
dump(unsigned char *buf, int len)
{
int i;
for (i = 0; i < len;) {
@ -79,7 +80,8 @@ void dump(unsigned char *buf, int len)
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;
for (i = 0; i < k; i++) {
@ -91,7 +93,8 @@ void dump_matrix(unsigned char **s, int k, int m)
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;
for (i = 0; i < k; i++) {
@ -103,7 +106,8 @@ void dump_u8xu8(unsigned char *s, int k, int m)
printf("\n");
}
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int i, j, rtest, srcs, m, k, nerrs, r, err;
void *buf;
@ -318,8 +322,10 @@ int main(int argc, char *argv[])
// Do more random tests
for (rtest = 0; rtest < RANDOMS; rtest++) {
while ((m = (rand() % MMAX)) < 2) ;
while ((k = (rand() % KMAX)) >= m || k < 1) ;
while ((m = (rand() % MMAX)) < 2)
;
while ((k = (rand() % KMAX)) >= m || k < 1)
;
if (m > MMAX || k > KMAX)
continue;
@ -351,7 +357,8 @@ int main(int argc, char *argv[])
src_err_list[nerrs++] = i;
}
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_in_err[err] = 1;
}
@ -474,8 +481,7 @@ int main(int argc, char *argv[])
FUNCTION_UNDER_TEST(size, srcs, g_tbls, ubuffs, udest_ptr);
if (memcmp(dest_ref, udest_ptr, size)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign srcs=%d\n",
srcs);
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign srcs=%d\n", srcs);
dump_matrix(ubuffs, 5, TEST_SOURCES);
printf("dprod_base:");
dump(dest_ref, 25);
@ -522,8 +528,7 @@ int main(int argc, char *argv[])
FUNCTION_UNDER_TEST(size, srcs, g_tbls, buffs, dest);
if (memcmp(dest_ref, dest, size)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign len=%d\n",
size);
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " ualign len=%d\n", size);
dump_matrix(buffs, 5, TEST_SOURCES);
printf("dprod_base:");
dump(dest_ref, 25);

View File

@ -34,44 +34,44 @@
#include "test.h"
#ifndef ALIGN_SIZE
# define ALIGN_SIZE 32
#define ALIGN_SIZE 32
#endif
#ifndef FUNCTION_UNDER_TEST
//By default, test multi-binary version
# define FUNCTION_UNDER_TEST gf_vect_mad
# define REF_FUNCTION gf_vect_dot_prod
# define VECT 1
// By default, test multi-binary version
#define FUNCTION_UNDER_TEST gf_vect_mad
#define REF_FUNCTION gf_vect_dot_prod
#define VECT 1
#endif
#ifndef TEST_MIN_SIZE
# define TEST_MIN_SIZE 64
#define TEST_MIN_SIZE 64
#endif
#define str(s) #s
#define xstr(s) str(s)
#define TEST_LEN 8192
#define TEST_SIZE (TEST_LEN/2)
#define TEST_SIZE (TEST_LEN / 2)
#define TEST_MEM TEST_SIZE
#define TEST_LOOPS 20000
#define TEST_TYPE_STR ""
#ifndef TEST_SOURCES
# define TEST_SOURCES 16
#define TEST_SOURCES 16
#endif
#ifndef RANDOMS
# define RANDOMS 20
#define RANDOMS 20
#endif
#ifdef EC_ALIGNED_ADDR
// Define power of 2 range to check ptr, len alignment
# define PTR_ALIGN_CHK_B 0
# define LEN_ALIGN_CHK_B 0 // 0 for aligned only
#define PTR_ALIGN_CHK_B 0
#define LEN_ALIGN_CHK_B 0 // 0 for aligned only
#else
// Define power of 2 range to check ptr, len alignment
# define PTR_ALIGN_CHK_B ALIGN_SIZE
# define LEN_ALIGN_CHK_B ALIGN_SIZE // 0 for aligned only
#define PTR_ALIGN_CHK_B ALIGN_SIZE
#define LEN_ALIGN_CHK_B ALIGN_SIZE // 0 for aligned only
#endif
#define str(s) #s
@ -80,17 +80,19 @@
typedef unsigned char u8;
#if (VECT == 1)
# define LAST_ARG *dest
#define LAST_ARG *dest
#else
# define LAST_ARG **dest
#define LAST_ARG **dest
#endif
extern void FUNCTION_UNDER_TEST(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char LAST_ARG);
extern void REF_FUNCTION(int len, int vlen, unsigned char *gftbls, unsigned char **src,
extern void
FUNCTION_UNDER_TEST(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
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;
for (i = 0; i < len;) {
@ -101,7 +103,8 @@ void dump(unsigned char *buf, int len)
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;
for (i = 0; i < k; i++) {
@ -113,7 +116,8 @@ void dump_matrix(unsigned char **s, int k, int m)
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;
for (i = 0; i < k; i++) {
@ -125,7 +129,8 @@ void dump_u8xu8(unsigned char *s, int k, int m)
printf("\n");
}
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int i, j, rtest, srcs;
void *buf;
@ -208,8 +213,8 @@ int main(int argc, char *argv[])
}
for (i = 0; i < vector; i++)
gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[i * 32 * TEST_SOURCES],
buffs, dest_ref[i]);
gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES, &g_tbls[i * 32 * TEST_SOURCES], buffs,
dest_ref[i]);
for (i = 0; i < vector; i++)
memset(dest_ptrs[i], 0, TEST_LEN);
@ -269,8 +274,7 @@ int main(int argc, char *argv[])
for (i = 0; i < vector; i++)
gf_vect_dot_prod_base(TEST_LEN, TEST_SOURCES,
&g_tbls[i * 32 * TEST_SOURCES], buffs,
dest_ref[i]);
&g_tbls[i * 32 * TEST_SOURCES], buffs, dest_ref[i]);
for (i = 0; i < vector; i++)
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],
*dest_ptrs);
#else
FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, i, g_tbls, buffs[i],
dest_ptrs);
FUNCTION_UNDER_TEST(TEST_LEN, TEST_SOURCES, i, g_tbls, buffs[i], dest_ptrs);
#endif
}
for (i = 0; i < vector; i++) {
if (0 != memcmp(dest_ref[i], dest_ptrs[i], TEST_LEN)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test%d %d\n",
i, rtest);
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test%d %d\n", i,
rtest);
dump_matrix(buffs, vector, TEST_SOURCES);
printf("dprod_base:");
dump(dest_ref[i], 25);
@ -316,8 +319,8 @@ int main(int argc, char *argv[])
}
for (i = 0; i < vector; i++)
gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[i * 32 * srcs],
buffs, dest_ref[i]);
gf_vect_dot_prod_base(TEST_LEN, srcs, &g_tbls[i * 32 * srcs], buffs,
dest_ref[i]);
for (i = 0; i < vector; i++)
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],
*dest_ptrs);
#else
FUNCTION_UNDER_TEST(TEST_LEN, srcs, i, g_tbls, buffs[i],
dest_ptrs);
FUNCTION_UNDER_TEST(TEST_LEN, srcs, i, g_tbls, buffs[i], dest_ptrs);
#endif
}
for (i = 0; i < vector; i++) {
if (0 != memcmp(dest_ref[i], dest_ptrs[i], TEST_LEN)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST)
" test%d srcs=%d\n", i, srcs);
printf("Fail rand " xstr(
FUNCTION_UNDER_TEST) " test%d srcs=%d\n",
i, srcs);
dump_matrix(buffs, vector, TEST_SOURCES);
printf("dprod_base:");
dump(dest_ref[i], 25);
@ -368,9 +370,8 @@ int main(int argc, char *argv[])
}
for (i = 0; i < vector; i++)
gf_vect_dot_prod_base(size, TEST_SOURCES,
&g_tbls[i * 32 * TEST_SOURCES], efence_buffs,
dest_ref[i]);
gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[i * 32 * TEST_SOURCES],
efence_buffs, dest_ref[i]);
for (i = 0; i < vector; i++)
memset(dest_ptrs[i], 0, size);
@ -385,8 +386,8 @@ int main(int argc, char *argv[])
}
for (i = 0; i < vector; i++) {
if (0 != memcmp(dest_ref[i], dest_ptrs[i], size)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST)
" test%d size=%d\n", i, size);
printf("Fail rand " xstr(FUNCTION_UNDER_TEST) " test%d size=%d\n",
i, size);
dump_matrix(buffs, vector, TEST_SOURCES);
printf("dprod_base:");
dump(dest_ref[i], TEST_MIN_SIZE + align);
@ -442,8 +443,9 @@ int main(int argc, char *argv[])
}
for (i = 0; i < vector; i++) {
if (0 != memcmp(dest_ref[i], udest_ptrs[i], size)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST)
" test%d ualign srcs=%d\n", i, srcs);
printf("Fail rand " xstr(
FUNCTION_UNDER_TEST) " test%d ualign srcs=%d\n",
i, srcs);
dump_matrix(buffs, vector, TEST_SOURCES);
printf("dprod_base:");
dump(dest_ref[i], 25);
@ -462,8 +464,7 @@ int main(int argc, char *argv[])
printf("Fail rand ualign pad1 start\n");
return -1;
}
if (memcmp
(dest_ptrs[i] + offset + size, dest_ref[0],
if (memcmp(dest_ptrs[i] + offset + size, dest_ref[0],
PTR_ALIGN_CHK_B - offset)) {
printf("Fail rand ualign pad1 end\n");
return -1;
@ -493,23 +494,21 @@ int main(int argc, char *argv[])
}
for (i = 0; i < vector; i++)
gf_vect_dot_prod_base(size, TEST_SOURCES,
&g_tbls[i * 32 * TEST_SOURCES], buffs,
dest_ref[i]);
gf_vect_dot_prod_base(size, TEST_SOURCES, &g_tbls[i * 32 * TEST_SOURCES],
buffs, dest_ref[i]);
for (i = 0; i < TEST_SOURCES; i++) {
#if (VECT == 1)
FUNCTION_UNDER_TEST(size, TEST_SOURCES, i, g_tbls, buffs[i],
*dest_ptrs);
FUNCTION_UNDER_TEST(size, TEST_SOURCES, i, g_tbls, buffs[i], *dest_ptrs);
#else
FUNCTION_UNDER_TEST(size, TEST_SOURCES, i, g_tbls, buffs[i],
dest_ptrs);
FUNCTION_UNDER_TEST(size, TEST_SOURCES, i, g_tbls, buffs[i], dest_ptrs);
#endif
}
for (i = 0; i < vector; i++) {
if (0 != memcmp(dest_ref[i], dest_ptrs[i], size)) {
printf("Fail rand " xstr(FUNCTION_UNDER_TEST)
" test%d ualign len=%d\n", i, size);
printf("Fail rand " xstr(
FUNCTION_UNDER_TEST) " test%d ualign len=%d\n",
i, size);
dump_matrix(buffs, vector, TEST_SOURCES);
printf("dprod_base:");
dump(dest_ref[i], 25);
@ -522,10 +521,8 @@ int main(int argc, char *argv[])
#ifdef TEST_VERBOSE
putchar('.');
#endif
}
printf("Pass\n");
return 0;
}

View File

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

View File

@ -34,34 +34,36 @@
#include "test.h"
#ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */
#define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset
# define TEST_SOURCES 10
# define TEST_LEN 8*1024
# define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST)
#define TEST_SOURCES 10
#define TEST_LEN 8 * 1024
#define TEST_TYPE_STR "_warm"
#elif defined(COLD_TEST)
// Uncached test. Pull from large mem base.
# define TEST_SOURCES 10
# define TEST_LEN (GT_L3_CACHE / 2)
# define TEST_TYPE_STR "_cold"
#elif defined (TEST_CUSTOM)
# define TEST_TYPE_STR "_cus"
#define TEST_SOURCES 10
#define TEST_LEN (GT_L3_CACHE / 2)
#define TEST_TYPE_STR "_cold"
#elif defined(TEST_CUSTOM)
#define TEST_TYPE_STR "_cus"
#endif
#define TEST_MEM (2 * TEST_LEN)
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(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;
struct perf start;
@ -85,7 +87,7 @@ int main(int argc, char *argv[])
BENCHMARK(&start, BENCHMARK_TIME, gf_vect_mul_perf(a, gf_const_tbl, buff1, buff2));
printf("gf_vect_mul" TEST_TYPE_STR ": ");
perf_print(start, (long long)TEST_LEN);
perf_print(start, (long long) TEST_LEN);
return 0;
}

View File

@ -31,11 +31,12 @@
#include <stdlib.h>
#include "erasure_code.h"
#define TEST_SIZE (128*1024)
#define TEST_SIZE (128 * 1024)
typedef unsigned char u8;
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int i, ret = -1;
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++) {
if (gf_mul(a, buff1[i]) != buff2[i]) {
printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i,
buff1[i], buff2[i], gf_mul(2, buff1[i]));
printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, buff1[i], buff2[i],
gf_mul(2, buff1[i]));
goto exit;
}
}
@ -81,8 +82,8 @@ int main(int argc, char *argv[])
// Check reference function
for (i = 0; i < TEST_SIZE; i++) {
if (buff2[i] != buff3[i]) {
printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n",
i, a, buff1[i], buff2[i], gf_mul(a, buff1[i]));
printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", i, a, buff1[i], buff2[i],
gf_mul(a, buff1[i]));
goto exit;
}
}
@ -100,8 +101,8 @@ int main(int argc, char *argv[])
for (i = 0; i < TEST_SIZE; i++)
if (gf_mul(a, buff1[i]) != buff2[i]) {
printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n",
i, a, buff1[i], buff2[i], gf_mul(2, buff1[i]));
printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", i, a, buff1[i],
buff2[i], gf_mul(2, buff1[i]));
goto exit;
}
#ifdef TEST_VERBOSE
@ -120,8 +121,8 @@ int main(int argc, char *argv[])
for (i = 0; i < tsize; i++)
if (gf_mul(a, buff1[i]) != buff2[i]) {
printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n",
i, a, buff1[i], buff2[i], gf_mul(2, buff1[i]));
printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", i, a, buff1[i],
buff2[i], gf_mul(2, buff1[i]));
goto exit;
}
#ifdef TEST_VERBOSE
@ -147,22 +148,21 @@ int main(int argc, char *argv[])
for (i = 0; i < TEST_SIZE - size; i++)
if (gf_mul(a, efence_buff1[i]) != efence_buff2[i]) {
printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n",
i, efence_buff1[i], efence_buff2[i],
gf_mul(2, efence_buff1[i]));
printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, efence_buff1[i],
efence_buff2[i], gf_mul(2, efence_buff1[i]));
goto exit;
}
if (gf_vect_mul_base
(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff3) != 0) {
if (gf_vect_mul_base(TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff3) !=
0) {
printf("fail line up TEST_SIZE from end\n");
goto exit;
}
// Check reference function
for (i = 0; i < TEST_SIZE - size; i++)
if (efence_buff2[i] != efence_buff3[i]) {
printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n",
i, a, efence_buff2[i], efence_buff3[i],
printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", i, a,
efence_buff2[i], efence_buff3[i],
gf_mul(2, efence_buff1[i]));
goto exit;
}
@ -174,8 +174,7 @@ int main(int argc, char *argv[])
// Test all unsupported sizes up to TEST_SIZE
for (size = 0; size < TEST_SIZE; size++) {
if (size % align != 0 && gf_vect_mul(size, gf_const_tbl, buff1, buff2) == 0) {
printf
("fail expecting nonzero return code for unaligned size param (%d)\n",
printf("fail expecting nonzero return code for unaligned size param (%d)\n",
size);
goto exit;
}
@ -185,7 +184,7 @@ int main(int argc, char *argv[])
fflush(0);
ret = 0;
exit:
exit:
free(buff1);
free(buff2);

View File

@ -1,21 +1,21 @@
#include "erasure_code.h"
#include "ec_base_vsx.h"
void gf_vect_dot_prod(int len, int vlen, unsigned char *v,
unsigned char **src, unsigned char *dest)
void
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);
}
void gf_vect_mad(int len, int vec, int vec_i, unsigned char *v,
unsigned char *src, unsigned char *dest)
void
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);
}
void ec_encode_data(int len, int srcs, int dests, unsigned char *v,
unsigned char **src, unsigned char **dest)
void
ec_encode_data(int len, int srcs, int dests, unsigned char *v, unsigned char **src,
unsigned char **dest)
{
if (len < 64) {
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,
unsigned char *data, unsigned char **dest)
void
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) {
ec_encode_data_update_base(len, k, rows, vec_i, v, data, dest);
@ -90,17 +91,19 @@ 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 */
if ((len % 32) != 0)
return -1;
gf_vect_mul_vsx(len, a, (unsigned char *)src, (unsigned char *)dest);
gf_vect_mul_vsx(len, a, (unsigned char *) src, (unsigned char *) dest);
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);
}

View File

@ -19,18 +19,26 @@ extern "C" {
#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))
#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;
__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;
}
#define EC_vec_permxor(va, vb, vc) __builtin_crypto_vpermxor(va, vb, vec_nor(vc, vc))
#endif
#else
#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;
__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;
}
#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
*/
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.
@ -77,8 +86,9 @@ void gf_vect_mul_vsx(int len, unsigned char *gftbls, unsigned char *src, unsigne
* @returns none
*/
void gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char *dest);
void
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.
@ -99,8 +109,9 @@ void gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @returns none
*/
void gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
void
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.
@ -121,8 +132,9 @@ void gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @returns none
*/
void gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
void
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.
@ -143,8 +155,9 @@ void gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @returns none
*/
void gf_4vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
void
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.
@ -165,8 +178,9 @@ void gf_4vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @returns none
*/
void gf_5vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
void
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.
@ -187,8 +201,9 @@ void gf_5vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @returns none
*/
void gf_6vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest);
void
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.
@ -211,7 +226,8 @@ void gf_6vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
* @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);
/**
* @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
*/
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);
/**
@ -258,7 +275,8 @@ void gf_2vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsign
* @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);
/**
@ -282,7 +300,8 @@ void gf_3vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsign
* @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);
/**
@ -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.
* @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);
/**
@ -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.
* @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);
#ifdef __cplusplus

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest)
void
gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest)
{
unsigned char *s, *t0, *t1;
vector unsigned char vX1, vX2, vX3, vX4;
@ -11,8 +12,8 @@ void gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
int i, j, head;
if (vlen < 128) {
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *)dest[0]);
gf_vect_mul_vsx(len, &gftbls[1 * 32 * vlen], src[0], (unsigned char *)dest[1]);
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *) dest[0]);
gf_vect_mul_vsx(len, &gftbls[1 * 32 * vlen], src[0], (unsigned char *) dest[1]);
for (j = 1; j < vlen; j++) {
gf_2vect_mad_vsx(len, vlen, j, gftbls, src[j], dest);
@ -20,8 +21,8 @@ void gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
return;
}
t0 = (unsigned char *)dest[0];
t1 = (unsigned char *)dest[1];
t0 = (unsigned char *) dest[0];
t1 = (unsigned char *) dest[1];
head = len % 64;
if (head != 0) {
@ -44,7 +45,7 @@ void gf_2vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char *g1 = &gftbls[1 * 32 * vlen];
for (j = 0; j < vlen; j++) {
s = (unsigned char *)src[j];
s = (unsigned char *) src[j];
vX1 = vec_xl(0, s + i);
vX2 = vec_xl(16, s + i);
vX3 = vec_xl(32, s + i);

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_2vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char **dest)
void
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;
vector unsigned char vX1, vX2, vX3, vX4;
@ -10,9 +11,9 @@ void gf_2vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
vector unsigned char vhi0, vlo0, vhi1, vlo1;
int i, head;
s = (unsigned char *)src;
t0 = (unsigned char *)dest[0];
t1 = (unsigned char *)dest[1];
s = (unsigned char *) src;
t0 = (unsigned char *) dest[0];
t1 = (unsigned char *) dest[1];
head = len % 64;
if (head != 0) {

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest)
void
gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char **dest)
{
unsigned char *s, *t0, *t1, *t2;
vector unsigned char vX1, vX2, vX3, vX4;
@ -11,9 +12,9 @@ void gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
int i, j, head;
if (vlen < 128) {
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *)dest[0]);
gf_vect_mul_vsx(len, &gftbls[1 * 32 * vlen], src[0], (unsigned char *)dest[1]);
gf_vect_mul_vsx(len, &gftbls[2 * 32 * vlen], src[0], (unsigned char *)dest[2]);
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *) dest[0]);
gf_vect_mul_vsx(len, &gftbls[1 * 32 * vlen], src[0], (unsigned char *) dest[1]);
gf_vect_mul_vsx(len, &gftbls[2 * 32 * vlen], src[0], (unsigned char *) dest[2]);
for (j = 1; j < vlen; j++) {
gf_3vect_mad_vsx(len, vlen, j, gftbls, src[j], dest);
@ -21,9 +22,9 @@ void gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
return;
}
t0 = (unsigned char *)dest[0];
t1 = (unsigned char *)dest[1];
t2 = (unsigned char *)dest[2];
t0 = (unsigned char *) dest[0];
t1 = (unsigned char *) dest[1];
t2 = (unsigned char *) dest[2];
head = len % 64;
if (head != 0) {
@ -52,7 +53,7 @@ void gf_3vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char *g2 = &gftbls[2 * 32 * vlen];
for (j = 0; j < vlen; j++) {
s = (unsigned char *)src[j];
s = (unsigned char *) src[j];
vX1 = vec_xl(0, s + i);
vX2 = vec_xl(16, s + i);
vX3 = vec_xl(32, s + i);

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_3vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char **dest)
void
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;
vector unsigned char vX1, vX2, vX3, vX4;
@ -10,10 +11,10 @@ void gf_3vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
vector unsigned char vhi0, vlo0, vhi1, vlo1, vhi2, vlo2;
int i, head;
s = (unsigned char *)src;
t0 = (unsigned char *)dest[0];
t1 = (unsigned char *)dest[1];
t2 = (unsigned char *)dest[2];
s = (unsigned char *) src;
t0 = (unsigned char *) dest[0];
t1 = (unsigned char *) dest[1];
t2 = (unsigned char *) dest[2];
head = len % 64;
if (head != 0) {

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_4vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest)
void
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;
vector unsigned char vX1, vX2, vX3, vX4;
@ -11,10 +12,10 @@ void gf_4vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
int i, j, head;
if (vlen < 128) {
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *)dest[0]);
gf_vect_mul_vsx(len, &gftbls[1 * 32 * vlen], src[0], (unsigned char *)dest[1]);
gf_vect_mul_vsx(len, &gftbls[2 * 32 * vlen], src[0], (unsigned char *)dest[2]);
gf_vect_mul_vsx(len, &gftbls[3 * 32 * vlen], src[0], (unsigned char *)dest[3]);
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *) dest[0]);
gf_vect_mul_vsx(len, &gftbls[1 * 32 * vlen], src[0], (unsigned char *) dest[1]);
gf_vect_mul_vsx(len, &gftbls[2 * 32 * vlen], src[0], (unsigned char *) dest[2]);
gf_vect_mul_vsx(len, &gftbls[3 * 32 * vlen], src[0], (unsigned char *) dest[3]);
for (j = 1; j < vlen; j++) {
gf_4vect_mad_vsx(len, vlen, j, gftbls, src[j], dest);
@ -22,10 +23,10 @@ void gf_4vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
return;
}
t0 = (unsigned char *)dest[0];
t1 = (unsigned char *)dest[1];
t2 = (unsigned char *)dest[2];
t3 = (unsigned char *)dest[3];
t0 = (unsigned char *) dest[0];
t1 = (unsigned char *) dest[1];
t2 = (unsigned char *) dest[2];
t3 = (unsigned char *) dest[3];
head = len % 64;
if (head != 0) {
@ -60,7 +61,7 @@ void gf_4vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char *g3 = &gftbls[3 * 32 * vlen];
for (j = 0; j < vlen; j++) {
s = (unsigned char *)src[j];
s = (unsigned char *) src[j];
vX1 = vec_xl(0, s + i);
vX2 = vec_xl(16, s + i);
vX3 = vec_xl(32, s + i);

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_4vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char **dest)
void
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;
vector unsigned char vX1, vX2, vX3, vX4;
@ -10,11 +11,11 @@ void gf_4vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
vector unsigned char vhi0, vlo0, vhi1, vlo1, vhi2, vlo2, vhi3, vlo3;
int i, head;
s = (unsigned char *)src;
t0 = (unsigned char *)dest[0];
t1 = (unsigned char *)dest[1];
t2 = (unsigned char *)dest[2];
t3 = (unsigned char *)dest[3];
s = (unsigned char *) src;
t0 = (unsigned char *) dest[0];
t1 = (unsigned char *) dest[1];
t2 = (unsigned char *) dest[2];
t3 = (unsigned char *) dest[3];
head = len % 64;
if (head != 0) {

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_5vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest)
void
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;
vector unsigned char vX1, vX2, vX3, vX4;
@ -11,11 +12,11 @@ void gf_5vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
int i, j, head;
if (vlen < 128) {
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *)dest[0]);
gf_vect_mul_vsx(len, &gftbls[1 * 32 * vlen], src[0], (unsigned char *)dest[1]);
gf_vect_mul_vsx(len, &gftbls[2 * 32 * vlen], src[0], (unsigned char *)dest[2]);
gf_vect_mul_vsx(len, &gftbls[3 * 32 * vlen], src[0], (unsigned char *)dest[3]);
gf_vect_mul_vsx(len, &gftbls[4 * 32 * vlen], src[0], (unsigned char *)dest[4]);
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *) dest[0]);
gf_vect_mul_vsx(len, &gftbls[1 * 32 * vlen], src[0], (unsigned char *) dest[1]);
gf_vect_mul_vsx(len, &gftbls[2 * 32 * vlen], src[0], (unsigned char *) dest[2]);
gf_vect_mul_vsx(len, &gftbls[3 * 32 * vlen], src[0], (unsigned char *) dest[3]);
gf_vect_mul_vsx(len, &gftbls[4 * 32 * vlen], src[0], (unsigned char *) dest[4]);
for (j = 1; j < vlen; j++) {
gf_5vect_mad_vsx(len, vlen, j, gftbls, src[j], dest);
@ -23,11 +24,11 @@ void gf_5vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
return;
}
t0 = (unsigned char *)dest[0];
t1 = (unsigned char *)dest[1];
t2 = (unsigned char *)dest[2];
t3 = (unsigned char *)dest[3];
t4 = (unsigned char *)dest[4];
t0 = (unsigned char *) dest[0];
t1 = (unsigned char *) dest[1];
t2 = (unsigned char *) dest[2];
t3 = (unsigned char *) dest[3];
t4 = (unsigned char *) dest[4];
head = len % 64;
if (head != 0) {
@ -68,7 +69,7 @@ void gf_5vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char *g4 = &gftbls[4 * 32 * vlen];
for (j = 0; j < vlen; j++) {
s = (unsigned char *)src[j];
s = (unsigned char *) src[j];
vX1 = vec_xl(0, s + i);
vX2 = vec_xl(16, s + i);
vX3 = vec_xl(32, s + i);

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_5vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char **dest)
void
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;
vector unsigned char vX1, vX2, vX3, vX4;
@ -10,12 +11,12 @@ void gf_5vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
vector unsigned char vhi0, vlo0, vhi1, vlo1, vhi2, vlo2, vhi3, vlo3, vhi4, vlo4;
int i, head;
s = (unsigned char *)src;
t0 = (unsigned char *)dest[0];
t1 = (unsigned char *)dest[1];
t2 = (unsigned char *)dest[2];
t3 = (unsigned char *)dest[3];
t4 = (unsigned char *)dest[4];
s = (unsigned char *) src;
t0 = (unsigned char *) dest[0];
t1 = (unsigned char *) dest[1];
t2 = (unsigned char *) dest[2];
t3 = (unsigned char *) dest[3];
t4 = (unsigned char *) dest[4];
head = len % 64;
if (head != 0) {

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_6vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char **dest)
void
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;
vector unsigned char vX1, vX2, vX3, vX4;
@ -12,12 +13,12 @@ void gf_6vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
int i, j, head;
if (vlen < 128) {
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *)dest[0]);
gf_vect_mul_vsx(len, &gftbls[1 * 32 * vlen], src[0], (unsigned char *)dest[1]);
gf_vect_mul_vsx(len, &gftbls[2 * 32 * vlen], src[0], (unsigned char *)dest[2]);
gf_vect_mul_vsx(len, &gftbls[3 * 32 * vlen], src[0], (unsigned char *)dest[3]);
gf_vect_mul_vsx(len, &gftbls[4 * 32 * vlen], src[0], (unsigned char *)dest[4]);
gf_vect_mul_vsx(len, &gftbls[5 * 32 * vlen], src[0], (unsigned char *)dest[5]);
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *) dest[0]);
gf_vect_mul_vsx(len, &gftbls[1 * 32 * vlen], src[0], (unsigned char *) dest[1]);
gf_vect_mul_vsx(len, &gftbls[2 * 32 * vlen], src[0], (unsigned char *) dest[2]);
gf_vect_mul_vsx(len, &gftbls[3 * 32 * vlen], src[0], (unsigned char *) dest[3]);
gf_vect_mul_vsx(len, &gftbls[4 * 32 * vlen], src[0], (unsigned char *) dest[4]);
gf_vect_mul_vsx(len, &gftbls[5 * 32 * vlen], src[0], (unsigned char *) dest[5]);
for (j = 1; j < vlen; j++) {
gf_6vect_mad_vsx(len, vlen, j, gftbls, src[j], dest);
@ -25,12 +26,12 @@ void gf_6vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
return;
}
t0 = (unsigned char *)dest[0];
t1 = (unsigned char *)dest[1];
t2 = (unsigned char *)dest[2];
t3 = (unsigned char *)dest[3];
t4 = (unsigned char *)dest[4];
t5 = (unsigned char *)dest[5];
t0 = (unsigned char *) dest[0];
t1 = (unsigned char *) dest[1];
t2 = (unsigned char *) dest[2];
t3 = (unsigned char *) dest[3];
t4 = (unsigned char *) dest[4];
t5 = (unsigned char *) dest[5];
head = len % 64;
if (head != 0) {
@ -77,7 +78,7 @@ void gf_6vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char *g5 = &gftbls[5 * 32 * vlen];
for (j = 0; j < vlen; j++) {
s = (unsigned char *)src[j];
s = (unsigned char *) src[j];
vX1 = vec_xl(0, s + i);
vX2 = vec_xl(16, s + i);
vX3 = vec_xl(32, s + i);

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_6vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char **dest)
void
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;
vector unsigned char vX1, vX2, vX3, vX4;
@ -11,13 +12,13 @@ void gf_6vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
vector unsigned char vhi3, vlo3, vhi4, vlo4, vhi5, vlo5;
int i, head;
s = (unsigned char *)src;
t0 = (unsigned char *)dest[0];
t1 = (unsigned char *)dest[1];
t2 = (unsigned char *)dest[2];
t3 = (unsigned char *)dest[3];
t4 = (unsigned char *)dest[4];
t5 = (unsigned char *)dest[5];
s = (unsigned char *) src;
t0 = (unsigned char *) dest[0];
t1 = (unsigned char *) dest[1];
t2 = (unsigned char *) dest[2];
t3 = (unsigned char *) dest[3];
t4 = (unsigned char *) dest[4];
t5 = (unsigned char *) dest[5];
head = len % 64;
if (head != 0) {

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char **src, unsigned char *dest)
void
gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls, unsigned char **src,
unsigned char *dest)
{
unsigned char *s, *t0;
vector unsigned char vX1, vY1;
@ -16,7 +17,7 @@ void gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
int i, j, head;
if (vlen < 128) {
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *)dest);
gf_vect_mul_vsx(len, &gftbls[0 * 32 * vlen], src[0], (unsigned char *) dest);
for (j = 1; j < vlen; j++) {
gf_vect_mad_vsx(len, vlen, j, gftbls, src[j], dest);
@ -24,7 +25,7 @@ void gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
return;
}
t0 = (unsigned char *)dest;
t0 = (unsigned char *) dest;
head = len % 128;
if (head != 0) {
@ -45,7 +46,7 @@ void gf_vect_dot_prod_vsx(int len, int vlen, unsigned char *gftbls,
unsigned char *g0 = &gftbls[0 * 32 * vlen];
for (j = 0; j < vlen; j++) {
s = (unsigned char *)src[j];
s = (unsigned char *) src[j];
vX1 = vec_xl(0, s + i);
vX2 = vec_xl(16, s + i);
vX3 = vec_xl(32, s + i);

View File

@ -1,7 +1,8 @@
#include "ec_base_vsx.h"
void gf_vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
unsigned char *src, unsigned char *dest)
void
gf_vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls, unsigned char *src,
unsigned char *dest)
{
unsigned char *s, *t0;
vector unsigned char vX1, vY1;
@ -11,8 +12,8 @@ void gf_vect_mad_vsx(int len, int vec, int vec_i, unsigned char *gftbls,
vector unsigned char vhi0, vlo0;
int i, head;
s = (unsigned char *)src;
t0 = (unsigned char *)dest;
s = (unsigned char *) src;
t0 = (unsigned char *) dest;
head = len % 64;
if (head != 0) {

View File

@ -3,10 +3,10 @@
/*
* 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,
unsigned char *dest)
static void
_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];
while (len-- > 0)
@ -14,7 +14,8 @@ static void _gf_vect_mul_base(int len, unsigned char *a, unsigned char *src,
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;
vector unsigned char vX1, vY1;
@ -28,8 +29,8 @@ void gf_vect_mul_vsx(int len, unsigned char *gftbl, unsigned char *src, unsigned
vector unsigned char vhi0, vlo0;
int i, head;
s = (unsigned char *)src;
t0 = (unsigned char *)dest;
s = (unsigned char *) src;
t0 = (unsigned char *) dest;
head = len % 128;
if (head != 0) {