justin = { main feed , music , code , askjf , pubkey };
Ask Justin Frankel
No reasonable question unanswered since 2009!

Suggested topics: programming, music, sleep, coffee, etc.

Note: please do not ask questions about REAPER features, bugs or scheduling, use the forums instead.


Name: Ask: Human (enter yes):
[back to index] | [unreplied] | [replied] | [recent comments] | [all]

Question: Second daw question: what's the 10 feet high level view of multithreading? I assume roughly when you get called by the call back you have a pool of threads you ask to process a DAG starting from the leaves without dependencies and going up? Let me bluntly know as soon as the questions become annoying and I'll stop :p
Asked by eubn (79.40.196.x) on December 11 2019, 11:17pm
Reply on December 12 2019, 4:53am:
    Maybe twitter would be better to avoid flooding this thing? or do it in the comments to this question? What is DAG? A good first place to look at threads is on getting data from disk. This can almost always (and should almost always) be done from a worker thread at a lower priority...


Comments:
  • Posted by eubn (79.40.196.x) on December 12 2019, 6:28am:
    Sure! If the comments here work for you, they're fine for me. I'll also maybe ask some question on the cockos forum, lots of smart people there. A DAG is a directed acyclic graph. What I assume happens is this: you have the audio thread plus a pool of N-1 threads where N is the amount of native threads always. Then you order all the the tracks in the order they must be processed, Concrete example might be easier: first we have to completely work on tracks A, B and C which go into folder D. (1/?)

  • Posted by eubn (79.40.196.x) on December 12 2019, 6:31am:
    Folder D and track E go into the master channel. The audio thread asks three threads from the pool to work on A, B and C. It spinlocks until they're all computed, then it asks a thread from the pool to do the mixing into D and a thread from the pool to do the work for track E. It spinlocks until both are done, and then does the mixing of D and E and the processing for the master track. Am I completely off track or is this roughly it?

  • Posted by eubn (79.40.196.x) on December 12 2019, 6:33am:
    And also again I don't want to be too much of a bother; if you feel like you're becoming like an unpaid university professor just tell me to heck off :p

  • Posted by Justin on December 12 2019, 1:09pm:
    The thing is, you might have more tracks than threads, so really you want to have a work queue, and have each thread pull a track from the queue and process it and then ask for more. Also the main audio thread should be one of those workers, too, you don't want it spinning when it could be doing legit work! Anyway once there's no more work to be done, and all of the worker threads have completed, you can combine the results. But that's just for parallelizing track FX processing

  • Posted by Justin on December 12 2019, 1:10pm:
    ...and that's just for processing that has to be done in realtime (input monitoring, or whatever). If any of those tracks aren't input monitoring, you could actually render them a few blocks ahead asynchronously, then when the time comes to render the audio block, they wouldn't really have to be processed, the block would already be done

  • Posted by eubn (151.46.138.x) on December 12 2019, 5:48pm:
    Crystal clear! Thanks.


Comment:
    Your Name:   -- Site Owner's Name:  (for human-verification)

    Comment:    

    
  
[back to index] | [unreplied] | [replied] | [recent comments] | [all]
Copyright 2024 Justin Frankel. | RSS