stbrumme / crc32 Goto Github PK
View Code? Open in Web Editor NEWFast CRC32
Home Page: https://create.stephan-brumme.com/crc32/
License: zlib License
Fast CRC32
Home Page: https://create.stephan-brumme.com/crc32/
License: zlib License
We want to pass along that the Makefile doesn't currently use the FLAGS, so that the out-of-the-box compiling doesn't invoke -O3 (or any optimization). Turning that on sped up the 16-way code by a factor of 4 and got us up to the speed on your web page.
Thanks for making this code available! It works nicely and was easy to read.
In Crc32.h there is
CRC32_USE_LOOKUP_TABLE_SLICING_BY_8
is defined twice and CRC32_USE_LOOKUP_TABLE_SLICING_BY_4
is not defined at all. Changing it allows to actually have slicing-by-4 algorithm in test.
Crc32.h.diff:
12c12
< #define CRC32_USE_LOOKUP_TABLE_SLICING_BY_8
---
> #define CRC32_USE_LOOKUP_TABLE_SLICING_BY_4
The __BYTE_ORDER and __BIG_ENDIAN macros are not defined at MAC OS
X CODE Version 11.2.1 (11B500)
all hash functions except of 1byte-version uses big_endian by default - it is a reason of wrong hashes
Raspberry Pi OS "bookworm" on Raspberry Pi 2 B+ (32 bit)
xx@raspberrypi:~/crc32 $ cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5
Hardware : BCM2835
Revision : a01041
Model : Raspberry Pi 2 Model B Rev 1.1
xx@raspberrypi:~/crc32 $ make
g++ -O3 -Wall -Wextra -pedantic -s -c Crc32.cpp -o Crc32.o
g++ -O3 -Wall -Wextra -pedantic -s -c Crc32Test.cpp -o Crc32Test.o
g++ Crc32.o Crc32Test.o -O3 -Wall -Wextra -pedantic -s -lrt -o Crc32Test
xx@raspberrypi:~/crc32 $ ./Crc32Test
Please wait ...
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted
xx@raspberrypi:~/crc32 $ gdb Crc32Test
GNU gdb (Raspbian 13.1-3) 13.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from Crc32Test...
(No debugging symbols found in Crc32Test)
(gdb) run
Starting program: /home/jb/crc32/Crc32Test
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
Please wait ...
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=1996292672, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44 pthread_kill.c: No such file or directory.
(gdb) where
#0 __pthread_kill_implementation (threadid=1996292672, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1 0x76c93a7c in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2 0x76c4bcfc in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x76c350a0 in __GI_abort () at abort.c:79
#4 0x76e534b0 in __gnu_cxx::__verbose_terminate_handler() () from /lib/arm-linux-gnueabihf/libstdc++.so.6
#5 0x76e50fec in ?? () from /lib/arm-linux-gnueabihf/libstdc++.so.6
#6 0x76e51078 in std::terminate() () from /lib/arm-linux-gnueabihf/libstdc++.so.6
#7 0x76e513d0 in __cxa_throw () from /lib/arm-linux-gnueabihf/libstdc++.so.6
#8 0x76e51a68 in operator new(unsigned int) () from /lib/arm-linux-gnueabihf/libstdc++.so.6
#9 0x0001052c in ?? ()
#10 0x76c353c0 in __libc_start_call_main (main=0x76c353c0 <__libc_start_call_main+140>, main@entry=0x10510, argc=1993887744, argc@entry=1, argv=0x10510,
argv@entry=0x7efff544) at ../sysdeps/nptl/libc_start_call_main.h:58
#11 0x76c354c8 in __libc_start_main_impl (main=0x10510, argc=1, argv=0x7efff544, init=<optimized out>, fini=0x0, rtld_fini=0x76fdb310 <_dl_fini>, stack_end=0x7efff544)
at libc-start.c:360
#12 0x00010b64 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.