Closed brechtvl closed 2 weeks ago
Filed as internal issue #USD-8384
@brechtvl I noticed this pull request now has merge conflicts.
This merge left out the build system changes. But I guess that was intentional, and there are more changes coming before it's considered ready.
That's right - we're landing the last few changes now, @brechtvl - thanks so much for your giant contributions, here!
Description of Change(s)
After the various simple changes submitted as separate pull requests, this actually does the bulk of the work of adding TBB 2021 support. It is optional, older TBB version should still work exactly the same.
build_usd.py
option--onetbb
, disabled by default.The impact of the thread limits changes in complex applications like DCCs is not easy to understand. One would hope that such applications do not use the USD API or environment variables to set thread limits.
If there are multiple parts of the application using and configuring TBB thread limits, here are some potential differences when using oneTBB. This is from my understanding of the docs and code, not testing in practice.
With older TBB, the first created
task_scheduler_init
wins and determines the number of threads. USD can create one as part of static initialization, which can happen before a host application creates one, and so override the number of threads for the entire application. With oneTBB, everyglobal_control
call changes the number of threads instead of just the first.With older TBB,
task_scheduler_init
affects one thread spawing tasks. It may commonly be used early on in the main thread and affect the entire application, but not necessarily. With oneTBB,global_control
always affects the entire application regardless of the thread it is called from.After these changes, the thread limit API can still be used to decrease the number of threads used by TBB. But it can no longer increase them beyond the number of cores just by itself. To increase the number of threads, the parallel code now needs to be run inside a task arena with increased max concurrency as well. I could not find a mechanism in oneTBB that allows changing the max concurrency of the current existing task arena.
Fixes Issue(s)
Part of #1471, adding oneTBB support.