-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
| Bugzilla Link | 35567 |
| Version | 7.0 |
| OS | Linux |
| Attachments | Adler32 C implementation |
| CC | @adibiagio,@topperc,@RKSimon,@rotateright |
Extended Description
adler32-standalone.c (attached, also at https://github.com/google/wuffs/blob/master/script/adler32-standalone.c) is some straight C code to calculate the standard Adler32 hash, used by the zlib format.
Measuring throughput on a recent Debian Testing system (clang 5.0 and gcc 7.2), Intel x86_64 Broadwell, suggests that clang's generated code is 1.3x slower.
$ clang-5.0 -O3 adler32-standalone.c; ./a.out
2311 MiB/s, clang 5.0.0 (tags/RELEASE_500/rc2)
$ gcc -O3 adler32-standalone.c; ./a.out
3052 MiB/s, gcc 7.2.1 20171025
The core loop (manually unrolled 8 times) is:
while (p < end0) {
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
s1 += ((uint32_t)(*p));
s2 += s1;
p++;
}