Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Multiple pre-emptive thread pools in TBB

stephen_d_
Beginner
510 Views

I have a requirement to create a number of real time processing chains one running at n Hz and others running at x, y and z Hz in a single process. Where x, y and z are some multiple (not necessarily a simple multiple) of n. For example one chain running at 1Hz and others running at 3Hz and 4Hz. Each processing chain needs to make use of TBB to parallelize some of their computations etc. and so needs to have a pool of TBB worker threads that match the number of hardware processors, but the higher frequency chains need to pre-empt the lower frequency chains in order for the system to work. How can this be achieved using TBB?

It seems from the documentation that it is not possible to create competing pools of TBB workers that will pre-empt each other, since TBBs task groups etc. seem to share a single pool of real threads and there does not appear to be anyway to set the real system priority of a TBB worker thread, or am I missing something?

0 Kudos
1 Reply
jimdempseyatthecove
Honored Contributor III
510 Views

I suggest you consider running multiple processes with an arena of shared inter-process memory. On Windows you would use a memory mapped file, Linux should have a similar capability. Then set the thread and/or process priorities to the desired priorities. *** Note, I don't have it handy now, but TBB has a tuning parameter related to a SpinWait time or equivalent to OpenMP's OMP_BLOCK_TIME. When you have competing thread pools at different priorities then only permit the lowest priority to keep a non-zero (default) spin wait time. All others should have 0 block time. You can get fancy and vary the block time.

Care must be made to not place heap allocated and/or scalable allocated (and auto-resizable) objects in the shared memory area.

Jim Dempsey

0 Kudos
Reply