Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of deprecated and removed tbb::task_scheduler_init and task API (Intel oneTBB) #72

Closed
valpackett opened this issue Jan 19, 2021 · 8 comments
Assignees

Comments

@valpackett
Copy link

valpackett commented Jan 19, 2021

tbb::task_scheduler_init has been deprecated since Intel TBB 4.3 Update 5 and in the new Intel oneTBB 2021.x releases it is finally completely gone.

According to documentation,

Using task_scheduler_init is optional in Intel® Threading Building Blocks (Intel® TBB) 2.2. By default, Intel TBB 2.2 automatically creates a task scheduler the first time that a thread uses task scheduling services and destroys it when the last such thread exits.

and Intel does not recommend specifying the number of threads anywhere:

The reason for not specifying the number of threads in production code is that in a large software project, there is no way for various components to know how many threads would be optimal for other threads. Hardware threads are a shared global resource. It is best to leave the decision of how many threads to use to the task scheduler.

Please remove the usage of tbb::task_scheduler_init and the tbb/task_scheduler_init.h header, or at least detect their existence in the build system if you want to preserve the behavior with older TBB versions.

task_scheduler_init
init (nthreads <= 0 ? (task_scheduler_init::automatic) : nthreads) ;


Actually the whole tbb::task API is gone. task_group is suggested as a replacement.

@valpackett valpackett changed the title Usage of deprecated and removed tbb::task_scheduler_init (Intel oneTBB) Usage of deprecated and removed tbb::task_scheduler_init and task API (Intel oneTBB) Jan 19, 2021
@DrTimothyAldenDavis
Copy link
Owner

Thanks for the heads up ... that's a very unpleasant surprise. This is a serious issue because controlling the # of threads is a feature that I require to satisfy the needs of MATLAB. SPQR must follow the # of threads set by the MATLAB maxNumCompThreads (see https://www.mathworks.com/help/matlab/ref/maxnumcompthreads.html). TBB seems to be disallowing any control over the # of threads used. This function is used in x=A\b inside MATLAB, and this deprecation breaks it.

Intel's recommendation is an overstatement. I need to limit the task schedule in ways that no task scheduler inside TBB can predict, unless it can somehow glean the maxNumCompThreads itself from MATLAB. I'm happy to let TBB create its own tasks and threads but I have to have control over an upper bound on the number of threads it is permitted to use. It would be free to use any number of threads it likes, between 1 and my provided upper bound. But TBB has no mechanism for this. At least none that I can find.

With this deprecation and removal of task_schedule_init, TBB has become unusable to me. There seems to be no workaround. I will see about transitioning SuiteSparseQR to OpenMP tasking, and dropping the use of TBB entirely. I only use TBB within this single file, to execute a simple task tree. It shouldn't be too hard to switch to OpenMP tasks instead.

If there's a method for providing a max upper bound on the # of threads TBB is permitted to use, can you point it out to me?

@DrTimothyAldenDavis
Copy link
Owner

You'll note in my code that default is to let TBB pick the # of threads to use. It's in the non-default case that I require control.

@valpackett
Copy link
Author

providing a max upper bound on the # of threads TBB is permitted to use

global_control?

@DrTimothyAldenDavis
Copy link
Owner

global_control would be fine in MATLAB, since it's an application, but not inside a library like SPQR. Intel doesn't recommend global_control inside a library.

I need to control the # of threads used when I combine my parallel library with the parallel BLAS. For that, I need specific control, such as mkl_set_num_threads_local ( https://software.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/support-functions/threading-control/mkl-set-num-threads-local.html ).

global_control would be a sledge hammer, compared to a finer control like that function. So I don't think I can use global_control.

@Faroito
Copy link

Faroito commented Mar 26, 2021

Maybe you can use task_arena?

@DrTimothyAldenDavis
Copy link
Owner

It's not safe to switch to another feature of TBB. This is not a minor change to TBB.   I was using a core part of TBB, and now all features I was using in TBB are entirely gone. If Intel is willing to deprecate x=A\b in MATLAB, there's no guarantee task_arena will be around in 10 years either.

The solution is to switch to OpenMP tasking instead, and jettison all uses of TBB. 

carlocab added a commit to carlocab/homebrew-core that referenced this issue Oct 18, 2021
SuiteSparse is not compatible with the latest version of TBB. See
DrTimothyAldenDavis/SuiteSparse#72.

We didn't encounter any problems in CI about this because the build just
carried on as if TBB were not installed.

We can use `tbb@2020`, but this causes issues for dependents that
currently depend on `tbb`. Since the formula isn't using the `tbb`
dependency currently, and upstream plans to drop it at some point, let's
just remove the dependency.
BrewTestBot pushed a commit to Homebrew/homebrew-core that referenced this issue Oct 18, 2021
SuiteSparse is not compatible with the latest version of TBB. See
DrTimothyAldenDavis/SuiteSparse#72.

We didn't encounter any problems in CI about this because the build just
carried on as if TBB were not installed.

We can use `tbb@2020`, but this causes issues for dependents that
currently depend on `tbb`. Since the formula isn't using the `tbb`
dependency currently, and upstream plans to drop it at some point, let's
just remove the dependency.

Closes #87485.

Signed-off-by: Sean Molenaar <1484494+SMillerDev@users.noreply.github.com>
Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>
archlinux-github pushed a commit to archlinux/svntogit-packages that referenced this issue Nov 23, 2021
git-svn-id: file:///srv/repos/svn-packages/svn@428978 eb2447ed-0c53-47e4-bac8-5bc4a241df78
archlinux-github pushed a commit to archlinux/svntogit-packages that referenced this issue Nov 23, 2021
git-svn-id: file:///srv/repos/svn-packages/svn@428978 eb2447ed-0c53-47e4-bac8-5bc4a241df78
payerle added a commit to payerle/spack that referenced this issue Dec 16, 2021
See DrTimothyAldenDavis/SuiteSparse#72

suite-sparse depends on task_schedule_init to control the number
of threads when e.g. interfacing with MATLAB.  However, Intel
dropped task_schedule_init in the 2021.x releases of TBB (it has
been deprecated since TBB 4.3.5).

We just raise a spack conflict when using tbb @2021.x and +tbb

Because tbb is a virtual package and is not versioned, I have
instead checked for either intel-oneapi-tbb@2021: or
intel-tbb@2021:, not the most elegant but should do the job
alalazo pushed a commit to spack/spack that referenced this issue Dec 17, 2021
* suite-sparse: Fix check for +/- tbb variant

Changed
'tbb' in spec
to
'+tbb' in spec

The former would configure suite-sparse to use tbb if any dependency
package (e.g. intel-oneapi-mkl) depends on tbb, even if
suite-sparse~tbb was specified.

* suite-sparse: conflict when trying to use 2021.x versions of tbb

See DrTimothyAldenDavis/SuiteSparse#72

suite-sparse depends on task_schedule_init to control the number
of threads when e.g. interfacing with MATLAB.  However, Intel
dropped task_schedule_init in the 2021.x releases of TBB (it has
been deprecated since TBB 4.3.5).

We just raise a spack conflict when using tbb @2021.x and +tbb

Because tbb is a virtual package and is not versioned, I have
instead checked for either intel-oneapi-tbb@2021: or
intel-tbb@2021:, not the most elegant but should do the job

* suite-sparse: fix style issues
@anton-potapov
Copy link

@DrTimothyAldenDavis it was 15 years from first version of TBB till the revamp (oneTBB, which removed tbb_scheduller_init). While it is not a guarantee, but IMHO it is safe to assume that task_arena will be there for 10 years :)

@DrTimothyAldenDavis
Copy link
Owner

Fixed in the draft SuiteSparse v5.11.0 (TBB is removed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants