How is multicore handled in hise?
-
I've seen a couple of nodes (convolution reverb e.g.) having a button to enable multithreading, which greatly improves performance.
how are the synth voices handled? is there a way to spread them across cores? or any heavy lifting in general?
-
@Morphoice
I'm also very interested in SIMD in hise.
The tricky thing about parallel processing as I understand it is that it's pretty custom depending on what you are making because you have to program everything to work in batches and because presumably if you made one thing SIMD, then you couldn't another. For example what happens if the synth voices are sent to each core, but each synth voice has its own convolver which is also multi threaded? Weird situation which im guessing would either not work at all, or would decrease performance. I think that hise is set up with XSIMD, and possibly even Chow's utility wrappers for it.... but I think it's only included because RTNeural uses it to parallel process the AI models.
It's on my list of things to investigate. I'd like to tap into XSIMD for my custom nodes, even for simple stuff such as volume envelopes and LFO application.Quite a while ago Christoph made a comment about SIMD to me on here, he said something to the effect that modern compilers do such a good job of optimizing nowadays that it's not really necessary. However he also highlighted that it does give you up to a 30% CPU efficiency boost using SIMD in some circumstances, and that kind of difference matters to me a lot.
Just commenting to bump the discussion, I'd like to hear more about the SIMD in hise in general.
-
@Morphoice @griffinboy I think this is one of those things where you just let the compiler do its thing, and don't worry about it. You'll get the best performance by using HISE (and therefore JUCE) as intended.
-
@clevername27 In HISE we trust! :)
-
Two different topics:
- Multithreading does only make sense if you can defer some processing so that it doesn't have to be calculated immediately (like the tail of impulse responses or fetching & interpolating samples from disk). This excludes most audio calculations which must happen within the audio callback. There are a few synths which go out of their way to enable multithreaded processing for voices (I think Diva is one of them), but usually a single plugin should never exceed the capacity of a single core for its audio calculations.
- SIMD on an architectural level (calculating multiple voices with a single vector instruction requires a very narrow architecture of the voice handling & modulation and will not work with a generic solution like HISE. And even then the performance benefit is not worth the programming overhead. If you have a custom narrowly scoped algorithm (eg. a special filter), then rewriting this with SIMD instructions might be a good thing, but even then you won't XIMD for it, but can just use SSE / Neon directly or use the JUCE wrappers.
-
Thanks, I see my confusion:
multithreading and SIMD are different things.Thanks for your thoughts, I'm very noob when it comes to this area, all I know is that I see a lot of people talking about SIMD for pretty much every dsp algorithm, from what I've seen, it seemed like good practice. I'll look into the SEE and NEON as well as the juce simd wrappers, thanks for the suggestion.
-
all I know is that I see a lot of people talking about SIMD for pretty much every dsp algorithm
That's because it sounds tempting to just change the instructions of your code and get a 4x speedup, but in most cases you need to rethink the entire algorithm to allow multiple data points to be processed. Eg. with a simple filter algorithm you somehow have to make sure that you rewrite the recursive structure of IIRs (take the last two samples and multiply them with some coefficients) to something else so that it can process 4 samples at once.
I'm very noob when it comes to this area,
I would recommend not focussing on that then but get your algos right, sound good and be reasonably performant. In step 2 you then can learn how to profile hotspots and in step 3 you can try out if using SIMD will yield measurable benefits that you can verify with step 2.
-
@Christoph-Hart thanks for clarifying! that helps! And yes, Urs did it on Diva, it's about one of the only projects I know of that did it well and right.