mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 16:47:28 +01:00
Add std/adler32 hasher.up_arm_neon
On a Raspberry Pi 4 (32-bit armv7l) with -march=native and -mfpu=neon
("native" means "armv8-a+crc+simd"):
wuffs_adler32_10k/clang9 1.21GB/s ± 0% 6.58GB/s ± 1% +442.43% (p=0.008 n=5+5)
wuffs_adler32_100k/clang9 1.20GB/s ± 0% 6.58GB/s ± 0% +449.37% (p=0.008 n=5+5)
wuffs_adler32_10k/gcc8 1.24GB/s ± 0% 4.31GB/s ± 0% +248.87% (p=0.008 n=5+5)
wuffs_adler32_100k/gcc8 1.22GB/s ± 0% 4.29GB/s ± 0% +251.09% (p=0.008 n=5+5)
mimic_adler32_10k 1.40GB/s ± 0% 1.40GB/s ± 0% -0.04% (p=0.008 n=5+5)
mimic_adler32_100k 1.35GB/s ± 0% 1.38GB/s ± 0% +2.77% (p=0.008 n=5+5)
wuffs_zlib_decode_10k/clang9 85.3MB/s ± 0% 91.1MB/s ± 0% +6.83% (p=0.008 n=5+5)
wuffs_zlib_decode_100k/clang9 107MB/s ± 0% 113MB/s ± 0% +5.20% (p=0.008 n=5+5)
wuffs_zlib_decode_10k/gcc8 86.1MB/s ± 0% 91.0MB/s ± 0% +5.69% (p=0.008 n=5+5)
wuffs_zlib_decode_100k/gcc8 104MB/s ± 0% 111MB/s ± 0% +7.08% (p=0.016 n=5+4)
mimic_zlib_decode_10k 108MB/s ± 0% 108MB/s ± 0% ~ (p=0.548 n=5+5)
mimic_zlib_decode_100k 142MB/s ± 0% 141MB/s ± 1% ~ (p=0.310 n=5+5)
wuffs_png_decode_image_19k_8bpp/clang9 69.9MB/s ± 0% 74.3MB/s ± 0% +6.37% (p=0.016 n=5+4)
wuffs_png_decode_image_40k_24bpp/clang9 99.4MB/s ± 0% 104.3MB/s ± 0% +4.92% (p=0.008 n=5+5)
wuffs_png_decode_image_77k_8bpp/clang9 266MB/s ± 0% 280MB/s ± 0% +5.21% (p=0.008 n=5+5)
wuffs_png_decode_image_552k_32bpp_ignore_checksum/clang9 165MB/s ± 0% 169MB/s ± 0% +2.45% (p=0.008 n=5+5)
wuffs_png_decode_image_552k_32bpp_verify_checksum/clang9 146MB/s ± 0% 163MB/s ± 0% +11.86% (p=0.008 n=5+5)
wuffs_png_decode_image_4002k_24bpp/clang9 93.2MB/s ± 0% 97.7MB/s ± 0% +4.78% (p=0.008 n=5+5)
wuffs_png_decode_image_19k_8bpp/gcc8 70.3MB/s ± 0% 74.3MB/s ± 0% +5.70% (p=0.008 n=5+5)
wuffs_png_decode_image_40k_24bpp/gcc8 101MB/s ± 0% 107MB/s ± 0% +5.67% (p=0.008 n=5+5)
wuffs_png_decode_image_77k_8bpp/gcc8 247MB/s ± 0% 259MB/s ± 0% +4.71% (p=0.008 n=5+5)
wuffs_png_decode_image_552k_32bpp_ignore_checksum/gcc8 162MB/s ± 0% 162MB/s ± 0% +0.09% (p=0.032 n=5+4)
wuffs_png_decode_image_552k_32bpp_verify_checksum/gcc8 140MB/s ± 0% 155MB/s ± 0% +10.67% (p=0.008 n=5+5)
wuffs_png_decode_image_4002k_24bpp/gcc8 94.1MB/s ± 0% 99.4MB/s ± 0% +5.57% (p=0.008 n=5+5)
mimic_png_decode_image_19k_8bpp 43.6MB/s ± 0% 43.3MB/s ± 1% ~ (p=0.167 n=5+5)
mimic_png_decode_image_40k_24bpp 54.6MB/s ± 0% 54.6MB/s ± 0% ~ (p=1.000 n=5+5)
mimic_png_decode_image_77k_8bpp 125MB/s ± 0% 123MB/s ± 0% -1.03% (p=0.016 n=5+4)
mimic_png_decode_image_552k_32bpp_ignore_checksum skipped
mimic_png_decode_image_552k_32bpp_verify_checksum 102MB/s ± 0% 101MB/s ± 0% -0.43% (p=0.008 n=5+5)
mimic_png_decode_image_4002k_24bpp 81.3MB/s ± 0% 81.8MB/s ± 0% +0.62% (p=0.008 n=5+5)
This commit is contained in:
1 parent
d13039d96e
commit
010b34ed38
7 files changed
+629
-50
No files matched your search
@@ -17665,6 +17665,13 @@ wuffs_adler32__hasher__up_sse42(
|
||||
wuffs_base__slice_u8 a_x);
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__ARM_NEON)
|
||||
static wuffs_base__empty_struct
|
||||
wuffs_adler32__hasher__up_arm_neon(
|
||||
wuffs_adler32__hasher* self,
|
||||
wuffs_base__slice_u8 a_x);
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__ARM_NEON)
|
||||
|
||||
// ---------------- VTables
|
||||
|
||||
const wuffs_base__hasher_u32__func_ptrs
|
||||
@@ -17776,6 +17783,9 @@ wuffs_adler32__hasher__update_u32(
|
||||
self->private_impl.f_started = true;
|
||||
self->private_impl.f_state = 1;
|
||||
self->private_impl.choosy_up = (
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__ARM_NEON)
|
||||
wuffs_base__cpu_arch__have_arm_neon() ? &wuffs_adler32__hasher__up_arm_neon :
|
||||
#endif
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
wuffs_base__cpu_arch__have_sse42() ? &wuffs_adler32__hasher__up_sse42 :
|
||||
#endif
|
||||
@@ -17951,6 +17961,110 @@ wuffs_adler32__hasher__up_sse42(
|
||||
}
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
|
||||
// -------- func adler32.hasher.up_arm_neon
|
||||
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__ARM_NEON)
|
||||
static wuffs_base__empty_struct
|
||||
wuffs_adler32__hasher__up_arm_neon(
|
||||
wuffs_adler32__hasher* self,
|
||||
wuffs_base__slice_u8 a_x) {
|
||||
uint32_t v_s1 = 0;
|
||||
uint32_t v_s2 = 0;
|
||||
wuffs_base__slice_u8 v_remaining = {0};
|
||||
wuffs_base__slice_u8 v_p = {0};
|
||||
uint8x16_t v_p__left = {0};
|
||||
uint8x16_t v_p_right = {0};
|
||||
uint8x16_t v_v1 = {0};
|
||||
uint8x16_t v_v2 = {0};
|
||||
uint8x16_t v_col0 = {0};
|
||||
uint8x16_t v_col1 = {0};
|
||||
uint8x16_t v_col2 = {0};
|
||||
uint8x16_t v_col3 = {0};
|
||||
uint8x8_t v_sum1 = {0};
|
||||
uint8x8_t v_sum2 = {0};
|
||||
uint8x8_t v_sum12 = {0};
|
||||
uint32_t v_num_iterate_bytes = 0;
|
||||
uint64_t v_tail_index = 0;
|
||||
|
||||
v_s1 = ((self->private_impl.f_state) & 0xFFFF);
|
||||
v_s2 = ((self->private_impl.f_state) >> (32 - (16)));
|
||||
while ((((uint64_t)(a_x.len)) > 0) && ((15 & ((uint32_t)(0xFFF & (uintptr_t)(a_x.ptr)))) != 0)) {
|
||||
v_s1 += ((uint32_t)(a_x.ptr[0]));
|
||||
v_s2 += v_s1;
|
||||
a_x = wuffs_base__slice_u8__subslice_i(a_x, 1);
|
||||
}
|
||||
v_s1 %= 65521;
|
||||
v_s2 %= 65521;
|
||||
while (((uint64_t)(a_x.len)) > 0) {
|
||||
v_remaining = wuffs_base__slice_u8__subslice_j(a_x, 0);
|
||||
if (((uint64_t)(a_x.len)) > 5536) {
|
||||
v_remaining = wuffs_base__slice_u8__subslice_i(a_x, 5536);
|
||||
a_x = wuffs_base__slice_u8__subslice_j(a_x, 5536);
|
||||
}
|
||||
v_num_iterate_bytes = ((uint32_t)((((uint64_t)(a_x.len)) & 4294967264)));
|
||||
v_s2 += ((uint32_t)(v_s1 * v_num_iterate_bytes));
|
||||
v_v1 = vreinterpretq_u8_u32(vdupq_n_u32(0));
|
||||
v_v2 = vreinterpretq_u8_u32(vdupq_n_u32(0));
|
||||
v_col0 = vreinterpretq_u8_u16(vdupq_n_u16(0));
|
||||
v_col1 = vreinterpretq_u8_u16(vdupq_n_u16(0));
|
||||
v_col2 = vreinterpretq_u8_u16(vdupq_n_u16(0));
|
||||
v_col3 = vreinterpretq_u8_u16(vdupq_n_u16(0));
|
||||
{
|
||||
wuffs_base__slice_u8 i_slice_p = a_x;
|
||||
v_p.ptr = i_slice_p.ptr;
|
||||
v_p.len = 32;
|
||||
uint8_t* i_end0_p = v_p.ptr + (((i_slice_p.len - (size_t)(v_p.ptr - i_slice_p.ptr)) / 32) * 32);
|
||||
while (v_p.ptr < i_end0_p) {
|
||||
v_p__left = vld1q_u8(wuffs_base__slice_u8__subslice_j(v_p, 16).ptr);
|
||||
v_p_right = vld1q_u8(wuffs_base__slice_u8__subslice_ij(v_p, 16, 32).ptr);
|
||||
v_v2 = vreinterpretq_u8_u32(vaddq_u32(vreinterpretq_u32_u8(v_v2), vreinterpretq_u32_u8(v_v1)));
|
||||
v_v1 = vreinterpretq_u8_u32(vpadalq_u16(vreinterpretq_u32_u8(v_v1), vreinterpretq_u16_u8(vreinterpretq_u8_u16(vpadalq_u8(vreinterpretq_u16_u8(vreinterpretq_u8_u16(vpaddlq_u8(v_p__left))), v_p_right)))));
|
||||
v_col0 = vreinterpretq_u8_u16(vaddw_u8(vreinterpretq_u16_u8(v_col0), vget_low_u8(v_p__left)));
|
||||
v_col1 = vreinterpretq_u8_u16(vaddw_u8(vreinterpretq_u16_u8(v_col1), vget_high_u8(v_p__left)));
|
||||
v_col2 = vreinterpretq_u8_u16(vaddw_u8(vreinterpretq_u16_u8(v_col2), vget_low_u8(v_p_right)));
|
||||
v_col3 = vreinterpretq_u8_u16(vaddw_u8(vreinterpretq_u16_u8(v_col3), vget_high_u8(v_p_right)));
|
||||
v_p.ptr += 32;
|
||||
}
|
||||
v_p.len = 0;
|
||||
}
|
||||
v_v2 = vreinterpretq_u8_u32(vshlq_n_u32(vreinterpretq_u32_u8(v_v2), 5));
|
||||
v_v2 = vreinterpretq_u8_u32(vmlal_u16(vreinterpretq_u32_u8(v_v2), vreinterpret_u16_u8(vreinterpret_u8_u16(vget_low_u16(vreinterpretq_u16_u8(v_col0)))), vreinterpret_u16_u8(vreinterpret_u8_u16((uint16x4_t){32, 31, 30, 29}))));
|
||||
v_v2 = vreinterpretq_u8_u32(vmlal_u16(vreinterpretq_u32_u8(v_v2), vreinterpret_u16_u8(vreinterpret_u8_u16(vget_high_u16(vreinterpretq_u16_u8(v_col0)))), vreinterpret_u16_u8(vreinterpret_u8_u16((uint16x4_t){28, 27, 26, 25}))));
|
||||
v_v2 = vreinterpretq_u8_u32(vmlal_u16(vreinterpretq_u32_u8(v_v2), vreinterpret_u16_u8(vreinterpret_u8_u16(vget_low_u16(vreinterpretq_u16_u8(v_col1)))), vreinterpret_u16_u8(vreinterpret_u8_u16((uint16x4_t){24, 23, 22, 21}))));
|
||||
v_v2 = vreinterpretq_u8_u32(vmlal_u16(vreinterpretq_u32_u8(v_v2), vreinterpret_u16_u8(vreinterpret_u8_u16(vget_high_u16(vreinterpretq_u16_u8(v_col1)))), vreinterpret_u16_u8(vreinterpret_u8_u16((uint16x4_t){20, 19, 18, 17}))));
|
||||
v_v2 = vreinterpretq_u8_u32(vmlal_u16(vreinterpretq_u32_u8(v_v2), vreinterpret_u16_u8(vreinterpret_u8_u16(vget_low_u16(vreinterpretq_u16_u8(v_col2)))), vreinterpret_u16_u8(vreinterpret_u8_u16((uint16x4_t){16, 15, 14, 13}))));
|
||||
v_v2 = vreinterpretq_u8_u32(vmlal_u16(vreinterpretq_u32_u8(v_v2), vreinterpret_u16_u8(vreinterpret_u8_u16(vget_high_u16(vreinterpretq_u16_u8(v_col2)))), vreinterpret_u16_u8(vreinterpret_u8_u16((uint16x4_t){12, 11, 10, 9}))));
|
||||
v_v2 = vreinterpretq_u8_u32(vmlal_u16(vreinterpretq_u32_u8(v_v2), vreinterpret_u16_u8(vreinterpret_u8_u16(vget_low_u16(vreinterpretq_u16_u8(v_col3)))), vreinterpret_u16_u8(vreinterpret_u8_u16((uint16x4_t){8, 7, 6, 5}))));
|
||||
v_v2 = vreinterpretq_u8_u32(vmlal_u16(vreinterpretq_u32_u8(v_v2), vreinterpret_u16_u8(vreinterpret_u8_u16(vget_high_u16(vreinterpretq_u16_u8(v_col3)))), vreinterpret_u16_u8(vreinterpret_u8_u16((uint16x4_t){4, 3, 2, 1}))));
|
||||
v_sum1 = vreinterpret_u8_u32(vpadd_u32(vreinterpret_u32_u8(vreinterpret_u8_u32(vget_low_u32(vreinterpretq_u32_u8(v_v1)))), vreinterpret_u32_u8(vreinterpret_u8_u32(vget_high_u32(vreinterpretq_u32_u8(v_v1))))));
|
||||
v_sum2 = vreinterpret_u8_u32(vpadd_u32(vreinterpret_u32_u8(vreinterpret_u8_u32(vget_low_u32(vreinterpretq_u32_u8(v_v2)))), vreinterpret_u32_u8(vreinterpret_u8_u32(vget_high_u32(vreinterpretq_u32_u8(v_v2))))));
|
||||
v_sum12 = vreinterpret_u8_u32(vpadd_u32(vreinterpret_u32_u8(v_sum1), vreinterpret_u32_u8(v_sum2)));
|
||||
v_s1 += vget_lane_u32(vreinterpret_u32_u8(v_sum12), 0);
|
||||
v_s2 += vget_lane_u32(vreinterpret_u32_u8(v_sum12), 1);
|
||||
v_tail_index = (((uint64_t)(a_x.len)) & 18446744073709551584u);
|
||||
if (v_tail_index < ((uint64_t)(a_x.len))) {
|
||||
{
|
||||
wuffs_base__slice_u8 i_slice_p = wuffs_base__slice_u8__subslice_i(a_x, v_tail_index);
|
||||
v_p.ptr = i_slice_p.ptr;
|
||||
v_p.len = 1;
|
||||
uint8_t* i_end0_p = i_slice_p.ptr + i_slice_p.len;
|
||||
while (v_p.ptr < i_end0_p) {
|
||||
v_s1 += ((uint32_t)(v_p.ptr[0]));
|
||||
v_s2 += v_s1;
|
||||
v_p.ptr += 1;
|
||||
}
|
||||
v_p.len = 0;
|
||||
}
|
||||
}
|
||||
v_s1 %= 65521;
|
||||
v_s2 %= 65521;
|
||||
a_x = v_remaining;
|
||||
}
|
||||
self->private_impl.f_state = (((v_s2 & 65535) << 16) | (v_s1 & 65535));
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__ARM_NEON)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ADLER32)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BMP)
|
||||
|
||||
Reference in new issue
Block a user