Submarine technical articles

I’ve added another document to the technical articles I’m writing on my wiki.

This one is about why I modified the SSE fast sine approximation, in order to squeeze a tiny bit more out of it.

<TL;DR> Rather than a general purpose sine function which takes an input in radians and returns a value in the range ±1. By modifying the coefficients in the approximation, I get a function which takes an input in cycles and returns a value in the range ±5. Which saves me two multiplications.

9 Likes

I enjoying these articles. Keep them coming David!

How does the approximation compare with std::sin for performance, how much faster is it?

I’m finding it difficult to profile, because it all ends up being inlined.

For the PO-204 module as a whole I got a 2 times improvement by replacing the 4 x looped processing with the SSE code, but that covers a lot of ground.


Actually the profiling I have just managed, suggests that the SSE approximation can calculate 4 sine values in half the time it takes for a single call to std::sin

1 Like

I know @Vortico has been looking for someone to donate a fast sin to the common code, so… btw, when I looked at the AS mixers to see why they were so slow, they do a sin and cos on every pan control, every sample. Made it almost 7X faster just using a lookup table.

Just to be clear. My optimisations are just tiny tweaks to code that is already included in the VCVRack api. If you need to do 3 or more sine or cosine calculations at a time, these SSE functions are in the include/simd directory.

My optimisations were to make those functions just that tiny bit more applicable to my use-case.

The big jump in performance that I reported above is not my work.

1 Like

Ah, thanks. I haven’t been keeping up. I get it now.