mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-29 19:37:06 -05:00
Add portable 128-bit vector parity routines for gen1/gen2/genz to optimize non-x86 CPUs
This commit is contained in:
parent
d03a583523
commit
b78542685f
10 changed files with 336 additions and 6 deletions
|
|
@ -65,16 +65,30 @@
|
|||
#define __noreturn __attribute__((noreturn))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Enable C-based SIMD-accelerated vector optimizations on:
|
||||
* - x86/x64 (SSE2)
|
||||
* - ARM (NEON)
|
||||
* - RISC-V (Vector Extension)
|
||||
*/
|
||||
#if defined(__SSE2__) || defined(__ARM_NEON) || defined(__riscv_vector)
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(__vector_size__)
|
||||
#define CONFIG_VEC128 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Architecture for inline assembly.
|
||||
* Enable Assembly-based SIMD-accelerated vector optimizations on:
|
||||
* - x86_32 (32 bit)
|
||||
* - x86_64 (64 bit)
|
||||
*/
|
||||
#if HAVE_ASSEMBLY
|
||||
#if defined(__i386__)
|
||||
#define CONFIG_X86 1
|
||||
#define CONFIG_X86_32 1
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__)
|
||||
#define CONFIG_X86 1
|
||||
#define CONFIG_X86_64 1
|
||||
|
|
|
|||
|
|
@ -157,6 +157,11 @@ void speed(int period, int nd, int size)
|
|||
#else
|
||||
printf("128-bit integers are not supported\n");
|
||||
#endif
|
||||
#if CONFIG_VEC128
|
||||
printf("128-bit vectors are supported\n");
|
||||
#else
|
||||
printf("128-bit vectors are not supported\n");
|
||||
#endif
|
||||
|
||||
#if HAVE_FUTIMENS
|
||||
printf("Support nanosecond timestamps with futimens()\n");
|
||||
|
|
@ -274,6 +279,9 @@ void speed(int period, int nd, int size)
|
|||
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");
|
||||
|
|
@ -325,6 +333,15 @@ void speed(int period, int nd, int size)
|
|||
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 {
|
||||
|
|
@ -388,6 +405,15 @@ void speed(int period, int nd, int size)
|
|||
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 {
|
||||
|
|
@ -473,6 +499,15 @@ void speed(int period, int nd, int size)
|
|||
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 {
|
||||
|
|
@ -525,6 +560,9 @@ void speed(int period, int nd, int size)
|
|||
|
||||
printf("%8s", "");
|
||||
printf("%8s", "");
|
||||
#if CONFIG_VEC128
|
||||
printf("%8s", "");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_X86
|
||||
if (raid_cpu_has_sse2()) {
|
||||
|
|
@ -605,6 +643,9 @@ void speed(int period, int nd, int size)
|
|||
|
||||
printf("%8s", "");
|
||||
printf("%8s", "");
|
||||
#if CONFIG_VEC128
|
||||
printf("%8s", "");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_X86
|
||||
if (raid_cpu_has_sse2()) {
|
||||
|
|
@ -685,6 +726,9 @@ void speed(int period, int nd, int size)
|
|||
|
||||
printf("%8s", "");
|
||||
printf("%8s", "");
|
||||
#if CONFIG_VEC128
|
||||
printf("%8s", "");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_X86
|
||||
if (raid_cpu_has_sse2()) {
|
||||
|
|
@ -764,6 +808,9 @@ void speed(int period, int nd, int size)
|
|||
|
||||
printf("%8s", "");
|
||||
printf("%8s", "");
|
||||
#if CONFIG_VEC128
|
||||
printf("%8s", "");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_X86
|
||||
if (raid_cpu_has_sse2()) {
|
||||
|
|
@ -857,7 +904,11 @@ void speed(int period, int nd, int size)
|
|||
|
||||
SPEED_START {
|
||||
/* ensure to use same hardware in the delta step */
|
||||
#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
|
||||
|
|
@ -932,7 +983,11 @@ void speed(int period, int nd, int size)
|
|||
|
||||
SPEED_START {
|
||||
/* ensure to use same hardware in the delta step */
|
||||
#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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue