More optimized CRC implementations
authorJussi Kivilinna <jussi.kivilinna@iki.fi>
Sat, 2 May 2015 21:34:34 +0000 (00:34 +0300)
committerJussi Kivilinna <jussi.kivilinna@iki.fi>
Sat, 2 May 2015 21:34:34 +0000 (00:34 +0300)
commit06e122baa3321483a47bbf82fd2a4540becfa0c9
treeca6b74c0a96bcf48b7f7b0e1e44cc21af80d6965
parent66129b3334a5aa54ff8a97981507e4704f759571
More optimized CRC implementations

* cipher/crc.c (crc32_table, crc24_table): Replace with new table
contents.
(update_crc32, CRC24_INIT, CRC24_POLY): Remove.
(crc32_next, crc32_next4, crc24_init, crc24_next, crc24_next4)
(crc24_final): New.
(crc24rfc2440_init): Use crc24_init.
(crc32_write): Rewrite to use crc32_next & crc32_next4.
(crc24_write): Rewrite to use crc24_next & crc24_next4.
(crc32_final, crc32rfc1510_final): Use buf_put_be32.
(crc24rfc2440_final): Use crc24_final & buf_put_le32.
* tests/basic.c (check_digests): Add CRC "123456789" tests.
--

Patch adds more optimized CRC implementations generated with universal_crc
tool by Danjel McGougan: http://www.mcgougan.se/universal_crc/

Benchmark on Intel Haswell (no-turbo, 3200 Mhz):

Before:
 CRC32          |      2.52 ns/B     378.3 MiB/s      8.07 c/B
 CRC32RFC1510   |      2.52 ns/B     378.1 MiB/s      8.07 c/B
 CRC24RFC2440   |     46.62 ns/B     20.46 MiB/s     149.2 c/B

After:
 CRC32          |     0.918 ns/B    1039.3 MiB/s      2.94 c/B
 CRC32RFC1510   |     0.918 ns/B    1039.0 MiB/s      2.94 c/B
 CRC24RFC2440   |     0.918 ns/B    1039.4 MiB/s      2.94 c/B

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
cipher/crc.c
tests/basic.c