std/crc64: use slicing-by-M algorithm

name                           old speed     new speed      delta

wuffs_crc64_ecma_10k/clang11   485MB/s ± 0%  1774MB/s ± 0%  +265.68%  (p=0.008 n=5+5)
wuffs_crc64_ecma_100k/clang11  485MB/s ± 0%  1777MB/s ± 0%  +266.41%  (p=0.008 n=5+5)

wuffs_crc64_ecma_10k/gcc10     478MB/s ± 0%  1858MB/s ± 0%  +288.52%  (p=0.016 n=4+5)
wuffs_crc64_ecma_100k/gcc10    480MB/s ± 1%  1857MB/s ± 0%  +287.21%  (p=0.008 n=5+5)
This commit is contained in:
Nigel Tao committed 2023-10-15 00:08:56 +11:00
1 parent b2ab3ba008
commit 920ac3e5c5
4 files changed
+741 -7

No files matched your search

+1 -1
View File
@@ -44,7 +44,7 @@ func main1() error {
// the slicing-by-M algorithm. We use an M of 16.
for i := 0; i < 256; i++ {
crc := tables[0][i]
for j := 1; j < 16; j++ {
for j := 1; j < len(tables); j++ {
crc = tables[0][crc&0xFF] ^ (crc >> 8)
tables[j][i] = crc
}
+10 -1
View File
@@ -37,9 +37,18 @@ func main() {
func main1() error {
flag.Parse()
tables := [1]crc64.Table{}
tables := [8]crc64.Table{}
tables[0] = *crc64.MakeTable(crc64.ECMA)
// Use the same slicing-by-M algorithm as for std/crc32, with M = 8.
for i := 0; i < 256; i++ {
crc := tables[0][i]
for j := 1; j < len(tables); j++ {
crc = tables[0][crc&0xFF] ^ (crc >> 8)
tables[j][i] = crc
}
}
for i, t := range tables {
if *reverse {
reverseTable(&t)