I’m just starting out with SIMD by writing some AVX code. The module will eventually be a Multi Stage Envelope Generator. I started by writing sample based reference code, which I then tried to translate to AVX.
I managed to code a very basic translation, but struggled to get my head around the branching:
In my sample based code, I check after every sample if the current segment in the MSEG is finished, and move on to the next one then. In the AVX code, I process eight samples simultaneously… so no branching?
So far I just ignore it and check for the segment change after the AVX block is finished, which leads to innacurate results of course.
One option I can think of is to check whether the next eight samples will fit inside the current segment and then use either AVX or sample based code to suit the situation. This seems overly complicated?
To top it all off, I did some profiling and the AVX code seems to give around a 20-40% performance gain, so maybe it’s not worth the hassle after all? That being said it is the first SIMD code I write, which might leave much more to be optimized.