mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Use primitive generator 3 for AES Cauchy mode
This commit is contained in:
parent
f855bf4d82
commit
b5d507fbe9
21 changed files with 7444 additions and 5791 deletions
|
|
@ -1,7 +1,15 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright (C) 2013 Andrea Mazzoleni
|
||||
|
||||
/* Matrix inversion test for the RAID library */
|
||||
/*
|
||||
* Matrix inversion test for the RAID library.
|
||||
*
|
||||
* Verifies that all square submatrices of the Extended Cauchy matrix are
|
||||
* nonsingular (invertible) for both operating modes:
|
||||
*
|
||||
* RAID: GF polynomial 0x11d, primitive generator g=2
|
||||
* AES: GF polynomial 0x11b, primitive generator g=3
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
|
@ -72,7 +80,7 @@ long long EXPECTED[RAID_PARITY_MAX] = {
|
|||
327012476050LL
|
||||
};
|
||||
|
||||
static __always_inline int test_sub_matrix(int nr, int64_t *total)
|
||||
static __always_inline int test_sub_matrix(int nr, int mode, const char *name, int64_t *total)
|
||||
{
|
||||
uint8_t M[RAID_PARITY_MAX * RAID_PARITY_MAX];
|
||||
int np = RAID_PARITY_MAX;
|
||||
|
|
@ -82,7 +90,10 @@ static __always_inline int test_sub_matrix(int nr, int64_t *total)
|
|||
int64_t count;
|
||||
int64_t expected;
|
||||
|
||||
printf("\n%ux%u\n", nr, nr);
|
||||
/* select the operating mode before reading raid_gfgen or using inv()/mul() */
|
||||
raid_mode(mode);
|
||||
|
||||
printf("\n%ux%u %s\n", nr, nr, name);
|
||||
|
||||
count = 0;
|
||||
expected = EXPECTED[nr - 1];
|
||||
|
|
@ -101,8 +112,18 @@ static __always_inline int test_sub_matrix(int nr, int64_t *total)
|
|||
M[i * nr + j] = raid_gfgen[ip[i]][id[j]];
|
||||
|
||||
/* invert */
|
||||
if (raid_invert_fast(M, nr) != 0)
|
||||
if (raid_invert_fast(M, nr) != 0) {
|
||||
int k;
|
||||
printf("\nFAILED %s %ux%u submatrix\n", name, nr, nr);
|
||||
printf("parity:");
|
||||
for (k = 0; k < nr; ++k)
|
||||
printf(" %d", ip[k]);
|
||||
printf("\ndata:");
|
||||
for (k = 0; k < nr; ++k)
|
||||
printf(" %d", id[k]);
|
||||
printf("\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (++count % TEST_REFRESH == 0) {
|
||||
printf("\r%.3f %%", count * (double)100 / expected);
|
||||
|
|
@ -111,8 +132,10 @@ static __always_inline int test_sub_matrix(int nr, int64_t *total)
|
|||
} while (combination_next(nr, np, ip));
|
||||
} while (combination_next(nr, nd, id));
|
||||
|
||||
if (count != expected)
|
||||
if (count != expected) {
|
||||
printf("\nFAILED %s %ux%u count mismatch: %" PRIi64 " != %" PRIi64 "\n", name, nr, nr, count, expected);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("\rTested %" PRIi64 " matrix\n", count);
|
||||
|
||||
|
|
@ -123,30 +146,45 @@ static __always_inline int test_sub_matrix(int nr, int64_t *total)
|
|||
|
||||
int test_all_sub_matrix(void)
|
||||
{
|
||||
int64_t total;
|
||||
int64_t total_raid;
|
||||
int64_t total_aes;
|
||||
|
||||
printf("Invert all square submatrices of the %dx%d Cauchy matrix\n",
|
||||
printf("Invert all square submatrices of the %dx%d Cauchy matrices in RAID and AES modes\n",
|
||||
RAID_PARITY_MAX, RAID_DATA_MAX);
|
||||
|
||||
printf("\nPlease wait about 2 days...\n");
|
||||
printf("\nThis exhaustive test may take days...\n");
|
||||
|
||||
total = 0;
|
||||
total_raid = 0;
|
||||
total_aes = 0;
|
||||
|
||||
/* force inlining of everything */
|
||||
if (test_sub_matrix(1, &total) != 0)
|
||||
if (test_sub_matrix(1, RAID_MODE_CAUCHY_RAID, "RAID", &total_raid) != 0)
|
||||
return -1;
|
||||
if (test_sub_matrix(2, &total) != 0)
|
||||
if (test_sub_matrix(1, RAID_MODE_CAUCHY_AES, "AES", &total_aes) != 0)
|
||||
return -1;
|
||||
if (test_sub_matrix(3, &total) != 0)
|
||||
if (test_sub_matrix(2, RAID_MODE_CAUCHY_RAID, "RAID", &total_raid) != 0)
|
||||
return -1;
|
||||
if (test_sub_matrix(4, &total) != 0)
|
||||
if (test_sub_matrix(2, RAID_MODE_CAUCHY_AES, "AES", &total_aes) != 0)
|
||||
return -1;
|
||||
if (test_sub_matrix(5, &total) != 0)
|
||||
if (test_sub_matrix(3, RAID_MODE_CAUCHY_RAID, "RAID", &total_raid) != 0)
|
||||
return -1;
|
||||
if (test_sub_matrix(6, &total) != 0)
|
||||
if (test_sub_matrix(3, RAID_MODE_CAUCHY_AES, "AES", &total_aes) != 0)
|
||||
return -1;
|
||||
if (test_sub_matrix(4, RAID_MODE_CAUCHY_RAID, "RAID", &total_raid) != 0)
|
||||
return -1;
|
||||
if (test_sub_matrix(4, RAID_MODE_CAUCHY_AES, "AES", &total_aes) != 0)
|
||||
return -1;
|
||||
if (test_sub_matrix(5, RAID_MODE_CAUCHY_RAID, "RAID", &total_raid) != 0)
|
||||
return -1;
|
||||
if (test_sub_matrix(5, RAID_MODE_CAUCHY_AES, "AES", &total_aes) != 0)
|
||||
return -1;
|
||||
if (test_sub_matrix(6, RAID_MODE_CAUCHY_RAID, "RAID", &total_raid) != 0)
|
||||
return -1;
|
||||
if (test_sub_matrix(6, RAID_MODE_CAUCHY_AES, "AES", &total_aes) != 0)
|
||||
return -1;
|
||||
|
||||
printf("\nTested in total %" PRIi64 " matrix\n", total);
|
||||
printf("\nTested in total %" PRIi64 " RAID matrix\n", total_raid);
|
||||
printf("Tested in total %" PRIi64 " AES matrix\n", total_aes);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
/* Self-test for the RAID library */
|
||||
|
||||
#include "internal.h"
|
||||
#include "test.h"
|
||||
#include "cpu.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
@ -16,15 +17,23 @@ int main(void)
|
|||
raid_init();
|
||||
|
||||
printf("Test Cauchy RAID\n");
|
||||
if (raid_test_poly(RAID_MODE_CAUCHY_RAID) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_selftest() != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
raid_mode(RAID_MODE_CAUCHY_AES);
|
||||
|
||||
printf("Test Cauchy AES\n");
|
||||
if (raid_test_poly(RAID_MODE_CAUCHY_AES) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_selftest() != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue