Support dynamic runtime selection of RAID AES mode

This commit is contained in:
Andrea Mazzoleni 2026-07-29 12:47:13 +02:00
parent ca5ad2f842
commit 5a8e4e5d67
24 changed files with 16502 additions and 16479 deletions

View file

@ -32,7 +32,7 @@ CC = gcc
LD = ld
CFLAGS = -I.. -Wall -Wextra -g
ifeq ($(COVERAGE),)
CFLAGS += -O2 -DUSE_RAID_AES
CFLAGS += -O2
else
CFLAGS += -O0 --coverage -DCOVERAGE=1 -DNDEBUG=1
endif

View file

@ -44,17 +44,9 @@ int main(void)
if (raid_cpu_has_avx512bw())
printf("Including x86 AVX512BW\n");
if (raid_cpu_has_avx2gfni())
#ifdef USE_RAID_AES
printf("Including x86 AVX2GFNI\n");
#else
printf("Excluding x86 AVX2GFNI due polynomial mismatch\n");
#endif
if (raid_cpu_has_avx512gfni())
#ifdef USE_RAID_AES
printf("Including x86 AVX512GFNI\n");
#else
printf("Excluding x86 AVX512GFNI due polynomial mismatch\n");
#endif
#endif
#endif
@ -81,36 +73,51 @@ int main(void)
/* LCOV_EXCL_STOP */
}
printf("Test Cauchy parity generation with 1-%u data disks...\n", RAID_DATA_MAX);
printf("Test Cauchy RAID parity generation with 1-%u data disks...\n", RAID_DATA_MAX);
for (int i = 1; i <= RAID_DATA_MAX; ++i) {
if (raid_test_par(RAID_MODE_CAUCHY, i, TEST_SIZE) != 0) {
if (raid_test_par(RAID_MODE_CAUCHY_RAID, i, TEST_SIZE) != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
}
printf("Test Cauchy recovering with all combinations of %u data and 6 parity blocks...\n", TEST_COUNT);
if (raid_test_rec(RAID_MODE_CAUCHY, TEST_COUNT, TEST_SIZE) != 0) {
printf("Test Cauchy RAID recovering with all combinations of %u data and 6 parity blocks...\n", TEST_COUNT);
if (raid_test_rec(RAID_MODE_CAUCHY_RAID, TEST_COUNT, TEST_SIZE) != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
printf("Test Vandermonde parity generation with %u data disks...\n", RAID_DATA_MAX);
if (raid_test_par(RAID_MODE_VANDERMONDE, RAID_DATA_MAX, TEST_SIZE) != 0) {
printf("Test Cauchy AES parity generation with 1-%u data disks...\n", RAID_DATA_MAX);
for (int i = 1; i <= RAID_DATA_MAX; ++i) {
if (raid_test_par(RAID_MODE_CAUCHY_AES, i, TEST_SIZE) != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
}
printf("Test Cauchy AES recovering with all combinations of %u data and 6 parity blocks...\n", TEST_COUNT);
if (raid_test_rec(RAID_MODE_CAUCHY_AES, TEST_COUNT, TEST_SIZE) != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
printf("Test Vandermonde recovering with all combinations of %u data and 3 parity blocks...\n", TEST_COUNT);
if (raid_test_rec(RAID_MODE_VANDERMONDE, TEST_COUNT, TEST_SIZE) != 0) {
printf("Test Vandermonde RAID parity generation with %u data disks...\n", RAID_DATA_MAX);
if (raid_test_par(RAID_MODE_VANDERMONDE_RAID, RAID_DATA_MAX, TEST_SIZE) != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
printf("Test Vandermonde RAID recovering with all combinations of %u data and 3 parity blocks...\n", TEST_COUNT);
if (raid_test_rec(RAID_MODE_VANDERMONDE_RAID, TEST_COUNT, TEST_SIZE) != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
printf("OK\n");
return 0;
@ -121,4 +128,3 @@ bail:
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -98,7 +98,7 @@ static __always_inline int test_sub_matrix(int nr, int64_t *total)
/* setup the submatrix */
for (i = 0; i < nr; ++i)
for (j = 0; j < nr; ++j)
M[i * nr + j] = gfgen[ip[i]][id[j]];
M[i * nr + j] = raid_gfgen[ip[i]][id[j]];
/* invert */
if (raid_invert_fast(M, nr) != 0)
@ -155,7 +155,7 @@ int main(void)
{
printf("Matrix inversion test for the RAID Cauchy library\n\n");
/* required to set the gfgen table */
/* required to set the raid tables */
raid_init();
if (test_all_sub_matrix() != 0) {
@ -166,4 +166,3 @@ int main(void)
return 0;
}

View file

@ -15,15 +15,28 @@ int main(void)
raid_init();
printf("Self-test...\n");
printf("Test Cauchy RAID\n");
if (raid_selftest() != 0) {
/* LCOV_EXCL_START */
printf("FAILED!\n");
exit(EXIT_FAILURE);
goto bail;
/* LCOV_EXCL_STOP */
}
printf("OK\n\n");
raid_mode(RAID_MODE_CAUCHY_AES);
printf("Test Cauchy AES\n");
if (raid_selftest() != 0) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
printf("OK\n");
return 0;
}
bail:
/* LCOV_EXCL_START */
printf("FAILED!\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}

View file

@ -58,8 +58,8 @@ static int64_t diffgettimeofday(struct timeval *start, struct timeval *stop)
* Stop time measurement.
*/
#define SPEED_STOP \
count += delta; \
gettimeofday(&stop, 0); \
count += delta; \
gettimeofday(&stop, 0); \
} while (diffgettimeofday(&start, &stop) < period); \
ds = size * (int64_t)count * nd; \
dt = diffgettimeofday(&start, &stop);
@ -87,7 +87,7 @@ void speed_mem(int nd, void **v, int size, int delta, int period)
printf("\n");
}
void speed_gen(int nd, void **v, int size, int delta, int period, const char* msg)
void speed_gen(int nd, void **v, int size, int delta, int period, const char *msg)
{
struct timeval start;
struct timeval stop;
@ -1285,7 +1285,7 @@ void speed(void)
memset(v[nd + RAID_PARITY_MAX], 0, size);
memset(v_direct[nd + RAID_PARITY_MAX], 0, size);
raid_zero(v[nd + RAID_PARITY_MAX]);
speed_mem(nd, v, size, delta, period);
speed_gen(nd, v, size, delta, period, "");
speed_gen(nd, v_direct, size, delta, period, " (without displacement)");
@ -1316,17 +1316,9 @@ int main(void)
if (raid_cpu_has_avx512bw())
printf("Including x86 AVX512BW\n");
if (raid_cpu_has_avx2gfni())
#ifdef USE_RAID_AES
printf("Including x86 AVX2GFNI\n");
#else
printf("Including x86 AVX2GFNI (Performance reference only. Polynomial mismatch prevents use)\n");
#endif
if (raid_cpu_has_avx512gfni())
#ifdef USE_RAID_AES
printf("Including x86 AVX512GFNI\n");
#else
printf("Including x86 AVX512GFNI (Performance reference only. Polynomial mismatch prevents use)\n");
#endif
#endif
printf("\nPlease wait about 30 seconds...\n\n");
@ -1335,4 +1327,3 @@ int main(void)
return 0;
}