mirror of
https://github.com/intel/isa-l.git
synced 2024-12-12 09:23:50 +01:00
examples: reformat using new code style
Signed-off-by: Marcel Cornu <marcel.d.cornu@intel.com>
This commit is contained in:
parent
300260a4d9
commit
9d99f8215d
@ -49,14 +49,14 @@
|
||||
|
||||
int verbose; // Global for tests
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
# define __builtin_parity(x) (__popcnt64(x) & 1)
|
||||
#if defined(_MSC_VER)
|
||||
#define __builtin_parity(x) (__popcnt64(x) & 1)
|
||||
#endif
|
||||
|
||||
#if defined (__GNUC__) || defined (__clang__)
|
||||
# define ATTRIBUTE_TARGET(x) __attribute__((target(x)))
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define ATTRIBUTE_TARGET(x) __attribute__((target(x)))
|
||||
#else
|
||||
# define ATTRIBUTE_TARGET(x)
|
||||
#define ATTRIBUTE_TARGET(x)
|
||||
#endif
|
||||
|
||||
struct crc64_desc {
|
||||
@ -66,7 +66,8 @@ struct crc64_desc {
|
||||
uint64_t k8;
|
||||
};
|
||||
|
||||
void gen_crc64_refl_consts(uint64_t poly, struct crc64_desc *c)
|
||||
void
|
||||
gen_crc64_refl_consts(uint64_t poly, struct crc64_desc *c)
|
||||
{
|
||||
uint64_t quotienth = 0;
|
||||
uint64_t div;
|
||||
@ -84,7 +85,8 @@ void gen_crc64_refl_consts(uint64_t poly, struct crc64_desc *c)
|
||||
c->k8 = poly << 1;
|
||||
}
|
||||
|
||||
void gen_crc64_norm_consts(uint64_t poly, struct crc64_desc *c)
|
||||
void
|
||||
gen_crc64_norm_consts(uint64_t poly, struct crc64_desc *c)
|
||||
{
|
||||
uint64_t quotientl = 0;
|
||||
uint64_t div;
|
||||
@ -103,7 +105,8 @@ void gen_crc64_norm_consts(uint64_t poly, struct crc64_desc *c)
|
||||
c->k8 = poly;
|
||||
}
|
||||
|
||||
uint32_t calc_xi_mod(int n)
|
||||
uint32_t
|
||||
calc_xi_mod(int n)
|
||||
{
|
||||
uint32_t rem = 0x1ul;
|
||||
int i, j;
|
||||
@ -120,7 +123,8 @@ uint32_t calc_xi_mod(int n)
|
||||
return rem;
|
||||
}
|
||||
|
||||
uint64_t calc64_refl_xi_mod(int n, struct crc64_desc *c)
|
||||
uint64_t
|
||||
calc64_refl_xi_mod(int n, struct crc64_desc *c)
|
||||
{
|
||||
uint64_t rem = 1ull;
|
||||
int i, j;
|
||||
@ -137,7 +141,8 @@ uint64_t calc64_refl_xi_mod(int n, struct crc64_desc *c)
|
||||
return rem;
|
||||
}
|
||||
|
||||
uint64_t calc64_norm_xi_mod(int n, struct crc64_desc *c)
|
||||
uint64_t
|
||||
calc64_norm_xi_mod(int n, struct crc64_desc *c)
|
||||
{
|
||||
uint64_t rem = 1ull;
|
||||
int i, j;
|
||||
@ -157,7 +162,8 @@ uint64_t calc64_norm_xi_mod(int n, struct crc64_desc *c)
|
||||
// Base function for crc32_iscsi_shiftx() if c++ multi-function versioning
|
||||
#ifdef __cplusplus
|
||||
|
||||
static inline uint32_t bit_reverse32(uint32_t x)
|
||||
static inline uint32_t
|
||||
bit_reverse32(uint32_t x)
|
||||
{
|
||||
x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1));
|
||||
x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2));
|
||||
@ -169,7 +175,8 @@ static inline uint32_t bit_reverse32(uint32_t x)
|
||||
// Base function for crc32_iscsi_shiftx without clmul optimizations
|
||||
|
||||
ATTRIBUTE_TARGET("default")
|
||||
uint32_t crc32_iscsi_shiftx(uint32_t crc1, uint32_t x)
|
||||
uint32_t
|
||||
crc32_iscsi_shiftx(uint32_t crc1, uint32_t x)
|
||||
{
|
||||
int i;
|
||||
uint64_t xrev, q = 0;
|
||||
@ -190,7 +197,8 @@ uint32_t crc32_iscsi_shiftx(uint32_t crc1, uint32_t x)
|
||||
#endif // cplusplus
|
||||
|
||||
ATTRIBUTE_TARGET("pclmul,sse4.2")
|
||||
uint32_t crc32_iscsi_shiftx(uint32_t crc1, uint32_t x)
|
||||
uint32_t
|
||||
crc32_iscsi_shiftx(uint32_t crc1, uint32_t x)
|
||||
{
|
||||
__m128i crc1x, constx;
|
||||
uint64_t crc64;
|
||||
@ -204,11 +212,12 @@ uint32_t crc32_iscsi_shiftx(uint32_t crc1, uint32_t x)
|
||||
}
|
||||
|
||||
ATTRIBUTE_TARGET("pclmul,sse4.2")
|
||||
uint64_t crc64_refl_shiftx(uint64_t crc1, uint64_t x, struct crc64_desc *c)
|
||||
uint64_t
|
||||
crc64_refl_shiftx(uint64_t crc1, uint64_t x, struct crc64_desc *c)
|
||||
{
|
||||
__m128i crc1x, crc2x, crc3x, constx;
|
||||
const __m128i rk5 = _mm_loadu_si64(&c->k5);
|
||||
const __m128i rk7 = _mm_loadu_si128((__m128i *) & c->k7);
|
||||
const __m128i rk7 = _mm_loadu_si128((__m128i *) &c->k7);
|
||||
|
||||
crc1x = _mm_cvtsi64_si128(crc1);
|
||||
constx = _mm_cvtsi64_si128(x);
|
||||
@ -229,11 +238,12 @@ uint64_t crc64_refl_shiftx(uint64_t crc1, uint64_t x, struct crc64_desc *c)
|
||||
}
|
||||
|
||||
ATTRIBUTE_TARGET("pclmul,sse4.2")
|
||||
uint64_t crc64_norm_shiftx(uint64_t crc1, uint64_t x, struct crc64_desc *c)
|
||||
uint64_t
|
||||
crc64_norm_shiftx(uint64_t crc1, uint64_t x, struct crc64_desc *c)
|
||||
{
|
||||
__m128i crc1x, crc2x, crc3x, constx;
|
||||
const __m128i rk5 = _mm_loadu_si64(&c->k5);
|
||||
const __m128i rk7 = _mm_loadu_si128((__m128i *) & c->k7);
|
||||
const __m128i rk7 = _mm_loadu_si128((__m128i *) &c->k7);
|
||||
|
||||
crc1x = _mm_cvtsi64_si128(crc1);
|
||||
constx = _mm_cvtsi64_si128(x);
|
||||
@ -252,9 +262,10 @@ uint64_t crc64_norm_shiftx(uint64_t crc1, uint64_t x, struct crc64_desc *c)
|
||||
return _mm_extract_epi64(crc1x, 0);
|
||||
}
|
||||
|
||||
uint32_t crc32_iscsi_combine_4k(uint32_t * crc_array, int n)
|
||||
uint32_t
|
||||
crc32_iscsi_combine_4k(uint32_t *crc_array, int n)
|
||||
{
|
||||
const uint32_t cn4k = 0x82f89c77; //calc_xi_mod(4*1024);
|
||||
const uint32_t cn4k = 0x82f89c77; // calc_xi_mod(4*1024);
|
||||
int i;
|
||||
|
||||
if (n < 1)
|
||||
@ -270,10 +281,17 @@ uint32_t crc32_iscsi_combine_4k(uint32_t * crc_array, int n)
|
||||
|
||||
// Tests
|
||||
|
||||
#define printv(...) {if (verbose) printf(__VA_ARGS__); else printf(".");}
|
||||
#define printv(...) \
|
||||
{ \
|
||||
if (verbose) \
|
||||
printf(__VA_ARGS__); \
|
||||
else \
|
||||
printf("."); \
|
||||
}
|
||||
|
||||
uint64_t test_combine64(uint8_t * inp, size_t len, uint64_t poly, int reflected,
|
||||
uint64_t(*func) (uint64_t, const uint8_t *, uint64_t))
|
||||
uint64_t
|
||||
test_combine64(uint8_t *inp, size_t len, uint64_t poly, int reflected,
|
||||
uint64_t (*func)(uint64_t, const uint8_t *, uint64_t))
|
||||
{
|
||||
|
||||
uint64_t crc64_init, crc64, crc64a, crc64b;
|
||||
@ -341,13 +359,14 @@ uint64_t test_combine64(uint8_t * inp, size_t len, uint64_t poly, int reflected,
|
||||
}
|
||||
|
||||
#define N (1024)
|
||||
#define B (2*N)
|
||||
#define T (3*N)
|
||||
#define N4k (4*1024)
|
||||
#define B (2 * N)
|
||||
#define T (3 * N)
|
||||
#define N4k (4 * 1024)
|
||||
#define NMAX 32
|
||||
#define NMAX_SIZE (NMAX * N4k)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
uint32_t crc, crca, crcb, crc1, crc2, crc3, crcn;
|
||||
@ -384,8 +403,7 @@ int main(int argc, char *argv[])
|
||||
crc1 = crc32_iscsi(&inp[0], 100, crc_init);
|
||||
crc2 = crc32_iscsi(&inp[100], 100, 0);
|
||||
crc3 = crc32_iscsi(&inp[200], B - 200, 0);
|
||||
crcn = crc3 ^
|
||||
crc32_iscsi_shiftx(crc2, calc_xi_mod(B - 200)) ^
|
||||
crcn = crc3 ^ crc32_iscsi_shiftx(crc2, calc_xi_mod(B - 200)) ^
|
||||
crc32_iscsi_shiftx(crc1, calc_xi_mod(B - 100));
|
||||
printv("crcB combined3 = 0x%" PRIx32 "\n\n", crcn);
|
||||
err |= crcn ^ crc;
|
||||
@ -398,16 +416,14 @@ int main(int argc, char *argv[])
|
||||
crc1 = crc32_iscsi(&inp[0], N, crc_init);
|
||||
crc2 = crc32_iscsi(&inp[N], N, 0);
|
||||
crc3 = crc32_iscsi(&inp[2 * N], N, 0);
|
||||
crcn = crc3 ^
|
||||
crc32_iscsi_shiftx(crc2, calc_xi_mod(N)) ^
|
||||
crcn = crc3 ^ crc32_iscsi_shiftx(crc2, calc_xi_mod(N)) ^
|
||||
crc32_iscsi_shiftx(crc1, calc_xi_mod(2 * N));
|
||||
printv("crcT combined3 = 0x%" PRIx32 "\n", crcn);
|
||||
err |= crcn ^ crc;
|
||||
|
||||
// Combine 3 segments with one const by sequential shift
|
||||
uint32_t xi_mod_n = calc_xi_mod(N);
|
||||
crcn = crc3 ^ crc32_iscsi_shiftx(crc32_iscsi_shiftx(crc1, xi_mod_n)
|
||||
^ crc2, xi_mod_n);
|
||||
crcn = crc3 ^ crc32_iscsi_shiftx(crc32_iscsi_shiftx(crc1, xi_mod_n) ^ crc2, xi_mod_n);
|
||||
printv("crcT comb3 seq = 0x%" PRIx32 "\n\n", crcn);
|
||||
err |= crcn ^ crc;
|
||||
|
||||
|
@ -40,7 +40,8 @@
|
||||
typedef unsigned char u8;
|
||||
int verbose = 0;
|
||||
|
||||
int usage(void)
|
||||
int
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: ec_piggyback_example [options]\n"
|
||||
@ -57,7 +58,8 @@ int usage(void)
|
||||
}
|
||||
|
||||
// Cauchy-based matrix
|
||||
void gf_gen_full_pb_cauchy_matrix(u8 * a, int m, int k)
|
||||
void
|
||||
gf_gen_full_pb_cauchy_matrix(u8 *a, int m, int k)
|
||||
{
|
||||
int i, j, p = m - k;
|
||||
|
||||
@ -94,7 +96,8 @@ void gf_gen_full_pb_cauchy_matrix(u8 * a, int m, int k)
|
||||
}
|
||||
|
||||
// Vandermonde based matrix - not recommended due to limits when invertable
|
||||
void gf_gen_full_pb_vand_matrix(u8 * a, int m, int k)
|
||||
void
|
||||
gf_gen_full_pb_vand_matrix(u8 *a, int m, int k)
|
||||
{
|
||||
int i, j, p = m - k;
|
||||
unsigned char q, gen = 1;
|
||||
@ -141,7 +144,8 @@ void gf_gen_full_pb_vand_matrix(u8 * a, int m, int k)
|
||||
}
|
||||
}
|
||||
|
||||
void print_matrix(int m, int k, unsigned char *s, const char *msg)
|
||||
void
|
||||
print_matrix(int m, int k, unsigned char *s, const char *msg)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
@ -156,7 +160,8 @@ void print_matrix(int m, int k, unsigned char *s, const char *msg)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_list(int n, unsigned char *s, const char *msg)
|
||||
void
|
||||
print_list(int n, unsigned char *s, const char *msg)
|
||||
{
|
||||
int i;
|
||||
if (!verbose)
|
||||
@ -168,14 +173,12 @@ void print_list(int n, unsigned char *s, const char *msg)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static int gf_gen_decode_matrix(u8 * encode_matrix,
|
||||
u8 * decode_matrix,
|
||||
u8 * invert_matrix,
|
||||
u8 * temp_matrix,
|
||||
u8 * decode_index,
|
||||
u8 * frag_err_list, int nerrs, int k, int m);
|
||||
static int
|
||||
gf_gen_decode_matrix(u8 *encode_matrix, u8 *decode_matrix, u8 *invert_matrix, u8 *temp_matrix,
|
||||
u8 *decode_index, u8 *frag_err_list, int nerrs, int k, int m);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i, j, m, c, e, ret;
|
||||
int k = 10, p = 4, len = 8 * 1024; // Default params
|
||||
@ -246,13 +249,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Check for valid parameters
|
||||
if (m > (MMAX / 2) || k > (KMAX / 2) || m < 0 || p < 2 || k < 1) {
|
||||
printf(" Input test parameter error m=%d, k=%d, p=%d, erasures=%d\n",
|
||||
m, k, p, nerrs);
|
||||
printf(" Input test parameter error m=%d, k=%d, p=%d, erasures=%d\n", m, k, p,
|
||||
nerrs);
|
||||
usage();
|
||||
}
|
||||
if (nerrs > p) {
|
||||
printf(" Number of erasures chosen exceeds power of code erasures=%d p=%d\n",
|
||||
nerrs, p);
|
||||
printf(" Number of erasures chosen exceeds power of code erasures=%d p=%d\n", nerrs,
|
||||
p);
|
||||
}
|
||||
for (i = 0; i < nerrs; i++) {
|
||||
if (frag_err_list[i] >= m)
|
||||
@ -279,8 +282,8 @@ int main(int argc, char *argv[])
|
||||
temp_matrix = malloc(m2 * k2);
|
||||
g_tbls = malloc(k2 * p2 * 32);
|
||||
|
||||
if (encode_matrix == NULL || decode_matrix == NULL
|
||||
|| invert_matrix == NULL || temp_matrix == NULL || g_tbls == NULL) {
|
||||
if (encode_matrix == NULL || decode_matrix == NULL || invert_matrix == NULL ||
|
||||
temp_matrix == NULL || g_tbls == NULL) {
|
||||
printf("Test failure! Error with malloc\n");
|
||||
return -1;
|
||||
}
|
||||
@ -336,8 +339,7 @@ int main(int argc, char *argv[])
|
||||
if (benchmark) {
|
||||
struct perf start;
|
||||
BENCHMARK(&start, BENCHMARK_TIME,
|
||||
ec_encode_data(len / 2, k2, p2, g_tbls, frag_ptrs,
|
||||
parity_ptrs));
|
||||
ec_encode_data(len / 2, k2, p2, g_tbls, frag_ptrs, parity_ptrs));
|
||||
printf("ec_piggyback_encode_std: ");
|
||||
perf_print(start, m2 * len / 2);
|
||||
}
|
||||
@ -362,8 +364,7 @@ int main(int argc, char *argv[])
|
||||
memcpy(&encode_matrix_faster[k * i], &encode_matrix[k2 * j], k);
|
||||
|
||||
if (verbose) {
|
||||
print_matrix(p, k, &encode_matrix_faster[k * k],
|
||||
"encode via sparse-opt");
|
||||
print_matrix(p, k, &encode_matrix_faster[k * k], "encode via sparse-opt");
|
||||
print_matrix(p2 / 2, k2, &encode_matrix[(k2 + p2 / 2) * k2],
|
||||
"encode via sparse-opt");
|
||||
}
|
||||
@ -372,16 +373,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Generate EC parity blocks from sources
|
||||
ec_encode_data(len / 2, k, p, g_tbls_faster, frag_ptrs, parity_ptrs);
|
||||
ec_encode_data(len / 2, k2, p, &g_tbls[k2 * p * 32], frag_ptrs,
|
||||
&parity_ptrs[p]);
|
||||
ec_encode_data(len / 2, k2, p, &g_tbls[k2 * p * 32], frag_ptrs, &parity_ptrs[p]);
|
||||
|
||||
if (benchmark) {
|
||||
struct perf start;
|
||||
BENCHMARK(&start, BENCHMARK_TIME,
|
||||
ec_encode_data(len / 2, k, p, g_tbls_faster, frag_ptrs,
|
||||
parity_ptrs);
|
||||
ec_encode_data(len / 2, k2, p, &g_tbls[k2 * p * 32],
|
||||
frag_ptrs, &parity_ptrs[p]));
|
||||
ec_encode_data(len / 2, k2, p, &g_tbls[k2 * p * 32], frag_ptrs,
|
||||
&parity_ptrs[p]));
|
||||
printf("ec_piggyback_encode_sparse: ");
|
||||
perf_print(start, m2 * len / 2);
|
||||
}
|
||||
@ -399,9 +399,8 @@ int main(int argc, char *argv[])
|
||||
print_list(nerrs2, frag_err_list, " frag err list");
|
||||
|
||||
// Find a decode matrix to regenerate all erasures from remaining frags
|
||||
ret = gf_gen_decode_matrix(encode_matrix, decode_matrix,
|
||||
invert_matrix, temp_matrix, decode_index, frag_err_list,
|
||||
nerrs2, k2, m2);
|
||||
ret = gf_gen_decode_matrix(encode_matrix, decode_matrix, invert_matrix, temp_matrix,
|
||||
decode_index, frag_err_list, nerrs2, k2, m2);
|
||||
|
||||
if (ret != 0) {
|
||||
printf("Fail on generate decode matrix\n");
|
||||
@ -423,8 +422,7 @@ int main(int argc, char *argv[])
|
||||
if (benchmark) {
|
||||
struct perf start;
|
||||
BENCHMARK(&start, BENCHMARK_TIME,
|
||||
ec_encode_data(len / 2, k2, nerrs2, g_tbls, recover_srcs,
|
||||
recover_outp));
|
||||
ec_encode_data(len / 2, k2, nerrs2, g_tbls, recover_srcs, recover_outp));
|
||||
printf("ec_piggyback_decode: ");
|
||||
perf_print(start, (k2 + nerrs2) * len / 2);
|
||||
}
|
||||
@ -444,11 +442,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Generate decode matrix from encode matrix and erasure list
|
||||
|
||||
static int gf_gen_decode_matrix(u8 * encode_matrix,
|
||||
u8 * decode_matrix,
|
||||
u8 * invert_matrix,
|
||||
u8 * temp_matrix,
|
||||
u8 * decode_index, u8 * frag_err_list, int nerrs, int k, int m)
|
||||
static int
|
||||
gf_gen_decode_matrix(u8 *encode_matrix, u8 *decode_matrix, u8 *invert_matrix, u8 *temp_matrix,
|
||||
u8 *decode_index, u8 *frag_err_list, int nerrs, int k, int m)
|
||||
{
|
||||
int i, j, p, r;
|
||||
int nsrcerrs = 0;
|
||||
|
@ -38,7 +38,8 @@
|
||||
|
||||
typedef unsigned char u8;
|
||||
|
||||
int usage(void)
|
||||
int
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: ec_simple_example [options]\n"
|
||||
@ -51,14 +52,13 @@ int usage(void)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static int gf_gen_decode_matrix_simple(u8 * encode_matrix,
|
||||
u8 * decode_matrix,
|
||||
u8 * invert_matrix,
|
||||
u8 * temp_matrix,
|
||||
u8 * decode_index,
|
||||
u8 * frag_err_list, int nerrs, int k, int m);
|
||||
static int
|
||||
gf_gen_decode_matrix_simple(u8 *encode_matrix, u8 *decode_matrix, u8 *invert_matrix,
|
||||
u8 *temp_matrix, u8 *decode_index, u8 *frag_err_list, int nerrs, int k,
|
||||
int m);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i, j, m, c, e, ret;
|
||||
int k = 10, p = 4, len = 8 * 1024; // Default params
|
||||
@ -116,13 +116,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Check for valid parameters
|
||||
if (m > MMAX || k > KMAX || m < 0 || p < 1 || k < 1) {
|
||||
printf(" Input test parameter error m=%d, k=%d, p=%d, erasures=%d\n",
|
||||
m, k, p, nerrs);
|
||||
printf(" Input test parameter error m=%d, k=%d, p=%d, erasures=%d\n", m, k, p,
|
||||
nerrs);
|
||||
usage();
|
||||
}
|
||||
if (nerrs > p) {
|
||||
printf(" Number of erasures chosen exceeds power of code erasures=%d p=%d\n",
|
||||
nerrs, p);
|
||||
printf(" Number of erasures chosen exceeds power of code erasures=%d p=%d\n", nerrs,
|
||||
p);
|
||||
usage();
|
||||
}
|
||||
for (i = 0; i < nerrs; i++) {
|
||||
@ -141,8 +141,8 @@ int main(int argc, char *argv[])
|
||||
temp_matrix = malloc(m * k);
|
||||
g_tbls = malloc(k * p * 32);
|
||||
|
||||
if (encode_matrix == NULL || decode_matrix == NULL
|
||||
|| invert_matrix == NULL || temp_matrix == NULL || g_tbls == NULL) {
|
||||
if (encode_matrix == NULL || decode_matrix == NULL || invert_matrix == NULL ||
|
||||
temp_matrix == NULL || g_tbls == NULL) {
|
||||
printf("Test failure! Error with malloc\n");
|
||||
return -1;
|
||||
}
|
||||
@ -185,9 +185,8 @@ int main(int argc, char *argv[])
|
||||
printf(" recover %d fragments\n", nerrs);
|
||||
|
||||
// Find a decode matrix to regenerate all erasures from remaining frags
|
||||
ret = gf_gen_decode_matrix_simple(encode_matrix, decode_matrix,
|
||||
invert_matrix, temp_matrix, decode_index,
|
||||
frag_err_list, nerrs, k, m);
|
||||
ret = gf_gen_decode_matrix_simple(encode_matrix, decode_matrix, invert_matrix, temp_matrix,
|
||||
decode_index, frag_err_list, nerrs, k, m);
|
||||
if (ret != 0) {
|
||||
printf("Fail on generate decode matrix\n");
|
||||
return -1;
|
||||
@ -219,11 +218,9 @@ int main(int argc, char *argv[])
|
||||
*
|
||||
*/
|
||||
|
||||
static int gf_gen_decode_matrix_simple(u8 * encode_matrix,
|
||||
u8 * decode_matrix,
|
||||
u8 * invert_matrix,
|
||||
u8 * temp_matrix,
|
||||
u8 * decode_index, u8 * frag_err_list, int nerrs, int k,
|
||||
static int
|
||||
gf_gen_decode_matrix_simple(u8 *encode_matrix, u8 *decode_matrix, u8 *invert_matrix,
|
||||
u8 *temp_matrix, u8 *decode_index, u8 *frag_err_list, int nerrs, int k,
|
||||
int m)
|
||||
{
|
||||
int i, j, p, r;
|
||||
@ -257,8 +254,7 @@ static int gf_gen_decode_matrix_simple(u8 * encode_matrix,
|
||||
for (i = 0; i < nerrs; i++) {
|
||||
if (frag_err_list[i] < k) // A src err
|
||||
for (j = 0; j < k; j++)
|
||||
decode_matrix[k * i + j] =
|
||||
invert_matrix[k * frag_err_list[i] + j];
|
||||
decode_matrix[k * i + j] = invert_matrix[k * frag_err_list[i] + j];
|
||||
}
|
||||
|
||||
// For non-src (parity) erasures need to multiply encode matrix * invert
|
||||
|
Loading…
Reference in New Issue
Block a user