Threading Garauntee


#1

I am working on a little proof of concept stem mixing daw. Each stem there’s a heavy amount of processing.

Is there a way to look at how many threads are available (this is easy enough) then spawn up a worker per thread and have the workers guaranteed to be on different threads. I was thinking about using future for this but realised I wanted the threads to persist (new threads in a loop aint a great idea).


#2

SystemStats::getNumCpus() and Thread::setAffinityMask
It’s non-trivial to manage this though, gets pretty hairy.


#3

I should imagine. My other option is CUDA which I’m also messing around with. CUDA seems to be fast enough in transfer now to be useful in an audio loop.

But with AMD pushing higher Ryzen core count and thus forcing Intel to up their game. I feel like it’s time to consider these kinds of architecture. My problem has always bin waking threads correctly without using the sleep in a loop


#4

Sleep in a loop? Why not use wait() and then notify() to get it going again?


#5

I do now :wink: - I said “My problem has always bin waking threads correctly without using the sleep in a loop” past tense.