Maybe this helps someone to start writing cross platform SSE optimization without messing up the code too much, keep it maintainable and avoiding big additional libraries.
This class can help to calculate two double values parallel (for example a stereo signal). The same is also possible with four floats. It seems to work on Windows and OSX.
// store stereo input values in SSE register
vec2 a(*sampleL, *sampleR);
// define a constant value to multiply
vec2 b(0.5);
// calculate things like it would be mono (you need to make a lot more operations; otherwise this makes no sense)
vec2 result = a * b / a;
// store values from SSE registers back to local doubles
double rL; double rR;
_mm_store1_pd(&rL, result.v);
_mm_storeh_pd(&rR, result.v);
// write the stereo values to the output
*sampleL = rL;
*sampleR = rR;
It's possible to read and store values directly from an array, but you have to make sure that the array is aligned to 16 bit or you can use special SSE commands that are able to load and store unaligned values.
I've started some time ago a simd wrapper library, and will continue development in the next months (now i'm a bit busy with other project).
It's basically a convenient wrapper "math" abstraction that works on buffers of data (int/float/double) and should autodetect the running CPU features and take up the most convenient and faster implementation possible (it's possible to also force a particular usage of a simd instruction set). The project will implement all commons buffer operations (copy, add, mult, swap) and some specific operations suited for audio (peak rms, min max, feedback check, basic filtering, pan laws, dry wet mixing, power spectrum, and so on) and for image manipulation.
https://github.com/kunitoki/waterspout
Maybe other people also are interested in joining...
Btw, any ideas on how we could make this a better is appreciated :)
Thanks a lot Kraken, your library seems very interesting.
FYI, here are a few other libraries similar to yours that you might want to have a look at too.
Vc: Vector Classes (LGPL) http://code.compeng.uni-frankfurt.de/projects/vc
Seems quite mature and in active development
Nova SIMD (GPL) https://github.com/timblechmann/nova-simd
Looks very good but GPL unfortunately
Metascale NT2 / Boost.simd (boost license) https://github.com/MetaScale/nt2
Looks very promising, covers many domains, is actively developped and will probably be included in a next revision of boost
Talk about resurecting an old thread. But I loved this idea, and I’m adding my own spice to it. Maybe will release as a free JUCE Module. How should I credit the original author?
Here’s what I have done so far to test a few things out.