Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
2421 Discussions

TBB and nested parallelism with other thread libraries

ahelwer
New Contributor I
136 Views
Given a tbb flow graph of tasks, in which one graph node uses either boost threads or OpenMP to execute some operation in parallel, will the threads used in that node and the threads used by the tbb scheduler stomp on each other with context switches?
0 Kudos
3 Replies
jimdempseyatthecove
Black Belt
136 Views
This can be an implimentation issue. Generally speaking TBB thread pool will be seperate from OpenMP thread pool and seperate from Boost threads. As such, oversubscription will (may) occure. You can start each thread pool with undersubscription.

*** Caution. TheOpenMP thread pool usually assumes the process main thread initiated the OpenMP thread pool .AND. is the root thread on all subsequent entries into OpenMP parallel regions.

Jim Dempsey
TimP
Black Belt
136 Views
The cilk+ implementation is intended to cooperate with TBB in scheduling threads.
If working with OpenMP, not only is there no protection agains over-subscription, but the OpenMP affinity (KMP_AFFINITY for Intel OpenMP) would probably have to be left at default (none) as it will not track conflicts in core scheduling between TBB and OpenMP. You would depend on the OS scheduler to spread the work across available cores, but it would have no idea of any scheduling preferences from your application.
RafSchietekat
Black Belt
136 Views
"If working with OpenMP, not only is there no protection agains over-subscription, but the OpenMP affinity (KMP_AFFINITY for Intel OpenMP) would probably have to be left at default (none) as it will not track conflicts in core scheduling between TBB and OpenMP."
I would think that Intel OpenMP uses the RML to play nice with TBB?
Reply