Add portable 128-bit vector parity routines for gen1/gen2/genz to optimize non-x86 CPUs

This commit is contained in:
Andrea Mazzoleni 2026-06-04 17:53:25 +02:00
parent d03a583523
commit b78542685f
10 changed files with 336 additions and 6 deletions

View file

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

View file

@ -30,6 +30,9 @@ int main(void)
raid_init();
#ifdef CONFIG_VEC128
printf("Including 128-bit vectors\n");
#endif
#ifdef CONFIG_X86
if (raid_cpu_has_sse2())
printf("Including x86 SSE2\n");

View file

@ -125,6 +125,9 @@ void speed(void)
printf("%8s", "int8");
printf("%8s", "int32");
printf("%8s", "int64");
#if CONFIG_VEC128
printf("%8s", "vec128");
#endif
#ifdef CONFIG_X86
if (raid_cpu_has_sse2()) {
printf("%8s", "sse2");
@ -179,6 +182,15 @@ void speed(void)
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#if CONFIG_VEC128
SPEED_START {
raid_gen1_vec128(nd, size, v);
} SPEED_STOP
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#endif
#ifdef CONFIG_X86
if (raid_cpu_has_sse2()) {
SPEED_START {
@ -242,6 +254,15 @@ void speed(void)
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#if CONFIG_VEC128
SPEED_START {
raid_gen2_vec128(nd, size, v);
} SPEED_STOP
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#endif
#ifdef CONFIG_X86
if (raid_cpu_has_sse2()) {
SPEED_START {
@ -327,6 +348,15 @@ void speed(void)
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#if CONFIG_VEC128
SPEED_START {
raid_genz_vec128(nd, size, v);
} SPEED_STOP
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#endif
#ifdef CONFIG_X86
if (raid_cpu_has_sse2()) {
SPEED_START {
@ -380,6 +410,9 @@ void speed(void)
printf("%8s", "");
printf("%8s", "");
#if CONFIG_VEC128
printf("%8s", "");
#endif
#ifdef CONFIG_X86
if (raid_cpu_has_sse2()) {
@ -458,6 +491,9 @@ void speed(void)
printf("%8s", "");
printf("%8s", "");
#if CONFIG_VEC128
printf("%8s", "");
#endif
#ifdef CONFIG_X86
if (raid_cpu_has_sse2()) {
@ -536,6 +572,9 @@ void speed(void)
printf("%8s", "");
printf("%8s", "");
#if CONFIG_VEC128
printf("%8s", "");
#endif
#ifdef CONFIG_X86
if (raid_cpu_has_sse2()) {
@ -614,6 +653,9 @@ void speed(void)
printf("%8s", "");
printf("%8s", "");
#if CONFIG_VEC128
printf("%8s", "");
#endif
#ifdef CONFIG_X86
if (raid_cpu_has_sse2()) {
@ -705,7 +747,11 @@ void speed(void)
fflush(stdout);
SPEED_START {
#if CONFIG_VEC128
raid_gen_force(1, raid_gen1_vec128);
#else
raid_gen_force(1, sizeof(void *) == 8 ? raid_gen1_int64 : raid_gen1_int32);
#endif
/* +1 to avoid GEN1 optimized case */
raid_rec1_int8(1, id, ip + 1, nd, size, v);
} SPEED_STOP
@ -774,7 +820,11 @@ void speed(void)
fflush(stdout);
SPEED_START {
#if CONFIG_VEC128
raid_gen_force(2, raid_gen2_vec128);
#else
raid_gen_force(2, sizeof(void *) == 8 ? raid_gen2_int64 : raid_gen2_int32);
#endif
/* +1 to avoid GEN2 optimized case */
raid_rec2_int8(2, id, ip + 1, nd, size, v);
} SPEED_STOP
@ -1133,6 +1183,9 @@ int main(void)
raid_init();
#ifdef CONFIG_VEC128
printf("Including 128-bit vectors\n");
#endif
#ifdef CONFIG_X86
if (raid_cpu_has_sse2())
printf("Including x86 SSE2\n");