Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up AC3 demodulator #805

Merged
merged 3 commits into from Oct 16, 2022
Merged

Conversation

atsampson
Copy link
Collaborator

CC @LeightonSmallshire.

These changes to Demodulator make the program as a whole about five times faster with -O3 -march=native - here's the time taken for the original and the three commits on a 10s sample:
Figure_1

The bottleneck now is reading the contents of the buffer for each output bit - since the buffer's only 3 words there's not much that can be done to improve this within this code, but you could get around it by reworking Reclocker to accept multiple input bits at once...

By default, reading from cin forces cout to be flushed first (in case
you've printed a prompt to cout that needs to be visible). Since these
programs both read a lot of data from cin one character at a time, they
were spending significant amounts of time flushing cout.
This works the same way as the existing version, but it reworks the
buffer code to avoid using % on the indexes in the loop. This means that
GCC can use vector instructions, and schedule the unrolled outer loop a
bit more effectively.

I've also replaced 320 etc. with the derivations of the constants.
This means the comparison can be done with an XOR and popcount, which is
quite a bit faster.

Since ld-decode is currently C++17, we can't use std::popcount yet; use
the GCC/Clang intrinsic if available, otherwise use a from-scratch
implementation (based on the version GCC's optimiser recognises -- it's
the HAKMEM-inspired algorithm from p69 of "Hacker's Delight").
@happycube happycube merged commit 589811c into happycube:ac3-test1 Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants