Secrets to writing fast DSP (VST) code?

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Also, have a look at the block processing code above by Urs.
Not that I have tried it in any audio processing algorithm, but similar things are very effective in general for about almost everything.
For example, if you have a stream of bytes in memory, about which a checksum needs to be calculated, summing them byte by byte is comparably slow while you could sum 64 bit integers and add remaining a few bytes later.
~stratum~

Post

Things that have sped things up for me.

Low-level stuff:
-Vectorized code (SSE2/SSE3/AVX) taking advantage of fine-grain SIMD parallelism.
-Aligned heap memory (write your own memory allocator) so that all blocks are either 16 or 32 byte aligned in memory. This will prevent the cache from thrashing and will make memory load/write SIMD operations aligned.
-Write assembly if your bottle-neck is compute-bound and you think you have a clever way of reusing registers that the compiler fails to do (often algorithm dependent).
-Pre-allocate all your heap memory; don't want audio-thread waiting for OS to allocate memory (terrible overhead) while doing any processing

High-level
-Learn fast algorithms. Get familiar with FFT based convolution variants if you're working with FIRs.
-Mult-threading / OpenMP for coarser-grain parallelism if what you're computing can't be done in real-time.
-Learn maths. Often, many complex problems reduce to simple mathematical formulations or at least good approximations if you work them out.

Cheap-stuff
-Fast intel compiler, fast assembly optimized FFT library (e.g. FFTW/MKL)

Post Reply

Return to “DSP and Plugin Development”